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/index.js
CHANGED
|
@@ -24301,7 +24301,7 @@ var BeplusClient = class {
|
|
|
24301
24301
|
const started = Date.now();
|
|
24302
24302
|
for (let attempt = 0; ; attempt++) {
|
|
24303
24303
|
let res = null;
|
|
24304
|
-
let
|
|
24304
|
+
let failure2 = null;
|
|
24305
24305
|
try {
|
|
24306
24306
|
res = await fetchWithAuth(
|
|
24307
24307
|
this.cfg,
|
|
@@ -24316,11 +24316,11 @@ var BeplusClient = class {
|
|
|
24316
24316
|
);
|
|
24317
24317
|
} catch (e) {
|
|
24318
24318
|
if (!(e instanceof ApiError) || e.httpStatus !== 0) throw e;
|
|
24319
|
-
|
|
24319
|
+
failure2 = e;
|
|
24320
24320
|
}
|
|
24321
24321
|
const status = res ? res.status : 0;
|
|
24322
24322
|
if (!retry || !RETRYABLE.has(status)) {
|
|
24323
|
-
if (
|
|
24323
|
+
if (failure2) throw failure2;
|
|
24324
24324
|
return this.read(res, path);
|
|
24325
24325
|
}
|
|
24326
24326
|
const step = Math.min(p.capMs, p.baseMs * 2 ** attempt);
|
|
@@ -24438,6 +24438,29 @@ var BeplusClient = class {
|
|
|
24438
24438
|
);
|
|
24439
24439
|
return r?.state ?? null;
|
|
24440
24440
|
}
|
|
24441
|
+
// `retry: false` nas leituras de apoio: 503 aqui é "não configurado" e não pode segurar list_models nem check_generation.
|
|
24442
|
+
elevenLabsCatalog(opts = {}) {
|
|
24443
|
+
return this.request("GET", "/elevenlabs/catalog", { timeoutMs: 15e3, ...opts });
|
|
24444
|
+
}
|
|
24445
|
+
elevenLabsVoices(query) {
|
|
24446
|
+
return this.request("GET", "/elevenlabs/voices", { query, timeoutMs: 2e4 });
|
|
24447
|
+
}
|
|
24448
|
+
deleteElevenLabsVoice(id) {
|
|
24449
|
+
return this.request("DELETE", `/elevenlabs/voices/${encodeURIComponent(id)}`, { timeoutMs: 3e4 });
|
|
24450
|
+
}
|
|
24451
|
+
saveElevenLabsVoice(body2) {
|
|
24452
|
+
return this.request("POST", "/elevenlabs/voices/design/save", { body: body2, timeoutMs: 6e4 });
|
|
24453
|
+
}
|
|
24454
|
+
elevenLabsEstimate(body2) {
|
|
24455
|
+
return this.request("POST", "/elevenlabs/estimate", { body: body2, timeoutMs: 6e4 });
|
|
24456
|
+
}
|
|
24457
|
+
// Sem repetição: este POST cobra. Ferramenta longa volta `processing` logo, a rápida segura até a resposta.
|
|
24458
|
+
elevenLabsGenerate(body2) {
|
|
24459
|
+
return this.request("POST", "/elevenlabs/generate", { body: body2, timeoutMs: 18e4 });
|
|
24460
|
+
}
|
|
24461
|
+
elevenLabsJob(id, opts = {}) {
|
|
24462
|
+
return this.request("GET", `/elevenlabs/generations/${encodeURIComponent(id)}`, { timeoutMs: 15e3, ...opts });
|
|
24463
|
+
}
|
|
24441
24464
|
models() {
|
|
24442
24465
|
return this.request("GET", "/models");
|
|
24443
24466
|
}
|
|
@@ -24835,6 +24858,11 @@ async function uploadBytes(cfg, file) {
|
|
|
24835
24858
|
}
|
|
24836
24859
|
return fileUrl;
|
|
24837
24860
|
}
|
|
24861
|
+
async function toStorageUrl(cfg, ref) {
|
|
24862
|
+
if (!isRemoteRef(ref)) return uploadBytes(cfg, await loadLocal(ref));
|
|
24863
|
+
if (new URL(ref).host === BEPLUS_STORAGE_HOST) return ref;
|
|
24864
|
+
return uploadBytes(cfg, await loadRemote(ref));
|
|
24865
|
+
}
|
|
24838
24866
|
async function uploadFile(cfg, ref) {
|
|
24839
24867
|
return uploadBytes(cfg, await loadLocal(ref));
|
|
24840
24868
|
}
|
|
@@ -25130,6 +25158,19 @@ var ASPECT_RATIOS = ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "4:5", "
|
|
|
25130
25158
|
var VIDEO_ASPECT_RATIOS = [...ASPECT_RATIOS, "adaptive"];
|
|
25131
25159
|
var IMAGE_RESOLUTIONS = ["1K", "2K", "4K"];
|
|
25132
25160
|
var VIDEO_RESOLUTIONS = ["480p", "720p", "1080p", "4K"];
|
|
25161
|
+
var ELEVENLABS_TOOLS = [
|
|
25162
|
+
"tts",
|
|
25163
|
+
"dialogue",
|
|
25164
|
+
"sfx",
|
|
25165
|
+
"isolate",
|
|
25166
|
+
"voice_change",
|
|
25167
|
+
"transcribe",
|
|
25168
|
+
"align",
|
|
25169
|
+
"music",
|
|
25170
|
+
"stems",
|
|
25171
|
+
"video_music",
|
|
25172
|
+
"voice_design"
|
|
25173
|
+
];
|
|
25133
25174
|
var DEFAULTS = {
|
|
25134
25175
|
imageModel: "google/nano-banana-2.1",
|
|
25135
25176
|
imageAspect: "1:1",
|
|
@@ -25388,6 +25429,433 @@ function formatToolResult(state, fullWords) {
|
|
|
25388
25429
|
return lines.join("\n") || "(sem resultado)";
|
|
25389
25430
|
}
|
|
25390
25431
|
|
|
25432
|
+
// src/tools/elevenlabs.ts
|
|
25433
|
+
import { randomUUID } from "crypto";
|
|
25434
|
+
var elevenLabsPolling = {
|
|
25435
|
+
intervalMs: 3e3,
|
|
25436
|
+
budgetMs: 9e4,
|
|
25437
|
+
sleep: (ms) => new Promise((r) => setTimeout(r, ms))
|
|
25438
|
+
};
|
|
25439
|
+
var MAX_TEXT_CHARS = 2e4;
|
|
25440
|
+
var SITE_ONLY_TOOLS = /* @__PURE__ */ new Set(["dub", "voice_clone"]);
|
|
25441
|
+
var SITE_ONLY_LABEL = "s\xF3 no site da BePlus, na aba \xC1udio do IA Lab";
|
|
25442
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
25443
|
+
var DESTINATION_NOTE = " Vai para o cliente e projeto ativos: confirme o destino com o usu\xE1rio antes (list_clients, list_projects).";
|
|
25444
|
+
var COST_NOTE = " Gasta diamantes; dry_run: true mostra o custo sem gastar.";
|
|
25445
|
+
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).";
|
|
25446
|
+
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.";
|
|
25447
|
+
var COMMON_FIELDS = {
|
|
25448
|
+
project: external_exports.string().max(64).optional().describe("Projeto (uuid ou code curto). Omita para usar o projeto ativo."),
|
|
25449
|
+
billing: external_exports.enum(["personal"]).optional().describe('"personal" cobra do seu saldo pessoal e ignora o projeto, mesmo o ativo. Incompat\xEDvel com project.'),
|
|
25450
|
+
dry_run: external_exports.boolean().optional().describe("true devolve o custo em diamantes sem gerar nem gastar.")
|
|
25451
|
+
};
|
|
25452
|
+
function contractMessage(e) {
|
|
25453
|
+
if (!(e instanceof ApiError)) return void 0;
|
|
25454
|
+
const body2 = e.body;
|
|
25455
|
+
const message = body2?.error?.message ?? body2?.result?.error?.message;
|
|
25456
|
+
return typeof message === "string" && message ? message : void 0;
|
|
25457
|
+
}
|
|
25458
|
+
async function failure(client, e) {
|
|
25459
|
+
const ready = contractMessage(e);
|
|
25460
|
+
const raw = ready ?? (e instanceof Error ? e.message : "");
|
|
25461
|
+
if (isTeamGatingError(raw)) return errorResult(await buildPickProjectMessage(client));
|
|
25462
|
+
const text = ready ?? apiErrorToUserMessage(e);
|
|
25463
|
+
return errorResult(isBudgetBlockedError(raw) ? `${text}
|
|
25464
|
+
${BUDGET_BLOCKED_GUIDANCE}` : text);
|
|
25465
|
+
}
|
|
25466
|
+
var VOICE_ORIGIN = { premade: "padr\xE3o", library: "biblioteca", mine: "sua" };
|
|
25467
|
+
function voiceLine(v) {
|
|
25468
|
+
const traits = [v.language, v.gender, v.accent].filter(Boolean).join(", ");
|
|
25469
|
+
const description = v.description ? ` | ${v.description.length > 110 ? `${v.description.slice(0, 107)}...` : v.description}` : "";
|
|
25470
|
+
return `${v.id} | ${v.name} | ${VOICE_ORIGIN[v.source]}${traits ? ` | ${traits}` : ""}${description}`;
|
|
25471
|
+
}
|
|
25472
|
+
function jobFooter(job) {
|
|
25473
|
+
const balance = job.balance === void 0 ? "" : ` \xB7 Saldo: ${job.balance} \u{1F48E}`;
|
|
25474
|
+
return `Gera\xE7\xE3o: ${job.generationId}
|
|
25475
|
+
Custo: ${job.diamonds} \u{1F48E}${balance}`;
|
|
25476
|
+
}
|
|
25477
|
+
function formatJob(job) {
|
|
25478
|
+
if (job.status === "failed") return errorResult(`${job.error?.message ?? "A gera\xE7\xE3o falhou."}
|
|
25479
|
+
${jobFooter(job)}`);
|
|
25480
|
+
if (job.status === "processing") {
|
|
25481
|
+
return textResult(
|
|
25482
|
+
`\u23F3 Ainda em processamento. N\xE3o gere de novo: use check_generation com o id abaixo.
|
|
25483
|
+
${jobFooter(job)}`
|
|
25484
|
+
);
|
|
25485
|
+
}
|
|
25486
|
+
const out = job.output ?? {};
|
|
25487
|
+
const lines = [`\u2705 Pronto (${job.tool}).`];
|
|
25488
|
+
for (const f of out.files ?? []) {
|
|
25489
|
+
const duration3 = f.durationSec === void 0 ? "" : ` (${f.durationSec.toFixed(1)}s)`;
|
|
25490
|
+
lines.push(`${f.label ? `${f.label}: ` : ""}${f.url}${duration3}`);
|
|
25491
|
+
}
|
|
25492
|
+
if (out.text) {
|
|
25493
|
+
const cut = out.text.length > MAX_TEXT_CHARS;
|
|
25494
|
+
lines.push(cut ? `${out.text.slice(0, MAX_TEXT_CHARS)}
|
|
25495
|
+
[texto cortado em ${MAX_TEXT_CHARS} caracteres]` : out.text);
|
|
25496
|
+
}
|
|
25497
|
+
if (out.words?.length) {
|
|
25498
|
+
const speakers = new Set(out.words.map((w) => w.speaker).filter(Boolean)).size;
|
|
25499
|
+
lines.push(`${out.words.length} palavras com tempo${speakers ? `, ${speakers} locutores` : ""}.`);
|
|
25500
|
+
}
|
|
25501
|
+
if (out.srtUrl) lines.push(`Legenda: ${out.srtUrl}`);
|
|
25502
|
+
if (out.previews?.length) {
|
|
25503
|
+
lines.push("Pr\xE9vias (id | \xE1udio):", ...out.previews.map((p) => `${p.id} | ${p.url}`));
|
|
25504
|
+
lines.push("Mostre as pr\xE9vias ao usu\xE1rio. A escolhida vira voz com elevenlabs_voice_design_save.");
|
|
25505
|
+
}
|
|
25506
|
+
if (out.voice) lines.push(`Voz: ${voiceLine(out.voice)}`);
|
|
25507
|
+
lines.push(jobFooter(job));
|
|
25508
|
+
return textResult(lines.join("\n"));
|
|
25509
|
+
}
|
|
25510
|
+
async function waitForJob(client, first) {
|
|
25511
|
+
const { intervalMs, budgetMs, sleep: sleep4 } = elevenLabsPolling;
|
|
25512
|
+
let job = first;
|
|
25513
|
+
for (let waited = 0; job.status === "processing" && waited < budgetMs; waited += intervalMs) {
|
|
25514
|
+
await sleep4(intervalMs);
|
|
25515
|
+
try {
|
|
25516
|
+
job = await client.elevenLabsJob(first.generationId);
|
|
25517
|
+
} catch {
|
|
25518
|
+
return job;
|
|
25519
|
+
}
|
|
25520
|
+
}
|
|
25521
|
+
return job;
|
|
25522
|
+
}
|
|
25523
|
+
async function toSource(cfg, ref) {
|
|
25524
|
+
if (UUID.test(ref)) return { generationId: ref };
|
|
25525
|
+
try {
|
|
25526
|
+
return { fileUrl: await toStorageUrl(cfg, ref) };
|
|
25527
|
+
} catch (e) {
|
|
25528
|
+
if (e instanceof ApiError && e.httpStatus === 413) throw new ApiError(413, TOO_LARGE_MESSAGE);
|
|
25529
|
+
throw e;
|
|
25530
|
+
}
|
|
25531
|
+
}
|
|
25532
|
+
function uploadedHint(body2) {
|
|
25533
|
+
const url = body2.source?.fileUrl;
|
|
25534
|
+
return url ? `
|
|
25535
|
+
Arquivo na BePlus: ${url}. Use esta URL em source para n\xE3o subir de novo.` : "";
|
|
25536
|
+
}
|
|
25537
|
+
async function estimate(client, body2) {
|
|
25538
|
+
const res = await client.elevenLabsEstimate(body2);
|
|
25539
|
+
const duration3 = res.durationSec === void 0 ? "" : ` para ${res.durationSec.toFixed(1)}s`;
|
|
25540
|
+
return textResult(`Custo estimado: ${res.diamonds} \u{1F48E}${duration3}. Nada foi gerado nem cobrado.${uploadedHint(body2)}`);
|
|
25541
|
+
}
|
|
25542
|
+
async function generate(client, body2) {
|
|
25543
|
+
let job;
|
|
25544
|
+
try {
|
|
25545
|
+
job = await client.elevenLabsGenerate({ ...body2, idempotencyKey: randomUUID() });
|
|
25546
|
+
} catch (e) {
|
|
25547
|
+
if (e instanceof ApiError && (e.httpStatus === 0 || e.httpStatus === 408)) {
|
|
25548
|
+
return errorResult(
|
|
25549
|
+
"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."
|
|
25550
|
+
);
|
|
25551
|
+
}
|
|
25552
|
+
throw e;
|
|
25553
|
+
}
|
|
25554
|
+
return formatJob(await waitForJob(client, job));
|
|
25555
|
+
}
|
|
25556
|
+
async function estimateElevenLabsModel(client, cfg, model, params, file) {
|
|
25557
|
+
const [, tool, variant] = model.split("/");
|
|
25558
|
+
if (!ELEVENLABS_TOOLS.includes(tool ?? "")) {
|
|
25559
|
+
return errorResult(`Ferramenta desconhecida em "${model}". Use elevenlabs/<ferramenta>: ${ELEVENLABS_TOOLS.join(", ")}.`);
|
|
25560
|
+
}
|
|
25561
|
+
try {
|
|
25562
|
+
const body2 = { ...params, tool };
|
|
25563
|
+
if (variant) body2.model = variant;
|
|
25564
|
+
if (file) body2.source = await toSource(cfg, file);
|
|
25565
|
+
return await estimate(client, body2);
|
|
25566
|
+
} catch (e) {
|
|
25567
|
+
return failure(client, e);
|
|
25568
|
+
}
|
|
25569
|
+
}
|
|
25570
|
+
function elevenLabsCatalogBlock(catalog) {
|
|
25571
|
+
if (!catalog?.enabled) return "";
|
|
25572
|
+
const lines = catalog.tools.filter((t) => t.available).map((t) => {
|
|
25573
|
+
if (SITE_ONLY_TOOLS.has(t.tool)) return `\u2022 ${t.label}: ${SITE_ONLY_LABEL}.`;
|
|
25574
|
+
const models = t.models?.length ? ` Modelos: ${t.models.map((m) => m.id).join(", ")}.` : "";
|
|
25575
|
+
return `\u2022 elevenlabs_${t.tool}: ${t.label}, ${t.diamondsPerUnitHint}.${models}`;
|
|
25576
|
+
});
|
|
25577
|
+
return lines.length ? `
|
|
25578
|
+
|
|
25579
|
+
ElevenLabs (detalhes e limites em elevenlabs_catalog):
|
|
25580
|
+
${lines.join("\n")}` : "";
|
|
25581
|
+
}
|
|
25582
|
+
function registerElevenLabsTools(server, client, cfg) {
|
|
25583
|
+
function spendTool(name, title, description, shape, build2) {
|
|
25584
|
+
server.registerTool(
|
|
25585
|
+
name,
|
|
25586
|
+
{
|
|
25587
|
+
title,
|
|
25588
|
+
description: description + COST_NOTE + DESTINATION_NOTE,
|
|
25589
|
+
inputSchema: { ...shape, ...COMMON_FIELDS },
|
|
25590
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true }
|
|
25591
|
+
},
|
|
25592
|
+
(async (args) => {
|
|
25593
|
+
try {
|
|
25594
|
+
const body2 = compact({
|
|
25595
|
+
...await build2(args),
|
|
25596
|
+
project: resolveProjectArg(args.project, args.billing, cfg.activeProject),
|
|
25597
|
+
billing: args.billing
|
|
25598
|
+
});
|
|
25599
|
+
return await (args.dry_run ? estimate(client, body2) : generate(client, body2));
|
|
25600
|
+
} catch (e) {
|
|
25601
|
+
return failure(client, e);
|
|
25602
|
+
}
|
|
25603
|
+
})
|
|
25604
|
+
);
|
|
25605
|
+
}
|
|
25606
|
+
const modelField = (example) => external_exports.string().min(1).describe(`Id do modelo, ex.: ${example}. A lista sai de elevenlabs_catalog.`);
|
|
25607
|
+
const voiceField = external_exports.string().min(1).describe("Id de uma voz de elevenlabs_list_voices. Outra voz \xE9 recusada.");
|
|
25608
|
+
const sourceField = external_exports.string().min(1).describe(SOURCE_HELP);
|
|
25609
|
+
server.registerTool(
|
|
25610
|
+
"elevenlabs_catalog",
|
|
25611
|
+
{
|
|
25612
|
+
title: "ElevenLabs: ferramentas e modelos",
|
|
25613
|
+
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.",
|
|
25614
|
+
inputSchema: {},
|
|
25615
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
25616
|
+
},
|
|
25617
|
+
async () => {
|
|
25618
|
+
try {
|
|
25619
|
+
const catalog = await client.elevenLabsCatalog();
|
|
25620
|
+
if (!catalog.enabled) return textResult("A ElevenLabs est\xE1 desligada na plataforma agora.");
|
|
25621
|
+
const lines = catalog.tools.map((t) => {
|
|
25622
|
+
if (SITE_ONLY_TOOLS.has(t.tool)) return `${t.label}: ${SITE_ONLY_LABEL}. N\xE3o h\xE1 tool para isso aqui.`;
|
|
25623
|
+
const head = `elevenlabs_${t.tool} | ${t.label} | ${t.available ? t.diamondsPerUnitHint : "indispon\xEDvel agora"}`;
|
|
25624
|
+
const models = (t.models ?? []).map((m) => ` ${m.id}: ${m.label}. ${m.description}`);
|
|
25625
|
+
return [head, ` ${t.description}`, ` Limites: ${JSON.stringify(t.limits)}`, ...models].join("\n");
|
|
25626
|
+
});
|
|
25627
|
+
return textResult(lines.join("\n"));
|
|
25628
|
+
} catch (e) {
|
|
25629
|
+
return failure(client, e);
|
|
25630
|
+
}
|
|
25631
|
+
}
|
|
25632
|
+
);
|
|
25633
|
+
server.registerTool(
|
|
25634
|
+
"elevenlabs_list_voices",
|
|
25635
|
+
{
|
|
25636
|
+
title: "ElevenLabs: listar vozes",
|
|
25637
|
+
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.",
|
|
25638
|
+
inputSchema: {
|
|
25639
|
+
search: external_exports.string().max(100).optional().describe("Texto livre: nome, descri\xE7\xE3o, sotaque."),
|
|
25640
|
+
language: external_exports.string().max(12).optional().describe("Idioma, ex.: pt, en."),
|
|
25641
|
+
gender: external_exports.string().max(20).optional(),
|
|
25642
|
+
page: external_exports.number().int().min(1).optional().describe("Padr\xE3o 1.")
|
|
25643
|
+
},
|
|
25644
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
25645
|
+
},
|
|
25646
|
+
async (args) => {
|
|
25647
|
+
try {
|
|
25648
|
+
const res = await client.elevenLabsVoices(compact(args));
|
|
25649
|
+
if (!res.voices.length) return textResult("Nenhuma voz encontrada com esses filtros.");
|
|
25650
|
+
const more = res.hasMore ? `
|
|
25651
|
+
Use page=${res.page + 1} para ver mais.` : "";
|
|
25652
|
+
return textResult(`Vozes, p\xE1gina ${res.page} (id | nome | origem | detalhes):
|
|
25653
|
+
${res.voices.map(voiceLine).join("\n")}${more}`);
|
|
25654
|
+
} catch (e) {
|
|
25655
|
+
return failure(client, e);
|
|
25656
|
+
}
|
|
25657
|
+
}
|
|
25658
|
+
);
|
|
25659
|
+
server.registerTool(
|
|
25660
|
+
"elevenlabs_delete_voice",
|
|
25661
|
+
{
|
|
25662
|
+
title: "ElevenLabs: apagar voz sua",
|
|
25663
|
+
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.",
|
|
25664
|
+
inputSchema: { id: external_exports.string().min(1).describe('Id da voz em elevenlabs_list_voices, com origem "sua".') },
|
|
25665
|
+
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true }
|
|
25666
|
+
},
|
|
25667
|
+
async ({ id }) => {
|
|
25668
|
+
try {
|
|
25669
|
+
await client.deleteElevenLabsVoice(id);
|
|
25670
|
+
return textResult(`\u2705 Voz ${id} apagada.`);
|
|
25671
|
+
} catch (e) {
|
|
25672
|
+
return failure(client, e);
|
|
25673
|
+
}
|
|
25674
|
+
}
|
|
25675
|
+
);
|
|
25676
|
+
server.registerTool(
|
|
25677
|
+
"elevenlabs_voice_design_save",
|
|
25678
|
+
{
|
|
25679
|
+
title: "ElevenLabs: salvar voz criada",
|
|
25680
|
+
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.",
|
|
25681
|
+
inputSchema: {
|
|
25682
|
+
preview_id: external_exports.string().min(1).describe("Id da pr\xE9via escolhida."),
|
|
25683
|
+
name: external_exports.string().min(1).max(40).describe("Nome da voz.")
|
|
25684
|
+
},
|
|
25685
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true }
|
|
25686
|
+
},
|
|
25687
|
+
async ({ preview_id, name }) => {
|
|
25688
|
+
try {
|
|
25689
|
+
const voice = await client.saveElevenLabsVoice({ previewId: preview_id, name });
|
|
25690
|
+
return textResult(`\u2705 Voz salva.
|
|
25691
|
+
${voiceLine(voice)}`);
|
|
25692
|
+
} catch (e) {
|
|
25693
|
+
return failure(client, e);
|
|
25694
|
+
}
|
|
25695
|
+
}
|
|
25696
|
+
);
|
|
25697
|
+
spendTool(
|
|
25698
|
+
"elevenlabs_tts",
|
|
25699
|
+
"ElevenLabs: texto em fala",
|
|
25700
|
+
"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.",
|
|
25701
|
+
{
|
|
25702
|
+
text: external_exports.string().min(1).describe("Texto a falar. O teto depende do modelo."),
|
|
25703
|
+
voice: voiceField,
|
|
25704
|
+
model: modelField("eleven_v4"),
|
|
25705
|
+
language: external_exports.string().max(12).optional().describe("Idioma do texto, ex.: pt."),
|
|
25706
|
+
stability: external_exports.number().min(0).max(1).optional(),
|
|
25707
|
+
similarity: external_exports.number().min(0).max(1).optional(),
|
|
25708
|
+
style: external_exports.number().min(0).max(1).optional().describe("N\xE3o vale nos modelos eleven_v4."),
|
|
25709
|
+
speed: external_exports.number().positive().optional().describe("N\xE3o vale nos modelos eleven_v4.")
|
|
25710
|
+
},
|
|
25711
|
+
({ text, voice, model, language, stability, similarity, style, speed }) => {
|
|
25712
|
+
if (model.startsWith("eleven_v4") && (style !== void 0 || speed !== void 0)) {
|
|
25713
|
+
throw new Error("Os modelos eleven_v4 n\xE3o aceitam style nem speed. Tire esses campos ou troque o modelo.");
|
|
25714
|
+
}
|
|
25715
|
+
const settings = compact({ stability, similarity, style, speed });
|
|
25716
|
+
return { tool: "tts", text, voice, model, language, settings: Object.keys(settings).length ? settings : void 0 };
|
|
25717
|
+
}
|
|
25718
|
+
);
|
|
25719
|
+
spendTool(
|
|
25720
|
+
"elevenlabs_dialogue",
|
|
25721
|
+
"ElevenLabs: di\xE1logo",
|
|
25722
|
+
"Conversa entre duas ou mais vozes num \xE1udio s\xF3, na ordem das falas. Para uma voz s\xF3 use elevenlabs_tts.",
|
|
25723
|
+
{
|
|
25724
|
+
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."),
|
|
25725
|
+
model: modelField("eleven_v3")
|
|
25726
|
+
},
|
|
25727
|
+
({ lines, model }) => ({ tool: "dialogue", lines, model })
|
|
25728
|
+
);
|
|
25729
|
+
spendTool(
|
|
25730
|
+
"elevenlabs_sfx",
|
|
25731
|
+
"ElevenLabs: efeito sonoro",
|
|
25732
|
+
"Cria um efeito sonoro a partir de uma descri\xE7\xE3o (porta batendo, chuva, whoosh). Para trilha musical use elevenlabs_music.",
|
|
25733
|
+
{
|
|
25734
|
+
text: external_exports.string().min(1).describe("Descri\xE7\xE3o do som."),
|
|
25735
|
+
model: modelField("eleven_text_to_sound_v2"),
|
|
25736
|
+
duration_sec: external_exports.number().positive().optional().describe("De 0,5 a 30 s. Omita para o modelo decidir."),
|
|
25737
|
+
loop: external_exports.boolean().optional().describe("true faz o som emendar sem corte."),
|
|
25738
|
+
prompt_influence: external_exports.number().min(0).max(1).optional().describe("Quanto seguir a descri\xE7\xE3o ao p\xE9 da letra.")
|
|
25739
|
+
},
|
|
25740
|
+
({ text, model, duration_sec, loop, prompt_influence }) => ({
|
|
25741
|
+
tool: "sfx",
|
|
25742
|
+
text,
|
|
25743
|
+
model,
|
|
25744
|
+
durationSec: duration_sec,
|
|
25745
|
+
loop,
|
|
25746
|
+
promptInfluence: prompt_influence
|
|
25747
|
+
})
|
|
25748
|
+
);
|
|
25749
|
+
spendTool(
|
|
25750
|
+
"elevenlabs_isolate",
|
|
25751
|
+
"ElevenLabs: isolar voz",
|
|
25752
|
+
"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.",
|
|
25753
|
+
{ source: sourceField },
|
|
25754
|
+
async ({ source }) => ({ tool: "isolate", source: await toSource(cfg, source) })
|
|
25755
|
+
);
|
|
25756
|
+
spendTool(
|
|
25757
|
+
"elevenlabs_voice_change",
|
|
25758
|
+
"ElevenLabs: trocar a voz",
|
|
25759
|
+
"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.",
|
|
25760
|
+
{
|
|
25761
|
+
source: sourceField,
|
|
25762
|
+
voice: voiceField,
|
|
25763
|
+
model: external_exports.string().min(1).optional().describe("Id do modelo, ex.: eleven_multilingual_sts_v2."),
|
|
25764
|
+
remove_noise: external_exports.boolean().optional().describe("true limpa o ru\xEDdo da grava\xE7\xE3o antes.")
|
|
25765
|
+
},
|
|
25766
|
+
async ({ source, voice, model, remove_noise }) => ({
|
|
25767
|
+
tool: "voice_change",
|
|
25768
|
+
source: await toSource(cfg, source),
|
|
25769
|
+
voice,
|
|
25770
|
+
model,
|
|
25771
|
+
removeNoise: remove_noise
|
|
25772
|
+
})
|
|
25773
|
+
);
|
|
25774
|
+
spendTool(
|
|
25775
|
+
"elevenlabs_transcribe",
|
|
25776
|
+
"ElevenLabs: transcrever",
|
|
25777
|
+
"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.",
|
|
25778
|
+
{
|
|
25779
|
+
source: sourceField,
|
|
25780
|
+
language: external_exports.string().max(12).optional().describe("Idioma falado. Omita para detectar."),
|
|
25781
|
+
diarize: external_exports.boolean().optional().describe("true separa quem falou o qu\xEA."),
|
|
25782
|
+
num_speakers: external_exports.number().int().min(1).optional().describe("Quantas pessoas falam, se souber."),
|
|
25783
|
+
audio_events: external_exports.boolean().optional().describe("true marca risos, palmas e outros sons."),
|
|
25784
|
+
keyterms: external_exports.array(external_exports.string().min(1)).optional().describe("Nomes e termos dif\xEDceis para acertar a grafia.")
|
|
25785
|
+
},
|
|
25786
|
+
async ({ source, language, diarize, num_speakers, audio_events, keyterms }) => ({
|
|
25787
|
+
tool: "transcribe",
|
|
25788
|
+
source: await toSource(cfg, source),
|
|
25789
|
+
language,
|
|
25790
|
+
diarize,
|
|
25791
|
+
numSpeakers: num_speakers,
|
|
25792
|
+
audioEvents: audio_events,
|
|
25793
|
+
keyterms
|
|
25794
|
+
})
|
|
25795
|
+
);
|
|
25796
|
+
spendTool(
|
|
25797
|
+
"elevenlabs_align",
|
|
25798
|
+
"ElevenLabs: alinhar texto ao \xE1udio",
|
|
25799
|
+
"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.",
|
|
25800
|
+
{ source: sourceField, text: external_exports.string().min(1).describe("Texto exato do que \xE9 falado.") },
|
|
25801
|
+
async ({ source, text }) => ({ tool: "align", source: await toSource(cfg, source), text })
|
|
25802
|
+
);
|
|
25803
|
+
spendTool(
|
|
25804
|
+
"elevenlabs_music",
|
|
25805
|
+
"ElevenLabs: m\xFAsica",
|
|
25806
|
+
"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.",
|
|
25807
|
+
{
|
|
25808
|
+
prompt: external_exports.string().min(1).describe("Estilo, clima e instrumentos."),
|
|
25809
|
+
model: external_exports.string().min(1).optional().describe("Id do modelo. Omita para o padr\xE3o."),
|
|
25810
|
+
duration_sec: external_exports.number().min(3).optional().describe("Dura\xE7\xE3o em segundos, m\xEDnimo 3."),
|
|
25811
|
+
instrumental: external_exports.boolean().optional(),
|
|
25812
|
+
lyrics: external_exports.string().min(1).optional().describe("Letra pr\xF3pria.")
|
|
25813
|
+
},
|
|
25814
|
+
({ prompt, model, duration_sec, instrumental, lyrics }) => ({
|
|
25815
|
+
tool: "music",
|
|
25816
|
+
prompt,
|
|
25817
|
+
model,
|
|
25818
|
+
durationSec: duration_sec,
|
|
25819
|
+
instrumental,
|
|
25820
|
+
lyrics
|
|
25821
|
+
})
|
|
25822
|
+
);
|
|
25823
|
+
spendTool(
|
|
25824
|
+
"elevenlabs_stems",
|
|
25825
|
+
"ElevenLabs: separar faixas",
|
|
25826
|
+
"Separa uma m\xFAsica em faixas (voz, bateria, baixo e outras). Para limpar uma fala gravada use elevenlabs_isolate.",
|
|
25827
|
+
{ source: sourceField },
|
|
25828
|
+
async ({ source }) => ({ tool: "stems", source: await toSource(cfg, source) })
|
|
25829
|
+
);
|
|
25830
|
+
spendTool(
|
|
25831
|
+
"elevenlabs_video_music",
|
|
25832
|
+
"ElevenLabs: trilha para v\xEDdeo",
|
|
25833
|
+
"Cria trilha que acompanha um v\xEDdeo existente. Para m\xFAsica sem v\xEDdeo use elevenlabs_music.",
|
|
25834
|
+
{
|
|
25835
|
+
source: sourceField,
|
|
25836
|
+
description: external_exports.string().min(1).optional().describe("Clima desejado."),
|
|
25837
|
+
add_sfx: external_exports.boolean().optional().describe("true acrescenta efeitos sonoros.")
|
|
25838
|
+
},
|
|
25839
|
+
async ({ source, description, add_sfx }) => ({
|
|
25840
|
+
tool: "video_music",
|
|
25841
|
+
source: await toSource(cfg, source),
|
|
25842
|
+
description,
|
|
25843
|
+
addSfx: add_sfx
|
|
25844
|
+
})
|
|
25845
|
+
);
|
|
25846
|
+
spendTool(
|
|
25847
|
+
"elevenlabs_voice_design",
|
|
25848
|
+
"ElevenLabs: criar voz por descri\xE7\xE3o",
|
|
25849
|
+
"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.",
|
|
25850
|
+
{
|
|
25851
|
+
description: external_exports.string().min(20).describe("Idade, timbre, sotaque e jeito de falar. M\xEDnimo 20 caracteres."),
|
|
25852
|
+
text: external_exports.string().min(1).optional().describe("Frase que as pr\xE9vias v\xE3o falar."),
|
|
25853
|
+
model: external_exports.string().min(1).optional().describe("Id do modelo. Omita para o padr\xE3o.")
|
|
25854
|
+
},
|
|
25855
|
+
({ description, text, model }) => ({ tool: "voice_design", description, text, model })
|
|
25856
|
+
);
|
|
25857
|
+
}
|
|
25858
|
+
|
|
25391
25859
|
// src/tools/generation.ts
|
|
25392
25860
|
var IMAGE_BUDGET_MS = 9e4;
|
|
25393
25861
|
var VIDEO_BUDGET_MS = 12e4;
|
|
@@ -25920,13 +26388,15 @@ ${BUDGET_BLOCKED_GUIDANCE}`);
|
|
|
25920
26388
|
"check_generation",
|
|
25921
26389
|
{
|
|
25922
26390
|
title: "Checar gera\xE7\xE3o",
|
|
25923
|
-
description: "Consulta o status de uma gera\xE7\xE3o ass\xEDncrona (imagem
|
|
26391
|
+
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.",
|
|
25924
26392
|
inputSchema: {
|
|
25925
|
-
generation_id: external_exports.string().min(1).describe("O id retornado por generate_image
|
|
26393
|
+
generation_id: external_exports.string().min(1).describe("O id retornado por generate_image, generate_video ou elevenlabs_*.")
|
|
25926
26394
|
}
|
|
25927
26395
|
},
|
|
25928
26396
|
async ({ generation_id }) => {
|
|
25929
26397
|
try {
|
|
26398
|
+
const job = await client.elevenLabsJob(generation_id, { retry: false }).catch(() => null);
|
|
26399
|
+
if (job?.generationId) return formatJob(job);
|
|
25930
26400
|
const status = await client.getStatus(generation_id);
|
|
25931
26401
|
if (status.status === "completed") {
|
|
25932
26402
|
const urls = outputUrls(status);
|
|
@@ -26002,6 +26472,7 @@ ${list}${flagsLine(status)}${draftHint}` }, ...blocks] };
|
|
|
26002
26472
|
await client.cancel(generation_id);
|
|
26003
26473
|
return textResult(`\u2705 Gera\xE7\xE3o ${generation_id} cancelada (diamantes estornados quando aplic\xE1vel).`);
|
|
26004
26474
|
} catch (e) {
|
|
26475
|
+
if (e instanceof ApiError && e.httpStatus === 409) return textResult(e.message);
|
|
26005
26476
|
return errorResult(apiErrorToUserMessage(e));
|
|
26006
26477
|
}
|
|
26007
26478
|
}
|
|
@@ -26897,7 +27368,7 @@ Use o valor de "voice" no generate_audio com um modelo 3.8 (sem multi_speaker).`
|
|
|
26897
27368
|
}
|
|
26898
27369
|
|
|
26899
27370
|
// src/tools/account.ts
|
|
26900
|
-
function registerAccountTools(server, client,
|
|
27371
|
+
function registerAccountTools(server, client, cfg) {
|
|
26901
27372
|
server.registerTool(
|
|
26902
27373
|
"whoami",
|
|
26903
27374
|
{
|
|
@@ -26954,14 +27425,17 @@ ${budget}` : "")
|
|
|
26954
27425
|
},
|
|
26955
27426
|
async () => {
|
|
26956
27427
|
try {
|
|
26957
|
-
const m = await
|
|
27428
|
+
const [m, elevenLabs] = await Promise.all([
|
|
27429
|
+
client.models(),
|
|
27430
|
+
client.elevenLabsCatalog({ retry: false }).catch(() => null)
|
|
27431
|
+
]);
|
|
26958
27432
|
const lines = m.models.map((x) => {
|
|
26959
27433
|
const price = typeof x.pricing === "number" ? `$${x.pricing}` : JSON.stringify(x.pricing);
|
|
26960
27434
|
return `\u2022 ${x.model} \u2014 ${price} (base USD)`;
|
|
26961
27435
|
});
|
|
26962
27436
|
const analyzeBlock = analyzeCatalogBlock(m.analyze);
|
|
26963
27437
|
const txt = `Modelos de gera\xE7\xE3o:
|
|
26964
|
-
${lines.join("\n") || "(nenhum)"}` + analyzeBlock + `
|
|
27438
|
+
${lines.join("\n") || "(nenhum)"}` + analyzeBlock + elevenLabsCatalogBlock(elevenLabs) + `
|
|
26965
27439
|
|
|
26966
27440
|
Limites simult\xE2neos por usu\xE1rio: imagem=${m.limits.perUserMaxImage}, v\xEDdeo=${m.limits.perUserMaxVideo}, \xE1udio=${m.limits.perUserMaxAudio}.
|
|
26967
27441
|
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).`;
|
|
@@ -26975,9 +27449,10 @@ Limites simult\xE2neos por usu\xE1rio: imagem=${m.limits.perUserMaxImage}, v\xED
|
|
|
26975
27449
|
"estimate_cost",
|
|
26976
27450
|
{
|
|
26977
27451
|
title: "Estimar custo",
|
|
26978
|
-
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.",
|
|
27452
|
+
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_*).",
|
|
26979
27453
|
inputSchema: {
|
|
26980
27454
|
model: external_exports.string().min(1).describe("Id do modelo (ex.: google/nano-banana-pro, bytedance/seedance-2.0)."),
|
|
27455
|
+
elevenlabs_params: external_exports.record(external_exports.unknown()).optional().describe('[ElevenLabs] Campos do pedido no formato da API, ex.: { "voice": "...", "text": "..." }.'),
|
|
26981
27456
|
resolution: external_exports.string().optional(),
|
|
26982
27457
|
duration: external_exports.number().int().optional(),
|
|
26983
27458
|
mode: external_exports.string().optional(),
|
|
@@ -27003,6 +27478,9 @@ Limites simult\xE2neos por usu\xE1rio: imagem=${m.limits.perUserMaxImage}, v\xED
|
|
|
27003
27478
|
}
|
|
27004
27479
|
},
|
|
27005
27480
|
async (args) => {
|
|
27481
|
+
if (args.model.startsWith("elevenlabs/")) {
|
|
27482
|
+
return estimateElevenLabsModel(client, cfg, args.model, args.elevenlabs_params, args.file);
|
|
27483
|
+
}
|
|
27006
27484
|
try {
|
|
27007
27485
|
let width2 = args.source_width;
|
|
27008
27486
|
let height = args.source_height;
|
|
@@ -27744,6 +28222,33 @@ var KINDS = {
|
|
|
27744
28222
|
outputs: ["audio", "approved"],
|
|
27745
28223
|
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"
|
|
27746
28224
|
},
|
|
28225
|
+
"audio-tools": {
|
|
28226
|
+
title: "Ferramentas de \xE1udio",
|
|
28227
|
+
size: { w: 320, h: 212 },
|
|
28228
|
+
data: {
|
|
28229
|
+
tool: "sfx",
|
|
28230
|
+
model: null,
|
|
28231
|
+
voice: null,
|
|
28232
|
+
durationSec: null,
|
|
28233
|
+
loop: false,
|
|
28234
|
+
instrumental: true,
|
|
28235
|
+
removeNoise: false,
|
|
28236
|
+
language: null,
|
|
28237
|
+
diarize: true,
|
|
28238
|
+
audioEvents: false,
|
|
28239
|
+
targetLang: "en",
|
|
28240
|
+
sourceLang: null,
|
|
28241
|
+
dubMode: "v1",
|
|
28242
|
+
history: [],
|
|
28243
|
+
pinned: null,
|
|
28244
|
+
results: [],
|
|
28245
|
+
pinnedResult: null
|
|
28246
|
+
},
|
|
28247
|
+
inputs: ["prompt", "lyrics", "source"],
|
|
28248
|
+
outputs: ["audio", "approved", "text", "subtitle", "video"],
|
|
28249
|
+
dynamic: "as portas mudam com data.tool (sfx, isolate, voice_change, music, stems, transcribe, dub)",
|
|
28250
|
+
main: "tool"
|
|
28251
|
+
},
|
|
27747
28252
|
music: {
|
|
27748
28253
|
title: "Trilha",
|
|
27749
28254
|
size: { w: 320, h: 212 },
|
|
@@ -27834,6 +28339,7 @@ function ratioOfAspect(aspect) {
|
|
|
27834
28339
|
const height = Number(match[2]);
|
|
27835
28340
|
return width2 > 0 && height > 0 ? width2 / height : null;
|
|
27836
28341
|
}
|
|
28342
|
+
var DUB_NOTE = "Dublagem no Canvas exige clique de pessoa: agente n\xE3o roda. ";
|
|
27837
28343
|
function isGeneratorKind(kind) {
|
|
27838
28344
|
return kind === "image" || kind === "video";
|
|
27839
28345
|
}
|
|
@@ -27856,7 +28362,7 @@ function knownPort(kind, side, port) {
|
|
|
27856
28362
|
}
|
|
27857
28363
|
|
|
27858
28364
|
// src/canvas/core.ts
|
|
27859
|
-
import { randomBytes, randomUUID } from "crypto";
|
|
28365
|
+
import { randomBytes, randomUUID as randomUUID2 } from "crypto";
|
|
27860
28366
|
var SCHEMA_VERSION = 1;
|
|
27861
28367
|
var MAX_ENVELOPES_PER_COMMIT = 200;
|
|
27862
28368
|
var MAX_OP_BYTES = 64 * 1024;
|
|
@@ -27942,7 +28448,7 @@ function checkOp(op) {
|
|
|
27942
28448
|
}
|
|
27943
28449
|
}
|
|
27944
28450
|
function envelope(boardId4, op, actorId) {
|
|
27945
|
-
return { id:
|
|
28451
|
+
return { id: randomUUID2(), boardId: boardId4, clientId: CLIENT_ID, actorId, seq: null, ts: Date.now(), op };
|
|
27946
28452
|
}
|
|
27947
28453
|
function checkEnvelope(env) {
|
|
27948
28454
|
const bad = checkOp(env.op);
|
|
@@ -27954,7 +28460,7 @@ function checkEnvelope(env) {
|
|
|
27954
28460
|
}
|
|
27955
28461
|
function emptyBoard(title, now = Date.now()) {
|
|
27956
28462
|
return {
|
|
27957
|
-
id:
|
|
28463
|
+
id: randomUUID2(),
|
|
27958
28464
|
schemaVersion: SCHEMA_VERSION,
|
|
27959
28465
|
title,
|
|
27960
28466
|
ownerId: "",
|
|
@@ -27971,7 +28477,7 @@ function emptyBoard(title, now = Date.now()) {
|
|
|
27971
28477
|
function makeNode(init) {
|
|
27972
28478
|
const now = init.now ?? Date.now();
|
|
27973
28479
|
return {
|
|
27974
|
-
id: init.id ??
|
|
28480
|
+
id: init.id ?? randomUUID2(),
|
|
27975
28481
|
type: init.type,
|
|
27976
28482
|
position: { x: init.position.x, y: init.position.y },
|
|
27977
28483
|
size: { w: init.size.w, h: init.size.h },
|
|
@@ -27985,7 +28491,7 @@ function makeNode(init) {
|
|
|
27985
28491
|
}
|
|
27986
28492
|
function makeEdge(init) {
|
|
27987
28493
|
return {
|
|
27988
|
-
id:
|
|
28494
|
+
id: randomUUID2(),
|
|
27989
28495
|
source: init.source,
|
|
27990
28496
|
sourcePort: init.sourcePort,
|
|
27991
28497
|
target: init.target,
|
|
@@ -29223,7 +29729,7 @@ ${text}`;
|
|
|
29223
29729
|
}
|
|
29224
29730
|
|
|
29225
29731
|
// src/canvas/upload.ts
|
|
29226
|
-
import { randomUUID as
|
|
29732
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
29227
29733
|
import { basename as basename2, extname as extname3 } from "path";
|
|
29228
29734
|
function kindOfMime(mime) {
|
|
29229
29735
|
if (mime.startsWith("image/")) return "image";
|
|
@@ -29263,7 +29769,7 @@ async function uploadMedia(cfg, source, name) {
|
|
|
29263
29769
|
meta: meta ?? {},
|
|
29264
29770
|
measuredBy,
|
|
29265
29771
|
reused,
|
|
29266
|
-
assetId: `asset_${
|
|
29772
|
+
assetId: `asset_${randomUUID3()}`
|
|
29267
29773
|
};
|
|
29268
29774
|
}
|
|
29269
29775
|
function mediaItem(u) {
|
|
@@ -29445,7 +29951,7 @@ ${payload(u)}`
|
|
|
29445
29951
|
}
|
|
29446
29952
|
|
|
29447
29953
|
// src/tools/canvas-run.ts
|
|
29448
|
-
import { randomUUID as
|
|
29954
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
29449
29955
|
var MAX_REMEMBERED = 50;
|
|
29450
29956
|
var acceptedPacing = { repeats: 8, pauseMs: 2e3 };
|
|
29451
29957
|
var statusPacing = {
|
|
@@ -29474,23 +29980,23 @@ function prettyClient(name) {
|
|
|
29474
29980
|
function modeText(mode) {
|
|
29475
29981
|
return mode === "simulated" ? "Simulado (n\xE3o gasta)" : mode === "live" ? "Real" : mode ?? "?";
|
|
29476
29982
|
}
|
|
29477
|
-
function estimateLines(
|
|
29478
|
-
if (!
|
|
29983
|
+
function estimateLines(estimate2, titleOf) {
|
|
29984
|
+
if (!estimate2) return [];
|
|
29479
29985
|
const lines = [];
|
|
29480
|
-
const nodes =
|
|
29986
|
+
const nodes = estimate2.nodes ?? [];
|
|
29481
29987
|
const now = nodes.filter((n) => n.willRun);
|
|
29482
29988
|
for (const n of now) {
|
|
29483
29989
|
const cost = n.error ? `estimativa falhou (${n.error})` : dia(n.diamonds);
|
|
29484
29990
|
lines.push(`- ${n.title ?? titleOf(n.nodeId)} (${n.nodeId}): ${cost}`);
|
|
29485
29991
|
}
|
|
29486
|
-
if (
|
|
29487
|
-
lines.push(`\u2026 e mais ${
|
|
29992
|
+
if (estimate2.omitted) {
|
|
29993
|
+
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).`);
|
|
29488
29994
|
}
|
|
29489
|
-
const cached2 =
|
|
29995
|
+
const cached2 = estimate2.cached ?? nodes.filter((n) => !n.willRun && !n.afterApproval).length;
|
|
29490
29996
|
if (cached2) lines.push(`Em cache (n\xE3o rodam): ${cached2}.`);
|
|
29491
|
-
const later =
|
|
29492
|
-
if (later) lines.push(`Esperando aprova\xE7\xE3o no board depois disso: ${later} n\xF3(s), \u2248 ${dia(
|
|
29493
|
-
const unknown2 =
|
|
29997
|
+
const later = estimate2.counts?.later ?? estimate2.later?.nodes?.length ?? 0;
|
|
29998
|
+
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).`);
|
|
29999
|
+
const unknown2 = estimate2.counts?.unknown ?? estimate2.unknown?.length ?? 0;
|
|
29494
30000
|
if (unknown2) {
|
|
29495
30001
|
lines.push(`Sem estimativa: ${unknown2} n\xF3(s) (texto cobra por token; o total \xE9 piso).`);
|
|
29496
30002
|
}
|
|
@@ -29596,7 +30102,7 @@ function registerCanvasRunTools(server, api, run) {
|
|
|
29596
30102
|
},
|
|
29597
30103
|
async (args) => run(async () => {
|
|
29598
30104
|
const target = targetOf(args);
|
|
29599
|
-
const requestId = (args.request_id ??
|
|
30105
|
+
const requestId = (args.request_id ?? randomUUID4()).toLowerCase();
|
|
29600
30106
|
const label = args.label ?? prettyClient(server.server.getClientVersion()?.name);
|
|
29601
30107
|
const ask = async () => {
|
|
29602
30108
|
try {
|
|
@@ -30461,7 +30967,7 @@ N\xF3s: ${Object.entries(ids).map(([k, v]) => `${k}=${v}`).join(" \xB7 ")}` : ""
|
|
|
30461
30967
|
"canvas_add_node",
|
|
30462
30968
|
{
|
|
30463
30969
|
title: "Canvas: adicionar n\xF3",
|
|
30464
|
-
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,
|
|
30970
|
+
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,
|
|
30465
30971
|
inputSchema: {
|
|
30466
30972
|
board_id: boardId3,
|
|
30467
30973
|
kind: external_exports.string().min(1).max(40),
|
|
@@ -30526,7 +31032,7 @@ N\xF3s: ${Object.entries(ids).map(([k, v]) => `${k}=${v}`).join(" \xB7 ")}` : ""
|
|
|
30526
31032
|
"canvas_update_node",
|
|
30527
31033
|
{
|
|
30528
31034
|
title: "Canvas: editar n\xF3",
|
|
30529
|
-
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,
|
|
31035
|
+
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,
|
|
30530
31036
|
inputSchema: {
|
|
30531
31037
|
board_id: boardId3,
|
|
30532
31038
|
node_id: nodeIdArg2,
|
|
@@ -30554,7 +31060,7 @@ N\xF3s: ${Object.entries(ids).map(([k, v]) => `${k}=${v}`).join(" \xB7 ")}` : ""
|
|
|
30554
31060
|
"canvas_update_nodes",
|
|
30555
31061
|
{
|
|
30556
31062
|
title: "Canvas: editar v\xE1rios n\xF3s",
|
|
30557
|
-
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.',
|
|
31063
|
+
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,
|
|
30558
31064
|
inputSchema: {
|
|
30559
31065
|
board_id: boardId3,
|
|
30560
31066
|
nodes: external_exports.array(
|
|
@@ -30606,7 +31112,7 @@ N\xF3s: ${Object.entries(ids).map(([k, v]) => `${k}=${v}`).join(" \xB7 ")}` : ""
|
|
|
30606
31112
|
"canvas_patch_node",
|
|
30607
31113
|
{
|
|
30608
31114
|
title: "Canvas: gravar por caminho",
|
|
30609
|
-
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,
|
|
31115
|
+
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,
|
|
30610
31116
|
inputSchema: {
|
|
30611
31117
|
board_id: boardId3,
|
|
30612
31118
|
node_id: nodeIdArg2,
|
|
@@ -30846,7 +31352,7 @@ N\xF3s: ${Object.entries(ids).map(([k, v]) => `${k}=${v}`).join(" \xB7 ")}` : ""
|
|
|
30846
31352
|
import { createRequire } from "module";
|
|
30847
31353
|
var require2 = createRequire(import.meta.url);
|
|
30848
31354
|
function readVersion() {
|
|
30849
|
-
if ("0.
|
|
31355
|
+
if ("0.46.0") return "0.46.0";
|
|
30850
31356
|
try {
|
|
30851
31357
|
const pkg = require2("../package.json");
|
|
30852
31358
|
return pkg.version ?? "0.0.0-unknown";
|
|
@@ -30859,7 +31365,7 @@ var VERSION = readVersion();
|
|
|
30859
31365
|
// src/server.ts
|
|
30860
31366
|
var SERVER_INSTRUCTIONS = [
|
|
30861
31367
|
"BePlus: tudo roda pela conta do usu\xE1rio (diamantes, limites e hist\xF3rico na plataforma).",
|
|
30862
|
-
'M\xEDdia: generate_*
|
|
31368
|
+
'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.',
|
|
30863
31369
|
"Calls: search_calls acha, get_call traz a transcri\xE7\xE3o.",
|
|
30864
31370
|
"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.",
|
|
30865
31371
|
"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.",
|
|
@@ -30874,6 +31380,7 @@ function buildServer(cfg) {
|
|
|
30874
31380
|
registerUpscaleTools(server, client, cfg);
|
|
30875
31381
|
registerAudioTools(server, client, cfg);
|
|
30876
31382
|
registerMusicTools(server, client, cfg);
|
|
31383
|
+
registerElevenLabsTools(server, client, cfg);
|
|
30877
31384
|
registerAccountTools(server, client, cfg);
|
|
30878
31385
|
registerAnalyzeTools(server, client, cfg);
|
|
30879
31386
|
registerProjectTools(server, client, cfg);
|