@synthetic-ai/premiere-mcp 2.3.5 → 3.0.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/LICENSE +5 -21
- package/README.md +10 -242
- package/launcher.mjs +111 -0
- package/package.json +10 -54
- package/CHANGELOG.md +0 -180
- package/cep-plugin/.debug +0 -8
- package/cep-plugin/CSInterface.js +0 -92
- package/cep-plugin/CSXS/manifest.xml +0 -49
- package/cep-plugin/host.jsx +0 -7
- package/cep-plugin/i18n-core.cjs +0 -224
- package/cep-plugin/i18n-locales.js +0 -3
- package/cep-plugin/i18n-panel.cjs +0 -178
- package/cep-plugin/index.html +0 -507
- package/cep-plugin/main.js +0 -793
- package/cep-plugin/premiere.jsx +0 -24947
- package/cep-plugin/synthetic-logo.png +0 -0
- package/dist/bridge/file-bridge.d.ts +0 -29
- package/dist/bridge/file-bridge.js +0 -146
- package/dist/bridge/script-builder.d.ts +0 -19
- package/dist/bridge/script-builder.js +0 -408
- package/dist/http-server.d.ts +0 -22
- package/dist/http-server.js +0 -143
- package/dist/i18n.d.ts +0 -42
- package/dist/i18n.js +0 -69
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -179
- package/dist/license.d.ts +0 -22
- package/dist/license.js +0 -129
- package/dist/resources/extendscript-reference.d.ts +0 -2
- package/dist/resources/extendscript-reference.js +0 -219
- package/dist/server.d.ts +0 -4
- package/dist/server.js +0 -292
- package/dist/tools/advanced.d.ts +0 -530
- package/dist/tools/advanced.js +0 -923
- package/dist/tools/audio-advanced.d.ts +0 -847
- package/dist/tools/audio-advanced.js +0 -1653
- package/dist/tools/audio.d.ts +0 -84
- package/dist/tools/audio.js +0 -123
- package/dist/tools/captions.d.ts +0 -30
- package/dist/tools/captions.js +0 -73
- package/dist/tools/clipboard.d.ts +0 -153
- package/dist/tools/clipboard.js +0 -381
- package/dist/tools/color-advanced.d.ts +0 -821
- package/dist/tools/color-advanced.js +0 -772
- package/dist/tools/discovery.d.ts +0 -128
- package/dist/tools/discovery.js +0 -445
- package/dist/tools/effects.d.ts +0 -211
- package/dist/tools/effects.js +0 -555
- package/dist/tools/export-presets.d.ts +0 -333
- package/dist/tools/export-presets.js +0 -490
- package/dist/tools/export.d.ts +0 -320
- package/dist/tools/export.js +0 -619
- package/dist/tools/health.d.ts +0 -9
- package/dist/tools/health.js +0 -25
- package/dist/tools/inspection.d.ts +0 -179
- package/dist/tools/inspection.js +0 -1089
- package/dist/tools/keyframes.d.ts +0 -253
- package/dist/tools/keyframes.js +0 -611
- package/dist/tools/markers.d.ts +0 -117
- package/dist/tools/markers.js +0 -206
- package/dist/tools/media.d.ts +0 -297
- package/dist/tools/media.js +0 -493
- package/dist/tools/metadata.d.ts +0 -178
- package/dist/tools/metadata.js +0 -278
- package/dist/tools/multicam.d.ts +0 -199
- package/dist/tools/multicam.js +0 -212
- package/dist/tools/playback.d.ts +0 -34
- package/dist/tools/playback.js +0 -63
- package/dist/tools/playhead.d.ts +0 -77
- package/dist/tools/playhead.js +0 -185
- package/dist/tools/project-manager.d.ts +0 -65
- package/dist/tools/project-manager.js +0 -81
- package/dist/tools/project.d.ts +0 -390
- package/dist/tools/project.js +0 -596
- package/dist/tools/scripting.d.ts +0 -98
- package/dist/tools/scripting.js +0 -434
- package/dist/tools/selection.d.ts +0 -120
- package/dist/tools/selection.js +0 -334
- package/dist/tools/sequence-advanced.d.ts +0 -84
- package/dist/tools/sequence-advanced.js +0 -476
- package/dist/tools/sequence-settings.d.ts +0 -397
- package/dist/tools/sequence-settings.js +0 -975
- package/dist/tools/sequence.d.ts +0 -211
- package/dist/tools/sequence.js +0 -400
- package/dist/tools/source-monitor.d.ts +0 -95
- package/dist/tools/source-monitor.js +0 -180
- package/dist/tools/text.d.ts +0 -97
- package/dist/tools/text.js +0 -159
- package/dist/tools/timeline.d.ts +0 -265
- package/dist/tools/timeline.js +0 -575
- package/dist/tools/track-management.d.ts +0 -482
- package/dist/tools/track-management.js +0 -787
- package/dist/tools/track-targeting.d.ts +0 -666
- package/dist/tools/track-targeting.js +0 -1318
- package/dist/tools/tracks.d.ts +0 -90
- package/dist/tools/tracks.js +0 -183
- package/dist/tools/transitions-motion.d.ts +0 -788
- package/dist/tools/transitions-motion.js +0 -680
- package/dist/tools/transitions.d.ts +0 -124
- package/dist/tools/transitions.js +0 -268
- package/dist/tools/utility.d.ts +0 -469
- package/dist/tools/utility.js +0 -1118
- package/dist/tools/workspace.d.ts +0 -25
- package/dist/tools/workspace.js +0 -61
- package/i18n/i18n-core.cjs +0 -224
- package/i18n/locales/de.json +0 -1488
- package/i18n/locales/en.json +0 -1488
- package/i18n/locales/es.json +0 -1488
- package/i18n/locales/fr.json +0 -1488
- package/i18n/locales/hashes/de.json +0 -1488
- package/i18n/locales/hashes/es.json +0 -1488
- package/i18n/locales/hashes/fr.json +0 -1488
- package/i18n/locales/hashes/ja.json +0 -1488
- package/i18n/locales/hashes/pt-BR.json +0 -1488
- package/i18n/locales/ja.json +0 -1488
- package/i18n/locales/pt-BR.json +0 -1488
- package/i18n/node.cjs +0 -124
- package/scripts/build-chat-dmg.sh +0 -210
- package/scripts/build-chat-zip.sh +0 -291
- package/scripts/install-cep-windows.ps1 +0 -99
- package/scripts/install-cep.sh +0 -66
- package/scripts/install-chat-plugin.bat +0 -67
- package/scripts/install-chat-plugin.sh +0 -85
- package/scripts/install-windows.bat +0 -95
- package/scripts/package.mjs +0 -270
- package/scripts/sync-i18n.mjs +0 -117
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**************************************************************************************************
|
|
2
|
-
* ADOBE SYSTEMS INCORPORATED
|
|
3
|
-
* Copyright 2013 Adobe Systems Incorporated
|
|
4
|
-
* All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
|
|
7
|
-
* terms of the Adobe license agreement accompanying it. If you have received this file from a
|
|
8
|
-
* source other than Adobe, then your use, modification, or distribution of it requires the prior
|
|
9
|
-
* written permission of Adobe.
|
|
10
|
-
*
|
|
11
|
-
* CSInterface.js - v12.0.0 (minimal shim for MCP Bridge)
|
|
12
|
-
* Download the full version from: https://github.com/nicscott9/CSInterface
|
|
13
|
-
**************************************************************************************************/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* CSInterface class for Adobe CEP extensions.
|
|
17
|
-
* This is a minimal implementation. For production use, download the full
|
|
18
|
-
* CSInterface.js from Adobe's GitHub repository.
|
|
19
|
-
*/
|
|
20
|
-
function CSInterface() {}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Evaluates an ExtendScript in the host application.
|
|
24
|
-
* @param {string} script - The ExtendScript to evaluate.
|
|
25
|
-
* @param {function} callback - Callback with the result string.
|
|
26
|
-
*/
|
|
27
|
-
CSInterface.prototype.evalScript = function (script, callback) {
|
|
28
|
-
if (typeof __adobe_cep__ !== "undefined") {
|
|
29
|
-
// CEP 9+ requires the callback to be passed directly to __adobe_cep__.evalScript.
|
|
30
|
-
// Calling it without a callback causes the result to be silently discarded,
|
|
31
|
-
// making every command return null/undefined.
|
|
32
|
-
__adobe_cep__.evalScript(script, callback || function () {});
|
|
33
|
-
} else {
|
|
34
|
-
// Running outside CEP (for testing)
|
|
35
|
-
console.warn("[CSInterface] Not running in CEP environment");
|
|
36
|
-
if (callback) callback("EvalScript Error: Not in CEP environment");
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Get the host environment.
|
|
42
|
-
*/
|
|
43
|
-
CSInterface.prototype.getHostEnvironment = function () {
|
|
44
|
-
if (typeof __adobe_cep__ !== "undefined") {
|
|
45
|
-
try {
|
|
46
|
-
return JSON.parse(__adobe_cep__.getHostEnvironment());
|
|
47
|
-
} catch (e) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Get the system path.
|
|
56
|
-
* @param {string} pathType - The path type constant.
|
|
57
|
-
*/
|
|
58
|
-
CSInterface.prototype.getSystemPath = function (pathType) {
|
|
59
|
-
if (typeof __adobe_cep__ !== "undefined") {
|
|
60
|
-
return __adobe_cep__.getSystemPath(pathType);
|
|
61
|
-
}
|
|
62
|
-
return "";
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// System path constants
|
|
66
|
-
CSInterface.prototype.EXTENSION_ID = "extensionId";
|
|
67
|
-
|
|
68
|
-
/** SystemPath constants — main.js reads these as SystemPath.EXTENSION, but
|
|
69
|
-
* this shim never declared the global. Older CEP hosts happened to inject
|
|
70
|
-
* a SystemPath global on their own, so cs.getSystemPath(SystemPath.EXTENSION)
|
|
71
|
-
* worked by accident; hosts that stop doing that throw "SystemPath is not
|
|
72
|
-
* defined" and halt init() before premiere.jsx loads or license/update code
|
|
73
|
-
* runs. Same bug class already hit and fixed in the sibling AE MCP panel
|
|
74
|
-
* (cep-plugin/CSInterface.js, v2.4.2). Values match Adobe's canonical
|
|
75
|
-
* CSInterface.js — must be strings, not indexes: the native
|
|
76
|
-
* __adobe_cep__.getSystemPath() doesn't throw on an unrecognized pathType,
|
|
77
|
-
* it silently returns the literal string "invalidParam", which then fails
|
|
78
|
-
* downstream in a confusing way (e.g. fs.mkdirSync() trying to create a
|
|
79
|
-
* folder actually named "invalidParam"). */
|
|
80
|
-
var SystemPath = {
|
|
81
|
-
USER_DATA: "userData",
|
|
82
|
-
COMMON_FILES: "commonFiles",
|
|
83
|
-
MY_DOCUMENTS: "myDocuments",
|
|
84
|
-
APPLICATION: "application",
|
|
85
|
-
EXTENSION: "extension",
|
|
86
|
-
EXTENSION_DATA: "extensionData",
|
|
87
|
-
HOST_APPLICATION: "hostApplication"
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// Note: This is a minimal shim. For the full CSInterface.js, download from:
|
|
91
|
-
// https://github.com/nicscott9/CSInterface
|
|
92
|
-
// and replace this file with the appropriate version for your CEP target.
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<ExtensionManifest Version="7.0" ExtensionBundleId="com.mcp.premiere.bridge" ExtensionBundleVersion="1.1.6" ExtensionBundleName="Synthetic Premiere MCP">
|
|
3
|
-
<ExtensionList>
|
|
4
|
-
<Extension Id="com.mcp.premiere.bridge.panel" Version="1.1.6"/>
|
|
5
|
-
</ExtensionList>
|
|
6
|
-
<ExecutionEnvironment>
|
|
7
|
-
<HostList>
|
|
8
|
-
<Host Name="PPRO" Version="[14.0,99.9]"/>
|
|
9
|
-
</HostList>
|
|
10
|
-
<LocaleList>
|
|
11
|
-
<Locale Code="All"/>
|
|
12
|
-
</LocaleList>
|
|
13
|
-
<RequiredRuntimeList>
|
|
14
|
-
<RequiredRuntime Name="CSXS" Version="9.0"/>
|
|
15
|
-
</RequiredRuntimeList>
|
|
16
|
-
</ExecutionEnvironment>
|
|
17
|
-
<DispatchInfoList>
|
|
18
|
-
<Extension Id="com.mcp.premiere.bridge.panel">
|
|
19
|
-
<DispatchInfo>
|
|
20
|
-
<Resources>
|
|
21
|
-
<MainPath>./index.html</MainPath>
|
|
22
|
-
<ScriptPath>./host.jsx</ScriptPath>
|
|
23
|
-
<CEFCommandLine>
|
|
24
|
-
<Parameter>--allow-file-access-from-files</Parameter>
|
|
25
|
-
<Parameter>--enable-nodejs</Parameter>
|
|
26
|
-
</CEFCommandLine>
|
|
27
|
-
</Resources>
|
|
28
|
-
<Lifecycle>
|
|
29
|
-
<AutoVisible>true</AutoVisible>
|
|
30
|
-
</Lifecycle>
|
|
31
|
-
<UI>
|
|
32
|
-
<Type>Panel</Type>
|
|
33
|
-
<Menu>Synthetic Premiere MCP</Menu>
|
|
34
|
-
<Geometry>
|
|
35
|
-
<Size>
|
|
36
|
-
<Height>300</Height>
|
|
37
|
-
<Width>400</Width>
|
|
38
|
-
</Size>
|
|
39
|
-
<MinSize>
|
|
40
|
-
<Height>200</Height>
|
|
41
|
-
<Width>300</Width>
|
|
42
|
-
</MinSize>
|
|
43
|
-
</Geometry>
|
|
44
|
-
<Icons/>
|
|
45
|
-
</UI>
|
|
46
|
-
</DispatchInfo>
|
|
47
|
-
</Extension>
|
|
48
|
-
</DispatchInfoList>
|
|
49
|
-
</ExtensionManifest>
|
package/cep-plugin/host.jsx
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Host-side ExtendScript (runs in Premiere Pro's ExtendScript engine)
|
|
2
|
-
// This file can contain ExtendScript helper functions that are always available.
|
|
3
|
-
// The main execution happens dynamically via CSInterface.evalScript() from main.js.
|
|
4
|
-
|
|
5
|
-
function mcpBridgePing() {
|
|
6
|
-
return "pong";
|
|
7
|
-
}
|
package/cep-plugin/i18n-core.cjs
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
/* synthetic-idiomas · core/i18n-core.cjs
|
|
2
|
-
*
|
|
3
|
-
* Runtime de idiomas compartido por todos los productos Synthetic (servers MCP en Node y
|
|
4
|
-
* paneles CEP en el navegador). Sin dependencias. UMD: `require()`/`import` desde Node,
|
|
5
|
-
* o <script> (queda en window.SyntheticI18n).
|
|
6
|
-
*
|
|
7
|
-
* Reglas:
|
|
8
|
-
* - Inglés es el idioma fuente. Cualquier clave que falte en otro idioma cae al inglés; si
|
|
9
|
-
* tampoco está, al texto por defecto que pase el código; si tampoco, a la clave. Nunca vacío.
|
|
10
|
-
* - Las traducciones de descripciones de tools llevan la huella (hash) del inglés del que se
|
|
11
|
-
* tradujeron. Si el inglés cambió desde entonces, se usa el inglés nuevo: nunca se muestra
|
|
12
|
-
* una traducción vieja que ya no corresponde.
|
|
13
|
-
*/
|
|
14
|
-
(function (root, factory) {
|
|
15
|
-
var api = factory();
|
|
16
|
-
if (typeof module === 'object' && module.exports) module.exports = api;
|
|
17
|
-
// En CEP con Node habilitado existen `module` y `window` a la vez: el panel lo busca en window.
|
|
18
|
-
if (root && (typeof module !== 'object' || typeof root.document !== 'undefined')) root.SyntheticI18n = api;
|
|
19
|
-
})(typeof self !== 'undefined' ? self : this, function () {
|
|
20
|
-
'use strict';
|
|
21
|
-
|
|
22
|
-
// Idiomas soportados, en el orden en que se muestran en los selectores.
|
|
23
|
-
var LANGUAGES = [
|
|
24
|
-
{ code: 'en', name: 'English' },
|
|
25
|
-
{ code: 'es', name: 'Español' },
|
|
26
|
-
{ code: 'pt-BR', name: 'Português (Brasil)' },
|
|
27
|
-
{ code: 'fr', name: 'Français' },
|
|
28
|
-
{ code: 'de', name: 'Deutsch' },
|
|
29
|
-
{ code: 'ja', name: '日本語' }
|
|
30
|
-
];
|
|
31
|
-
var CODES = LANGUAGES.map(function (l) { return l.code; });
|
|
32
|
-
var SOURCE = 'en';
|
|
33
|
-
|
|
34
|
-
// "es-AR", "es_419" → "es"; "pt", "pt-PT" → "pt-BR"; "EN-us" → "en"; desconocido → null.
|
|
35
|
-
function normalizeLanguage(input) {
|
|
36
|
-
if (!input || typeof input !== 'string') return null;
|
|
37
|
-
var s = input.trim().replace('_', '-').toLowerCase();
|
|
38
|
-
if (!s) return null;
|
|
39
|
-
for (var i = 0; i < CODES.length; i++) if (CODES[i].toLowerCase() === s) return CODES[i];
|
|
40
|
-
var base = s.split('-')[0];
|
|
41
|
-
if (base === 'pt') return 'pt-BR';
|
|
42
|
-
for (var j = 0; j < CODES.length; j++) if (CODES[j].toLowerCase() === base) return CODES[j];
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// FNV-1a de 32 bits sobre UTF-16: rápido, determinístico e idéntico en Node y navegador.
|
|
47
|
-
function hash(text) {
|
|
48
|
-
var h = 0x811c9dc5;
|
|
49
|
-
var s = String(text);
|
|
50
|
-
for (var i = 0; i < s.length; i++) {
|
|
51
|
-
h ^= s.charCodeAt(i);
|
|
52
|
-
h = (h + ((h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24))) >>> 0;
|
|
53
|
-
}
|
|
54
|
-
return ('0000000' + h.toString(16)).slice(-8);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// "Hola {name}" + {name:"Ana"} → "Hola Ana". Placeholders sin valor quedan tal cual.
|
|
58
|
-
function interpolate(text, vars) {
|
|
59
|
-
if (!vars) return text;
|
|
60
|
-
return String(text).replace(/\{([a-zA-Z0-9_]+)\}/g, function (m, k) {
|
|
61
|
-
return Object.prototype.hasOwnProperty.call(vars, k) && vars[k] != null ? String(vars[k]) : m;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @param {object} opts
|
|
67
|
-
* locales: { en: {key: text}, es: {...}, ... } diccionarios planos
|
|
68
|
-
* hashes: { es: {key: hashDelInglés}, ... } (opcional) huellas de las traducciones de tools
|
|
69
|
-
* language: código pedido (se normaliza; si no está soportado, inglés)
|
|
70
|
-
*/
|
|
71
|
-
function createI18n(opts) {
|
|
72
|
-
opts = opts || {};
|
|
73
|
-
var locales = opts.locales || {};
|
|
74
|
-
var hashes = opts.hashes || {};
|
|
75
|
-
var language = normalizeLanguage(opts.language) || SOURCE;
|
|
76
|
-
if (!locales[language] && language !== SOURCE) language = SOURCE;
|
|
77
|
-
var en = locales[SOURCE] || {};
|
|
78
|
-
var lockMap = hashes[language] || {};
|
|
79
|
-
// Una traducción cuyo inglés cambió desde que se tradujo no se usa (cae al inglés actual).
|
|
80
|
-
var dict = {};
|
|
81
|
-
var raw = locales[language] || {};
|
|
82
|
-
Object.keys(raw).forEach(function (k) {
|
|
83
|
-
var lock = lockMap[k];
|
|
84
|
-
if (lock && typeof en[k] === 'string' && hash(en[k]) !== lock) return;
|
|
85
|
-
dict[k] = raw[k];
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
function has(key) { return Object.prototype.hasOwnProperty.call(dict, key) && typeof dict[key] === 'string' && dict[key] !== ''; }
|
|
89
|
-
|
|
90
|
-
// Texto de una clave de UI/mensajes con caída al inglés.
|
|
91
|
-
function t(key, vars, fallbackText) {
|
|
92
|
-
var text = has(key) ? dict[key]
|
|
93
|
-
: (typeof en[key] === 'string' && en[key] !== '') ? en[key]
|
|
94
|
-
: (fallbackText != null && fallbackText !== '') ? fallbackText
|
|
95
|
-
: key;
|
|
96
|
-
return interpolate(text, vars);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Traducción de un texto en inglés "vivo" (tomado del código en ejecución): solo si la
|
|
100
|
-
// traducción se hizo a partir de ese mismo inglés. Si no, devuelve el inglés.
|
|
101
|
-
function translateLive(key, englishNow) {
|
|
102
|
-
if (language === SOURCE || typeof englishNow !== 'string' || englishNow === '') return englishNow;
|
|
103
|
-
if (!has(key)) return englishNow;
|
|
104
|
-
var lock = lockMap[key];
|
|
105
|
-
if (lock && lock !== hash(englishNow)) return englishNow;
|
|
106
|
-
return dict[key];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Recorre un JSON Schema y traduce cada `description` (y `title`) con claves estables:
|
|
110
|
-
// tool.<nombre>.param.<ruta> ej.: tool.apply_effect.param.clipId
|
|
111
|
-
// rutas anidadas con ".", ítems de arrays con "[]", ramas anyOf/oneOf con "|n".
|
|
112
|
-
function localizeSchema(schema, keyBase) {
|
|
113
|
-
if (!schema || typeof schema !== 'object') return schema;
|
|
114
|
-
var out = Array.isArray(schema) ? schema.slice() : Object.assign({}, schema);
|
|
115
|
-
if (typeof out.description === 'string') out.description = translateLive(keyBase, out.description);
|
|
116
|
-
if (typeof out.title === 'string') out.title = translateLive(keyBase + '#title', out.title);
|
|
117
|
-
if (out.properties && typeof out.properties === 'object') {
|
|
118
|
-
var props = {};
|
|
119
|
-
Object.keys(out.properties).forEach(function (name) {
|
|
120
|
-
props[name] = localizeSchema(out.properties[name], joinPath(keyBase, name));
|
|
121
|
-
});
|
|
122
|
-
out.properties = props;
|
|
123
|
-
}
|
|
124
|
-
if (out.items && typeof out.items === 'object' && !Array.isArray(out.items)) out.items = localizeSchema(out.items, keyBase + '[]');
|
|
125
|
-
['anyOf', 'oneOf', 'allOf'].forEach(function (k) {
|
|
126
|
-
if (Array.isArray(out[k])) out[k] = out[k].map(function (s, i) { return localizeSchema(s, keyBase + '|' + i); });
|
|
127
|
-
});
|
|
128
|
-
if (out.additionalProperties && typeof out.additionalProperties === 'object') {
|
|
129
|
-
out.additionalProperties = localizeSchema(out.additionalProperties, keyBase + '{}');
|
|
130
|
-
}
|
|
131
|
-
return out;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Traduce la lista de tools de una respuesta tools/list. Devuelve copias; no toca el original.
|
|
135
|
-
function localizeTools(tools) {
|
|
136
|
-
if (language === SOURCE || !Array.isArray(tools)) return tools;
|
|
137
|
-
return tools.map(function (tool) {
|
|
138
|
-
if (!tool || typeof tool.name !== 'string') return tool;
|
|
139
|
-
var base = 'tool.' + tool.name;
|
|
140
|
-
var copy = Object.assign({}, tool);
|
|
141
|
-
if (typeof copy.description === 'string') copy.description = translateLive(base, copy.description);
|
|
142
|
-
if (typeof copy.title === 'string') copy.title = translateLive(base + '#title', copy.title);
|
|
143
|
-
if (copy.inputSchema) copy.inputSchema = localizeSchemaRoot(copy.inputSchema, base);
|
|
144
|
-
return copy;
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
// En la raíz del inputSchema la descripción del objeto no se usa como parámetro.
|
|
148
|
-
function localizeSchemaRoot(schema, base) {
|
|
149
|
-
var out = Object.assign({}, schema);
|
|
150
|
-
if (out.properties) {
|
|
151
|
-
var props = {};
|
|
152
|
-
Object.keys(out.properties).forEach(function (name) {
|
|
153
|
-
props[name] = localizeSchema(out.properties[name], base + '.param.' + name);
|
|
154
|
-
});
|
|
155
|
-
out.properties = props;
|
|
156
|
-
}
|
|
157
|
-
return out;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Plurales: busca "<clave>.<categoría>" según las reglas del idioma (Intl.PluralRules:
|
|
161
|
-
// one/other, en japonés solo other), después "<clave>.other" y por último "<clave>".
|
|
162
|
-
// {count} queda disponible como placeholder.
|
|
163
|
-
var pluralRules = null;
|
|
164
|
-
try { pluralRules = new Intl.PluralRules(language === 'pt-BR' ? 'pt-BR' : language); } catch (e) { pluralRules = null; }
|
|
165
|
-
function tn(key, count, vars) {
|
|
166
|
-
var v = Object.assign({ count: count }, vars || {});
|
|
167
|
-
var cat = pluralRules ? pluralRules.select(count) : (count === 1 ? 'one' : 'other');
|
|
168
|
-
var candidates = [key + '.' + cat, key + '.other', key];
|
|
169
|
-
for (var i = 0; i < candidates.length; i++) {
|
|
170
|
-
var k = candidates[i];
|
|
171
|
-
if (has(k) || (typeof en[k] === 'string' && en[k] !== '')) return t(k, v);
|
|
172
|
-
}
|
|
173
|
-
return t(key, v);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
language: language,
|
|
178
|
-
t: t,
|
|
179
|
-
tn: tn,
|
|
180
|
-
translateLive: translateLive,
|
|
181
|
-
localizeTools: localizeTools,
|
|
182
|
-
has: has
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function joinPath(base, name) { return base + '.' + name; }
|
|
187
|
-
|
|
188
|
-
// Aplana la lista de tools de tools/list a { clave: inglés } con las mismas claves que usa
|
|
189
|
-
// localizeTools. Lo usa el extractor para generar el diccionario fuente.
|
|
190
|
-
function flattenTools(tools) {
|
|
191
|
-
var out = {};
|
|
192
|
-
(tools || []).forEach(function (tool) {
|
|
193
|
-
if (!tool || typeof tool.name !== 'string') return;
|
|
194
|
-
var base = 'tool.' + tool.name;
|
|
195
|
-
if (typeof tool.description === 'string' && tool.description) out[base] = tool.description;
|
|
196
|
-
if (typeof tool.title === 'string' && tool.title) out[base + '#title'] = tool.title;
|
|
197
|
-
var props = tool.inputSchema && tool.inputSchema.properties;
|
|
198
|
-
if (props) Object.keys(props).forEach(function (name) { walk(props[name], base + '.param.' + name); });
|
|
199
|
-
});
|
|
200
|
-
function walk(schema, key) {
|
|
201
|
-
if (!schema || typeof schema !== 'object') return;
|
|
202
|
-
if (typeof schema.description === 'string' && schema.description) out[key] = schema.description;
|
|
203
|
-
if (typeof schema.title === 'string' && schema.title) out[key + '#title'] = schema.title;
|
|
204
|
-
if (schema.properties) Object.keys(schema.properties).forEach(function (n) { walk(schema.properties[n], key + '.' + n); });
|
|
205
|
-
if (schema.items && typeof schema.items === 'object' && !Array.isArray(schema.items)) walk(schema.items, key + '[]');
|
|
206
|
-
['anyOf', 'oneOf', 'allOf'].forEach(function (k) {
|
|
207
|
-
if (Array.isArray(schema[k])) schema[k].forEach(function (s, i) { walk(s, key + '|' + i); });
|
|
208
|
-
});
|
|
209
|
-
if (schema.additionalProperties && typeof schema.additionalProperties === 'object') walk(schema.additionalProperties, key + '{}');
|
|
210
|
-
}
|
|
211
|
-
return out;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return {
|
|
215
|
-
LANGUAGES: LANGUAGES,
|
|
216
|
-
CODES: CODES,
|
|
217
|
-
SOURCE: SOURCE,
|
|
218
|
-
normalizeLanguage: normalizeLanguage,
|
|
219
|
-
hash: hash,
|
|
220
|
-
interpolate: interpolate,
|
|
221
|
-
createI18n: createI18n,
|
|
222
|
-
flattenTools: flattenTools
|
|
223
|
-
};
|
|
224
|
-
});
|