@taptap/maker 0.0.25-beta.1 → 0.0.25-beta.2

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 CHANGED
@@ -30,4 +30,4 @@ This package contains only the Maker CLI/MCP bundle and Maker workflow skills.
30
30
  It does not include the legacy TapTap Open API MCP server, proxy, native signer,
31
31
  or OpenClaw plugin package contents.
32
32
 
33
- Version: 0.0.25-beta.1
33
+ Version: 0.0.25-beta.2
package/dist/maker.js CHANGED
@@ -29287,7 +29287,17 @@ function createMakerAgentsPolicyBody() {
29287
29287
  "- `edit_image` for modifying existing project images.",
29288
29288
  "- `create_video_task` for game video assets or referenced image/video generation.",
29289
29289
  "- `query_video_task` for refreshing video task status and fetching completed videos.",
29290
- "- `text_to_music` for game music or audio assets.",
29290
+ "- `text_to_music` for game music.",
29291
+ "- `text_to_sound_effect` for one sound effect.",
29292
+ "- `batch_sound_effects` for multiple sound effects.",
29293
+ "- `text_to_dialogue` for final character dialogue.",
29294
+ "- `text_to_dialogue` automatically converts local project audio to data URLs and reuses confirmed local voice mappings.",
29295
+ "- After `audition_voices_for_character` returns previews, show them to the user and wait",
29296
+ " for the user to choose. Do not select or confirm a voice automatically.",
29297
+ "- Call `confirm_character_voice` only after the user explicitly chooses one preview.",
29298
+ "- Generated sound effects and dialogue are saved in the project.",
29299
+ "- Voice audition previews are not saved to the project.",
29300
+ "- Local MCP does not transcode generated audio to OGG.",
29291
29301
  "- `create_3d_asset` for the complete 3D lifecycle: start, query, explicit review continuation,",
29292
29302
  " option inspection, and post-processing.",
29293
29303
  "- Never automatically continue a 3D review step. Show returned previews and wait for explicit",
@@ -32345,7 +32355,17 @@ function formatMakerSkillStatus(_options = {}) {
32345
32355
  "- Prefer Maker MCP proxy tools over native AI image/video/audio tools for bound Maker projects.",
32346
32356
  "- If Maker proxy tools are missing, explain the session/configuration issue and available alternatives.",
32347
32357
  "- Use generate_image, batch_generate_images, edit_image for game image assets.",
32348
- "- Use create_video_task, query_video_task, and text_to_music for game video/audio assets.",
32358
+ "- Use create_video_task and query_video_task for game video assets.",
32359
+ "- Use text_to_music for game music.",
32360
+ "- Use text_to_sound_effect for one sound effect.",
32361
+ "- Use batch_sound_effects for multiple sound effects.",
32362
+ "- Use text_to_dialogue for final character dialogue.",
32363
+ "- text_to_dialogue automatically converts local project audio to data URLs and reuses confirmed local voice mappings.",
32364
+ "- After audition_voices_for_character returns previews, wait for the user to choose.",
32365
+ "- Call confirm_character_voice only after the user explicitly chooses a preview.",
32366
+ "- Generated sound effects and dialogue are saved in the project.",
32367
+ "- Voice audition previews are not saved to the project.",
32368
+ "- Local MCP does not transcode generated audio to OGG.",
32349
32369
  "- Use create_3d_asset with start/query/continue/post_process for game 3D model assets.",
32350
32370
  "- For any ad-related request, call get_ad_config first to get ad activation status and ad config.",
32351
32371
  "- Do not infer ad readiness from local SDK docs, .maker-mcp/config.json, or runtime callbacks.",
@@ -33466,6 +33486,7 @@ function sameStringSet(left, right) {
33466
33486
  // src/maker/server/proxyAssets.ts
33467
33487
  import fs15 from "node:fs";
33468
33488
  import path16 from "node:path";
33489
+ import { randomUUID } from "node:crypto";
33469
33490
  var IMAGE_ASSET_DIRS = ["assets/image"];
33470
33491
  var VIDEO_ASSET_DIRS = ["assets/video"];
33471
33492
  var AUDIO_ASSET_DIRS = ["assets/audio"];
@@ -33475,6 +33496,10 @@ var IMAGE_REFERENCE_MAX_BYTES = 10 * 1024 * 1024;
33475
33496
  var VIDEO_TASK_IMAGE_REFERENCE_MAX_BYTES = 30 * 1024 * 1024;
33476
33497
  var VIDEO_REFERENCE_MAX_BYTES = 50 * 1024 * 1024;
33477
33498
  var AUDIO_REFERENCE_MAX_BYTES = 15 * 1024 * 1024;
33499
+ var AUDIO_DIALOGUE_REFERENCE_MAX_BYTES = 20 * 1024 * 1024;
33500
+ var AUDIO_DIALOGUE_INPUT_TOTAL_MAX_BYTES = 28 * 1024 * 1024;
33501
+ var AUDIO_CONFIRM_MAX_BYTES = 1 * 1024 * 1024;
33502
+ var VOICE_CONFIRMATION_NEXT_STEP_HINT = "Call text_to_dialogue with character_name and text. The confirmed voice mapping is reused automatically; omit reference_audio unless the user requests a one-time override.";
33478
33503
  var DEBUG_FEEDBACK_PATH_HINT = "Use local_dir/local_log_paths/local_screenshot_paths when they are returned. If only local_candidate_* is present, it is a possible project-relative location and must not be treated as a downloaded local file.";
33479
33504
  var CREATE_3D_ASSET_PROXY_TOOL_NAME = "create_3d_asset";
33480
33505
  var DATA_URL_MIME_BY_EXTENSION = {
@@ -33490,10 +33515,20 @@ var DATA_URL_MIME_BY_EXTENSION = {
33490
33515
  ".mp4": "video/mp4"
33491
33516
  },
33492
33517
  audio: {
33518
+ ".aac": "audio/aac",
33519
+ ".m4a": "audio/mp4",
33493
33520
  ".mp3": "audio/mpeg",
33521
+ ".ogg": "audio/ogg",
33494
33522
  ".wav": "audio/wav"
33495
33523
  }
33496
33524
  };
33525
+ var AUDIO_MIME_BY_EXTENSION = {
33526
+ ".aac": "audio/aac",
33527
+ ".m4a": "audio/mp4",
33528
+ ".mp3": "audio/mpeg",
33529
+ ".ogg": "audio/ogg",
33530
+ ".wav": "audio/wav"
33531
+ };
33497
33532
  var RemoteProxyToolResultError = class extends Error {
33498
33533
  constructor(toolName, result) {
33499
33534
  super(
@@ -33509,6 +33544,9 @@ var RemoteProxyToolResultError = class extends Error {
33509
33544
  }
33510
33545
  };
33511
33546
  function prepareRemoteProxyToolArgs(options) {
33547
+ if (options.toolName === "audition_voices_for_character") {
33548
+ return validateVoiceAuditionArgs(options.args);
33549
+ }
33512
33550
  if (options.toolName === "edit_image") {
33513
33551
  return rewriteEditImageAssetArgs(options.targetDir, options.args);
33514
33552
  }
@@ -33524,8 +33562,21 @@ function prepareRemoteProxyToolArgs(options) {
33524
33562
  if (options.toolName === CREATE_3D_ASSET_PROXY_TOOL_NAME) {
33525
33563
  return rewriteCreate3dAssetArgs(options.targetDir, options.args);
33526
33564
  }
33565
+ if (options.toolName === "text_to_dialogue") {
33566
+ return rewriteTextToDialogueArgs(options.targetDir, options.args);
33567
+ }
33527
33568
  return options.args;
33528
33569
  }
33570
+ function validateVoiceAuditionArgs(args) {
33571
+ const voiceProfile = args.voice_profile;
33572
+ const gender = isRecord(voiceProfile) ? voiceProfile.gender : void 0;
33573
+ if (gender !== "male" && gender !== "female") {
33574
+ throw new Error(
33575
+ "voice_profile.gender is required for character voice audition and must be male or female. Extract it from character_description or the character settings before retrying."
33576
+ );
33577
+ }
33578
+ return args;
33579
+ }
33529
33580
  async function materializeRemoteProxyToolAssets(options) {
33530
33581
  if (isRemoteProxyToolErrorResult(options.result)) {
33531
33582
  throw new RemoteProxyToolResultError(options.toolName, options.result);
@@ -33586,6 +33637,11 @@ function shouldMaterializeRemoteProxyTool(toolName) {
33586
33637
  "create_video_task",
33587
33638
  "query_video_task",
33588
33639
  "text_to_music",
33640
+ "text_to_sound_effect",
33641
+ "batch_sound_effects",
33642
+ "text_to_dialogue",
33643
+ "audition_voices_for_character",
33644
+ "confirm_character_voice",
33589
33645
  CREATE_3D_ASSET_PROXY_TOOL_NAME,
33590
33646
  "get_debug_feedbacks"
33591
33647
  ].includes(toolName);
@@ -33633,6 +33689,12 @@ async function materializeParsedProxyResult(options) {
33633
33689
  if (options.toolName === "text_to_music") {
33634
33690
  return await materializeMusicResult(options);
33635
33691
  }
33692
+ if (options.toolName === "text_to_sound_effect" || options.toolName === "batch_sound_effects" || options.toolName === "text_to_dialogue") {
33693
+ return await materializeAudioFilesResult(options, options.toolName);
33694
+ }
33695
+ if (options.toolName === "confirm_character_voice") {
33696
+ return await materializeVoiceConfirmationResult(options);
33697
+ }
33636
33698
  if (options.toolName === CREATE_3D_ASSET_PROXY_TOOL_NAME) {
33637
33699
  return await materializeCreate3dAssetResult(options);
33638
33700
  }
@@ -34006,6 +34068,429 @@ async function materializeMusicResult(options) {
34006
34068
  })
34007
34069
  } : options.payload;
34008
34070
  }
34071
+ async function materializeAudioFilesResult(options, toolName) {
34072
+ if (!Array.isArray(options.payload.audio_files)) return options.payload;
34073
+ const audioFiles = [];
34074
+ for (const rawItem of options.payload.audio_files) {
34075
+ if (!isRecord(rawItem)) {
34076
+ audioFiles.push(rawItem);
34077
+ continue;
34078
+ }
34079
+ const item = { ...rawItem };
34080
+ const audioUrl = stringField2(item.audioUrl);
34081
+ const kind = stringField2(item.kind);
34082
+ const expectedKind = toolName === "text_to_dialogue" ? "dialogue" : "sound_effect";
34083
+ const expectedDirectory = expectedKind === "dialogue" ? "assets/audio/voice" : "assets/audio/sfx";
34084
+ const targetDirectory = stringField2(item.targetDirectory);
34085
+ const suggestedFileName = stringField2(item.suggestedFileName);
34086
+ const validationError = validateAudioAssetContract({
34087
+ audioUrl,
34088
+ kind,
34089
+ expectedKind,
34090
+ targetDirectory,
34091
+ expectedDirectory,
34092
+ suggestedFileName,
34093
+ format: stringField2(item.format),
34094
+ mimeType: stringField2(item.mimeType)
34095
+ });
34096
+ if (validationError) {
34097
+ audioFiles.push({
34098
+ ...item,
34099
+ ...audioUrl ? { audioUrl } : {},
34100
+ download: { success: false, error: validationError }
34101
+ });
34102
+ continue;
34103
+ }
34104
+ const extension = audioExtensionForItem(item, suggestedFileName);
34105
+ const materialized = await materializeAudioAsset({
34106
+ targetDir: options.targetDir,
34107
+ targetDirectory: expectedDirectory,
34108
+ fileName: suggestedFileName,
34109
+ url: audioUrl,
34110
+ extension,
34111
+ now: options.now,
34112
+ fetchImpl: options.fetchImpl
34113
+ });
34114
+ audioFiles.push(
34115
+ materialized ? persistMaterializedAsset({
34116
+ targetDir: options.targetDir,
34117
+ toolName,
34118
+ payload: item,
34119
+ materialized,
34120
+ cdnUrl: audioUrl,
34121
+ now: options.now,
34122
+ extraRegistryFields: { assetKind: "audio", kind }
34123
+ }) : item
34124
+ );
34125
+ }
34126
+ return { ...options.payload, audio_files: audioFiles };
34127
+ }
34128
+ function validateAudioAssetContract(options) {
34129
+ var _a3, _b;
34130
+ if (!options.audioUrl || !/^https?:\/\//i.test(options.audioUrl)) {
34131
+ return "audioUrl must be an HTTP(S) URL.";
34132
+ }
34133
+ if (options.kind !== options.expectedKind) {
34134
+ return `audio_files item kind must be ${options.expectedKind} for this tool.`;
34135
+ }
34136
+ if (options.targetDirectory !== options.expectedDirectory) {
34137
+ return `targetDirectory must be ${options.expectedDirectory}.`;
34138
+ }
34139
+ const fileName = options.suggestedFileName;
34140
+ if (!fileName || fileName === "." || fileName === ".." || fileName.includes("/") || fileName.includes("\\") || fileName.includes("\0")) {
34141
+ return "suggestedFileName must be a safe basename.";
34142
+ }
34143
+ if (path16.basename(fileName) !== fileName || fileName.endsWith(".") || fileName.endsWith(" ")) {
34144
+ return "suggestedFileName must be a safe basename.";
34145
+ }
34146
+ const format = (_a3 = options.format) == null ? void 0 : _a3.toLowerCase();
34147
+ const mimeType = (_b = options.mimeType) == null ? void 0 : _b.toLowerCase();
34148
+ const extension = path16.extname(fileName).toLowerCase();
34149
+ const contract = {
34150
+ mp3: { mimeType: "audio/mpeg", extension: ".mp3" },
34151
+ wav: { mimeType: "audio/wav", extension: ".wav" },
34152
+ pcm: { mimeType: "audio/l16", extension: ".pcm" },
34153
+ ogg_opus: { mimeType: "audio/ogg", extension: ".ogg" }
34154
+ }[format || ""];
34155
+ if (!contract) {
34156
+ return "audio output format is unsupported; format must be one of mp3, wav, pcm, or ogg_opus.";
34157
+ }
34158
+ if (mimeType !== contract.mimeType || extension !== contract.extension) {
34159
+ return `audio output contract mismatch: format ${format} requires mime ${contract.mimeType} and extension ${contract.extension}.`;
34160
+ }
34161
+ return void 0;
34162
+ }
34163
+ function audioExtensionForItem(item, fileName) {
34164
+ var _a3;
34165
+ const format = (_a3 = stringField2(item.format)) == null ? void 0 : _a3.toLowerCase();
34166
+ const byFormat = {
34167
+ mp3: "mp3",
34168
+ wav: "wav",
34169
+ pcm: "pcm",
34170
+ ogg_opus: "ogg",
34171
+ ogg: "ogg",
34172
+ m4a: "m4a",
34173
+ aac: "aac"
34174
+ };
34175
+ return byFormat[format || ""] || path16.extname(fileName).slice(1).toLowerCase() || "mp3";
34176
+ }
34177
+ async function materializeAudioAsset(options) {
34178
+ const relativeDir = options.targetDirectory;
34179
+ const directory = path16.join(options.targetDir, ...relativeDir.split("/"));
34180
+ try {
34181
+ fs15.mkdirSync(directory, { recursive: true });
34182
+ assertProjectDirectory(options.targetDir, directory);
34183
+ } catch (error2) {
34184
+ return {
34185
+ download: {
34186
+ success: false,
34187
+ error: `Audio target directory is outside the project: ${error2 instanceof Error ? error2.message : String(error2)}`
34188
+ }
34189
+ };
34190
+ }
34191
+ const baseName = path16.basename(options.fileName, path16.extname(options.fileName));
34192
+ let absolutePath;
34193
+ let relativePath;
34194
+ for (let index = 1; index <= 9999; index += 1) {
34195
+ const suffix = index === 1 ? "" : `_${index}`;
34196
+ const candidateName = `${baseName}${suffix}.${options.extension}`;
34197
+ const candidate = path16.join(directory, candidateName);
34198
+ if (!fs15.existsSync(candidate)) {
34199
+ absolutePath = candidate;
34200
+ relativePath = path16.posix.join(relativeDir, candidateName);
34201
+ break;
34202
+ }
34203
+ }
34204
+ if (!absolutePath || !relativePath) {
34205
+ return { download: { success: false, error: "Unable to allocate a unique audio asset path." } };
34206
+ }
34207
+ try {
34208
+ const response = await options.fetchImpl(options.url);
34209
+ if (!response.ok) {
34210
+ return {
34211
+ download: { success: false, error: `Asset download failed: HTTP ${response.status}` }
34212
+ };
34213
+ }
34214
+ const bytes = Buffer.from(await response.arrayBuffer());
34215
+ if (bytes.length === 0) {
34216
+ return { download: { success: false, error: "Asset download failed: empty response." } };
34217
+ }
34218
+ fs15.writeFileSync(absolutePath, bytes, { flag: "wx" });
34219
+ return { localPath: relativePath, absolutePath, download: { success: true } };
34220
+ } catch (error2) {
34221
+ return {
34222
+ download: {
34223
+ success: false,
34224
+ error: `Asset download failed: ${error2 instanceof Error ? error2.message : String(error2)}`
34225
+ }
34226
+ };
34227
+ }
34228
+ }
34229
+ async function materializeVoiceConfirmationResult(options) {
34230
+ if (options.payload.success !== true || !isRecord(options.payload.mapping)) {
34231
+ return withoutVoiceConfirmationNextStepHint(options.payload);
34232
+ }
34233
+ const payload = withoutVoiceConfirmationNextStepHint(options.payload);
34234
+ const successfulPayload = withVoiceConfirmationNextStepHint(options.payload);
34235
+ const mapping = payload.mapping;
34236
+ const provider = stringField2(mapping.provider);
34237
+ const characterName = stringField2(mapping.characterName) || stringField2(payload.characterName);
34238
+ if (!characterName || provider === "elevenlabs") {
34239
+ if (provider !== "elevenlabs" || !characterName) return payload;
34240
+ try {
34241
+ mergeVoiceMappingFile({
34242
+ targetDir: options.targetDir,
34243
+ provider: "elevenlabs",
34244
+ characterName,
34245
+ mapping,
34246
+ now: options.now
34247
+ });
34248
+ return successfulPayload;
34249
+ } catch (error2) {
34250
+ const message = `ElevenLabs voice mapping persistence failed: ${error2 instanceof Error ? error2.message : String(error2)}`;
34251
+ return {
34252
+ ...payload,
34253
+ localPersistenceError: message,
34254
+ mappingPersistenceError: message
34255
+ };
34256
+ }
34257
+ }
34258
+ if (provider !== "doubao" || !isRecord(payload.referenceAudio)) {
34259
+ return payload;
34260
+ }
34261
+ const referenceAudio = payload.referenceAudio;
34262
+ const audioUrl = stringField2(referenceAudio.audioUrl);
34263
+ const targetPath = stringField2(referenceAudio.targetPath);
34264
+ const pathError = validateDoubaoReferenceTarget(targetPath);
34265
+ if (!audioUrl || pathError) {
34266
+ return {
34267
+ ...payload,
34268
+ referenceAudio: {
34269
+ ...referenceAudio,
34270
+ download: { success: false, error: pathError || "referenceAudio.audioUrl is required." }
34271
+ }
34272
+ };
34273
+ }
34274
+ let bytes;
34275
+ try {
34276
+ const response = await options.fetchImpl(audioUrl);
34277
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
34278
+ bytes = Buffer.from(await response.arrayBuffer());
34279
+ } catch (error2) {
34280
+ return {
34281
+ ...payload,
34282
+ referenceAudio: {
34283
+ ...referenceAudio,
34284
+ download: {
34285
+ success: false,
34286
+ error: `Reference audio download failed: ${error2 instanceof Error ? error2.message : String(error2)}`
34287
+ }
34288
+ }
34289
+ };
34290
+ }
34291
+ if (bytes.length === 0 || bytes.length > AUDIO_CONFIRM_MAX_BYTES || !isStructurallyValidMp3(bytes)) {
34292
+ return {
34293
+ ...payload,
34294
+ referenceAudio: {
34295
+ ...referenceAudio,
34296
+ download: {
34297
+ success: false,
34298
+ error: "Reference audio must be a non-empty valid MP3 no larger than 1 MiB."
34299
+ }
34300
+ }
34301
+ };
34302
+ }
34303
+ try {
34304
+ mergeVoiceMappingFile({
34305
+ targetDir: options.targetDir,
34306
+ provider: "doubao",
34307
+ characterName,
34308
+ mapping,
34309
+ now: options.now,
34310
+ referenceAudio: { targetPath, bytes }
34311
+ });
34312
+ return {
34313
+ ...successfulPayload,
34314
+ referenceAudio: {
34315
+ ...referenceAudio,
34316
+ localPath: targetPath,
34317
+ absolutePath: path16.join(options.targetDir, ...targetPath.split("/")),
34318
+ download: { success: true }
34319
+ }
34320
+ };
34321
+ } catch (error2) {
34322
+ return {
34323
+ ...payload,
34324
+ referenceAudio: {
34325
+ ...referenceAudio,
34326
+ download: {
34327
+ success: false,
34328
+ error: `Voice mapping transaction failed: ${error2 instanceof Error ? error2.message : String(error2)}`
34329
+ }
34330
+ }
34331
+ };
34332
+ }
34333
+ }
34334
+ function withVoiceConfirmationNextStepHint(payload) {
34335
+ return typeof payload.next_step_hint === "string" && payload.next_step_hint.trim() ? payload : { ...payload, next_step_hint: VOICE_CONFIRMATION_NEXT_STEP_HINT };
34336
+ }
34337
+ function withoutVoiceConfirmationNextStepHint(payload) {
34338
+ if (!Object.prototype.hasOwnProperty.call(payload, "next_step_hint")) return payload;
34339
+ const nextPayload = { ...payload };
34340
+ delete nextPayload.next_step_hint;
34341
+ return nextPayload;
34342
+ }
34343
+ function validateDoubaoReferenceTarget(targetPath) {
34344
+ if (!targetPath) return "referenceAudio.targetPath is required.";
34345
+ if (!/^assets\/audio\/voice-reference\/[^/]+\.mp3$/.test(targetPath)) {
34346
+ return "referenceAudio.targetPath must be assets/audio/voice-reference/<basename>.mp3.";
34347
+ }
34348
+ const base = path16.posix.basename(targetPath, ".mp3");
34349
+ if (!base || base === "." || base === ".." || base.includes("\\") || base.includes("\0")) {
34350
+ return "referenceAudio.targetPath contains an unsafe basename.";
34351
+ }
34352
+ return void 0;
34353
+ }
34354
+ function isStructurallyValidMp3(bytes) {
34355
+ const firstOffset = mp3AudioOffset(bytes);
34356
+ if (firstOffset === void 0) return false;
34357
+ const first = parseMp3Frame(bytes, firstOffset);
34358
+ if (!first) return false;
34359
+ const second = parseMp3Frame(bytes, firstOffset + first.length);
34360
+ return Boolean(
34361
+ second && second.version === first.version && second.sampleRate === first.sampleRate
34362
+ );
34363
+ }
34364
+ function mp3AudioOffset(bytes) {
34365
+ if (bytes.subarray(0, 3).toString("ascii") !== "ID3") return 0;
34366
+ if (bytes.length < 10 || bytes[3] < 2 || bytes[3] > 4) return void 0;
34367
+ const sizeBytes = bytes.subarray(6, 10);
34368
+ if (sizeBytes.some((value) => (value & 128) !== 0)) return void 0;
34369
+ const size = sizeBytes[0] << 21 | sizeBytes[1] << 14 | sizeBytes[2] << 7 | sizeBytes[3];
34370
+ const offset = 10 + size + (bytes[3] === 4 && (bytes[5] & 16) !== 0 ? 10 : 0);
34371
+ return offset <= bytes.length ? offset : void 0;
34372
+ }
34373
+ function parseMp3Frame(bytes, offset) {
34374
+ if (offset + 4 > bytes.length || bytes[offset] !== 255 || (bytes[offset + 1] & 224) !== 224) {
34375
+ return void 0;
34376
+ }
34377
+ const versionBits = bytes[offset + 1] >> 3 & 3;
34378
+ const version2 = versionBits === 3 ? 1 : versionBits === 2 ? 2 : versionBits === 0 ? 2.5 : void 0;
34379
+ if (!version2 || (bytes[offset + 1] >> 1 & 3) !== 1) return void 0;
34380
+ const bitrateIndex = bytes[offset + 2] >> 4 & 15;
34381
+ const rateIndex = bytes[offset + 2] >> 2 & 3;
34382
+ if (bitrateIndex === 0 || bitrateIndex === 15 || rateIndex === 3) return void 0;
34383
+ const mpeg1Rates = [0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320];
34384
+ const mpeg2Rates = [0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160];
34385
+ const bitrate = (version2 === 1 ? mpeg1Rates : mpeg2Rates)[bitrateIndex];
34386
+ const baseSampleRate = [44100, 48e3, 32e3][rateIndex];
34387
+ const sampleRate = version2 === 1 ? baseSampleRate : version2 === 2 ? baseSampleRate / 2 : baseSampleRate / 4;
34388
+ const padding = bytes[offset + 2] >> 1 & 1;
34389
+ const length = Math.floor((version2 === 1 ? 144 : 72) * bitrate * 1e3 / sampleRate) + padding;
34390
+ return length > 4 && offset + length <= bytes.length ? { length, version: version2, sampleRate } : void 0;
34391
+ }
34392
+ function mergeVoiceMappingFile(options) {
34393
+ const configPath = path16.join(
34394
+ options.targetDir,
34395
+ ".project",
34396
+ options.provider === "doubao" ? "audio-voice-mapping.json" : "elevenlabs-voice-mapping.json"
34397
+ );
34398
+ const referencePath = options.referenceAudio ? path16.join(options.targetDir, ...options.referenceAudio.targetPath.split("/")) : void 0;
34399
+ const configDirectory = path16.dirname(configPath);
34400
+ const referenceDirectory = referencePath ? path16.dirname(referencePath) : void 0;
34401
+ fs15.mkdirSync(configDirectory, { recursive: true });
34402
+ assertProjectDirectory(options.targetDir, configDirectory);
34403
+ assertFileIsNotSymlink(configPath);
34404
+ if (referenceDirectory) {
34405
+ fs15.mkdirSync(referenceDirectory, { recursive: true });
34406
+ assertProjectDirectory(options.targetDir, referenceDirectory);
34407
+ assertFileIsNotSymlink(referencePath);
34408
+ }
34409
+ const oldConfig = snapshotFile(configPath);
34410
+ const oldReference = referencePath ? snapshotFile(referencePath) : void 0;
34411
+ const existing = readJsonFile2(configPath);
34412
+ const characters = isRecord(existing == null ? void 0 : existing.characters) ? { ...existing.characters } : {};
34413
+ const oldCharacter = isRecord(characters[options.characterName]) ? characters[options.characterName] : {};
34414
+ const createdAt = stringField2(oldCharacter.created_at) || options.now.toISOString();
34415
+ const character = {
34416
+ ...oldCharacter,
34417
+ ...Object.fromEntries(
34418
+ Object.entries(options.mapping).filter(([key]) => key !== "characterName")
34419
+ ),
34420
+ provider: options.provider,
34421
+ language: stringField2(options.mapping.language) || stringField2(oldCharacter.language) || stringField2(existing == null ? void 0 : existing.default_language) || "cmn",
34422
+ stability: typeof options.mapping.stability === "number" ? options.mapping.stability : typeof oldCharacter.stability === "number" ? oldCharacter.stability : typeof (existing == null ? void 0 : existing.default_stability) === "number" ? existing.default_stability : 0.5,
34423
+ created_at: createdAt,
34424
+ last_used: options.now.toISOString()
34425
+ };
34426
+ characters[options.characterName] = character;
34427
+ const nextConfig = {
34428
+ ...existing,
34429
+ version: options.provider === "doubao" ? 4 : "1.0",
34430
+ provider: options.provider,
34431
+ characters
34432
+ };
34433
+ if (options.provider === "doubao") {
34434
+ nextConfig.default_language = stringField2(existing == null ? void 0 : existing.default_language) || "cmn";
34435
+ nextConfig.default_stability = typeof (existing == null ? void 0 : existing.default_stability) === "number" ? existing.default_stability : 0.5;
34436
+ nextConfig.special_voices = isRecord(existing == null ? void 0 : existing.special_voices) ? existing.special_voices : {};
34437
+ } else {
34438
+ delete nextConfig.default_language;
34439
+ delete nextConfig.default_stability;
34440
+ delete nextConfig.special_voices;
34441
+ }
34442
+ const configBytes = Buffer.from(`${JSON.stringify(nextConfig, null, 2)}
34443
+ `, "utf8");
34444
+ const transactionId = randomUUID();
34445
+ const configTemp = `${configPath}.${transactionId}.tmp`;
34446
+ const referenceTemp = referencePath ? `${referencePath}.${transactionId}.tmp` : void 0;
34447
+ try {
34448
+ if (referenceTemp && options.referenceAudio) {
34449
+ fs15.writeFileSync(referenceTemp, options.referenceAudio.bytes, { flag: "wx" });
34450
+ fs15.renameSync(referenceTemp, referencePath);
34451
+ }
34452
+ fs15.writeFileSync(configTemp, configBytes, { flag: "wx" });
34453
+ fs15.renameSync(configTemp, configPath);
34454
+ } catch (error2) {
34455
+ try {
34456
+ if (fs15.existsSync(configTemp)) fs15.rmSync(configTemp, { force: true });
34457
+ if (referenceTemp && fs15.existsSync(referenceTemp)) fs15.rmSync(referenceTemp, { force: true });
34458
+ restoreFile(configPath, oldConfig);
34459
+ if (referencePath) restoreFile(referencePath, oldReference);
34460
+ } catch {
34461
+ }
34462
+ throw error2;
34463
+ }
34464
+ }
34465
+ function snapshotFile(filePath) {
34466
+ try {
34467
+ assertFileIsNotSymlink(filePath);
34468
+ return { exists: true, bytes: fs15.readFileSync(filePath) };
34469
+ } catch {
34470
+ if (isSymlink(filePath)) {
34471
+ throw new Error(`refusing to read symlinked file: ${filePath}`);
34472
+ }
34473
+ return { exists: false };
34474
+ }
34475
+ }
34476
+ function restoreFile(filePath, snapshot) {
34477
+ assertFileIsNotSymlink(filePath);
34478
+ if (snapshot.exists && snapshot.bytes) {
34479
+ fs15.mkdirSync(path16.dirname(filePath), { recursive: true });
34480
+ fs15.writeFileSync(filePath, snapshot.bytes);
34481
+ } else {
34482
+ fs15.rmSync(filePath, { force: true });
34483
+ }
34484
+ }
34485
+ function readJsonFile2(filePath) {
34486
+ assertFileIsNotSymlink(filePath);
34487
+ try {
34488
+ const parsed = JSON.parse(fs15.readFileSync(filePath, "utf8"));
34489
+ return isRecord(parsed) ? parsed : void 0;
34490
+ } catch {
34491
+ return void 0;
34492
+ }
34493
+ }
34009
34494
  async function materializeCreate3dAssetResult(options) {
34010
34495
  var _a3;
34011
34496
  const payload = isRecord(options.payload.preview) ? await materializeCreate3dAssetPreviewResult(options) : options.payload;
@@ -34277,17 +34762,25 @@ function persistMaterializedAsset(options) {
34277
34762
  if (!("localPath" in options.materialized) || !options.cdnUrl) {
34278
34763
  return nextPayload;
34279
34764
  }
34280
- upsertGeneratedAssetRecord(options.targetDir, options.materialized.localPath, {
34281
- tool: options.toolName,
34282
- name: stringField2(options.payload.name) || stringField2(options.payload.title),
34283
- prompt: stringField2(options.payload.prompt),
34284
- cdnUrl: options.cdnUrl,
34285
- previewUrl: options.cdnUrl,
34286
- localPath: options.materialized.localPath,
34287
- absolutePath: options.materialized.absolutePath,
34288
- createdAt: options.now.toISOString(),
34289
- ...options.extraRegistryFields
34290
- });
34765
+ try {
34766
+ upsertGeneratedAssetRecord(options.targetDir, options.materialized.localPath, {
34767
+ tool: options.toolName,
34768
+ name: stringField2(options.payload.name) || stringField2(options.payload.title),
34769
+ prompt: stringField2(options.payload.prompt),
34770
+ cdnUrl: options.cdnUrl,
34771
+ previewUrl: options.cdnUrl,
34772
+ localPath: options.materialized.localPath,
34773
+ absolutePath: options.materialized.absolutePath,
34774
+ createdAt: options.now.toISOString(),
34775
+ ...options.extraRegistryFields
34776
+ });
34777
+ } catch (error2) {
34778
+ return {
34779
+ ...nextPayload,
34780
+ registryError: `Generated asset registry persistence failed: ${error2 instanceof Error ? error2.message : String(error2)}`,
34781
+ localPersistenceError: `Generated asset registry persistence failed: ${error2 instanceof Error ? error2.message : String(error2)}`
34782
+ };
34783
+ }
34291
34784
  return nextPayload;
34292
34785
  }
34293
34786
  async function materializeAsset(options) {
@@ -34436,6 +34929,211 @@ function rewriteCreate3dAssetArgs(targetDir, args) {
34436
34929
  }
34437
34930
  };
34438
34931
  }
34932
+ function rewriteTextToDialogueArgs(targetDir, args) {
34933
+ if (!Array.isArray(args.inputs)) {
34934
+ return args;
34935
+ }
34936
+ const registry2 = readGeneratedAssetRegistry(targetDir);
34937
+ const localElevenLabsMapping = readLocalElevenLabsVoiceMapping(targetDir);
34938
+ const localDoubaoMapping = args.inputs.some(
34939
+ (value) => isRecord(value) && normalizeOptionalDialogueReference(value.reference_audio) === void 0 && normalizeOptionalDialogueReference(value.reference_audio_path) === void 0
34940
+ ) ? readLocalDoubaoVoiceMapping(targetDir) : void 0;
34941
+ let referenceAudioInputBytes = 0;
34942
+ return {
34943
+ ...args,
34944
+ inputs: args.inputs.map((value, index) => {
34945
+ if (!isRecord(value)) {
34946
+ return value;
34947
+ }
34948
+ let canonicalReference = normalizeOptionalDialogueReference(value.reference_audio);
34949
+ const legacyReference = normalizeOptionalDialogueReference(value.reference_audio_path);
34950
+ if (canonicalReference !== void 0 && legacyReference !== void 0) {
34951
+ throw new Error(
34952
+ `inputs[${index}].reference_audio and reference_audio_path are mutually exclusive.`
34953
+ );
34954
+ }
34955
+ const normalizedValue = { ...value };
34956
+ delete normalizedValue.reference_audio;
34957
+ delete normalizedValue.reference_audio_path;
34958
+ delete normalizedValue._local_voice_id;
34959
+ const localVoiceId = resolveLocalElevenLabsVoiceId(
34960
+ value.character_name,
34961
+ localElevenLabsMapping
34962
+ );
34963
+ if (localVoiceId) {
34964
+ normalizedValue._local_voice_id = localVoiceId;
34965
+ }
34966
+ if (canonicalReference === void 0 && legacyReference === void 0) {
34967
+ canonicalReference = resolveLocalDoubaoMappingReference({
34968
+ targetDir,
34969
+ characterName: value.character_name,
34970
+ mapping: localDoubaoMapping,
34971
+ registry: registry2,
34972
+ index
34973
+ });
34974
+ }
34975
+ if (canonicalReference === void 0) canonicalReference = legacyReference;
34976
+ if (canonicalReference === void 0) return normalizedValue;
34977
+ const referenceAudio = normalizeDialogueReference(
34978
+ targetDir,
34979
+ canonicalReference,
34980
+ registry2,
34981
+ index
34982
+ );
34983
+ referenceAudioInputBytes += Buffer.byteLength(referenceAudio, "utf8");
34984
+ if (referenceAudioInputBytes > AUDIO_DIALOGUE_INPUT_TOTAL_MAX_BYTES) {
34985
+ throw new Error(
34986
+ `reference_audio input total must not exceed ${AUDIO_DIALOGUE_INPUT_TOTAL_MAX_BYTES / 1024 / 1024} MiB.`
34987
+ );
34988
+ }
34989
+ return {
34990
+ ...normalizedValue,
34991
+ reference_audio: referenceAudio
34992
+ };
34993
+ })
34994
+ };
34995
+ }
34996
+ async function prepareRemoteProxyToolArgsAsync(options) {
34997
+ return prepareRemoteProxyToolArgs(options);
34998
+ }
34999
+ function readLocalDoubaoVoiceMapping(targetDir) {
35000
+ const mappingPath = path16.join(targetDir, ".project", "audio-voice-mapping.json");
35001
+ if (!fs15.existsSync(mappingPath)) return void 0;
35002
+ assertProjectDirectory(targetDir, path16.dirname(mappingPath));
35003
+ const mapping = readJsonFile2(mappingPath);
35004
+ return (mapping == null ? void 0 : mapping.provider) === "doubao" ? mapping : void 0;
35005
+ }
35006
+ function readLocalElevenLabsVoiceMapping(targetDir) {
35007
+ const mappingPath = path16.join(targetDir, ".project", "elevenlabs-voice-mapping.json");
35008
+ if (!fs15.existsSync(mappingPath)) return void 0;
35009
+ assertProjectDirectory(targetDir, path16.dirname(mappingPath));
35010
+ const mapping = readJsonFile2(mappingPath);
35011
+ return (mapping == null ? void 0 : mapping.provider) === "elevenlabs" ? mapping : void 0;
35012
+ }
35013
+ function resolveLocalElevenLabsVoiceId(characterName, mapping) {
35014
+ if (typeof characterName !== "string" || !mapping) return void 0;
35015
+ const characters = mapping.characters;
35016
+ if (!isRecord(characters)) return void 0;
35017
+ const character = characters[characterName];
35018
+ if (!isRecord(character) || character.provider !== "elevenlabs") return void 0;
35019
+ return stringField2(character.voice_id);
35020
+ }
35021
+ function resolveLocalDoubaoMappingReference(options) {
35022
+ if (typeof options.characterName !== "string" || !options.mapping) return void 0;
35023
+ const characters = options.mapping.characters;
35024
+ if (!isRecord(characters)) return void 0;
35025
+ const character = characters[options.characterName];
35026
+ if (!isRecord(character) || character.provider !== "doubao") return void 0;
35027
+ const referencePath = stringField2(character.reference_audio_path);
35028
+ if (!referencePath) return void 0;
35029
+ try {
35030
+ const reference = normalizeDialogueReference(
35031
+ options.targetDir,
35032
+ referencePath,
35033
+ options.registry,
35034
+ options.index
35035
+ );
35036
+ return reference.toLowerCase().startsWith("data:") ? reference : void 0;
35037
+ } catch (error2) {
35038
+ const reason = error2 instanceof Error ? error2.message : String(error2);
35039
+ throw new Error(
35040
+ `Local Doubao voice mapping for character "${options.characterName}" references unavailable audio "${referencePath}". Re-run confirm_character_voice to restore it. ${reason}`
35041
+ );
35042
+ }
35043
+ }
35044
+ function normalizeOptionalDialogueReference(value) {
35045
+ if (value === void 0 || value === null) return void 0;
35046
+ if (typeof value === "string") {
35047
+ const normalized = value.trim();
35048
+ if (normalized === "" || /^data:audio\/[^,]*,\s*$/i.test(normalized)) return void 0;
35049
+ }
35050
+ return value;
35051
+ }
35052
+ function normalizeDialogueReference(targetDir, value, registry2, index) {
35053
+ if (typeof value !== "string" || !value.trim()) {
35054
+ throw new Error(`inputs[${index}].reference_audio must be a non-empty string.`);
35055
+ }
35056
+ const trimmed = value.trim();
35057
+ if (trimmed.toLowerCase().startsWith("data:")) {
35058
+ validateAudioDataUrl(trimmed);
35059
+ return trimmed;
35060
+ }
35061
+ if (/^https?:\/\//i.test(trimmed)) {
35062
+ return trimmed;
35063
+ }
35064
+ const projectReference = normalizeDialogueProjectReference(targetDir, trimmed, registry2, index);
35065
+ return localDialogueAudioReferenceToDataUrl({
35066
+ targetDir,
35067
+ value: projectReference,
35068
+ localPath: projectReference
35069
+ });
35070
+ }
35071
+ function localDialogueAudioReferenceToDataUrl(options) {
35072
+ const absolutePath = resolveLocalAssetAbsolutePath(options.targetDir, options);
35073
+ if (!absolutePath) {
35074
+ throw new Error(`local reference audio file was not found: ${options.value}`);
35075
+ }
35076
+ const projectRoot = fs15.realpathSync(path16.resolve(options.targetDir));
35077
+ const realFile = fs15.realpathSync(absolutePath);
35078
+ const relative = path16.relative(projectRoot, realFile);
35079
+ if (relative === ".." || relative.startsWith(`..${path16.sep}`) || path16.isAbsolute(relative)) {
35080
+ throw new Error("local dialogue reference resolves outside the project target directory");
35081
+ }
35082
+ const stat = fs15.statSync(realFile);
35083
+ if (!stat.isFile()) {
35084
+ throw new Error(`local reference audio path is not a file: ${options.value}`);
35085
+ }
35086
+ if (stat.size > AUDIO_DIALOGUE_REFERENCE_MAX_BYTES) {
35087
+ throw new Error("local reference audio file must be no larger than 20 MiB.");
35088
+ }
35089
+ const mime = dataUrlMimeForPath(realFile, "audio");
35090
+ if (!mime) {
35091
+ throw new Error("local reference audio format is unsupported.");
35092
+ }
35093
+ return `data:${mime};base64,${fs15.readFileSync(realFile).toString("base64")}`;
35094
+ }
35095
+ function normalizeDialogueProjectReference(targetDir, value, registry2, index) {
35096
+ if (typeof value !== "string" || !value.trim()) {
35097
+ throw new Error(`inputs[${index}].reference_audio must be a non-empty project audio path.`);
35098
+ }
35099
+ let normalized = value.trim().replace(/^workspace\//, "");
35100
+ if (path16.isAbsolute(normalized)) {
35101
+ const relative = path16.relative(path16.resolve(targetDir), path16.resolve(normalized));
35102
+ if (relative === ".." || relative.startsWith(`..${path16.sep}`) || path16.isAbsolute(relative)) {
35103
+ throw new Error(`inputs[${index}].reference_audio must stay inside project assets/audio.`);
35104
+ }
35105
+ normalized = relative.split(path16.sep).join("/");
35106
+ }
35107
+ const localPath = resolveLocalAssetReference(targetDir, normalized, registry2, AUDIO_ASSET_DIRS);
35108
+ if (localPath) {
35109
+ normalized = localPath;
35110
+ }
35111
+ const segments = normalized.split("/");
35112
+ const extension = path16.extname(normalized).toLowerCase();
35113
+ if (segments.some((segment) => segment === "" || segment === "." || segment === "..") || !isKnownAssetPath(normalized, AUDIO_ASSET_DIRS) || !AUDIO_MIME_BY_EXTENSION[extension]) {
35114
+ throw new Error(`inputs[${index}].reference_audio must be an audio path under assets/audio.`);
35115
+ }
35116
+ return normalized;
35117
+ }
35118
+ function validateAudioDataUrl(value) {
35119
+ const match = /^data:([a-z0-9.+-]+\/[a-z0-9.+-]+)((?:;[a-z0-9.+-]+=[^;,]*)*);base64,([\s\S]+)$/i.exec(value);
35120
+ if (!match || !Object.values(AUDIO_MIME_BY_EXTENSION).includes(match[1].toLowerCase())) {
35121
+ throw new Error("reference_audio must be a valid audio data URL, not bare base64.");
35122
+ }
35123
+ const cleaned = match[3].replace(/\s/g, "");
35124
+ if (cleaned.length === 0 || cleaned.length % 4 !== 0 || !/^[A-Za-z0-9+/]+={0,2}$/.test(cleaned)) {
35125
+ throw new Error("reference_audio must be a valid audio data URL, not bare base64.");
35126
+ }
35127
+ const padding = cleaned.endsWith("==") ? 2 : cleaned.endsWith("=") ? 1 : 0;
35128
+ const estimatedBytes = cleaned.length / 4 * 3 - padding;
35129
+ if (estimatedBytes > AUDIO_DIALOGUE_REFERENCE_MAX_BYTES) {
35130
+ throw new Error("reference_audio data URL must be no larger than 20 MiB.");
35131
+ }
35132
+ const bytes = Buffer.from(cleaned, "base64");
35133
+ if (bytes.length === 0 || bytes.length > AUDIO_DIALOGUE_REFERENCE_MAX_BYTES) {
35134
+ throw new Error("reference_audio data URL must be no larger than 20 MiB.");
35135
+ }
35136
+ }
34439
35137
  function rewriteUrlObjectArray(targetDir, value, registry2, options) {
34440
35138
  if (!Array.isArray(value)) {
34441
35139
  return value;
@@ -34600,6 +35298,14 @@ function resolveProjectRelativePath(targetDir, value) {
34600
35298
  }
34601
35299
  return void 0;
34602
35300
  }
35301
+ function assertProjectDirectory(targetDir, directory) {
35302
+ const projectRoot = fs15.realpathSync(path16.resolve(targetDir));
35303
+ const realDirectory = fs15.realpathSync(directory);
35304
+ const relative = path16.relative(projectRoot, realDirectory);
35305
+ if (relative === ".." || relative.startsWith(`..${path16.sep}`) || path16.isAbsolute(relative)) {
35306
+ throw new Error("resolved directory escapes the project target directory");
35307
+ }
35308
+ }
34603
35309
  function isPathWithinDirectory(rootDir, candidatePath) {
34604
35310
  const relativePath = path16.relative(path16.resolve(rootDir), path16.resolve(candidatePath));
34605
35311
  return relativePath === "" || relativePath !== ".." && !relativePath.startsWith(`..${path16.sep}`) && !path16.isAbsolute(relativePath);
@@ -34608,15 +35314,19 @@ function dataUrlMimeForPath(filePath, mediaKind) {
34608
35314
  return DATA_URL_MIME_BY_EXTENSION[mediaKind][path16.extname(filePath).toLowerCase()];
34609
35315
  }
34610
35316
  function upsertGeneratedAssetRecord(targetDir, localPath, record2) {
35317
+ const registryPath = getGeneratedAssetRegistryPath(targetDir);
35318
+ const registryDirectory = path16.dirname(registryPath);
35319
+ fs15.mkdirSync(registryDirectory, { recursive: true });
35320
+ assertProjectDirectory(targetDir, registryDirectory);
35321
+ assertFileIsNotSymlink(registryPath);
34611
35322
  const registry2 = readGeneratedAssetRegistry(targetDir);
34612
35323
  registry2[localPath] = record2;
34613
- const registryPath = getGeneratedAssetRegistryPath(targetDir);
34614
- fs15.mkdirSync(path16.dirname(registryPath), { recursive: true });
34615
35324
  fs15.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
34616
35325
  `, "utf8");
34617
35326
  }
34618
35327
  function readGeneratedAssetRegistry(targetDir) {
34619
35328
  const registryPath = getGeneratedAssetRegistryPath(targetDir);
35329
+ assertFileIsNotSymlink(registryPath);
34620
35330
  if (!fs15.existsSync(registryPath)) {
34621
35331
  return {};
34622
35332
  }
@@ -34630,6 +35340,18 @@ function readGeneratedAssetRegistry(targetDir) {
34630
35340
  function getGeneratedAssetRegistryPath(targetDir) {
34631
35341
  return path16.join(targetDir, ".maker", "assets", "generated-assets.json");
34632
35342
  }
35343
+ function isSymlink(filePath) {
35344
+ try {
35345
+ return fs15.lstatSync(filePath).isSymbolicLink();
35346
+ } catch {
35347
+ return false;
35348
+ }
35349
+ }
35350
+ function assertFileIsNotSymlink(filePath) {
35351
+ if (isSymlink(filePath)) {
35352
+ throw new Error(`refusing to access symlinked file: ${filePath}`);
35353
+ }
35354
+ }
34633
35355
  function normalizeAssetRegistryKey(targetDir, value) {
34634
35356
  if (/^https?:\/\//i.test(value) || value.startsWith("data:")) {
34635
35357
  return void 0;
@@ -34825,7 +35547,7 @@ function applyDefaults(config2) {
34825
35547
  }
34826
35548
 
34827
35549
  // src/maker/server/mcp.ts
34828
- var VERSION = true ? "0.0.25-beta.1" : "dev";
35550
+ var VERSION = true ? "0.0.25-beta.2" : "dev";
34829
35551
  var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
34830
35552
  var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
34831
35553
  var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
@@ -34840,6 +35562,11 @@ var MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES = [
34840
35562
  "create_video_task",
34841
35563
  "query_video_task",
34842
35564
  "text_to_music",
35565
+ "text_to_sound_effect",
35566
+ "batch_sound_effects",
35567
+ "text_to_dialogue",
35568
+ "audition_voices_for_character",
35569
+ "confirm_character_voice",
34843
35570
  CREATE_3D_ASSET_PROXY_TOOL_NAME,
34844
35571
  "generate_test_qrcode",
34845
35572
  "get_ad_config",
@@ -35026,18 +35753,21 @@ function decorateRemoteProxyToolDefinition(tool) {
35026
35753
  const guidance = remoteProxyToolGuidance(tool.name);
35027
35754
  return {
35028
35755
  ...tool,
35029
- inputSchema: decorateRemoteProxyToolInputSchema(tool.inputSchema),
35756
+ inputSchema: decorateRemoteProxyToolInputSchema(tool.inputSchema, tool.name),
35030
35757
  description: [tool.description, guidance].filter(Boolean).join("\n\n")
35031
35758
  };
35032
35759
  }
35033
- function decorateRemoteProxyToolInputSchema(inputSchema) {
35760
+ function decorateRemoteProxyToolInputSchema(inputSchema, toolName) {
35034
35761
  const schema = isPlainRecord(inputSchema) ? inputSchema : {};
35035
35762
  const properties = isPlainRecord(schema.properties) ? schema.properties : {};
35763
+ const decoratedProperties = toolName === "text_to_dialogue" ? decorateTextToDialogueInputProperties(properties) : toolName === "audition_voices_for_character" ? decorateVoiceAuditionInputProperties(properties) : properties;
35764
+ const required2 = Array.isArray(schema.required) ? schema.required : [];
35036
35765
  return {
35037
35766
  ...schema,
35038
35767
  type: schema.type || "object",
35768
+ ...toolName === "audition_voices_for_character" ? { required: [.../* @__PURE__ */ new Set([...required2, "voice_profile"])] } : {},
35039
35769
  properties: {
35040
- ...properties,
35770
+ ...decoratedProperties,
35041
35771
  target_dir: {
35042
35772
  type: "string",
35043
35773
  description: "Optional local Maker project directory. This is a local Maker MCP private parameter used to resolve the current project for asset materialization and reference rewriting; it is not forwarded to the remote Maker tool."
@@ -35045,6 +35775,76 @@ function decorateRemoteProxyToolInputSchema(inputSchema) {
35045
35775
  }
35046
35776
  };
35047
35777
  }
35778
+ function decorateVoiceAuditionInputProperties(properties) {
35779
+ const remoteVoiceProfile = properties.voice_profile;
35780
+ const voiceProfile = isPlainRecord(remoteVoiceProfile) ? remoteVoiceProfile : {};
35781
+ const profileProperties = isPlainRecord(voiceProfile.properties) ? voiceProfile.properties : {};
35782
+ const profileRequired = Array.isArray(voiceProfile.required) ? voiceProfile.required : [];
35783
+ const remoteGender = profileProperties.gender;
35784
+ return {
35785
+ ...properties,
35786
+ voice_profile: {
35787
+ ...voiceProfile,
35788
+ type: voiceProfile.type || "object",
35789
+ description: [
35790
+ voiceProfile.description,
35791
+ "Required for character voice audition. Extract gender from character_description or the character settings instead of relying on a default."
35792
+ ].filter(Boolean).join(" "),
35793
+ properties: {
35794
+ ...profileProperties,
35795
+ gender: {
35796
+ ...isPlainRecord(remoteGender) ? remoteGender : {},
35797
+ type: "string",
35798
+ enum: ["male", "female"],
35799
+ description: "Required structured character gender. Extract male or female from character_description or the character settings."
35800
+ }
35801
+ },
35802
+ required: [.../* @__PURE__ */ new Set([...profileRequired, "gender"])]
35803
+ }
35804
+ };
35805
+ }
35806
+ function decorateTextToDialogueInputProperties(properties) {
35807
+ const inputs = properties.inputs;
35808
+ if (!isPlainRecord(inputs) || !isPlainRecord(inputs.items)) {
35809
+ return properties;
35810
+ }
35811
+ const itemProperties = inputs.items.properties;
35812
+ if (!isPlainRecord(itemProperties)) {
35813
+ return properties;
35814
+ }
35815
+ const referenceAudio = itemProperties.reference_audio;
35816
+ const referenceAudioPath = itemProperties.reference_audio_path;
35817
+ return {
35818
+ ...properties,
35819
+ inputs: {
35820
+ ...inputs,
35821
+ items: {
35822
+ ...inputs.items,
35823
+ properties: {
35824
+ ...itemProperties,
35825
+ ...isPlainRecord(referenceAudio) ? {
35826
+ reference_audio: {
35827
+ ...referenceAudio,
35828
+ description: [
35829
+ referenceAudio.description,
35830
+ "Use a local project audio path under assets/audio/, an HTTP(S) URL, or an audio data URL here. Local project audio must exist in the current project and is converted to a data URL automatically. Do not pass bare base64."
35831
+ ].filter(Boolean).join(" ")
35832
+ }
35833
+ } : {},
35834
+ ...isPlainRecord(referenceAudioPath) ? {
35835
+ reference_audio_path: {
35836
+ ...referenceAudioPath,
35837
+ description: [
35838
+ referenceAudioPath.description,
35839
+ "This legacy local project audio path must exist under assets/audio/ or workspace/assets/audio/. The local proxy converts it to the canonical reference_audio data URL; it is not a project-external filesystem path."
35840
+ ].filter(Boolean).join(" ")
35841
+ }
35842
+ } : {}
35843
+ }
35844
+ }
35845
+ }
35846
+ };
35847
+ }
35048
35848
  function isPlainRecord(value) {
35049
35849
  return typeof value === "object" && value !== null && !Array.isArray(value);
35050
35850
  }
@@ -35082,6 +35882,27 @@ function remoteProxyToolGuidance(toolName) {
35082
35882
  "**Maker asset workflow hint:** Prefer this Maker MCP proxy tool for Maker music generation so generated audio can be materialized into the project and recorded for later Maker references.",
35083
35883
  failurePolicy
35084
35884
  ].join(" ");
35885
+ case "text_to_sound_effect":
35886
+ case "batch_sound_effects":
35887
+ return [
35888
+ "**Maker asset workflow hint:** Prefer this Maker MCP proxy tool for game sound effects. Successful audio is materialized in its original format under assets/audio/sfx and recorded for later Maker references.",
35889
+ failurePolicy
35890
+ ].join(" ");
35891
+ case "text_to_dialogue":
35892
+ return [
35893
+ "**Maker voice workflow hint:** For normal dialogue, pass only character_name and text after voice confirmation; the local proxy automatically reuses a confirmed local Doubao reference. reference_audio is an optional per-call override and accepts a local project audio path under assets/audio/, an HTTP(S) URL, or an audio data URL. Project audio must exist locally and is converted to a data URL automatically. reference_audio and reference_audio_path are mutually exclusive; reference_audio is canonical and reference_audio_path is the legacy local-path field. Successful dialogue audio is materialized under assets/audio/voice.",
35894
+ failurePolicy
35895
+ ].join(" ");
35896
+ case "audition_voices_for_character":
35897
+ return [
35898
+ "**Maker voice workflow hint:** Use this Maker MCP proxy tool to create temporary preview voices for one character. voice_profile.gender is required: extract male or female from character_description or the character settings and pass it explicitly. Show every returned preview URL to the user and wait for their choice before calling confirm_character_voice. Preview candidates are not saved as game assets.",
35899
+ failurePolicy
35900
+ ].join(" ");
35901
+ case "confirm_character_voice":
35902
+ return [
35903
+ "**Maker voice workflow hint:** Call this Maker MCP proxy tool only after audition_voices_for_character and after the user selects a candidate or accepts the recommendation. Confirmation persists the provider-specific voice mapping for later text_to_dialogue calls.",
35904
+ failurePolicy
35905
+ ].join(" ");
35085
35906
  case CREATE_3D_ASSET_PROXY_TOOL_NAME:
35086
35907
  return [
35087
35908
  "**Maker asset workflow hint:** Use this tool for the complete Maker 3D asset lifecycle: start, query, continue after explicit user review, inspect options, and post-process completed assets.",
@@ -35150,7 +35971,7 @@ async function callRemoteProxyTool(options) {
35150
35971
  targetDir: options.targetDir,
35151
35972
  exposedTools: MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES
35152
35973
  });
35153
- const finalArgs = prepareRemoteProxyToolArgs({
35974
+ const finalArgs = await prepareRemoteProxyToolArgsAsync({
35154
35975
  toolName: options.name,
35155
35976
  targetDir: proxy.projectRoot,
35156
35977
  args: options.args
@@ -37390,7 +38211,7 @@ function formatError2(error2) {
37390
38211
  }
37391
38212
 
37392
38213
  // src/maker/cli/commands.ts
37393
- var VERSION2 = true ? "0.0.25-beta.1" : "dev";
38214
+ var VERSION2 = true ? "0.0.25-beta.2" : "dev";
37394
38215
  var DEFAULT_MCP_NAME = "taptap-maker";
37395
38216
  var MAKER_NPM_PACKAGE = "@taptap/maker";
37396
38217
  var TWO_PART_COMMANDS = /* @__PURE__ */ new Set(["pat", "mcp", "dev-kit", "logs", "python", "lua-lsp", "agents"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taptap/maker",
3
- "version": "0.0.25-beta.1",
3
+ "version": "0.0.25-beta.2",
4
4
  "type": "module",
5
5
  "description": "TapTap Maker local development CLI and MCP server",
6
6
  "main": "dist/maker.js",
@@ -147,7 +147,22 @@ This guidance helps users prefer Maker-managed tools for Maker game assets.
147
147
  - Use `edit_image` for modifying project images.
148
148
  - Use `create_video_task` for game videos and image/video referenced generation.
149
149
  - Use `query_video_task` to refresh video task status, release completed task quota, and fetch final videos.
150
- - Use `text_to_music` for game music or audio.
150
+ - Use `text_to_music` for game music.
151
+ - Use `text_to_sound_effect` for one sound effect.
152
+ - Use `batch_sound_effects` for multiple sound effects.
153
+ - Use `text_to_dialogue` for final character dialogue.
154
+ - `text_to_dialogue` automatically converts local project audio to data URLs and reuses confirmed local voice mappings.
155
+ - After `audition_voices_for_character` returns previews, show them to the user and wait
156
+ for the user to choose. Do not select or confirm a voice automatically.
157
+ - Before a Doubao audition, extract the character gender from the character settings or
158
+ `character_description` and pass `voice_profile.gender` as `male` or `female`; never rely on a
159
+ default gender.
160
+ - Call `confirm_character_voice` only after the user explicitly chooses one preview.
161
+ - After confirmation, follow `next_step_hint`: call `text_to_dialogue` with the character name and
162
+ text, and omit `reference_audio` unless the user requests a one-time override.
163
+ - Generated sound effects and dialogue are saved in the project.
164
+ - Voice audition previews are not saved to the project.
165
+ - Local MCP does not transcode generated audio to OGG.
151
166
  - Follow each tool schema for supported local path, remote URL, and data URL inputs.
152
167
  - Local proxy may convert resolvable local reference media to data URLs before forwarding.
153
168
  - If a Maker proxy tool returns an error or `isError`, report the full remote result/error payload.
@@ -235,9 +250,11 @@ directory.
235
250
  ### Proxy Tools Missing From The Current Session
236
251
 
237
252
  If the user is in a bound Maker project but `generate_image`, `batch_generate_images`, `edit_image`,
238
- `create_video_task`, `query_video_task`, `text_to_music`, `create_3d_asset`,
239
- `generate_test_qrcode`, `get_ad_config`, or `get_debug_feedbacks`
240
- are missing from the current AI tool list, diagnose the MCP cwd before
253
+ `create_video_task`, `query_video_task`, `text_to_music`, `text_to_sound_effect`,
254
+ `batch_sound_effects`, `text_to_dialogue`, `audition_voices_for_character`,
255
+ `confirm_character_voice`, `create_3d_asset`,
256
+ `generate_test_qrcode`, `get_ad_config`, or `get_debug_feedbacks` are missing from the current AI
257
+ tool list, diagnose the MCP cwd before
241
258
  suggesting repeated restarts:
242
259
 
243
260
  1. Read `maker://status` or call `maker_status_lite` without `target_dir` to see the MCP server cwd.
@@ -666,11 +683,11 @@ If conflicts occur:
666
683
  When showing conflict content, keep excerpts small and focused around conflict markers:
667
684
 
668
685
  ```text
669
- <<<<<<<
670
- local version
671
- =======
672
- remote version
673
- >>>>>>>
686
+ <<<<<<<
687
+ local version
688
+ =======
689
+ remote version
690
+ >>>>>>>
674
691
  ```
675
692
 
676
693
  Do not hide unresolved conflicts. After editing, run: