beplus-mcp 0.45.0 → 0.46.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/README.md +19 -2
- package/dist/index.js +540 -33
- package/dist/index.js.map +1 -1
- package/dist/remote-server.js +540 -33
- package/dist/remote-server.js.map +1 -1
- package/package.json +1 -1
package/dist/remote-server.js
CHANGED
|
@@ -25199,7 +25199,7 @@ var BeplusClient = class {
|
|
|
25199
25199
|
const started = Date.now();
|
|
25200
25200
|
for (let attempt = 0; ; attempt++) {
|
|
25201
25201
|
let res = null;
|
|
25202
|
-
let
|
|
25202
|
+
let failure2 = null;
|
|
25203
25203
|
try {
|
|
25204
25204
|
res = await fetchWithAuth(
|
|
25205
25205
|
this.cfg,
|
|
@@ -25214,11 +25214,11 @@ var BeplusClient = class {
|
|
|
25214
25214
|
);
|
|
25215
25215
|
} catch (e) {
|
|
25216
25216
|
if (!(e instanceof ApiError) || e.httpStatus !== 0) throw e;
|
|
25217
|
-
|
|
25217
|
+
failure2 = e;
|
|
25218
25218
|
}
|
|
25219
25219
|
const status = res ? res.status : 0;
|
|
25220
25220
|
if (!retry || !RETRYABLE.has(status)) {
|
|
25221
|
-
if (
|
|
25221
|
+
if (failure2) throw failure2;
|
|
25222
25222
|
return this.read(res, path);
|
|
25223
25223
|
}
|
|
25224
25224
|
const step = Math.min(p.capMs, p.baseMs * 2 ** attempt);
|
|
@@ -25336,6 +25336,29 @@ var BeplusClient = class {
|
|
|
25336
25336
|
);
|
|
25337
25337
|
return r?.state ?? null;
|
|
25338
25338
|
}
|
|
25339
|
+
// `retry: false` nas leituras de apoio: 503 aqui é "não configurado" e não pode segurar list_models nem check_generation.
|
|
25340
|
+
elevenLabsCatalog(opts = {}) {
|
|
25341
|
+
return this.request("GET", "/elevenlabs/catalog", { timeoutMs: 15e3, ...opts });
|
|
25342
|
+
}
|
|
25343
|
+
elevenLabsVoices(query) {
|
|
25344
|
+
return this.request("GET", "/elevenlabs/voices", { query, timeoutMs: 2e4 });
|
|
25345
|
+
}
|
|
25346
|
+
deleteElevenLabsVoice(id) {
|
|
25347
|
+
return this.request("DELETE", `/elevenlabs/voices/${encodeURIComponent(id)}`, { timeoutMs: 3e4 });
|
|
25348
|
+
}
|
|
25349
|
+
saveElevenLabsVoice(body2) {
|
|
25350
|
+
return this.request("POST", "/elevenlabs/voices/design/save", { body: body2, timeoutMs: 6e4 });
|
|
25351
|
+
}
|
|
25352
|
+
elevenLabsEstimate(body2) {
|
|
25353
|
+
return this.request("POST", "/elevenlabs/estimate", { body: body2, timeoutMs: 6e4 });
|
|
25354
|
+
}
|
|
25355
|
+
// Sem repetição: este POST cobra. Ferramenta longa volta `processing` logo, a rápida segura até a resposta.
|
|
25356
|
+
elevenLabsGenerate(body2) {
|
|
25357
|
+
return this.request("POST", "/elevenlabs/generate", { body: body2, timeoutMs: 18e4 });
|
|
25358
|
+
}
|
|
25359
|
+
elevenLabsJob(id, opts = {}) {
|
|
25360
|
+
return this.request("GET", `/elevenlabs/generations/${encodeURIComponent(id)}`, { timeoutMs: 15e3, ...opts });
|
|
25361
|
+
}
|
|
25339
25362
|
models() {
|
|
25340
25363
|
return this.request("GET", "/models");
|
|
25341
25364
|
}
|
|
@@ -25736,6 +25759,11 @@ async function uploadBytes(cfg, file) {
|
|
|
25736
25759
|
}
|
|
25737
25760
|
return fileUrl;
|
|
25738
25761
|
}
|
|
25762
|
+
async function toStorageUrl(cfg, ref) {
|
|
25763
|
+
if (!isRemoteRef(ref)) return uploadBytes(cfg, await loadLocal(ref));
|
|
25764
|
+
if (new URL(ref).host === BEPLUS_STORAGE_HOST) return ref;
|
|
25765
|
+
return uploadBytes(cfg, await loadRemote(ref));
|
|
25766
|
+
}
|
|
25739
25767
|
async function uploadFile(cfg, ref) {
|
|
25740
25768
|
return uploadBytes(cfg, await loadLocal(ref));
|
|
25741
25769
|
}
|
|
@@ -26027,6 +26055,19 @@ var ASPECT_RATIOS = ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "4:5", "
|
|
|
26027
26055
|
var VIDEO_ASPECT_RATIOS = [...ASPECT_RATIOS, "adaptive"];
|
|
26028
26056
|
var IMAGE_RESOLUTIONS = ["1K", "2K", "4K"];
|
|
26029
26057
|
var VIDEO_RESOLUTIONS = ["480p", "720p", "1080p", "4K"];
|
|
26058
|
+
var ELEVENLABS_TOOLS = [
|
|
26059
|
+
"tts",
|
|
26060
|
+
"dialogue",
|
|
26061
|
+
"sfx",
|
|
26062
|
+
"isolate",
|
|
26063
|
+
"voice_change",
|
|
26064
|
+
"transcribe",
|
|
26065
|
+
"align",
|
|
26066
|
+
"music",
|
|
26067
|
+
"stems",
|
|
26068
|
+
"video_music",
|
|
26069
|
+
"voice_design"
|
|
26070
|
+
];
|
|
26030
26071
|
var DEFAULTS = {
|
|
26031
26072
|
imageModel: "google/nano-banana-2.1",
|
|
26032
26073
|
imageAspect: "1:1",
|
|
@@ -26285,6 +26326,433 @@ function formatToolResult(state, fullWords) {
|
|
|
26285
26326
|
return lines.join("\n") || "(sem resultado)";
|
|
26286
26327
|
}
|
|
26287
26328
|
|
|
26329
|
+
// src/tools/elevenlabs.ts
|
|
26330
|
+
import { randomUUID } from "crypto";
|
|
26331
|
+
var elevenLabsPolling = {
|
|
26332
|
+
intervalMs: 3e3,
|
|
26333
|
+
budgetMs: 9e4,
|
|
26334
|
+
sleep: (ms) => new Promise((r) => setTimeout(r, ms))
|
|
26335
|
+
};
|
|
26336
|
+
var MAX_TEXT_CHARS = 2e4;
|
|
26337
|
+
var SITE_ONLY_TOOLS = /* @__PURE__ */ new Set(["dub", "voice_clone"]);
|
|
26338
|
+
var SITE_ONLY_LABEL = "s\xF3 no site da BePlus, na aba \xC1udio do IA Lab";
|
|
26339
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
26340
|
+
var DESTINATION_NOTE = " Vai para o cliente e projeto ativos: confirme o destino com o usu\xE1rio antes (list_clients, list_projects).";
|
|
26341
|
+
var COST_NOTE = " Gasta diamantes; dry_run: true mostra o custo sem gastar.";
|
|
26342
|
+
var SOURCE_HELP = "Arquivo local (s\xF3 no stdio), URL ou id de uma gera\xE7\xE3o sua. Arquivo e URL de fora sobem para a BePlus antes (at\xE9 95 MB; acima disso, s\xF3 pelo site).";
|
|
26343
|
+
var TOO_LARGE_MESSAGE = "Este arquivo passa de 95 MB, o limite de envio por aqui. Use a mesma ferramenta no site da BePlus, na aba \xC1udio do IA Lab, que aceita arquivos maiores.";
|
|
26344
|
+
var COMMON_FIELDS = {
|
|
26345
|
+
project: external_exports.string().max(64).optional().describe("Projeto (uuid ou code curto). Omita para usar o projeto ativo."),
|
|
26346
|
+
billing: external_exports.enum(["personal"]).optional().describe('"personal" cobra do seu saldo pessoal e ignora o projeto, mesmo o ativo. Incompat\xEDvel com project.'),
|
|
26347
|
+
dry_run: external_exports.boolean().optional().describe("true devolve o custo em diamantes sem gerar nem gastar.")
|
|
26348
|
+
};
|
|
26349
|
+
function contractMessage(e) {
|
|
26350
|
+
if (!(e instanceof ApiError)) return void 0;
|
|
26351
|
+
const body2 = e.body;
|
|
26352
|
+
const message = body2?.error?.message ?? body2?.result?.error?.message;
|
|
26353
|
+
return typeof message === "string" && message ? message : void 0;
|
|
26354
|
+
}
|
|
26355
|
+
async function failure(client, e) {
|
|
26356
|
+
const ready = contractMessage(e);
|
|
26357
|
+
const raw = ready ?? (e instanceof Error ? e.message : "");
|
|
26358
|
+
if (isTeamGatingError(raw)) return errorResult(await buildPickProjectMessage(client));
|
|
26359
|
+
const text = ready ?? apiErrorToUserMessage(e);
|
|
26360
|
+
return errorResult(isBudgetBlockedError(raw) ? `${text}
|
|
26361
|
+
${BUDGET_BLOCKED_GUIDANCE}` : text);
|
|
26362
|
+
}
|
|
26363
|
+
var VOICE_ORIGIN = { premade: "padr\xE3o", library: "biblioteca", mine: "sua" };
|
|
26364
|
+
function voiceLine(v) {
|
|
26365
|
+
const traits = [v.language, v.gender, v.accent].filter(Boolean).join(", ");
|
|
26366
|
+
const description = v.description ? ` | ${v.description.length > 110 ? `${v.description.slice(0, 107)}...` : v.description}` : "";
|
|
26367
|
+
return `${v.id} | ${v.name} | ${VOICE_ORIGIN[v.source]}${traits ? ` | ${traits}` : ""}${description}`;
|
|
26368
|
+
}
|
|
26369
|
+
function jobFooter(job) {
|
|
26370
|
+
const balance = job.balance === void 0 ? "" : ` \xB7 Saldo: ${job.balance} \u{1F48E}`;
|
|
26371
|
+
return `Gera\xE7\xE3o: ${job.generationId}
|
|
26372
|
+
Custo: ${job.diamonds} \u{1F48E}${balance}`;
|
|
26373
|
+
}
|
|
26374
|
+
function formatJob(job) {
|
|
26375
|
+
if (job.status === "failed") return errorResult(`${job.error?.message ?? "A gera\xE7\xE3o falhou."}
|
|
26376
|
+
${jobFooter(job)}`);
|
|
26377
|
+
if (job.status === "processing") {
|
|
26378
|
+
return textResult(
|
|
26379
|
+
`\u23F3 Ainda em processamento. N\xE3o gere de novo: use check_generation com o id abaixo.
|
|
26380
|
+
${jobFooter(job)}`
|
|
26381
|
+
);
|
|
26382
|
+
}
|
|
26383
|
+
const out = job.output ?? {};
|
|
26384
|
+
const lines = [`\u2705 Pronto (${job.tool}).`];
|
|
26385
|
+
for (const f of out.files ?? []) {
|
|
26386
|
+
const duration3 = f.durationSec === void 0 ? "" : ` (${f.durationSec.toFixed(1)}s)`;
|
|
26387
|
+
lines.push(`${f.label ? `${f.label}: ` : ""}${f.url}${duration3}`);
|
|
26388
|
+
}
|
|
26389
|
+
if (out.text) {
|
|
26390
|
+
const cut = out.text.length > MAX_TEXT_CHARS;
|
|
26391
|
+
lines.push(cut ? `${out.text.slice(0, MAX_TEXT_CHARS)}
|
|
26392
|
+
[texto cortado em ${MAX_TEXT_CHARS} caracteres]` : out.text);
|
|
26393
|
+
}
|
|
26394
|
+
if (out.words?.length) {
|
|
26395
|
+
const speakers = new Set(out.words.map((w) => w.speaker).filter(Boolean)).size;
|
|
26396
|
+
lines.push(`${out.words.length} palavras com tempo${speakers ? `, ${speakers} locutores` : ""}.`);
|
|
26397
|
+
}
|
|
26398
|
+
if (out.srtUrl) lines.push(`Legenda: ${out.srtUrl}`);
|
|
26399
|
+
if (out.previews?.length) {
|
|
26400
|
+
lines.push("Pr\xE9vias (id | \xE1udio):", ...out.previews.map((p) => `${p.id} | ${p.url}`));
|
|
26401
|
+
lines.push("Mostre as pr\xE9vias ao usu\xE1rio. A escolhida vira voz com elevenlabs_voice_design_save.");
|
|
26402
|
+
}
|
|
26403
|
+
if (out.voice) lines.push(`Voz: ${voiceLine(out.voice)}`);
|
|
26404
|
+
lines.push(jobFooter(job));
|
|
26405
|
+
return textResult(lines.join("\n"));
|
|
26406
|
+
}
|
|
26407
|
+
async function waitForJob(client, first) {
|
|
26408
|
+
const { intervalMs, budgetMs, sleep: sleep4 } = elevenLabsPolling;
|
|
26409
|
+
let job = first;
|
|
26410
|
+
for (let waited = 0; job.status === "processing" && waited < budgetMs; waited += intervalMs) {
|
|
26411
|
+
await sleep4(intervalMs);
|
|
26412
|
+
try {
|
|
26413
|
+
job = await client.elevenLabsJob(first.generationId);
|
|
26414
|
+
} catch {
|
|
26415
|
+
return job;
|
|
26416
|
+
}
|
|
26417
|
+
}
|
|
26418
|
+
return job;
|
|
26419
|
+
}
|
|
26420
|
+
async function toSource(cfg, ref) {
|
|
26421
|
+
if (UUID.test(ref)) return { generationId: ref };
|
|
26422
|
+
try {
|
|
26423
|
+
return { fileUrl: await toStorageUrl(cfg, ref) };
|
|
26424
|
+
} catch (e) {
|
|
26425
|
+
if (e instanceof ApiError && e.httpStatus === 413) throw new ApiError(413, TOO_LARGE_MESSAGE);
|
|
26426
|
+
throw e;
|
|
26427
|
+
}
|
|
26428
|
+
}
|
|
26429
|
+
function uploadedHint(body2) {
|
|
26430
|
+
const url = body2.source?.fileUrl;
|
|
26431
|
+
return url ? `
|
|
26432
|
+
Arquivo na BePlus: ${url}. Use esta URL em source para n\xE3o subir de novo.` : "";
|
|
26433
|
+
}
|
|
26434
|
+
async function estimate(client, body2) {
|
|
26435
|
+
const res = await client.elevenLabsEstimate(body2);
|
|
26436
|
+
const duration3 = res.durationSec === void 0 ? "" : ` para ${res.durationSec.toFixed(1)}s`;
|
|
26437
|
+
return textResult(`Custo estimado: ${res.diamonds} \u{1F48E}${duration3}. Nada foi gerado nem cobrado.${uploadedHint(body2)}`);
|
|
26438
|
+
}
|
|
26439
|
+
async function generate(client, body2) {
|
|
26440
|
+
let job;
|
|
26441
|
+
try {
|
|
26442
|
+
job = await client.elevenLabsGenerate({ ...body2, idempotencyKey: randomUUID() });
|
|
26443
|
+
} catch (e) {
|
|
26444
|
+
if (e instanceof ApiError && (e.httpStatus === 0 || e.httpStatus === 408)) {
|
|
26445
|
+
return errorResult(
|
|
26446
|
+
"A resposta n\xE3o chegou, ent\xE3o a gera\xE7\xE3o pode ter come\xE7ado e sido cobrada. N\xE3o repita: confira em list_generations antes."
|
|
26447
|
+
);
|
|
26448
|
+
}
|
|
26449
|
+
throw e;
|
|
26450
|
+
}
|
|
26451
|
+
return formatJob(await waitForJob(client, job));
|
|
26452
|
+
}
|
|
26453
|
+
async function estimateElevenLabsModel(client, cfg, model, params, file) {
|
|
26454
|
+
const [, tool, variant] = model.split("/");
|
|
26455
|
+
if (!ELEVENLABS_TOOLS.includes(tool ?? "")) {
|
|
26456
|
+
return errorResult(`Ferramenta desconhecida em "${model}". Use elevenlabs/<ferramenta>: ${ELEVENLABS_TOOLS.join(", ")}.`);
|
|
26457
|
+
}
|
|
26458
|
+
try {
|
|
26459
|
+
const body2 = { ...params, tool };
|
|
26460
|
+
if (variant) body2.model = variant;
|
|
26461
|
+
if (file) body2.source = await toSource(cfg, file);
|
|
26462
|
+
return await estimate(client, body2);
|
|
26463
|
+
} catch (e) {
|
|
26464
|
+
return failure(client, e);
|
|
26465
|
+
}
|
|
26466
|
+
}
|
|
26467
|
+
function elevenLabsCatalogBlock(catalog) {
|
|
26468
|
+
if (!catalog?.enabled) return "";
|
|
26469
|
+
const lines = catalog.tools.filter((t) => t.available).map((t) => {
|
|
26470
|
+
if (SITE_ONLY_TOOLS.has(t.tool)) return `\u2022 ${t.label}: ${SITE_ONLY_LABEL}.`;
|
|
26471
|
+
const models = t.models?.length ? ` Modelos: ${t.models.map((m) => m.id).join(", ")}.` : "";
|
|
26472
|
+
return `\u2022 elevenlabs_${t.tool}: ${t.label}, ${t.diamondsPerUnitHint}.${models}`;
|
|
26473
|
+
});
|
|
26474
|
+
return lines.length ? `
|
|
26475
|
+
|
|
26476
|
+
ElevenLabs (detalhes e limites em elevenlabs_catalog):
|
|
26477
|
+
${lines.join("\n")}` : "";
|
|
26478
|
+
}
|
|
26479
|
+
function registerElevenLabsTools(server, client, cfg) {
|
|
26480
|
+
function spendTool(name, title, description, shape, build2) {
|
|
26481
|
+
server.registerTool(
|
|
26482
|
+
name,
|
|
26483
|
+
{
|
|
26484
|
+
title,
|
|
26485
|
+
description: description + COST_NOTE + DESTINATION_NOTE,
|
|
26486
|
+
inputSchema: { ...shape, ...COMMON_FIELDS },
|
|
26487
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true }
|
|
26488
|
+
},
|
|
26489
|
+
(async (args) => {
|
|
26490
|
+
try {
|
|
26491
|
+
const body2 = compact({
|
|
26492
|
+
...await build2(args),
|
|
26493
|
+
project: resolveProjectArg(args.project, args.billing, cfg.activeProject),
|
|
26494
|
+
billing: args.billing
|
|
26495
|
+
});
|
|
26496
|
+
return await (args.dry_run ? estimate(client, body2) : generate(client, body2));
|
|
26497
|
+
} catch (e) {
|
|
26498
|
+
return failure(client, e);
|
|
26499
|
+
}
|
|
26500
|
+
})
|
|
26501
|
+
);
|
|
26502
|
+
}
|
|
26503
|
+
const modelField = (example) => external_exports.string().min(1).describe(`Id do modelo, ex.: ${example}. A lista sai de elevenlabs_catalog.`);
|
|
26504
|
+
const voiceField = external_exports.string().min(1).describe("Id de uma voz de elevenlabs_list_voices. Outra voz \xE9 recusada.");
|
|
26505
|
+
const sourceField = external_exports.string().min(1).describe(SOURCE_HELP);
|
|
26506
|
+
server.registerTool(
|
|
26507
|
+
"elevenlabs_catalog",
|
|
26508
|
+
{
|
|
26509
|
+
title: "ElevenLabs: ferramentas e modelos",
|
|
26510
|
+
description: "Mostra o que a ElevenLabs oferece agora na BePlus: ferramentas ligadas, modelos, pre\xE7o aproximado e limites. Chame antes da primeira gera\xE7\xE3o para escolher o model. Somente leitura, sem custo.",
|
|
26511
|
+
inputSchema: {},
|
|
26512
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
26513
|
+
},
|
|
26514
|
+
async () => {
|
|
26515
|
+
try {
|
|
26516
|
+
const catalog = await client.elevenLabsCatalog();
|
|
26517
|
+
if (!catalog.enabled) return textResult("A ElevenLabs est\xE1 desligada na plataforma agora.");
|
|
26518
|
+
const lines = catalog.tools.map((t) => {
|
|
26519
|
+
if (SITE_ONLY_TOOLS.has(t.tool)) return `${t.label}: ${SITE_ONLY_LABEL}. N\xE3o h\xE1 tool para isso aqui.`;
|
|
26520
|
+
const head = `elevenlabs_${t.tool} | ${t.label} | ${t.available ? t.diamondsPerUnitHint : "indispon\xEDvel agora"}`;
|
|
26521
|
+
const models = (t.models ?? []).map((m) => ` ${m.id}: ${m.label}. ${m.description}`);
|
|
26522
|
+
return [head, ` ${t.description}`, ` Limites: ${JSON.stringify(t.limits)}`, ...models].join("\n");
|
|
26523
|
+
});
|
|
26524
|
+
return textResult(lines.join("\n"));
|
|
26525
|
+
} catch (e) {
|
|
26526
|
+
return failure(client, e);
|
|
26527
|
+
}
|
|
26528
|
+
}
|
|
26529
|
+
);
|
|
26530
|
+
server.registerTool(
|
|
26531
|
+
"elevenlabs_list_voices",
|
|
26532
|
+
{
|
|
26533
|
+
title: "ElevenLabs: listar vozes",
|
|
26534
|
+
description: "Lista as vozes que voc\xEA pode usar nas ferramentas elevenlabs_*: as da biblioteca, as padr\xE3o e as que voc\xEA criou. N\xE3o serve para generate_audio, que tem vozes pr\xF3prias. Somente leitura, sem custo.",
|
|
26535
|
+
inputSchema: {
|
|
26536
|
+
search: external_exports.string().max(100).optional().describe("Texto livre: nome, descri\xE7\xE3o, sotaque."),
|
|
26537
|
+
language: external_exports.string().max(12).optional().describe("Idioma, ex.: pt, en."),
|
|
26538
|
+
gender: external_exports.string().max(20).optional(),
|
|
26539
|
+
page: external_exports.number().int().min(1).optional().describe("Padr\xE3o 1.")
|
|
26540
|
+
},
|
|
26541
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
26542
|
+
},
|
|
26543
|
+
async (args) => {
|
|
26544
|
+
try {
|
|
26545
|
+
const res = await client.elevenLabsVoices(compact(args));
|
|
26546
|
+
if (!res.voices.length) return textResult("Nenhuma voz encontrada com esses filtros.");
|
|
26547
|
+
const more = res.hasMore ? `
|
|
26548
|
+
Use page=${res.page + 1} para ver mais.` : "";
|
|
26549
|
+
return textResult(`Vozes, p\xE1gina ${res.page} (id | nome | origem | detalhes):
|
|
26550
|
+
${res.voices.map(voiceLine).join("\n")}${more}`);
|
|
26551
|
+
} catch (e) {
|
|
26552
|
+
return failure(client, e);
|
|
26553
|
+
}
|
|
26554
|
+
}
|
|
26555
|
+
);
|
|
26556
|
+
server.registerTool(
|
|
26557
|
+
"elevenlabs_delete_voice",
|
|
26558
|
+
{
|
|
26559
|
+
title: "ElevenLabs: apagar voz sua",
|
|
26560
|
+
description: "DESTRUTIVO e sem volta: apaga uma voz que voc\xEA criou e libera a vaga. \xC1udios j\xE1 gerados continuam tocando. N\xE3o devolve diamantes. Confirme com o usu\xE1rio antes.",
|
|
26561
|
+
inputSchema: { id: external_exports.string().min(1).describe('Id da voz em elevenlabs_list_voices, com origem "sua".') },
|
|
26562
|
+
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true }
|
|
26563
|
+
},
|
|
26564
|
+
async ({ id }) => {
|
|
26565
|
+
try {
|
|
26566
|
+
await client.deleteElevenLabsVoice(id);
|
|
26567
|
+
return textResult(`\u2705 Voz ${id} apagada.`);
|
|
26568
|
+
} catch (e) {
|
|
26569
|
+
return failure(client, e);
|
|
26570
|
+
}
|
|
26571
|
+
}
|
|
26572
|
+
);
|
|
26573
|
+
server.registerTool(
|
|
26574
|
+
"elevenlabs_voice_design_save",
|
|
26575
|
+
{
|
|
26576
|
+
title: "ElevenLabs: salvar voz criada",
|
|
26577
|
+
description: "Transforma uma pr\xE9via de elevenlabs_voice_design em voz sua, para usar nas ferramentas elevenlabs_*. Ocupa uma vaga de voz: salve s\xF3 a pr\xE9via que o usu\xE1rio escolheu.",
|
|
26578
|
+
inputSchema: {
|
|
26579
|
+
preview_id: external_exports.string().min(1).describe("Id da pr\xE9via escolhida."),
|
|
26580
|
+
name: external_exports.string().min(1).max(40).describe("Nome da voz.")
|
|
26581
|
+
},
|
|
26582
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true }
|
|
26583
|
+
},
|
|
26584
|
+
async ({ preview_id, name }) => {
|
|
26585
|
+
try {
|
|
26586
|
+
const voice = await client.saveElevenLabsVoice({ previewId: preview_id, name });
|
|
26587
|
+
return textResult(`\u2705 Voz salva.
|
|
26588
|
+
${voiceLine(voice)}`);
|
|
26589
|
+
} catch (e) {
|
|
26590
|
+
return failure(client, e);
|
|
26591
|
+
}
|
|
26592
|
+
}
|
|
26593
|
+
);
|
|
26594
|
+
spendTool(
|
|
26595
|
+
"elevenlabs_tts",
|
|
26596
|
+
"ElevenLabs: texto em fala",
|
|
26597
|
+
"Narra\xE7\xE3o com uma voz s\xF3, com a qualidade da ElevenLabs. Para duas ou mais vozes conversando use elevenlabs_dialogue. Para o TTS do Gemini e o SeedAudio use generate_audio.",
|
|
26598
|
+
{
|
|
26599
|
+
text: external_exports.string().min(1).describe("Texto a falar. O teto depende do modelo."),
|
|
26600
|
+
voice: voiceField,
|
|
26601
|
+
model: modelField("eleven_v4"),
|
|
26602
|
+
language: external_exports.string().max(12).optional().describe("Idioma do texto, ex.: pt."),
|
|
26603
|
+
stability: external_exports.number().min(0).max(1).optional(),
|
|
26604
|
+
similarity: external_exports.number().min(0).max(1).optional(),
|
|
26605
|
+
style: external_exports.number().min(0).max(1).optional().describe("N\xE3o vale nos modelos eleven_v4."),
|
|
26606
|
+
speed: external_exports.number().positive().optional().describe("N\xE3o vale nos modelos eleven_v4.")
|
|
26607
|
+
},
|
|
26608
|
+
({ text, voice, model, language, stability, similarity, style, speed }) => {
|
|
26609
|
+
if (model.startsWith("eleven_v4") && (style !== void 0 || speed !== void 0)) {
|
|
26610
|
+
throw new Error("Os modelos eleven_v4 n\xE3o aceitam style nem speed. Tire esses campos ou troque o modelo.");
|
|
26611
|
+
}
|
|
26612
|
+
const settings = compact({ stability, similarity, style, speed });
|
|
26613
|
+
return { tool: "tts", text, voice, model, language, settings: Object.keys(settings).length ? settings : void 0 };
|
|
26614
|
+
}
|
|
26615
|
+
);
|
|
26616
|
+
spendTool(
|
|
26617
|
+
"elevenlabs_dialogue",
|
|
26618
|
+
"ElevenLabs: di\xE1logo",
|
|
26619
|
+
"Conversa entre duas ou mais vozes num \xE1udio s\xF3, na ordem das falas. Para uma voz s\xF3 use elevenlabs_tts.",
|
|
26620
|
+
{
|
|
26621
|
+
lines: external_exports.array(external_exports.object({ voice: voiceField, text: external_exports.string().min(1) })).min(2).describe("Falas em ordem, cada uma com a sua voz. At\xE9 2.000 caracteres somando todas."),
|
|
26622
|
+
model: modelField("eleven_v3")
|
|
26623
|
+
},
|
|
26624
|
+
({ lines, model }) => ({ tool: "dialogue", lines, model })
|
|
26625
|
+
);
|
|
26626
|
+
spendTool(
|
|
26627
|
+
"elevenlabs_sfx",
|
|
26628
|
+
"ElevenLabs: efeito sonoro",
|
|
26629
|
+
"Cria um efeito sonoro a partir de uma descri\xE7\xE3o (porta batendo, chuva, whoosh). Para trilha musical use elevenlabs_music.",
|
|
26630
|
+
{
|
|
26631
|
+
text: external_exports.string().min(1).describe("Descri\xE7\xE3o do som."),
|
|
26632
|
+
model: modelField("eleven_text_to_sound_v2"),
|
|
26633
|
+
duration_sec: external_exports.number().positive().optional().describe("De 0,5 a 30 s. Omita para o modelo decidir."),
|
|
26634
|
+
loop: external_exports.boolean().optional().describe("true faz o som emendar sem corte."),
|
|
26635
|
+
prompt_influence: external_exports.number().min(0).max(1).optional().describe("Quanto seguir a descri\xE7\xE3o ao p\xE9 da letra.")
|
|
26636
|
+
},
|
|
26637
|
+
({ text, model, duration_sec, loop, prompt_influence }) => ({
|
|
26638
|
+
tool: "sfx",
|
|
26639
|
+
text,
|
|
26640
|
+
model,
|
|
26641
|
+
durationSec: duration_sec,
|
|
26642
|
+
loop,
|
|
26643
|
+
promptInfluence: prompt_influence
|
|
26644
|
+
})
|
|
26645
|
+
);
|
|
26646
|
+
spendTool(
|
|
26647
|
+
"elevenlabs_isolate",
|
|
26648
|
+
"ElevenLabs: isolar voz",
|
|
26649
|
+
"Tira ru\xEDdo e fundo de uma grava\xE7\xE3o e deixa s\xF3 a voz. Para separar instrumentos de uma m\xFAsica use elevenlabs_stems.",
|
|
26650
|
+
{ source: sourceField },
|
|
26651
|
+
async ({ source }) => ({ tool: "isolate", source: await toSource(cfg, source) })
|
|
26652
|
+
);
|
|
26653
|
+
spendTool(
|
|
26654
|
+
"elevenlabs_voice_change",
|
|
26655
|
+
"ElevenLabs: trocar a voz",
|
|
26656
|
+
"Refala uma grava\xE7\xE3o com outra voz, mantendo ritmo e emo\xE7\xE3o. Use s\xF3 em grava\xE7\xE3o que o usu\xE1rio pode alterar.",
|
|
26657
|
+
{
|
|
26658
|
+
source: sourceField,
|
|
26659
|
+
voice: voiceField,
|
|
26660
|
+
model: external_exports.string().min(1).optional().describe("Id do modelo, ex.: eleven_multilingual_sts_v2."),
|
|
26661
|
+
remove_noise: external_exports.boolean().optional().describe("true limpa o ru\xEDdo da grava\xE7\xE3o antes.")
|
|
26662
|
+
},
|
|
26663
|
+
async ({ source, voice, model, remove_noise }) => ({
|
|
26664
|
+
tool: "voice_change",
|
|
26665
|
+
source: await toSource(cfg, source),
|
|
26666
|
+
voice,
|
|
26667
|
+
model,
|
|
26668
|
+
removeNoise: remove_noise
|
|
26669
|
+
})
|
|
26670
|
+
);
|
|
26671
|
+
spendTool(
|
|
26672
|
+
"elevenlabs_transcribe",
|
|
26673
|
+
"ElevenLabs: transcrever",
|
|
26674
|
+
"Transforma \xE1udio ou v\xEDdeo em texto, com tempo por palavra e legenda. Se j\xE1 tem o texto e s\xF3 quer o tempo, use elevenlabs_align. Reuni\xE3o gravada da equipe j\xE1 est\xE1 em search_calls.",
|
|
26675
|
+
{
|
|
26676
|
+
source: sourceField,
|
|
26677
|
+
language: external_exports.string().max(12).optional().describe("Idioma falado. Omita para detectar."),
|
|
26678
|
+
diarize: external_exports.boolean().optional().describe("true separa quem falou o qu\xEA."),
|
|
26679
|
+
num_speakers: external_exports.number().int().min(1).optional().describe("Quantas pessoas falam, se souber."),
|
|
26680
|
+
audio_events: external_exports.boolean().optional().describe("true marca risos, palmas e outros sons."),
|
|
26681
|
+
keyterms: external_exports.array(external_exports.string().min(1)).optional().describe("Nomes e termos dif\xEDceis para acertar a grafia.")
|
|
26682
|
+
},
|
|
26683
|
+
async ({ source, language, diarize, num_speakers, audio_events, keyterms }) => ({
|
|
26684
|
+
tool: "transcribe",
|
|
26685
|
+
source: await toSource(cfg, source),
|
|
26686
|
+
language,
|
|
26687
|
+
diarize,
|
|
26688
|
+
numSpeakers: num_speakers,
|
|
26689
|
+
audioEvents: audio_events,
|
|
26690
|
+
keyterms
|
|
26691
|
+
})
|
|
26692
|
+
);
|
|
26693
|
+
spendTool(
|
|
26694
|
+
"elevenlabs_align",
|
|
26695
|
+
"ElevenLabs: alinhar texto ao \xE1udio",
|
|
26696
|
+
"Recebe o \xE1udio e o texto j\xE1 pronto e devolve o tempo de cada palavra, para legenda exata. Sem o texto, use elevenlabs_transcribe.",
|
|
26697
|
+
{ source: sourceField, text: external_exports.string().min(1).describe("Texto exato do que \xE9 falado.") },
|
|
26698
|
+
async ({ source, text }) => ({ tool: "align", source: await toSource(cfg, source), text })
|
|
26699
|
+
);
|
|
26700
|
+
spendTool(
|
|
26701
|
+
"elevenlabs_music",
|
|
26702
|
+
"ElevenLabs: m\xFAsica",
|
|
26703
|
+
"Cria m\xFAsica a partir de uma descri\xE7\xE3o, com letra ou instrumental. Para Suno use generate_music. Para trilha casada com um v\xEDdeo use elevenlabs_video_music.",
|
|
26704
|
+
{
|
|
26705
|
+
prompt: external_exports.string().min(1).describe("Estilo, clima e instrumentos."),
|
|
26706
|
+
model: external_exports.string().min(1).optional().describe("Id do modelo. Omita para o padr\xE3o."),
|
|
26707
|
+
duration_sec: external_exports.number().min(3).optional().describe("Dura\xE7\xE3o em segundos, m\xEDnimo 3."),
|
|
26708
|
+
instrumental: external_exports.boolean().optional(),
|
|
26709
|
+
lyrics: external_exports.string().min(1).optional().describe("Letra pr\xF3pria.")
|
|
26710
|
+
},
|
|
26711
|
+
({ prompt, model, duration_sec, instrumental, lyrics }) => ({
|
|
26712
|
+
tool: "music",
|
|
26713
|
+
prompt,
|
|
26714
|
+
model,
|
|
26715
|
+
durationSec: duration_sec,
|
|
26716
|
+
instrumental,
|
|
26717
|
+
lyrics
|
|
26718
|
+
})
|
|
26719
|
+
);
|
|
26720
|
+
spendTool(
|
|
26721
|
+
"elevenlabs_stems",
|
|
26722
|
+
"ElevenLabs: separar faixas",
|
|
26723
|
+
"Separa uma m\xFAsica em faixas (voz, bateria, baixo e outras). Para limpar uma fala gravada use elevenlabs_isolate.",
|
|
26724
|
+
{ source: sourceField },
|
|
26725
|
+
async ({ source }) => ({ tool: "stems", source: await toSource(cfg, source) })
|
|
26726
|
+
);
|
|
26727
|
+
spendTool(
|
|
26728
|
+
"elevenlabs_video_music",
|
|
26729
|
+
"ElevenLabs: trilha para v\xEDdeo",
|
|
26730
|
+
"Cria trilha que acompanha um v\xEDdeo existente. Para m\xFAsica sem v\xEDdeo use elevenlabs_music.",
|
|
26731
|
+
{
|
|
26732
|
+
source: sourceField,
|
|
26733
|
+
description: external_exports.string().min(1).optional().describe("Clima desejado."),
|
|
26734
|
+
add_sfx: external_exports.boolean().optional().describe("true acrescenta efeitos sonoros.")
|
|
26735
|
+
},
|
|
26736
|
+
async ({ source, description, add_sfx }) => ({
|
|
26737
|
+
tool: "video_music",
|
|
26738
|
+
source: await toSource(cfg, source),
|
|
26739
|
+
description,
|
|
26740
|
+
addSfx: add_sfx
|
|
26741
|
+
})
|
|
26742
|
+
);
|
|
26743
|
+
spendTool(
|
|
26744
|
+
"elevenlabs_voice_design",
|
|
26745
|
+
"ElevenLabs: criar voz por descri\xE7\xE3o",
|
|
26746
|
+
"Gera pr\xE9vias de uma voz nova a partir de uma descri\xE7\xE3o. N\xE3o cria a voz ainda: mostre as pr\xE9vias e salve a escolhida com elevenlabs_voice_design_save. Para vozes do Gemini use design_voice.",
|
|
26747
|
+
{
|
|
26748
|
+
description: external_exports.string().min(20).describe("Idade, timbre, sotaque e jeito de falar. M\xEDnimo 20 caracteres."),
|
|
26749
|
+
text: external_exports.string().min(1).optional().describe("Frase que as pr\xE9vias v\xE3o falar."),
|
|
26750
|
+
model: external_exports.string().min(1).optional().describe("Id do modelo. Omita para o padr\xE3o.")
|
|
26751
|
+
},
|
|
26752
|
+
({ description, text, model }) => ({ tool: "voice_design", description, text, model })
|
|
26753
|
+
);
|
|
26754
|
+
}
|
|
26755
|
+
|
|
26288
26756
|
// src/tools/generation.ts
|
|
26289
26757
|
var IMAGE_BUDGET_MS = 9e4;
|
|
26290
26758
|
var VIDEO_BUDGET_MS = 12e4;
|
|
@@ -26817,13 +27285,15 @@ ${BUDGET_BLOCKED_GUIDANCE}`);
|
|
|
26817
27285
|
"check_generation",
|
|
26818
27286
|
{
|
|
26819
27287
|
title: "Checar gera\xE7\xE3o",
|
|
26820
|
-
description: "Consulta o status de uma gera\xE7\xE3o ass\xEDncrona (imagem
|
|
27288
|
+
description: "Consulta o status de uma gera\xE7\xE3o ass\xEDncrona (imagem, v\xEDdeo ou ElevenLabs) pelo id. Use depois de generate_video, de um generate_image que estourou o tempo ou de uma elevenlabs_* em processamento. Retorna status, progresso e (quando pronto) as URLs.",
|
|
26821
27289
|
inputSchema: {
|
|
26822
|
-
generation_id: external_exports.string().min(1).describe("O id retornado por generate_image
|
|
27290
|
+
generation_id: external_exports.string().min(1).describe("O id retornado por generate_image, generate_video ou elevenlabs_*.")
|
|
26823
27291
|
}
|
|
26824
27292
|
},
|
|
26825
27293
|
async ({ generation_id }) => {
|
|
26826
27294
|
try {
|
|
27295
|
+
const job = await client.elevenLabsJob(generation_id, { retry: false }).catch(() => null);
|
|
27296
|
+
if (job?.generationId) return formatJob(job);
|
|
26827
27297
|
const status = await client.getStatus(generation_id);
|
|
26828
27298
|
if (status.status === "completed") {
|
|
26829
27299
|
const urls = outputUrls(status);
|
|
@@ -26899,6 +27369,7 @@ ${list}${flagsLine(status)}${draftHint}` }, ...blocks] };
|
|
|
26899
27369
|
await client.cancel(generation_id);
|
|
26900
27370
|
return textResult(`\u2705 Gera\xE7\xE3o ${generation_id} cancelada (diamantes estornados quando aplic\xE1vel).`);
|
|
26901
27371
|
} catch (e) {
|
|
27372
|
+
if (e instanceof ApiError && e.httpStatus === 409) return textResult(e.message);
|
|
26902
27373
|
return errorResult(apiErrorToUserMessage(e));
|
|
26903
27374
|
}
|
|
26904
27375
|
}
|
|
@@ -27794,7 +28265,7 @@ Use o valor de "voice" no generate_audio com um modelo 3.8 (sem multi_speaker).`
|
|
|
27794
28265
|
}
|
|
27795
28266
|
|
|
27796
28267
|
// src/tools/account.ts
|
|
27797
|
-
function registerAccountTools(server, client,
|
|
28268
|
+
function registerAccountTools(server, client, cfg) {
|
|
27798
28269
|
server.registerTool(
|
|
27799
28270
|
"whoami",
|
|
27800
28271
|
{
|
|
@@ -27851,14 +28322,17 @@ ${budget}` : "")
|
|
|
27851
28322
|
},
|
|
27852
28323
|
async () => {
|
|
27853
28324
|
try {
|
|
27854
|
-
const m = await
|
|
28325
|
+
const [m, elevenLabs] = await Promise.all([
|
|
28326
|
+
client.models(),
|
|
28327
|
+
client.elevenLabsCatalog({ retry: false }).catch(() => null)
|
|
28328
|
+
]);
|
|
27855
28329
|
const lines = m.models.map((x) => {
|
|
27856
28330
|
const price = typeof x.pricing === "number" ? `$${x.pricing}` : JSON.stringify(x.pricing);
|
|
27857
28331
|
return `\u2022 ${x.model} \u2014 ${price} (base USD)`;
|
|
27858
28332
|
});
|
|
27859
28333
|
const analyzeBlock = analyzeCatalogBlock(m.analyze);
|
|
27860
28334
|
const txt = `Modelos de gera\xE7\xE3o:
|
|
27861
|
-
${lines.join("\n") || "(nenhum)"}` + analyzeBlock + `
|
|
28335
|
+
${lines.join("\n") || "(nenhum)"}` + analyzeBlock + elevenLabsCatalogBlock(elevenLabs) + `
|
|
27862
28336
|
|
|
27863
28337
|
Limites simult\xE2neos por usu\xE1rio: imagem=${m.limits.perUserMaxImage}, v\xEDdeo=${m.limits.perUserMaxVideo}, \xE1udio=${m.limits.perUserMaxAudio}.
|
|
27864
28338
|
1 \u{1F48E} \u2248 $${m.pricing.diamondValueUsd} (margem ${m.pricing.diamondMargin}x, m\xEDn ${m.pricing.minDiamonds} \u{1F48E}). Use estimate_cost para o custo exato em diamantes (gera\xE7\xE3o).`;
|
|
@@ -27872,9 +28346,10 @@ Limites simult\xE2neos por usu\xE1rio: imagem=${m.limits.perUserMaxImage}, v\xED
|
|
|
27872
28346
|
"estimate_cost",
|
|
27873
28347
|
{
|
|
27874
28348
|
title: "Estimar custo",
|
|
27875
|
-
description: "Retorna o custo autoritativo em diamantes ANTES de gerar. Para \xE1udio (TTS) o custo \xE9 por segundo e s\xF3 \xE9 conhecido ap\xF3s a s\xEDntese.",
|
|
28349
|
+
description: "Retorna o custo autoritativo em diamantes ANTES de gerar. Para \xE1udio (TTS) o custo \xE9 por segundo e s\xF3 \xE9 conhecido ap\xF3s a s\xEDntese. ElevenLabs: model = elevenlabs/<ferramenta>[/<modelo>], os campos da gera\xE7\xE3o em elevenlabs_params e o arquivo em file (ou dry_run: true na pr\xF3pria ferramenta elevenlabs_*).",
|
|
27876
28350
|
inputSchema: {
|
|
27877
28351
|
model: external_exports.string().min(1).describe("Id do modelo (ex.: google/nano-banana-pro, bytedance/seedance-2.0)."),
|
|
28352
|
+
elevenlabs_params: external_exports.record(external_exports.unknown()).optional().describe('[ElevenLabs] Campos do pedido no formato da API, ex.: { "voice": "...", "text": "..." }.'),
|
|
27878
28353
|
resolution: external_exports.string().optional(),
|
|
27879
28354
|
duration: external_exports.number().int().optional(),
|
|
27880
28355
|
mode: external_exports.string().optional(),
|
|
@@ -27900,6 +28375,9 @@ Limites simult\xE2neos por usu\xE1rio: imagem=${m.limits.perUserMaxImage}, v\xED
|
|
|
27900
28375
|
}
|
|
27901
28376
|
},
|
|
27902
28377
|
async (args) => {
|
|
28378
|
+
if (args.model.startsWith("elevenlabs/")) {
|
|
28379
|
+
return estimateElevenLabsModel(client, cfg, args.model, args.elevenlabs_params, args.file);
|
|
28380
|
+
}
|
|
27903
28381
|
try {
|
|
27904
28382
|
let width2 = args.source_width;
|
|
27905
28383
|
let height = args.source_height;
|
|
@@ -28641,6 +29119,33 @@ var KINDS = {
|
|
|
28641
29119
|
outputs: ["audio", "approved"],
|
|
28642
29120
|
dynamic: "style conforme o modelo; SeedAudio 1.0 tem reference (audio, at\xE9 3 vozes na ordem @Audio1..3), volume seedLoudnessRate (-50..100), usa voice: seed-auto e seedConsent: true com refer\xEAncia; alternativa seedReferenceGenerationId de gera\xE7\xE3o pr\xF3pria"
|
|
28643
29121
|
},
|
|
29122
|
+
"audio-tools": {
|
|
29123
|
+
title: "Ferramentas de \xE1udio",
|
|
29124
|
+
size: { w: 320, h: 212 },
|
|
29125
|
+
data: {
|
|
29126
|
+
tool: "sfx",
|
|
29127
|
+
model: null,
|
|
29128
|
+
voice: null,
|
|
29129
|
+
durationSec: null,
|
|
29130
|
+
loop: false,
|
|
29131
|
+
instrumental: true,
|
|
29132
|
+
removeNoise: false,
|
|
29133
|
+
language: null,
|
|
29134
|
+
diarize: true,
|
|
29135
|
+
audioEvents: false,
|
|
29136
|
+
targetLang: "en",
|
|
29137
|
+
sourceLang: null,
|
|
29138
|
+
dubMode: "v1",
|
|
29139
|
+
history: [],
|
|
29140
|
+
pinned: null,
|
|
29141
|
+
results: [],
|
|
29142
|
+
pinnedResult: null
|
|
29143
|
+
},
|
|
29144
|
+
inputs: ["prompt", "lyrics", "source"],
|
|
29145
|
+
outputs: ["audio", "approved", "text", "subtitle", "video"],
|
|
29146
|
+
dynamic: "as portas mudam com data.tool (sfx, isolate, voice_change, music, stems, transcribe, dub)",
|
|
29147
|
+
main: "tool"
|
|
29148
|
+
},
|
|
28644
29149
|
music: {
|
|
28645
29150
|
title: "Trilha",
|
|
28646
29151
|
size: { w: 320, h: 212 },
|
|
@@ -28731,6 +29236,7 @@ function ratioOfAspect(aspect) {
|
|
|
28731
29236
|
const height = Number(match[2]);
|
|
28732
29237
|
return width2 > 0 && height > 0 ? width2 / height : null;
|
|
28733
29238
|
}
|
|
29239
|
+
var DUB_NOTE = "Dublagem no Canvas exige clique de pessoa: agente n\xE3o roda. ";
|
|
28734
29240
|
function isGeneratorKind(kind) {
|
|
28735
29241
|
return kind === "image" || kind === "video";
|
|
28736
29242
|
}
|
|
@@ -28753,7 +29259,7 @@ function knownPort(kind, side, port) {
|
|
|
28753
29259
|
}
|
|
28754
29260
|
|
|
28755
29261
|
// src/canvas/core.ts
|
|
28756
|
-
import { randomBytes, randomUUID } from "crypto";
|
|
29262
|
+
import { randomBytes, randomUUID as randomUUID2 } from "crypto";
|
|
28757
29263
|
var SCHEMA_VERSION = 1;
|
|
28758
29264
|
var MAX_ENVELOPES_PER_COMMIT = 200;
|
|
28759
29265
|
var MAX_OP_BYTES = 64 * 1024;
|
|
@@ -28839,7 +29345,7 @@ function checkOp(op) {
|
|
|
28839
29345
|
}
|
|
28840
29346
|
}
|
|
28841
29347
|
function envelope(boardId4, op, actorId) {
|
|
28842
|
-
return { id:
|
|
29348
|
+
return { id: randomUUID2(), boardId: boardId4, clientId: CLIENT_ID, actorId, seq: null, ts: Date.now(), op };
|
|
28843
29349
|
}
|
|
28844
29350
|
function checkEnvelope(env) {
|
|
28845
29351
|
const bad = checkOp(env.op);
|
|
@@ -28851,7 +29357,7 @@ function checkEnvelope(env) {
|
|
|
28851
29357
|
}
|
|
28852
29358
|
function emptyBoard(title, now = Date.now()) {
|
|
28853
29359
|
return {
|
|
28854
|
-
id:
|
|
29360
|
+
id: randomUUID2(),
|
|
28855
29361
|
schemaVersion: SCHEMA_VERSION,
|
|
28856
29362
|
title,
|
|
28857
29363
|
ownerId: "",
|
|
@@ -28868,7 +29374,7 @@ function emptyBoard(title, now = Date.now()) {
|
|
|
28868
29374
|
function makeNode(init) {
|
|
28869
29375
|
const now = init.now ?? Date.now();
|
|
28870
29376
|
return {
|
|
28871
|
-
id: init.id ??
|
|
29377
|
+
id: init.id ?? randomUUID2(),
|
|
28872
29378
|
type: init.type,
|
|
28873
29379
|
position: { x: init.position.x, y: init.position.y },
|
|
28874
29380
|
size: { w: init.size.w, h: init.size.h },
|
|
@@ -28882,7 +29388,7 @@ function makeNode(init) {
|
|
|
28882
29388
|
}
|
|
28883
29389
|
function makeEdge(init) {
|
|
28884
29390
|
return {
|
|
28885
|
-
id:
|
|
29391
|
+
id: randomUUID2(),
|
|
28886
29392
|
source: init.source,
|
|
28887
29393
|
sourcePort: init.sourcePort,
|
|
28888
29394
|
target: init.target,
|
|
@@ -30120,7 +30626,7 @@ ${text}`;
|
|
|
30120
30626
|
}
|
|
30121
30627
|
|
|
30122
30628
|
// src/canvas/upload.ts
|
|
30123
|
-
import { randomUUID as
|
|
30629
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
30124
30630
|
import { basename as basename2, extname as extname3 } from "path";
|
|
30125
30631
|
function kindOfMime(mime) {
|
|
30126
30632
|
if (mime.startsWith("image/")) return "image";
|
|
@@ -30160,7 +30666,7 @@ async function uploadMedia(cfg, source, name) {
|
|
|
30160
30666
|
meta: meta ?? {},
|
|
30161
30667
|
measuredBy,
|
|
30162
30668
|
reused,
|
|
30163
|
-
assetId: `asset_${
|
|
30669
|
+
assetId: `asset_${randomUUID3()}`
|
|
30164
30670
|
};
|
|
30165
30671
|
}
|
|
30166
30672
|
function mediaItem(u) {
|
|
@@ -30342,7 +30848,7 @@ ${payload(u)}`
|
|
|
30342
30848
|
}
|
|
30343
30849
|
|
|
30344
30850
|
// src/tools/canvas-run.ts
|
|
30345
|
-
import { randomUUID as
|
|
30851
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
30346
30852
|
var MAX_REMEMBERED = 50;
|
|
30347
30853
|
var acceptedPacing = { repeats: 8, pauseMs: 2e3 };
|
|
30348
30854
|
var statusPacing = {
|
|
@@ -30371,23 +30877,23 @@ function prettyClient(name) {
|
|
|
30371
30877
|
function modeText(mode) {
|
|
30372
30878
|
return mode === "simulated" ? "Simulado (n\xE3o gasta)" : mode === "live" ? "Real" : mode ?? "?";
|
|
30373
30879
|
}
|
|
30374
|
-
function estimateLines(
|
|
30375
|
-
if (!
|
|
30880
|
+
function estimateLines(estimate2, titleOf) {
|
|
30881
|
+
if (!estimate2) return [];
|
|
30376
30882
|
const lines = [];
|
|
30377
|
-
const nodes =
|
|
30883
|
+
const nodes = estimate2.nodes ?? [];
|
|
30378
30884
|
const now = nodes.filter((n) => n.willRun);
|
|
30379
30885
|
for (const n of now) {
|
|
30380
30886
|
const cost = n.error ? `estimativa falhou (${n.error})` : dia(n.diamonds);
|
|
30381
30887
|
lines.push(`- ${n.title ?? titleOf(n.nodeId)} (${n.nodeId}): ${cost}`);
|
|
30382
30888
|
}
|
|
30383
|
-
if (
|
|
30384
|
-
lines.push(`\u2026 e mais ${
|
|
30889
|
+
if (estimate2.omitted) {
|
|
30890
|
+
lines.push(`\u2026 e mais ${estimate2.omitted} n\xF3(s) fora da lista (a resposta da aba foi cortada pelo tamanho; o total vale para todos).`);
|
|
30385
30891
|
}
|
|
30386
|
-
const cached2 =
|
|
30892
|
+
const cached2 = estimate2.cached ?? nodes.filter((n) => !n.willRun && !n.afterApproval).length;
|
|
30387
30893
|
if (cached2) lines.push(`Em cache (n\xE3o rodam): ${cached2}.`);
|
|
30388
|
-
const later =
|
|
30389
|
-
if (later) lines.push(`Esperando aprova\xE7\xE3o no board depois disso: ${later} n\xF3(s), \u2248 ${dia(
|
|
30390
|
-
const unknown2 =
|
|
30894
|
+
const later = estimate2.counts?.later ?? estimate2.later?.nodes?.length ?? 0;
|
|
30895
|
+
if (later) lines.push(`Esperando aprova\xE7\xE3o no board depois disso: ${later} n\xF3(s), \u2248 ${dia(estimate2.later?.total ?? 0)} (fora desta conta).`);
|
|
30896
|
+
const unknown2 = estimate2.counts?.unknown ?? estimate2.unknown?.length ?? 0;
|
|
30391
30897
|
if (unknown2) {
|
|
30392
30898
|
lines.push(`Sem estimativa: ${unknown2} n\xF3(s) (texto cobra por token; o total \xE9 piso).`);
|
|
30393
30899
|
}
|
|
@@ -30493,7 +30999,7 @@ function registerCanvasRunTools(server, api, run) {
|
|
|
30493
30999
|
},
|
|
30494
31000
|
async (args) => run(async () => {
|
|
30495
31001
|
const target = targetOf(args);
|
|
30496
|
-
const requestId = (args.request_id ??
|
|
31002
|
+
const requestId = (args.request_id ?? randomUUID4()).toLowerCase();
|
|
30497
31003
|
const label = args.label ?? prettyClient(server.server.getClientVersion()?.name);
|
|
30498
31004
|
const ask = async () => {
|
|
30499
31005
|
try {
|
|
@@ -31358,7 +31864,7 @@ N\xF3s: ${Object.entries(ids).map(([k, v]) => `${k}=${v}`).join(" \xB7 ")}` : ""
|
|
|
31358
31864
|
"canvas_add_node",
|
|
31359
31865
|
{
|
|
31360
31866
|
title: "Canvas: adicionar n\xF3",
|
|
31361
|
-
description: `Adiciona um n\xF3 (n\xE3o executa). ${READ}kind: ${kindList()}. data completa o padr\xE3o do tipo; label d\xE1 o nome. Sem position, nasce ao lado do n\xF3 ligado ou \xE0 direita do board (com aba, no fim do conte\xFAdo da aba); aba grava data.abaId. Texto livre (label) sem size {w} nasce na largura do tamanho do texto: titulo 2000, subtitulo 1200, corpo 320. Prompt sem size nasce com 1024 \xD7 516; gerador de imagem ou v\xEDdeo, com altura 516 e a largura do aspect_ratio (16:9 917, 9:16 290, 1:1 516). inputs/outputs j\xE1 ligam o n\xF3 no mesmo passo. ` + MENTION_NOTE + MONTAGE_NOTE,
|
|
31867
|
+
description: `Adiciona um n\xF3 (n\xE3o executa). ${READ}kind: ${kindList()}. data completa o padr\xE3o do tipo; label d\xE1 o nome. Sem position, nasce ao lado do n\xF3 ligado ou \xE0 direita do board (com aba, no fim do conte\xFAdo da aba); aba grava data.abaId. Texto livre (label) sem size {w} nasce na largura do tamanho do texto: titulo 2000, subtitulo 1200, corpo 320. Prompt sem size nasce com 1024 \xD7 516; gerador de imagem ou v\xEDdeo, com altura 516 e a largura do aspect_ratio (16:9 917, 9:16 290, 1:1 516). inputs/outputs j\xE1 ligam o n\xF3 no mesmo passo. ` + DUB_NOTE + MENTION_NOTE + MONTAGE_NOTE,
|
|
31362
31868
|
inputSchema: {
|
|
31363
31869
|
board_id: boardId3,
|
|
31364
31870
|
kind: external_exports.string().min(1).max(40),
|
|
@@ -31423,7 +31929,7 @@ N\xF3s: ${Object.entries(ids).map(([k, v]) => `${k}=${v}`).join(" \xB7 ")}` : ""
|
|
|
31423
31929
|
"canvas_update_node",
|
|
31424
31930
|
{
|
|
31425
31931
|
title: "Canvas: editar n\xF3",
|
|
31426
|
-
description: `Muda campos do data de um n\xF3, chave a chave (null apaga a chave), sem executar. ${READ}label renomeia; position move; size {w, h} muda a caixa (piso: o cart\xE3o cresce com o conte\xFAdo). N\xE3o troca o tipo. Cada chave \xE9 gravada inteira: leia antes com canvas_read_node e mande o valor completo j\xE1 revisado, para n\xE3o apagar o que outra pessoa escreveu. Para mudar partes de uma estrutura grande (clipes da timeline), use canvas_patch_node, por caminho; v\xE1rios n\xF3s de uma vez, canvas_update_nodes. ` + MENTION_NOTE + MONTAGE_NOTE,
|
|
31932
|
+
description: `Muda campos do data de um n\xF3, chave a chave (null apaga a chave), sem executar. ${READ}label renomeia; position move; size {w, h} muda a caixa (piso: o cart\xE3o cresce com o conte\xFAdo). N\xE3o troca o tipo. Cada chave \xE9 gravada inteira: leia antes com canvas_read_node e mande o valor completo j\xE1 revisado, para n\xE3o apagar o que outra pessoa escreveu. Para mudar partes de uma estrutura grande (clipes da timeline), use canvas_patch_node, por caminho; v\xE1rios n\xF3s de uma vez, canvas_update_nodes. ` + DUB_NOTE + MENTION_NOTE + MONTAGE_NOTE,
|
|
31427
31933
|
inputSchema: {
|
|
31428
31934
|
board_id: boardId3,
|
|
31429
31935
|
node_id: nodeIdArg2,
|
|
@@ -31451,7 +31957,7 @@ N\xF3s: ${Object.entries(ids).map(([k, v]) => `${k}=${v}`).join(" \xB7 ")}` : ""
|
|
|
31451
31957
|
"canvas_update_nodes",
|
|
31452
31958
|
{
|
|
31453
31959
|
title: "Canvas: editar v\xE1rios n\xF3s",
|
|
31454
|
-
description: 'Muda v\xE1rios n\xF3s num passo s\xF3, cada um como no canvas_update_node (position, size, label, data com null apagando). layout_only: true aceita s\xF3 position e size {w, h}, n\xE3o exige leitura e n\xE3o recusa por "outra pessoa mexeu" (nesses dois campos vale quem grava por \xFAltimo). Sem layout_only, exige canvas_read_board nesta sess\xE3o e recusa se outra pessoa mexeu em algum desses n\xF3s. Quebra em envelopes de at\xE9 64 KB e relata cada um. Para arrumar linhas inteiras (t\xEDtulo, prompt, refer\xEAncia, gerador), use canvas_arrange_rows.',
|
|
31960
|
+
description: 'Muda v\xE1rios n\xF3s num passo s\xF3, cada um como no canvas_update_node (position, size, label, data com null apagando). layout_only: true aceita s\xF3 position e size {w, h}, n\xE3o exige leitura e n\xE3o recusa por "outra pessoa mexeu" (nesses dois campos vale quem grava por \xFAltimo). Sem layout_only, exige canvas_read_board nesta sess\xE3o e recusa se outra pessoa mexeu em algum desses n\xF3s. Quebra em envelopes de at\xE9 64 KB e relata cada um. Para arrumar linhas inteiras (t\xEDtulo, prompt, refer\xEAncia, gerador), use canvas_arrange_rows. ' + DUB_NOTE,
|
|
31455
31961
|
inputSchema: {
|
|
31456
31962
|
board_id: boardId3,
|
|
31457
31963
|
nodes: external_exports.array(
|
|
@@ -31503,7 +32009,7 @@ N\xF3s: ${Object.entries(ids).map(([k, v]) => `${k}=${v}`).join(" \xB7 ")}` : ""
|
|
|
31503
32009
|
"canvas_patch_node",
|
|
31504
32010
|
{
|
|
31505
32011
|
title: "Canvas: gravar por caminho",
|
|
31506
|
-
description: `Grava v\xE1rios caminhos dentro do data de um n\xF3, sem executar: {path, value} grava, {path, unset: true} apaga. ${READ}O caminho atravessa objetos (o n\xEDvel que falta \xE9 criado) e n\xE3o entra em lista: para mudar um item de lista, grave a lista inteira. Quebra sozinho em envelopes de at\xE9 64 KB, em ordem, e devolve o resultado de cada um; entre envelopes n\xE3o h\xE1 atomicidade (o que entrou fica). Serve para mexer em partes de uma estrutura grande, como clipes da timeline da Montagem, sem reenviar tudo. Leia antes com canvas_read_node. ` + MENTION_NOTE + MONTAGE_NOTE,
|
|
32012
|
+
description: `Grava v\xE1rios caminhos dentro do data de um n\xF3, sem executar: {path, value} grava, {path, unset: true} apaga. ${READ}O caminho atravessa objetos (o n\xEDvel que falta \xE9 criado) e n\xE3o entra em lista: para mudar um item de lista, grave a lista inteira. Quebra sozinho em envelopes de at\xE9 64 KB, em ordem, e devolve o resultado de cada um; entre envelopes n\xE3o h\xE1 atomicidade (o que entrou fica). Serve para mexer em partes de uma estrutura grande, como clipes da timeline da Montagem, sem reenviar tudo. Leia antes com canvas_read_node. ` + DUB_NOTE + MENTION_NOTE + MONTAGE_NOTE,
|
|
31507
32013
|
inputSchema: {
|
|
31508
32014
|
board_id: boardId3,
|
|
31509
32015
|
node_id: nodeIdArg2,
|
|
@@ -31743,7 +32249,7 @@ N\xF3s: ${Object.entries(ids).map(([k, v]) => `${k}=${v}`).join(" \xB7 ")}` : ""
|
|
|
31743
32249
|
import { createRequire } from "module";
|
|
31744
32250
|
var require2 = createRequire(import.meta.url);
|
|
31745
32251
|
function readVersion() {
|
|
31746
|
-
if ("0.
|
|
32252
|
+
if ("0.46.0") return "0.46.0";
|
|
31747
32253
|
try {
|
|
31748
32254
|
const pkg = require2("../package.json");
|
|
31749
32255
|
return pkg.version ?? "0.0.0-unknown";
|
|
@@ -31756,7 +32262,7 @@ var VERSION = readVersion();
|
|
|
31756
32262
|
// src/server.ts
|
|
31757
32263
|
var SERVER_INSTRUCTIONS = [
|
|
31758
32264
|
"BePlus: tudo roda pela conta do usu\xE1rio (diamantes, limites e hist\xF3rico na plataforma).",
|
|
31759
|
-
'M\xEDdia: generate_*
|
|
32265
|
+
'M\xEDdia: generate_* e elevenlabs_* gastam diamantes; confira com estimate_cost antes de lotes grandes. Sem project, a gera\xE7\xE3o cai no projeto ativo; billing:"personal" cobra do usu\xE1rio.',
|
|
31760
32266
|
"Calls: search_calls acha, get_call traz a transcri\xE7\xE3o.",
|
|
31761
32267
|
"Canvas online (canvas_*): leia com canvas_read_board antes de editar e siga o estado lido. Cada edi\xE7\xE3o vai num passo s\xF3; se outra pessoa mexeu nos mesmos n\xF3s, a ferramenta recusa e pede releitura. As canvas_* n\xE3o geram m\xEDdia, exceto canvas_run: roda n\xF3s pela aba do Canvas aberta do usu\xE1rio e gasta diamantes; max_diamonds \xE9 o teto que o usu\xE1rio autorizou (dry_run s\xF3 estima). D\xEA nome (label) aos n\xF3s, n\xE3o invente tipos nem portas, e confirme antes de canvas_delete.",
|
|
31762
32268
|
"Cada aba \xE9 um plano: ao criar, passe aba (id da se\xE7\xE3o) em canvas_add_node e canvas_upload_media, sen\xE3o o cart\xE3o pode cair em Avulsos. canvas_read_board com aba l\xEA uma aba s\xF3.",
|
|
@@ -31771,6 +32277,7 @@ function buildServer(cfg) {
|
|
|
31771
32277
|
registerUpscaleTools(server, client, cfg);
|
|
31772
32278
|
registerAudioTools(server, client, cfg);
|
|
31773
32279
|
registerMusicTools(server, client, cfg);
|
|
32280
|
+
registerElevenLabsTools(server, client, cfg);
|
|
31774
32281
|
registerAccountTools(server, client, cfg);
|
|
31775
32282
|
registerAnalyzeTools(server, client, cfg);
|
|
31776
32283
|
registerProjectTools(server, client, cfg);
|