@synthetic-ai/ae-mcp 2.10.0-dev.1 → 2.10.3
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/bridge.mjs +1 -1
- package/dist/i18n.mjs +60 -0
- package/dist/server.mjs +1 -1
- package/dist/store.mjs +1 -1
- package/i18n/i18n-core.cjs +224 -0
- package/i18n/i18n-source.json +6 -0
- package/i18n/locales/de.json +1161 -0
- package/i18n/locales/en.json +1161 -0
- package/i18n/locales/es.json +1161 -0
- package/i18n/locales/fr.json +1161 -0
- package/i18n/locales/hashes/de.json +1161 -0
- package/i18n/locales/hashes/es.json +1161 -0
- package/i18n/locales/hashes/fr.json +1161 -0
- package/i18n/locales/hashes/ja.json +1161 -0
- package/i18n/locales/hashes/pt-BR.json +1161 -0
- package/i18n/locales/ja.json +1161 -0
- package/i18n/locales/pt-BR.json +1161 -0
- package/i18n/node.cjs +124 -0
- package/package.json +59 -56
package/dist/store.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x489d88,_0x4d9bbb){const _0x3b97b6={_0x2593fa:0xc3,_0x224bfa:0xb7,_0x1fe339:0xa5,_0x197aa0:0x192,_0x2a5f9d:0x188,_0x3751fc:0x194,_0x27d698:0x191,_0x4e4640:0x199,_0x43436b:0x19d},_0x3ad7e7={_0xdc5a0e:0x1b2};function _0x3766d7(_0x1c4501,_0x3f8f56){return _0x5c18(_0x1c4501-0x95,_0x3f8f56);}function _0x4cedf4(_0x26bcb,_0x10a8d8){return _0x5c18(_0x10a8d8- -_0x3ad7e7._0xdc5a0e,_0x26bcb);}const _0x243534=_0x489d88();while(!![]){try{const _0x517c13=parseInt(_0x4cedf4(-_0x3b97b6._0x2593fa,-_0x3b97b6._0x224bfa))/0x1+-parseInt(_0x4cedf4(-0x9e,-_0x3b97b6._0x1fe339))/0x2*(-parseInt(_0x4cedf4(-0xc9,-0xbb))/0x3)+parseInt(_0x3766d7(_0x3b97b6._0x197aa0,_0x3b97b6._0x2a5f9d))/0x4+-parseInt(_0x4cedf4(-0xcb,-0xba))/0x5*(parseInt(_0x3766d7(0x1a6,0x1af))/0x6)+parseInt(_0x3766d7(0x199,_0x3b97b6._0x3751fc))/0x7*(parseInt(_0x4cedf4(-0xc2,-0xbd))/0x8)+-parseInt(_0x3766d7(_0x3b97b6._0x27d698,_0x3b97b6._0x4e4640))/0x9+parseInt(_0x3766d7(_0x3b97b6._0x43436b,0x192))/0xa*(-parseInt(_0x4cedf4(-0xae,-0xad))/0xb);if(_0x517c13===_0x4d9bbb)break;else _0x243534['push'](_0x243534['shift']());}catch(_0x418403){_0x243534['push'](_0x243534['shift']());}}}(_0x1363,0x894ba));function _0x5c18(_0x29ca8c,_0x25c961){_0x29ca8c=_0x29ca8c-0xf1;const _0x136353=_0x1363();let _0x5c18bf=_0x136353[_0x29ca8c];if(_0x5c18['FXgTfX']===undefined){var _0xcc1879=function(_0x321a06){const _0x15c37c='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x11b99b='',_0x3c8e87='';for(let _0x3dd044=0x0,_0x141ce4,_0x231af3,_0x1b1d4f=0x0;_0x231af3=_0x321a06['charAt'](_0x1b1d4f++);~_0x231af3&&(_0x141ce4=_0x3dd044%0x4?_0x141ce4*0x40+_0x231af3:_0x231af3,_0x3dd044++%0x4)?_0x11b99b+=String['fromCharCode'](0xff&_0x141ce4>>(-0x2*_0x3dd044&0x6)):0x0){_0x231af3=_0x15c37c['indexOf'](_0x231af3);}for(let _0x312c09=0x0,_0x39edf4=_0x11b99b['length'];_0x312c09<_0x39edf4;_0x312c09++){_0x3c8e87+='%'+('00'+_0x11b99b['charCodeAt'](_0x312c09)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3c8e87);};_0x5c18['Hcbjgp']=_0xcc1879,_0x5c18['ZNSBVk']={},_0x5c18['FXgTfX']=!![];}const _0x56425b=_0x136353[0x0],_0x48152f=_0x29ca8c+_0x56425b,_0x6186a1=_0x5c18['ZNSBVk'][_0x48152f];return!_0x6186a1?(_0x5c18bf=_0x5c18['Hcbjgp'](_0x5c18bf),_0x5c18['ZNSBVk'][_0x48152f]=_0x5c18bf):_0x5c18bf=_0x6186a1,_0x5c18bf;}function _0x1363(){const _0x48d2b4=['zMfSC2u','Dhj1zq','BMfTzq','BxnNlNDYyxbWzxiUChjVBw90zwruywC','DxrMltG','C3rYAw5NAwz5','ndy5tfDHAg5P','ntCYAuXbAej0','zgvMyxvSDa','lNn5BNrOzxrPyY1Hzs1Ty3a','odu1nZboBufpquq','zgvZy3jPChrPB24','AgfZt3DUuhjVCgvYDhK','CgfYyw1Z','DhjPBq','mtrPsgLUqxu','y29Kzq','C3bSAxq','BxnNlNDYyxbWzxiUBwLZC2LUz1bHCMfT','mZK0mZaYExLsuxvP','CMf3','DhLWzq','yM9VBgvHBG','AM9PBG','yxjYyxK','nZeZmdrhwvHyC1y','C3rYAw5N','mZe2otm4y29XveDp','mZvvtKTIsKe','CMvXDwLYzwq','BNvTyMvY','mJqYmJC2C3r0vhzU','nJuZnda5mfnYq2rmAq','mJq1nZu0ngPryNbRwa'];_0x1363=function(){return _0x48d2b4;};return _0x1363();}function _0x276224(_0x5e3067,_0x37e394){const _0x276b7f={_0x47b740:0x75};return _0x5c18(_0x37e394-_0x276b7f._0x47b740,_0x5e3067);}import{homedir}from'node:os';import{join}from'node:path';import{existsSync,mkdirSync,appendFileSync,readFileSync,writeFileSync}from'node:fs';function _0x332aff(_0xc8874,_0x31b0c6){return _0x5c18(_0xc8874- -0x212,_0x31b0c6);}import{i18n}from'./i18n.mjs';export const DATA_DIR=process.env.AE_MCP_DATA_DIR||join(homedir(),_0x332aff(-0x10b,-0x115));export const JOURNAL_PATH=join(DATA_DIR,'journal.jsonl');export const WRAPPERS_PATH=join(DATA_DIR,'wrappers.json');function ensureDir(){if(!existsSync(DATA_DIR))mkdirSync(DATA_DIR,{'recursive':!![]});}export function appendJournal(_0x11b99b){const _0x146db2={_0x4ef9cf:0xf8},_0x4be2ae={_0x24868e:0x18};function _0x27e6ac(_0x3ac7cb,_0x389100){return _0x332aff(_0x3ac7cb-_0x4be2ae._0x24868e,_0x389100);}try{ensureDir(),appendFileSync(JOURNAL_PATH,JSON['stringify'](_0x11b99b)+'\x0a',_0x27e6ac(-_0x146db2._0x4ef9cf,-0x106));}catch(_0x3c8e87){}}export function readJournal(){const _0x251584={_0x29d5e9:0x149,_0x4b4693:0x2a7},_0x3f67c2={_0x3a3fab:0x190};function _0x1918e1(_0x1c1129,_0xb2cbb4){return _0x332aff(_0xb2cbb4-0x25a,_0x1c1129);}if(!existsSync(JOURNAL_PATH))return[];function _0x2b90ad(_0x5080de,_0x5ad8a4){return _0x332aff(_0x5080de- -_0x3f67c2._0x3a3fab,_0x5ad8a4);}const _0x3dd044=[];for(const _0x141ce4 of readFileSync(JOURNAL_PATH,_0x1918e1(_0x251584._0x29d5e9,0x14a))[_0x1918e1(0x147,0x157)]('\x0a')){const _0x231af3=_0x141ce4[_0x2b90ad(-0x296,-_0x251584._0x4b4693)]();if(!_0x231af3)continue;try{_0x3dd044['push'](JSON['parse'](_0x231af3));}catch(_0x1b1d4f){}}return _0x3dd044;}export function readWrappers(){const _0x55b493={_0x6acc32:0x32b};if(!existsSync(WRAPPERS_PATH))return[];function _0x5118fa(_0x43f2dc,_0x24503c){return _0x332aff(_0x43f2dc-0x43b,_0x24503c);}try{const _0x312c09=JSON['parse'](readFileSync(WRAPPERS_PATH,_0x5118fa(_0x55b493._0x6acc32,0x32b)));return Array['isArray'](_0x312c09)?_0x312c09:[];}catch(_0x39edf4){return[];}}export function writeWrappers(_0x4e3ef0){const _0x1ed5f8={_0x4cade2:0x75},_0x57990f={_0x232a4b:0x9e};function _0x324901(_0x106321,_0x3979d6){return _0x332aff(_0x3979d6-_0x57990f._0x232a4b,_0x106321);}ensureDir(),writeFileSync(WRAPPERS_PATH,JSON['stringify'](_0x4e3ef0,null,0x2),_0x324901(-_0x1ed5f8._0x4cade2,-0x72));}const TYPE_TO_SCHEMA={'string':()=>({'type':'string'}),'number':()=>({'type':_0x332aff(-0x118,-0x118)}),'boolean':()=>({'type':_0x276224(0x15a,0x167)}),'array':()=>({'type':_0x276224(0x165,0x169)}),'object':()=>({'type':'object'}),'raw':()=>({'type':'string'})};export function wrapperToToolDef(_0x465fd3){const _0x3016a6={_0xf91e5a:0x106,_0x4322a2:0xfe,_0x135b06:0x111,_0x160bb6:0x108,_0x48652c:0x108,_0x2298e7:0x3},_0x382c79={_0x227c35:0x114};function _0x21572c(_0x431846,_0x1df4b8){return _0x332aff(_0x431846-_0x382c79._0x227c35,_0x1df4b8);}const _0x25a9da={};function _0x3c9ffb(_0x338aac,_0x180a39){return _0x332aff(_0x180a39-0x21a,_0x338aac);}const _0x1ddb6b=[];for(const _0x5c9387 of _0x465fd3[_0x3c9ffb(_0x3016a6._0xf91e5a,0x113)]||[]){const _0x150389=(TYPE_TO_SCHEMA[_0x5c9387['type']]||TYPE_TO_SCHEMA[_0x3c9ffb(0xf5,_0x3016a6._0x4322a2)])();_0x25a9da[_0x5c9387[_0x3c9ffb(0x106,0x108)]]={..._0x150389,'description':_0x5c9387[_0x3c9ffb(0x103,_0x3016a6._0x135b06)]||''};if(_0x5c9387['required'])_0x1ddb6b['push'](_0x5c9387[_0x3c9ffb(0x10f,_0x3016a6._0x160bb6)]);}return{'name':_0x465fd3[_0x3c9ffb(0xfa,_0x3016a6._0x48652c)],'description':(_0x465fd3['description']||'')+'\x20\x20'+i18n['t'](_0x21572c(_0x3016a6._0x2298e7,0xd)),'inputSchema':{'type':'object','properties':_0x25a9da,'required':_0x1ddb6b,'additionalProperties':![]}};}function renderLiteral(_0x40d421,_0xdba42c){const _0x26e3b2={_0x3e0f4a:0x165,_0x1d0c03:0x170,_0x44e969:0x16d,_0x5dd609:0x150,_0x3c11da:0x2b0,_0x2aaf96:0x15c,_0xc17ab5:0x15b,_0x17975a:0x14d,_0x108ba5:0x145},_0x5a651b={_0x2af3fc:0x4d};function _0x40a02a(_0xbd3299,_0xed74f){return _0x332aff(_0xed74f-0x3b9,_0xbd3299);}function _0x1e9edf(_0x9d7481,_0x5b620e){return _0x332aff(_0x9d7481- -_0x5a651b._0x2af3fc,_0x5b620e);}switch(_0xdba42c){case'string':return JSON['stringify'](String(_0x40d421??''));case _0x1e9edf(-_0x26e3b2._0x3e0f4a,-_0x26e3b2._0x1d0c03):return String(Number(_0x40d421));case _0x1e9edf(-0x16d,-_0x26e3b2._0x44e969):return _0x40d421?_0x1e9edf(-0x160,-_0x26e3b2._0x5dd609):_0x40a02a(_0x26e3b2._0x3c11da,0x2a5);case _0x1e9edf(-0x16b,-0x166):case'object':return JSON[_0x1e9edf(-_0x26e3b2._0x2aaf96,-_0x26e3b2._0xc17ab5)](_0x40d421??null);case _0x1e9edf(-_0x26e3b2._0x17975a,-_0x26e3b2._0x108ba5):return String(_0x40d421??'');default:return JSON[_0x40a02a(0x2a8,0x2aa)](String(_0x40d421??''));}}export function fillTemplate(_0x30e0bc,_0x35ee91){const _0xa293f8={_0x5b526b:0x199,_0x4394ea:0x19c,_0x38d959:0x4f1,_0x1ac354:0x4ef,_0x201ae5:0x198,_0x2aac44:0x4f5,_0x537e95:0x4e5,_0x861228:0x4d6};function _0x158c52(_0x5784e3,_0x3d3419){return _0x276224(_0x5784e3,_0x3d3419-0x370);}let _0x816951=_0x30e0bc[_0x158c52(0x500,0x4f3)];function _0x386d93(_0x32b0fa,_0x946e31){return _0x276224(_0x946e31,_0x32b0fa- -0x319);}for(const _0x442101 of _0x30e0bc[_0x386d93(-_0xa293f8._0x5b526b,-_0xa293f8._0x4394ea)]||[]){const _0x303dfd=_0x35ee91&&Object['prototype'][_0x158c52(_0xa293f8._0x38d959,_0xa293f8._0x1ac354)]['call'](_0x35ee91,_0x442101[_0x386d93(-0x1a4,-_0xa293f8._0x201ae5)]);let _0x110f64=_0x303dfd?_0x35ee91[_0x442101[_0x158c52(0x4f1,0x4e5)]]:_0x442101[_0x386d93(-0x19e,-0x18d)];if(_0x110f64===undefined){if(_0x442101[_0x386d93(-0x1ab,-0x19c)])throw new Error(i18n['t'](_0x158c52(0x4ea,_0xa293f8._0x2aac44),{'name':_0x442101[_0x158c52(_0xa293f8._0x38d959,_0xa293f8._0x537e95)]}));continue;}const _0x5a24ec=renderLiteral(_0x110f64,_0x442101[_0x158c52(0x4cf,_0xa293f8._0x861228)]);_0x816951=_0x816951['split']('{{'+_0x442101['name']+'}}')[_0x158c52(0x4cc,0x4d8)](_0x5a24ec);}return _0x816951;}
|
|
@@ -0,0 +1,224 @@
|
|
|
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
|
+
});
|