@taptap/maker 0.0.26-beta.1 → 0.0.26-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/maker.js CHANGED
@@ -3233,8 +3233,8 @@ var require_utils = __commonJS({
3233
3233
  }
3234
3234
  return ind;
3235
3235
  }
3236
- function removeDotSegments(path21) {
3237
- let input2 = path21;
3236
+ function removeDotSegments(path22) {
3237
+ let input2 = path22;
3238
3238
  const output2 = [];
3239
3239
  let nextSlash = -1;
3240
3240
  let len = 0;
@@ -3433,8 +3433,8 @@ var require_schemes = __commonJS({
3433
3433
  wsComponent.secure = void 0;
3434
3434
  }
3435
3435
  if (wsComponent.resourceName) {
3436
- const [path21, query] = wsComponent.resourceName.split("?");
3437
- wsComponent.path = path21 && path21 !== "/" ? path21 : void 0;
3436
+ const [path22, query] = wsComponent.resourceName.split("?");
3437
+ wsComponent.path = path22 && path22 !== "/" ? path22 : void 0;
3438
3438
  wsComponent.query = query;
3439
3439
  wsComponent.resourceName = void 0;
3440
3440
  }
@@ -12491,12 +12491,12 @@ var require_dist = __commonJS({
12491
12491
  throw new Error(`Unknown format "${name}"`);
12492
12492
  return f;
12493
12493
  };
12494
- function addFormats(ajv, list, fs19, exportName) {
12494
+ function addFormats(ajv, list, fs20, exportName) {
12495
12495
  var _a3;
12496
12496
  var _b;
12497
12497
  (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
12498
12498
  for (const f of list)
12499
- ajv.addFormat(f, fs19[f]);
12499
+ ajv.addFormat(f, fs20[f]);
12500
12500
  }
12501
12501
  module.exports = exports = formatsPlugin;
12502
12502
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -12509,8 +12509,8 @@ var require_windows = __commonJS({
12509
12509
  "node_modules/isexe/windows.js"(exports, module) {
12510
12510
  module.exports = isexe;
12511
12511
  isexe.sync = sync;
12512
- var fs19 = __require("fs");
12513
- function checkPathExt(path21, options) {
12512
+ var fs20 = __require("fs");
12513
+ function checkPathExt(path22, options) {
12514
12514
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
12515
12515
  if (!pathext) {
12516
12516
  return true;
@@ -12521,25 +12521,25 @@ var require_windows = __commonJS({
12521
12521
  }
12522
12522
  for (var i = 0; i < pathext.length; i++) {
12523
12523
  var p = pathext[i].toLowerCase();
12524
- if (p && path21.substr(-p.length).toLowerCase() === p) {
12524
+ if (p && path22.substr(-p.length).toLowerCase() === p) {
12525
12525
  return true;
12526
12526
  }
12527
12527
  }
12528
12528
  return false;
12529
12529
  }
12530
- function checkStat(stat, path21, options) {
12530
+ function checkStat(stat, path22, options) {
12531
12531
  if (!stat.isSymbolicLink() && !stat.isFile()) {
12532
12532
  return false;
12533
12533
  }
12534
- return checkPathExt(path21, options);
12534
+ return checkPathExt(path22, options);
12535
12535
  }
12536
- function isexe(path21, options, cb) {
12537
- fs19.stat(path21, function(er, stat) {
12538
- cb(er, er ? false : checkStat(stat, path21, options));
12536
+ function isexe(path22, options, cb) {
12537
+ fs20.stat(path22, function(er, stat) {
12538
+ cb(er, er ? false : checkStat(stat, path22, options));
12539
12539
  });
12540
12540
  }
12541
- function sync(path21, options) {
12542
- return checkStat(fs19.statSync(path21), path21, options);
12541
+ function sync(path22, options) {
12542
+ return checkStat(fs20.statSync(path22), path22, options);
12543
12543
  }
12544
12544
  }
12545
12545
  });
@@ -12549,14 +12549,14 @@ var require_mode = __commonJS({
12549
12549
  "node_modules/isexe/mode.js"(exports, module) {
12550
12550
  module.exports = isexe;
12551
12551
  isexe.sync = sync;
12552
- var fs19 = __require("fs");
12553
- function isexe(path21, options, cb) {
12554
- fs19.stat(path21, function(er, stat) {
12552
+ var fs20 = __require("fs");
12553
+ function isexe(path22, options, cb) {
12554
+ fs20.stat(path22, function(er, stat) {
12555
12555
  cb(er, er ? false : checkStat(stat, options));
12556
12556
  });
12557
12557
  }
12558
- function sync(path21, options) {
12559
- return checkStat(fs19.statSync(path21), options);
12558
+ function sync(path22, options) {
12559
+ return checkStat(fs20.statSync(path22), options);
12560
12560
  }
12561
12561
  function checkStat(stat, options) {
12562
12562
  return stat.isFile() && checkMode(stat, options);
@@ -12580,7 +12580,7 @@ var require_mode = __commonJS({
12580
12580
  // node_modules/isexe/index.js
12581
12581
  var require_isexe = __commonJS({
12582
12582
  "node_modules/isexe/index.js"(exports, module) {
12583
- var fs19 = __require("fs");
12583
+ var fs20 = __require("fs");
12584
12584
  var core;
12585
12585
  if (process.platform === "win32" || global.TESTING_WINDOWS) {
12586
12586
  core = require_windows();
@@ -12589,7 +12589,7 @@ var require_isexe = __commonJS({
12589
12589
  }
12590
12590
  module.exports = isexe;
12591
12591
  isexe.sync = sync;
12592
- function isexe(path21, options, cb) {
12592
+ function isexe(path22, options, cb) {
12593
12593
  if (typeof options === "function") {
12594
12594
  cb = options;
12595
12595
  options = {};
@@ -12599,7 +12599,7 @@ var require_isexe = __commonJS({
12599
12599
  throw new TypeError("callback not provided");
12600
12600
  }
12601
12601
  return new Promise(function(resolve, reject) {
12602
- isexe(path21, options || {}, function(er, is) {
12602
+ isexe(path22, options || {}, function(er, is) {
12603
12603
  if (er) {
12604
12604
  reject(er);
12605
12605
  } else {
@@ -12608,7 +12608,7 @@ var require_isexe = __commonJS({
12608
12608
  });
12609
12609
  });
12610
12610
  }
12611
- core(path21, options || {}, function(er, is) {
12611
+ core(path22, options || {}, function(er, is) {
12612
12612
  if (er) {
12613
12613
  if (er.code === "EACCES" || options && options.ignoreErrors) {
12614
12614
  er = null;
@@ -12618,9 +12618,9 @@ var require_isexe = __commonJS({
12618
12618
  cb(er, is);
12619
12619
  });
12620
12620
  }
12621
- function sync(path21, options) {
12621
+ function sync(path22, options) {
12622
12622
  try {
12623
- return core.sync(path21, options || {});
12623
+ return core.sync(path22, options || {});
12624
12624
  } catch (er) {
12625
12625
  if (options && options.ignoreErrors || er.code === "EACCES") {
12626
12626
  return false;
@@ -12636,7 +12636,7 @@ var require_isexe = __commonJS({
12636
12636
  var require_which = __commonJS({
12637
12637
  "node_modules/which/which.js"(exports, module) {
12638
12638
  var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
12639
- var path21 = __require("path");
12639
+ var path22 = __require("path");
12640
12640
  var COLON = isWindows ? ";" : ":";
12641
12641
  var isexe = require_isexe();
12642
12642
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -12674,7 +12674,7 @@ var require_which = __commonJS({
12674
12674
  return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
12675
12675
  const ppRaw = pathEnv[i];
12676
12676
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
12677
- const pCmd = path21.join(pathPart, cmd);
12677
+ const pCmd = path22.join(pathPart, cmd);
12678
12678
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
12679
12679
  resolve(subStep(p, i, 0));
12680
12680
  });
@@ -12701,7 +12701,7 @@ var require_which = __commonJS({
12701
12701
  for (let i = 0; i < pathEnv.length; i++) {
12702
12702
  const ppRaw = pathEnv[i];
12703
12703
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
12704
- const pCmd = path21.join(pathPart, cmd);
12704
+ const pCmd = path22.join(pathPart, cmd);
12705
12705
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
12706
12706
  for (let j = 0; j < pathExt.length; j++) {
12707
12707
  const cur = p + pathExt[j];
@@ -12749,7 +12749,7 @@ var require_path_key = __commonJS({
12749
12749
  var require_resolveCommand = __commonJS({
12750
12750
  "node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
12751
12751
  "use strict";
12752
- var path21 = __require("path");
12752
+ var path22 = __require("path");
12753
12753
  var which = require_which();
12754
12754
  var getPathKey = require_path_key();
12755
12755
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -12767,7 +12767,7 @@ var require_resolveCommand = __commonJS({
12767
12767
  try {
12768
12768
  resolved = which.sync(parsed.command, {
12769
12769
  path: env[getPathKey({ env })],
12770
- pathExt: withoutPathExt ? path21.delimiter : void 0
12770
+ pathExt: withoutPathExt ? path22.delimiter : void 0
12771
12771
  });
12772
12772
  } catch (e) {
12773
12773
  } finally {
@@ -12776,7 +12776,7 @@ var require_resolveCommand = __commonJS({
12776
12776
  }
12777
12777
  }
12778
12778
  if (resolved) {
12779
- resolved = path21.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
12779
+ resolved = path22.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
12780
12780
  }
12781
12781
  return resolved;
12782
12782
  }
@@ -12830,8 +12830,8 @@ var require_shebang_command = __commonJS({
12830
12830
  if (!match) {
12831
12831
  return null;
12832
12832
  }
12833
- const [path21, argument] = match[0].replace(/#! ?/, "").split(" ");
12834
- const binary = path21.split("/").pop();
12833
+ const [path22, argument] = match[0].replace(/#! ?/, "").split(" ");
12834
+ const binary = path22.split("/").pop();
12835
12835
  if (binary === "env") {
12836
12836
  return argument;
12837
12837
  }
@@ -12844,16 +12844,16 @@ var require_shebang_command = __commonJS({
12844
12844
  var require_readShebang = __commonJS({
12845
12845
  "node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
12846
12846
  "use strict";
12847
- var fs19 = __require("fs");
12847
+ var fs20 = __require("fs");
12848
12848
  var shebangCommand = require_shebang_command();
12849
12849
  function readShebang(command) {
12850
12850
  const size = 150;
12851
12851
  const buffer = Buffer.alloc(size);
12852
12852
  let fd;
12853
12853
  try {
12854
- fd = fs19.openSync(command, "r");
12855
- fs19.readSync(fd, buffer, 0, size, 0);
12856
- fs19.closeSync(fd);
12854
+ fd = fs20.openSync(command, "r");
12855
+ fs20.readSync(fd, buffer, 0, size, 0);
12856
+ fs20.closeSync(fd);
12857
12857
  } catch (e) {
12858
12858
  }
12859
12859
  return shebangCommand(buffer.toString());
@@ -12866,7 +12866,7 @@ var require_readShebang = __commonJS({
12866
12866
  var require_parse = __commonJS({
12867
12867
  "node_modules/cross-spawn/lib/parse.js"(exports, module) {
12868
12868
  "use strict";
12869
- var path21 = __require("path");
12869
+ var path22 = __require("path");
12870
12870
  var resolveCommand = require_resolveCommand();
12871
12871
  var escape2 = require_escape();
12872
12872
  var readShebang = require_readShebang();
@@ -12891,7 +12891,7 @@ var require_parse = __commonJS({
12891
12891
  const needsShell = !isExecutableRegExp.test(commandFile);
12892
12892
  if (parsed.options.forceShell || needsShell) {
12893
12893
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
12894
- parsed.command = path21.normalize(parsed.command);
12894
+ parsed.command = path22.normalize(parsed.command);
12895
12895
  parsed.command = escape2.command(parsed.command);
12896
12896
  parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
12897
12897
  const shellCommand = [parsed.command].concat(parsed.args).join(" ");
@@ -13003,8 +13003,8 @@ var require_cross_spawn = __commonJS({
13003
13003
 
13004
13004
  // src/maker/server/mcp.ts
13005
13005
  import { execFileSync, spawn as spawn4 } from "node:child_process";
13006
- import fs16 from "node:fs";
13007
- import path17 from "node:path";
13006
+ import fs17 from "node:fs";
13007
+ import path18 from "node:path";
13008
13008
  import { fileURLToPath as fileURLToPath2 } from "node:url";
13009
13009
 
13010
13010
  // node_modules/zod/v3/helpers/util.js
@@ -13366,8 +13366,8 @@ function getErrorMap() {
13366
13366
 
13367
13367
  // node_modules/zod/v3/helpers/parseUtil.js
13368
13368
  var makeIssue = (params) => {
13369
- const { data, path: path21, errorMaps, issueData } = params;
13370
- const fullPath = [...path21, ...issueData.path || []];
13369
+ const { data, path: path22, errorMaps, issueData } = params;
13370
+ const fullPath = [...path22, ...issueData.path || []];
13371
13371
  const fullIssue = {
13372
13372
  ...issueData,
13373
13373
  path: fullPath
@@ -13482,11 +13482,11 @@ var errorUtil;
13482
13482
 
13483
13483
  // node_modules/zod/v3/types.js
13484
13484
  var ParseInputLazyPath = class {
13485
- constructor(parent, value, path21, key) {
13485
+ constructor(parent, value, path22, key) {
13486
13486
  this._cachedPath = [];
13487
13487
  this.parent = parent;
13488
13488
  this.data = value;
13489
- this._path = path21;
13489
+ this._path = path22;
13490
13490
  this._key = key;
13491
13491
  }
13492
13492
  get path() {
@@ -17135,10 +17135,10 @@ function mergeDefs(...defs) {
17135
17135
  function cloneDef(schema) {
17136
17136
  return mergeDefs(schema._zod.def);
17137
17137
  }
17138
- function getElementAtPath(obj, path21) {
17139
- if (!path21)
17138
+ function getElementAtPath(obj, path22) {
17139
+ if (!path22)
17140
17140
  return obj;
17141
- return path21.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
17141
+ return path22.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
17142
17142
  }
17143
17143
  function promiseAllObject(promisesObj) {
17144
17144
  const keys = Object.keys(promisesObj);
@@ -17523,11 +17523,11 @@ function aborted(x, startIndex = 0) {
17523
17523
  }
17524
17524
  return false;
17525
17525
  }
17526
- function prefixIssues(path21, issues) {
17526
+ function prefixIssues(path22, issues) {
17527
17527
  return issues.map((iss) => {
17528
17528
  var _a3;
17529
17529
  (_a3 = iss).path ?? (_a3.path = []);
17530
- iss.path.unshift(path21);
17530
+ iss.path.unshift(path22);
17531
17531
  return iss;
17532
17532
  });
17533
17533
  }
@@ -29156,6 +29156,22 @@ async function fetchWithTimeout(fetchImpl, url2, init, timeoutMs, label) {
29156
29156
  import crypto from "node:crypto";
29157
29157
  import fs5 from "node:fs";
29158
29158
  import path6 from "node:path";
29159
+
29160
+ // src/maker/capabilityRouting.ts
29161
+ var MAKER_CAPABILITY_ROUTING_INDEX = `TapTap Maker routing index:
29162
+ - Start or resume Maker work, or diagnose project/MCP readiness: read
29163
+ maker://status; use maker_status_lite when resources are unavailable.
29164
+ - Build, preview, run, submit, or push: after checking project status, use
29165
+ maker_build_current_directory.
29166
+ - Tap flows: test QR -> generate_test_qrcode; ads or ad code -> first check
29167
+ Maker project status, then use get_ad_config when primary configs are ready;
29168
+ online player feedback, logs, or screenshots -> get_debug_feedbacks.
29169
+ - Game assets: Maker MCP also provides image, video, music, sound-effect,
29170
+ dialogue/voice, and 3D generation tools when exposed.
29171
+
29172
+ Follow the selected tool schema and returned next_action.`;
29173
+
29174
+ // src/maker/cli/agentsPolicy.ts
29159
29175
  var MAKER_AGENTS_FILE = "AGENTS.md";
29160
29176
  var POLICY_VERSION = "3";
29161
29177
  var POLICY_END = "<!-- <<< TapTap Maker managed AGENTS policy <<< -->";
@@ -29243,6 +29259,8 @@ function createMakerAgentsPolicyBody() {
29243
29259
  "",
29244
29260
  "This is a bound TapTap Maker project.",
29245
29261
  "",
29262
+ MAKER_CAPABILITY_ROUTING_INDEX,
29263
+ "",
29246
29264
  "Maker build workflow:",
29247
29265
  "",
29248
29266
  "- For user requests such as 构建, build, 预览, 跑一下, 查看结果, 看看效果, 验证游戏效果,",
@@ -29301,15 +29319,17 @@ function createMakerAgentsPolicyBody() {
29301
29319
  "",
29302
29320
  "Maker ad workflow:",
29303
29321
  "",
29304
- "- For any ad-related request or code touching ads, first call `get_ad_config` before reading",
29322
+ "- For any ad-related request or code touching ads, first inspect Maker project status. Call",
29323
+ " `get_ad_config` only after primary local project configs are initialized and before reading",
29305
29324
  " local SDK docs, editing ad code, or testing ad behavior. Triggers include 广告, 激励视频,",
29306
29325
  " 播放广告, ad ID, ad placement, ad status, ad config, and `ShowRewardVideoAd`.",
29307
29326
  "- Treat `get_ad_config` as the source of truth for current project ad activation status and",
29308
29327
  " ad config. Do not infer ad readiness from local SDK docs, `.maker-mcp/config.json`, or",
29309
29328
  " runtime callbacks.",
29310
- "- If `.project/project.json` is missing, build once with `maker_build_current_directory` to",
29311
- " initialize the project, then call `get_ad_config` again. Implement or test ad code only",
29312
- " after the config is available.",
29329
+ "- If primary local project configs are missing, keep ad config unavailable and do not call the",
29330
+ " remote tool. Build only for an explicit user build/submit/preview request. If a successful",
29331
+ " build still leaves local configs missing, explain the known limitation and do not rebuild",
29332
+ " automatically. Implement or test ad code only after the config is available.",
29313
29333
  "- If `get_ad_config` reports missing `app_id` or `developer_id`, call",
29314
29334
  " `generate_test_qrcode` once to generate test QR code metadata, then call `get_ad_config`",
29315
29335
  " again. Do not use publish-only tools for this recovery path.",
@@ -32412,9 +32432,9 @@ function formatMakerSkillStatus(_options = {}) {
32412
32432
  "- Voice audition previews are not saved to the project.",
32413
32433
  "- Local MCP does not transcode generated audio to OGG.",
32414
32434
  "- Use create_3d_asset with start/query/continue/post_process for game 3D model assets.",
32415
- "- For any ad-related request, call get_ad_config first to get ad activation status and ad config.",
32435
+ "- For any ad-related request, inspect Maker project status first and call get_ad_config only after primary local project configs are initialized.",
32416
32436
  "- Do not infer ad readiness from local SDK docs, .maker-mcp/config.json, or runtime callbacks.",
32417
- "- If .project/project.json is missing, build once with maker_build_current_directory, then call get_ad_config again.",
32437
+ "- If primary local project configs are missing, keep ad config unavailable. Build only for an explicit user build/submit/preview request, and do not automatically rebuild when local configs remain missing after success.",
32418
32438
  "- If get_ad_config reports missing app_id or developer_id, call generate_test_qrcode once, then call get_ad_config again.",
32419
32439
  "- For online player feedback, issue reports, real-device logs, or screenshots, call get_debug_feedbacks.",
32420
32440
  "- Use local runtime logs only for the current local build/runtime session.",
@@ -33377,7 +33397,7 @@ function formatMakerProjectInitializationStatus(status) {
33377
33397
  "- status: missing_project_json",
33378
33398
  `- config: ${status.projectJsonPath}`,
33379
33399
  "- impact: get_ad_config and other remote project-config tools cannot read project metadata yet.",
33380
- projectDirState === "directory" ? "- next_action: 已存在 .project 但 project.json 缺失;先从 Git 或完整副本恢复,构建不会覆盖该缺失文件。" : projectDirState === "invalid" ? "- next_action: .project 路径异常;先恢复为正常目录,再检查或恢复 project.json。" : "- next_action: 先调用 maker_build_current_directory 构建一次,生成 .project/project.json 后再重试。"
33400
+ projectDirState === "invalid" ? "- next_action: .project 路径异常;先恢复为正常目录,再检查或恢复 project.json。" : "- next_action: 本地主要配置尚未初始化;仅当用户明确要求构建、提交或预览时调用 maker_build_current_directory。构建成功后若本地仍缺少 .project/project.json,保持配置依赖功能不可用,不要自动重复构建。"
33381
33401
  ].join("\n");
33382
33402
  }
33383
33403
  return "";
@@ -33457,7 +33477,8 @@ function inspectMakerProjectHealth(projectRoot, mode = "status") {
33457
33477
  const resourcesJsonExists = resourcesJsonState === "file";
33458
33478
  const settingsJsonExists = settingsJsonState === "file";
33459
33479
  const hasMisplacedConfig = issues.some((item) => item.code === "misplaced_config");
33460
- if (!projectDirExists && !hasMisplacedConfig && issues.length === 0) {
33480
+ const hasNoPrimaryConfig = projectJsonState === "missing" && settingsJsonState === "missing";
33481
+ if (hasNoPrimaryConfig && !hasMisplacedConfig && issues.length === 0) {
33461
33482
  return createHealthResult(
33462
33483
  resolvedProjectRoot,
33463
33484
  mode,
@@ -33468,15 +33489,10 @@ function inspectMakerProjectHealth(projectRoot, mode = "status") {
33468
33489
  false
33469
33490
  );
33470
33491
  }
33471
- addCanonicalFileIssue(projectJsonState, ".project/project.json", issues, projectDirExists);
33472
- addCanonicalFileIssue(
33473
- resourcesJsonState,
33474
- ".project/resources.json",
33475
- issues,
33476
- mode === "qrcode" || projectDirExists
33477
- );
33492
+ addCanonicalFileIssue(projectJsonState, ".project/project.json", issues, mode === "qrcode");
33493
+ addCanonicalFileIssue(resourcesJsonState, ".project/resources.json", issues, mode === "qrcode");
33478
33494
  addCanonicalFileIssue(settingsJsonState, ".project/settings.json", issues, false);
33479
- if (projectDirExists && settingsJsonState === "missing" && mode !== "qrcode") {
33495
+ if (projectJsonExists && settingsJsonState === "missing") {
33480
33496
  issues.push(
33481
33497
  issue2(
33482
33498
  "missing_settings_json",
@@ -33536,9 +33552,10 @@ function inspectMakerProjectHealth(projectRoot, mode = "status") {
33536
33552
  }
33537
33553
  }
33538
33554
  const hasFatalIssues = issues.some((item) => item.severity === "error");
33539
- const status = hasMisplacedConfig ? "misplaced_config" : hasFatalIssues ? "error" : issues.length > 0 ? "warning" : "ready";
33555
+ const hasCompletePrimaryConfig = projectJsonExists && settingsJsonExists;
33556
+ const status = hasMisplacedConfig ? "misplaced_config" : hasFatalIssues ? "error" : !hasCompletePrimaryConfig ? "not_initialized" : issues.length > 0 ? "warning" : "ready";
33540
33557
  const canBuild = !issues.some((item) => item.severity === "error" && isBuildBlockingIssue(item));
33541
- const canGenerateTestQrcode = canGenerateQrcode(project, resources2, issues);
33558
+ const canGenerateTestQrcode = canGenerateQrcode(project, resources2, settingsJsonExists, issues);
33542
33559
  return createHealthResult(
33543
33560
  resolvedProjectRoot,
33544
33561
  mode,
@@ -33572,8 +33589,9 @@ function formatMakerProjectHealthStatus(health) {
33572
33589
  if (settingsSection) {
33573
33590
  lines.push("", settingsSection);
33574
33591
  }
33592
+ const isMissingSettings = health.issues.some((item) => item.code === "missing_settings_json");
33575
33593
  lines.push(
33576
- health.canBuild && !health.canGenerateTestQrcode ? "- next_action: 可以继续构建;生成测试二维码前请完善 .project/project.json 发布配置。" : health.canBuild ? "- next_action: 可以继续构建;检查器不会自动移动或覆盖文件。" : "- next_action: 修复上面的规范路径或配置问题后再构建;检查器不会自动移动或覆盖文件。"
33594
+ health.canBuild && !health.canGenerateTestQrcode ? isMissingSettings ? "- next_action: 可以继续构建;生成测试二维码前需要 .project/settings.json。" : "- next_action: 可以继续构建;生成测试二维码前请完善 .project/project.json 发布配置。" : health.canBuild ? "- next_action: 可以继续构建;检查器不会自动移动或覆盖文件。" : "- next_action: 修复上面的规范路径或配置问题后再构建;检查器不会自动移动或覆盖文件。"
33577
33595
  );
33578
33596
  return lines.join("\n");
33579
33597
  }
@@ -33816,18 +33834,25 @@ function isConfiguredTitle(value) {
33816
33834
  const title = value.trim();
33817
33835
  return !(title.startsWith("<") && title.endsWith(">") || title.startsWith("{") && title.endsWith("}"));
33818
33836
  }
33819
- function canGenerateQrcode(project, resources2, issues) {
33820
- if (!isPlainObject3(project) || !isPlainObject3(resources2) || !isConfiguredString(project.project_id) || !isConfiguredString(project.version) || !hasProjectEntry(project, resources2, "qrcode") || !isPlainObject3(project.taptap_publish)) {
33837
+ function canGenerateQrcode(project, resources2, settingsExists, issues) {
33838
+ if (!isPlainObject3(project) || !isPlainObject3(resources2) || !settingsExists || !isConfiguredString(project.project_id) || !isConfiguredString(project.version) || !hasProjectEntry(project, resources2, "qrcode") || !isPlainObject3(project.taptap_publish)) {
33821
33839
  return false;
33822
33840
  }
33823
33841
  const publish = project.taptap_publish;
33824
- if (!isConfiguredTitle(publish.title) || !isConfiguredString(publish.category) || publish.screen_orientation !== "landscape" && publish.screen_orientation !== "portrait") {
33842
+ if (!isConfiguredTitle(publish.title) || !isConfiguredString(publish.category)) {
33843
+ return false;
33844
+ }
33845
+ const orientation = publish.screen_orientation;
33846
+ if (orientation !== void 0 && orientation !== "landscape" && orientation !== "portrait") {
33825
33847
  return false;
33826
33848
  }
33827
33849
  return !issues.some((item) => {
33828
33850
  if (item.severity !== "error") {
33829
33851
  return false;
33830
33852
  }
33853
+ if (orientation === void 0 && item.code === "invalid_publish_field" && item.path === "taptap_publish.screen_orientation") {
33854
+ return false;
33855
+ }
33831
33856
  if (item.path === "taptap_publish" || item.path.startsWith("taptap_publish.")) {
33832
33857
  return true;
33833
33858
  }
@@ -33935,10 +33960,100 @@ function sameStringSet(left, right) {
33935
33960
  return left.length === right.length && right.every((item) => left.includes(item));
33936
33961
  }
33937
33962
 
33938
- // src/maker/server/proxyAssets.ts
33963
+ // src/maker/qrcodePreflight.ts
33964
+ import { randomUUID } from "node:crypto";
33939
33965
  import fs15 from "node:fs";
33940
33966
  import path16 from "node:path";
33941
- import { randomUUID } from "node:crypto";
33967
+ function inspectMakerQrcodePreflight(projectRoot, confirmedOrientation) {
33968
+ const projectJsonPath = path16.join(path16.resolve(projectRoot), ".project", "project.json");
33969
+ let projectJsonText;
33970
+ let project;
33971
+ try {
33972
+ projectJsonText = fs15.readFileSync(projectJsonPath, "utf8");
33973
+ project = JSON.parse(projectJsonText);
33974
+ } catch (error2) {
33975
+ return {
33976
+ ok: false,
33977
+ message: [
33978
+ "Maker QR project configuration is not ready.",
33979
+ `- config: ${projectJsonPath}`,
33980
+ `- error: ${error2 instanceof Error ? error2.message : String(error2)}`,
33981
+ "- next_action: Restore or initialize .project/project.json, then retry."
33982
+ ].join("\n")
33983
+ };
33984
+ }
33985
+ const configuredOrientation = readConfiguredOrientation(project);
33986
+ if (configuredOrientation) {
33987
+ return { ok: true, orientation: configuredOrientation };
33988
+ }
33989
+ if (!isScreenOrientation(confirmedOrientation)) {
33990
+ return {
33991
+ ok: false,
33992
+ message: [
33993
+ "Maker QR orientation is not configured yet.",
33994
+ "- field: taptap_publish.screen_orientation",
33995
+ "- next_action: Ask the user in a separate conversation turn to choose landscape or portrait, then retry with confirmed_screen_orientation.",
33996
+ "- do_not: Do not infer or default the game orientation."
33997
+ ].join("\n")
33998
+ };
33999
+ }
34000
+ if (!isRecord(project) || !isRecord(project.taptap_publish)) {
34001
+ return {
34002
+ ok: false,
34003
+ message: [
34004
+ "Maker QR project publishing configuration is not ready.",
34005
+ "- missing: taptap_publish",
34006
+ "- next_action: Restore or initialize the taptap_publish configuration, then retry."
34007
+ ].join("\n")
34008
+ };
34009
+ }
34010
+ project.taptap_publish.screen_orientation = confirmedOrientation;
34011
+ const tempPath = `${projectJsonPath}.${randomUUID()}.tmp`;
34012
+ try {
34013
+ fs15.writeFileSync(tempPath, `${JSON.stringify(project, null, 2)}
34014
+ `, {
34015
+ encoding: "utf8",
34016
+ flag: "wx"
34017
+ });
34018
+ if (fs15.readFileSync(projectJsonPath, "utf8") !== projectJsonText) {
34019
+ throw new Error("Maker QR project configuration changed while saving; retry the operation.");
34020
+ }
34021
+ fs15.renameSync(tempPath, projectJsonPath);
34022
+ } catch (error2) {
34023
+ try {
34024
+ fs15.rmSync(tempPath, { force: true });
34025
+ } catch {
34026
+ }
34027
+ return {
34028
+ ok: false,
34029
+ message: [
34030
+ "Maker QR project orientation could not be saved.",
34031
+ `- config: ${projectJsonPath}`,
34032
+ `- error: ${error2 instanceof Error ? error2.message : String(error2)}`,
34033
+ "- next_action: Fix the project configuration write error, then retry."
34034
+ ].join("\n")
34035
+ };
34036
+ }
34037
+ return { ok: true, orientation: confirmedOrientation };
34038
+ }
34039
+ function readConfiguredOrientation(project) {
34040
+ if (!isRecord(project) || !isRecord(project.taptap_publish)) {
34041
+ return void 0;
34042
+ }
34043
+ const orientation = project.taptap_publish.screen_orientation;
34044
+ return isScreenOrientation(orientation) ? orientation : void 0;
34045
+ }
34046
+ function isScreenOrientation(value) {
34047
+ return value === "landscape" || value === "portrait";
34048
+ }
34049
+ function isRecord(value) {
34050
+ return typeof value === "object" && value !== null && !Array.isArray(value);
34051
+ }
34052
+
34053
+ // src/maker/server/proxyAssets.ts
34054
+ import fs16 from "node:fs";
34055
+ import path17 from "node:path";
34056
+ import { randomUUID as randomUUID2 } from "node:crypto";
33942
34057
 
33943
34058
  // src/maker/server/diagnosticRedaction.ts
33944
34059
  function isSensitiveDiagnosticKey(key) {
@@ -34071,7 +34186,7 @@ function prepareRemoteProxyToolArgs(options) {
34071
34186
  }
34072
34187
  function validateVoiceAuditionArgs(args) {
34073
34188
  const voiceProfile = args.voice_profile;
34074
- const gender = isRecord(voiceProfile) ? voiceProfile.gender : void 0;
34189
+ const gender = isRecord2(voiceProfile) ? voiceProfile.gender : void 0;
34075
34190
  if (gender !== "male" && gender !== "female") {
34076
34191
  throw new Error(
34077
34192
  "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."
@@ -34235,7 +34350,7 @@ async function materializeDebugFeedbackResult(options) {
34235
34350
  ...materialized
34236
34351
  });
34237
34352
  }
34238
- const localCandidateSaveDir = remoteSaveDir ? resolveDebugFeedbackCandidatePath(options.targetDir, remoteSaveDir) : feedbacks.some(hasDebugFeedbackArtifactUrls) ? path16.join(options.targetDir, "logs", "feed_back") : void 0;
34353
+ const localCandidateSaveDir = remoteSaveDir ? resolveDebugFeedbackCandidatePath(options.targetDir, remoteSaveDir) : feedbacks.some(hasDebugFeedbackArtifactUrls) ? path17.join(options.targetDir, "logs", "feed_back") : void 0;
34239
34354
  const filesVerifiedLocally = nextFeedbacks.some(
34240
34355
  (feedback) => numberField2(feedback.artifacts_downloaded) > 0
34241
34356
  );
@@ -34263,7 +34378,7 @@ async function materializeDebugFeedbackArtifacts(options) {
34263
34378
  if (logUrls.length === 0 && screenshotUrls.length === 0 && extraUrls.length === 0) {
34264
34379
  return {};
34265
34380
  }
34266
- const localDir = path16.join(options.targetDir, "logs", "feed_back", `feedback_${feedbackId}`);
34381
+ const localDir = path17.join(options.targetDir, "logs", "feed_back", `feedback_${feedbackId}`);
34267
34382
  const localLogPaths = [];
34268
34383
  const localScreenshotPaths = [];
34269
34384
  const localDownloadPaths = [];
@@ -34271,7 +34386,7 @@ async function materializeDebugFeedbackArtifacts(options) {
34271
34386
  for (const [index, url2] of logUrls.entries()) {
34272
34387
  const result = await downloadDebugFeedbackArtifact({
34273
34388
  url: url2,
34274
- directory: path16.join(localDir, "logs"),
34389
+ directory: path17.join(localDir, "logs"),
34275
34390
  fallbackName: `log_${index + 1}.log`,
34276
34391
  fetchImpl: options.fetchImpl
34277
34392
  });
@@ -34284,7 +34399,7 @@ async function materializeDebugFeedbackArtifacts(options) {
34284
34399
  for (const [index, url2] of screenshotUrls.entries()) {
34285
34400
  const result = await downloadDebugFeedbackArtifact({
34286
34401
  url: url2,
34287
- directory: path16.join(localDir, "screenshots"),
34402
+ directory: path17.join(localDir, "screenshots"),
34288
34403
  fallbackName: `screenshot_${index + 1}.png`,
34289
34404
  fetchImpl: options.fetchImpl
34290
34405
  });
@@ -34297,7 +34412,7 @@ async function materializeDebugFeedbackArtifacts(options) {
34297
34412
  for (const [index, url2] of extraUrls.entries()) {
34298
34413
  const result = await downloadDebugFeedbackArtifact({
34299
34414
  url: url2,
34300
- directory: path16.join(localDir, "downloads"),
34415
+ directory: path17.join(localDir, "downloads"),
34301
34416
  fallbackName: `artifact_${index + 1}`,
34302
34417
  fetchImpl: options.fetchImpl
34303
34418
  });
@@ -34325,14 +34440,14 @@ async function downloadDebugFeedbackArtifact(options) {
34325
34440
  error: `${options.url}: HTTP ${response.status}`
34326
34441
  };
34327
34442
  }
34328
- fs15.mkdirSync(options.directory, { recursive: true });
34443
+ fs16.mkdirSync(options.directory, { recursive: true });
34329
34444
  const filePath = allocateDebugFeedbackArtifactPath(
34330
34445
  options.directory,
34331
34446
  options.url,
34332
34447
  options.fallbackName
34333
34448
  );
34334
34449
  const bytes = Buffer.from(await response.arrayBuffer());
34335
- fs15.writeFileSync(filePath, bytes);
34450
+ fs16.writeFileSync(filePath, bytes);
34336
34451
  return { success: true, path: filePath };
34337
34452
  } catch (error2) {
34338
34453
  return {
@@ -34343,14 +34458,14 @@ async function downloadDebugFeedbackArtifact(options) {
34343
34458
  }
34344
34459
  function allocateDebugFeedbackArtifactPath(directory, url2, fallbackName) {
34345
34460
  const rawName = fileNameFromUrl(url2) || fallbackName;
34346
- const rawExtension = path16.extname(rawName);
34461
+ const rawExtension = path17.extname(rawName);
34347
34462
  const finalExtension = rawExtension && rawExtension !== "." ? rawExtension.replace(/[^A-Za-z0-9.]/g, "_") : "";
34348
34463
  const rawStem = finalExtension ? rawName.slice(0, -rawExtension.length) : rawName;
34349
34464
  const stem = sanitizeAssetBaseName(rawStem);
34350
34465
  for (let index = 1; index <= 9999; index += 1) {
34351
34466
  const suffix = index === 1 ? "" : `_${index}`;
34352
- const candidate = path16.join(directory, `${stem}${suffix}${finalExtension}`);
34353
- if (!fs15.existsSync(candidate)) {
34467
+ const candidate = path17.join(directory, `${stem}${suffix}${finalExtension}`);
34468
+ if (!fs16.existsSync(candidate)) {
34354
34469
  return candidate;
34355
34470
  }
34356
34471
  }
@@ -34359,7 +34474,7 @@ function allocateDebugFeedbackArtifactPath(directory, url2, fallbackName) {
34359
34474
  function fileNameFromUrl(url2) {
34360
34475
  try {
34361
34476
  const pathname = new URL(url2).pathname;
34362
- const name = decodeURIComponent(path16.basename(pathname));
34477
+ const name = decodeURIComponent(path17.basename(pathname));
34363
34478
  return name && name !== "/" ? name : void 0;
34364
34479
  } catch {
34365
34480
  return void 0;
@@ -34370,18 +34485,18 @@ function hasDebugFeedbackArtifactUrls(feedback) {
34370
34485
  }
34371
34486
  function getDebugFeedbackSaveDir(payload) {
34372
34487
  const summary = payload.summary;
34373
- return stringField2(payload.save_dir) || (isRecord(summary) ? stringField2(summary.save_dir) : void 0);
34488
+ return stringField2(payload.save_dir) || (isRecord2(summary) ? stringField2(summary.save_dir) : void 0);
34374
34489
  }
34375
34490
  function resolveDebugFeedbackCandidatePath(targetDir, remotePath) {
34376
- if (path16.isAbsolute(remotePath)) {
34491
+ if (path17.isAbsolute(remotePath)) {
34377
34492
  return void 0;
34378
34493
  }
34379
34494
  const trimmedRemotePath = remotePath.replace(/[\\/]+$/, "");
34380
- return path16.normalize(path16.join(targetDir, trimmedRemotePath || "."));
34495
+ return path17.normalize(path17.join(targetDir, trimmedRemotePath || "."));
34381
34496
  }
34382
34497
  function replaceDebugFeedbackItems(payload, nextFeedbacks) {
34383
34498
  const summary = payload.summary;
34384
- if (isRecord(summary) && Array.isArray(summary.feedbacks)) {
34499
+ if (isRecord2(summary) && Array.isArray(summary.feedbacks)) {
34385
34500
  return {
34386
34501
  ...payload,
34387
34502
  summary: {
@@ -34406,14 +34521,14 @@ function replaceDebugFeedbackItems(payload, nextFeedbacks) {
34406
34521
  }
34407
34522
  function getDebugFeedbackItems(payload) {
34408
34523
  const summary = payload.summary;
34409
- if (isRecord(summary) && Array.isArray(summary.feedbacks)) {
34410
- return summary.feedbacks.filter(isRecord);
34524
+ if (isRecord2(summary) && Array.isArray(summary.feedbacks)) {
34525
+ return summary.feedbacks.filter(isRecord2);
34411
34526
  }
34412
34527
  if (Array.isArray(payload.feedbacks)) {
34413
- return payload.feedbacks.filter(isRecord);
34528
+ return payload.feedbacks.filter(isRecord2);
34414
34529
  }
34415
34530
  if (Array.isArray(payload.list)) {
34416
- return payload.list.filter(isRecord);
34531
+ return payload.list.filter(isRecord2);
34417
34532
  }
34418
34533
  return [];
34419
34534
  }
@@ -34445,7 +34560,7 @@ async function materializeBatchImageResult(options) {
34445
34560
  }
34446
34561
  const results = [];
34447
34562
  for (const item of options.payload.results) {
34448
- if (!isRecord(item) || item.success !== true) {
34563
+ if (!isRecord2(item) || item.success !== true) {
34449
34564
  results.push(item);
34450
34565
  continue;
34451
34566
  }
@@ -34530,13 +34645,13 @@ function findExistingMaterializedVideo(targetDir, options) {
34530
34645
  function resolveExistingMaterializedAssetPath(targetDir, record2, localPath) {
34531
34646
  const candidates = [];
34532
34647
  const absolutePath = stringField2(record2.absolutePath);
34533
- if (absolutePath && path16.isAbsolute(absolutePath)) {
34648
+ if (absolutePath && path17.isAbsolute(absolutePath)) {
34534
34649
  candidates.push(absolutePath);
34535
34650
  }
34536
- candidates.push(path16.join(targetDir, ...localPath.split("/")));
34651
+ candidates.push(path17.join(targetDir, ...localPath.split("/")));
34537
34652
  for (const candidate of candidates) {
34538
34653
  try {
34539
- if (fs15.statSync(candidate).isFile()) {
34654
+ if (fs16.statSync(candidate).isFile()) {
34540
34655
  return candidate;
34541
34656
  }
34542
34657
  } catch {
@@ -34548,7 +34663,7 @@ async function materializeMusicResult(options) {
34548
34663
  if (options.payload.success !== true) {
34549
34664
  return options.payload;
34550
34665
  }
34551
- if (!isRecord(options.payload.music)) {
34666
+ if (!isRecord2(options.payload.music)) {
34552
34667
  return options.payload;
34553
34668
  }
34554
34669
  const music = options.payload.music;
@@ -34580,7 +34695,7 @@ async function materializeAudioFilesResult(options, toolName) {
34580
34695
  if (!Array.isArray(options.payload.audio_files)) return options.payload;
34581
34696
  const audioFiles = [];
34582
34697
  for (const rawItem of options.payload.audio_files) {
34583
- if (!isRecord(rawItem)) {
34698
+ if (!isRecord2(rawItem)) {
34584
34699
  audioFiles.push(rawItem);
34585
34700
  continue;
34586
34701
  }
@@ -34648,12 +34763,12 @@ function validateAudioAssetContract(options) {
34648
34763
  if (!fileName || fileName === "." || fileName === ".." || fileName.includes("/") || fileName.includes("\\") || fileName.includes("\0")) {
34649
34764
  return "suggestedFileName must be a safe basename.";
34650
34765
  }
34651
- if (path16.basename(fileName) !== fileName || fileName.endsWith(".") || fileName.endsWith(" ")) {
34766
+ if (path17.basename(fileName) !== fileName || fileName.endsWith(".") || fileName.endsWith(" ")) {
34652
34767
  return "suggestedFileName must be a safe basename.";
34653
34768
  }
34654
34769
  const format = (_a3 = options.format) == null ? void 0 : _a3.toLowerCase();
34655
34770
  const mimeType = (_b = options.mimeType) == null ? void 0 : _b.toLowerCase();
34656
- const extension = path16.extname(fileName).toLowerCase();
34771
+ const extension = path17.extname(fileName).toLowerCase();
34657
34772
  const contract = {
34658
34773
  mp3: { mimeType: "audio/mpeg", extension: ".mp3" },
34659
34774
  wav: { mimeType: "audio/wav", extension: ".wav" },
@@ -34680,13 +34795,13 @@ function audioExtensionForItem(item, fileName) {
34680
34795
  m4a: "m4a",
34681
34796
  aac: "aac"
34682
34797
  };
34683
- return byFormat[format || ""] || path16.extname(fileName).slice(1).toLowerCase() || "mp3";
34798
+ return byFormat[format || ""] || path17.extname(fileName).slice(1).toLowerCase() || "mp3";
34684
34799
  }
34685
34800
  async function materializeAudioAsset(options) {
34686
34801
  const relativeDir = options.targetDirectory;
34687
- const directory = path16.join(options.targetDir, ...relativeDir.split("/"));
34802
+ const directory = path17.join(options.targetDir, ...relativeDir.split("/"));
34688
34803
  try {
34689
- fs15.mkdirSync(directory, { recursive: true });
34804
+ fs16.mkdirSync(directory, { recursive: true });
34690
34805
  assertProjectDirectory(options.targetDir, directory);
34691
34806
  } catch (error2) {
34692
34807
  return {
@@ -34696,16 +34811,16 @@ async function materializeAudioAsset(options) {
34696
34811
  }
34697
34812
  };
34698
34813
  }
34699
- const baseName = path16.basename(options.fileName, path16.extname(options.fileName));
34814
+ const baseName = path17.basename(options.fileName, path17.extname(options.fileName));
34700
34815
  let absolutePath;
34701
34816
  let relativePath;
34702
34817
  for (let index = 1; index <= 9999; index += 1) {
34703
34818
  const suffix = index === 1 ? "" : `_${index}`;
34704
34819
  const candidateName = `${baseName}${suffix}.${options.extension}`;
34705
- const candidate = path16.join(directory, candidateName);
34706
- if (!fs15.existsSync(candidate)) {
34820
+ const candidate = path17.join(directory, candidateName);
34821
+ if (!fs16.existsSync(candidate)) {
34707
34822
  absolutePath = candidate;
34708
- relativePath = path16.posix.join(relativeDir, candidateName);
34823
+ relativePath = path17.posix.join(relativeDir, candidateName);
34709
34824
  break;
34710
34825
  }
34711
34826
  }
@@ -34723,7 +34838,7 @@ async function materializeAudioAsset(options) {
34723
34838
  if (bytes.length === 0) {
34724
34839
  return { download: { success: false, error: "Asset download failed: empty response." } };
34725
34840
  }
34726
- fs15.writeFileSync(absolutePath, bytes, { flag: "wx" });
34841
+ fs16.writeFileSync(absolutePath, bytes, { flag: "wx" });
34727
34842
  return { localPath: relativePath, absolutePath, download: { success: true } };
34728
34843
  } catch (error2) {
34729
34844
  return {
@@ -34735,7 +34850,7 @@ async function materializeAudioAsset(options) {
34735
34850
  }
34736
34851
  }
34737
34852
  async function materializeVoiceConfirmationResult(options) {
34738
- if (options.payload.success !== true || !isRecord(options.payload.mapping)) {
34853
+ if (options.payload.success !== true || !isRecord2(options.payload.mapping)) {
34739
34854
  return withoutVoiceConfirmationNextStepHint(options.payload);
34740
34855
  }
34741
34856
  const payload = withoutVoiceConfirmationNextStepHint(options.payload);
@@ -34763,7 +34878,7 @@ async function materializeVoiceConfirmationResult(options) {
34763
34878
  };
34764
34879
  }
34765
34880
  }
34766
- if (provider !== "doubao" || !isRecord(payload.referenceAudio)) {
34881
+ if (provider !== "doubao" || !isRecord2(payload.referenceAudio)) {
34767
34882
  return payload;
34768
34883
  }
34769
34884
  const referenceAudio = payload.referenceAudio;
@@ -34822,7 +34937,7 @@ async function materializeVoiceConfirmationResult(options) {
34822
34937
  referenceAudio: {
34823
34938
  ...referenceAudio,
34824
34939
  localPath: targetPath,
34825
- absolutePath: path16.join(options.targetDir, ...targetPath.split("/")),
34940
+ absolutePath: path17.join(options.targetDir, ...targetPath.split("/")),
34826
34941
  download: { success: true }
34827
34942
  }
34828
34943
  };
@@ -34853,7 +34968,7 @@ function validateDoubaoReferenceTarget(targetPath) {
34853
34968
  if (!/^assets\/audio\/voice-reference\/[^/]+\.mp3$/.test(targetPath)) {
34854
34969
  return "referenceAudio.targetPath must be assets/audio/voice-reference/<basename>.mp3.";
34855
34970
  }
34856
- const base = path16.posix.basename(targetPath, ".mp3");
34971
+ const base = path17.posix.basename(targetPath, ".mp3");
34857
34972
  if (!base || base === "." || base === ".." || base.includes("\\") || base.includes("\0")) {
34858
34973
  return "referenceAudio.targetPath contains an unsafe basename.";
34859
34974
  }
@@ -34898,27 +35013,27 @@ function parseMp3Frame(bytes, offset) {
34898
35013
  return length > 4 && offset + length <= bytes.length ? { length, version: version2, sampleRate } : void 0;
34899
35014
  }
34900
35015
  function mergeVoiceMappingFile(options) {
34901
- const configPath = path16.join(
35016
+ const configPath = path17.join(
34902
35017
  options.targetDir,
34903
35018
  ".project",
34904
35019
  options.provider === "doubao" ? "audio-voice-mapping.json" : "elevenlabs-voice-mapping.json"
34905
35020
  );
34906
- const referencePath = options.referenceAudio ? path16.join(options.targetDir, ...options.referenceAudio.targetPath.split("/")) : void 0;
34907
- const configDirectory = path16.dirname(configPath);
34908
- const referenceDirectory = referencePath ? path16.dirname(referencePath) : void 0;
34909
- fs15.mkdirSync(configDirectory, { recursive: true });
35021
+ const referencePath = options.referenceAudio ? path17.join(options.targetDir, ...options.referenceAudio.targetPath.split("/")) : void 0;
35022
+ const configDirectory = path17.dirname(configPath);
35023
+ const referenceDirectory = referencePath ? path17.dirname(referencePath) : void 0;
35024
+ fs16.mkdirSync(configDirectory, { recursive: true });
34910
35025
  assertProjectDirectory(options.targetDir, configDirectory);
34911
35026
  assertFileIsNotSymlink(configPath);
34912
35027
  if (referenceDirectory) {
34913
- fs15.mkdirSync(referenceDirectory, { recursive: true });
35028
+ fs16.mkdirSync(referenceDirectory, { recursive: true });
34914
35029
  assertProjectDirectory(options.targetDir, referenceDirectory);
34915
35030
  assertFileIsNotSymlink(referencePath);
34916
35031
  }
34917
35032
  const oldConfig = snapshotFile(configPath);
34918
35033
  const oldReference = referencePath ? snapshotFile(referencePath) : void 0;
34919
35034
  const existing = readJsonFile2(configPath);
34920
- const characters = isRecord(existing == null ? void 0 : existing.characters) ? { ...existing.characters } : {};
34921
- const oldCharacter = isRecord(characters[options.characterName]) ? characters[options.characterName] : {};
35035
+ const characters = isRecord2(existing == null ? void 0 : existing.characters) ? { ...existing.characters } : {};
35036
+ const oldCharacter = isRecord2(characters[options.characterName]) ? characters[options.characterName] : {};
34922
35037
  const createdAt = stringField2(oldCharacter.created_at) || options.now.toISOString();
34923
35038
  const character = {
34924
35039
  ...oldCharacter,
@@ -34941,7 +35056,7 @@ function mergeVoiceMappingFile(options) {
34941
35056
  if (options.provider === "doubao") {
34942
35057
  nextConfig.default_language = stringField2(existing == null ? void 0 : existing.default_language) || "cmn";
34943
35058
  nextConfig.default_stability = typeof (existing == null ? void 0 : existing.default_stability) === "number" ? existing.default_stability : 0.5;
34944
- nextConfig.special_voices = isRecord(existing == null ? void 0 : existing.special_voices) ? existing.special_voices : {};
35059
+ nextConfig.special_voices = isRecord2(existing == null ? void 0 : existing.special_voices) ? existing.special_voices : {};
34945
35060
  } else {
34946
35061
  delete nextConfig.default_language;
34947
35062
  delete nextConfig.default_stability;
@@ -34949,20 +35064,20 @@ function mergeVoiceMappingFile(options) {
34949
35064
  }
34950
35065
  const configBytes = Buffer.from(`${JSON.stringify(nextConfig, null, 2)}
34951
35066
  `, "utf8");
34952
- const transactionId = randomUUID();
35067
+ const transactionId = randomUUID2();
34953
35068
  const configTemp = `${configPath}.${transactionId}.tmp`;
34954
35069
  const referenceTemp = referencePath ? `${referencePath}.${transactionId}.tmp` : void 0;
34955
35070
  try {
34956
35071
  if (referenceTemp && options.referenceAudio) {
34957
- fs15.writeFileSync(referenceTemp, options.referenceAudio.bytes, { flag: "wx" });
34958
- fs15.renameSync(referenceTemp, referencePath);
35072
+ fs16.writeFileSync(referenceTemp, options.referenceAudio.bytes, { flag: "wx" });
35073
+ fs16.renameSync(referenceTemp, referencePath);
34959
35074
  }
34960
- fs15.writeFileSync(configTemp, configBytes, { flag: "wx" });
34961
- fs15.renameSync(configTemp, configPath);
35075
+ fs16.writeFileSync(configTemp, configBytes, { flag: "wx" });
35076
+ fs16.renameSync(configTemp, configPath);
34962
35077
  } catch (error2) {
34963
35078
  try {
34964
- if (fs15.existsSync(configTemp)) fs15.rmSync(configTemp, { force: true });
34965
- if (referenceTemp && fs15.existsSync(referenceTemp)) fs15.rmSync(referenceTemp, { force: true });
35079
+ if (fs16.existsSync(configTemp)) fs16.rmSync(configTemp, { force: true });
35080
+ if (referenceTemp && fs16.existsSync(referenceTemp)) fs16.rmSync(referenceTemp, { force: true });
34966
35081
  restoreFile(configPath, oldConfig);
34967
35082
  if (referencePath) restoreFile(referencePath, oldReference);
34968
35083
  } catch {
@@ -34973,7 +35088,7 @@ function mergeVoiceMappingFile(options) {
34973
35088
  function snapshotFile(filePath) {
34974
35089
  try {
34975
35090
  assertFileIsNotSymlink(filePath);
34976
- return { exists: true, bytes: fs15.readFileSync(filePath) };
35091
+ return { exists: true, bytes: fs16.readFileSync(filePath) };
34977
35092
  } catch {
34978
35093
  if (isSymlink(filePath)) {
34979
35094
  throw new Error(`refusing to read symlinked file: ${filePath}`);
@@ -34984,25 +35099,25 @@ function snapshotFile(filePath) {
34984
35099
  function restoreFile(filePath, snapshot) {
34985
35100
  assertFileIsNotSymlink(filePath);
34986
35101
  if (snapshot.exists && snapshot.bytes) {
34987
- fs15.mkdirSync(path16.dirname(filePath), { recursive: true });
34988
- fs15.writeFileSync(filePath, snapshot.bytes);
35102
+ fs16.mkdirSync(path17.dirname(filePath), { recursive: true });
35103
+ fs16.writeFileSync(filePath, snapshot.bytes);
34989
35104
  } else {
34990
- fs15.rmSync(filePath, { force: true });
35105
+ fs16.rmSync(filePath, { force: true });
34991
35106
  }
34992
35107
  }
34993
35108
  function readJsonFile2(filePath) {
34994
35109
  assertFileIsNotSymlink(filePath);
34995
35110
  try {
34996
- const parsed = JSON.parse(fs15.readFileSync(filePath, "utf8"));
34997
- return isRecord(parsed) ? parsed : void 0;
35111
+ const parsed = JSON.parse(fs16.readFileSync(filePath, "utf8"));
35112
+ return isRecord2(parsed) ? parsed : void 0;
34998
35113
  } catch {
34999
35114
  return void 0;
35000
35115
  }
35001
35116
  }
35002
35117
  async function materializeCreate3dAssetResult(options) {
35003
35118
  var _a3;
35004
- const payload = isRecord(options.payload.preview) ? await materializeCreate3dAssetPreviewResult(options) : options.payload;
35005
- const modelFile = Array.isArray(payload.model_files) ? payload.model_files.find(isRecord) : void 0;
35119
+ const payload = isRecord2(options.payload.preview) ? await materializeCreate3dAssetPreviewResult(options) : options.payload;
35120
+ const modelFile = Array.isArray(payload.model_files) ? payload.model_files.find(isRecord2) : void 0;
35006
35121
  if (!modelFile) {
35007
35122
  return payload;
35008
35123
  }
@@ -35113,8 +35228,8 @@ async function materializeCreate3dAssetModelFile(options) {
35113
35228
  const targetDirectory = stringField2(options.modelFile.targetDirectory);
35114
35229
  const suggestedFileName = stringField2(options.modelFile.suggestedFileName);
35115
35230
  const targetAbsolutePath = targetDirectory ? resolveProjectRelativePath(options.targetDir, targetDirectory) : void 0;
35116
- const modelAssetRoot = path16.resolve(options.targetDir, MODEL_ASSET_DIRS[0]);
35117
- if (!targetDirectory || !targetAbsolutePath || !isKnownAssetPath(targetDirectory, MODEL_ASSET_DIRS) || !isPathWithinDirectory(modelAssetRoot, targetAbsolutePath) || !suggestedFileName || path16.posix.basename(suggestedFileName) !== suggestedFileName || suggestedFileName.includes("\\")) {
35231
+ const modelAssetRoot = path17.resolve(options.targetDir, MODEL_ASSET_DIRS[0]);
35232
+ if (!targetDirectory || !targetAbsolutePath || !isKnownAssetPath(targetDirectory, MODEL_ASSET_DIRS) || !isPathWithinDirectory(modelAssetRoot, targetAbsolutePath) || !suggestedFileName || path17.posix.basename(suggestedFileName) !== suggestedFileName || suggestedFileName.includes("\\")) {
35118
35233
  return {
35119
35234
  download: { success: false, error: "Invalid create_3d_asset local target path." }
35120
35235
  };
@@ -35122,7 +35237,7 @@ async function materializeCreate3dAssetModelFile(options) {
35122
35237
  if (options.materialization === "copy") {
35123
35238
  return await materializeAssetAtPath({
35124
35239
  url: options.remoteUrl,
35125
- relativePath: path16.posix.join(targetDirectory, suggestedFileName),
35240
+ relativePath: path17.posix.join(targetDirectory, suggestedFileName),
35126
35241
  targetDir: options.targetDir,
35127
35242
  fetchImpl: options.fetchImpl
35128
35243
  });
@@ -35140,7 +35255,7 @@ async function materializeCreate3dAssetModelFile(options) {
35140
35255
  url: options.remoteUrl,
35141
35256
  baseName: options.assetId,
35142
35257
  relativeDir: ".maker/assets/downloads",
35143
- extension: path16.extname(suggestedFileName).replace(/^\./, "") || "zip",
35258
+ extension: path17.extname(suggestedFileName).replace(/^\./, "") || "zip",
35144
35259
  now: options.now,
35145
35260
  fetchImpl: options.fetchImpl
35146
35261
  });
@@ -35150,14 +35265,14 @@ async function materializeCreate3dAssetModelFile(options) {
35150
35265
  };
35151
35266
  }
35152
35267
  try {
35153
- fs15.mkdirSync(targetAbsolutePath, { recursive: true });
35268
+ fs16.mkdirSync(targetAbsolutePath, { recursive: true });
35154
35269
  extractZip(archive.absolutePath, targetAbsolutePath, "3D model asset");
35155
35270
  const entrypointExtension = ((_a3 = stringField2(options.modelFile.entrypointExtension)) == null ? void 0 : _a3.toLowerCase()) || ".mdl";
35156
35271
  const entrypoint = findFileByExtension(targetAbsolutePath, entrypointExtension);
35157
35272
  if (!entrypoint) {
35158
35273
  throw new Error(`3D model archive contains no ${entrypointExtension} entrypoint.`);
35159
35274
  }
35160
- const localPath = path16.relative(options.targetDir, entrypoint).split(path16.sep).join("/");
35275
+ const localPath = path17.relative(options.targetDir, entrypoint).split(path17.sep).join("/");
35161
35276
  return {
35162
35277
  localPath,
35163
35278
  absolutePath: entrypoint,
@@ -35171,7 +35286,7 @@ async function materializeCreate3dAssetModelFile(options) {
35171
35286
  }
35172
35287
  };
35173
35288
  } finally {
35174
- fs15.rmSync(archive.absolutePath, { force: true });
35289
+ fs16.rmSync(archive.absolutePath, { force: true });
35175
35290
  }
35176
35291
  }
35177
35292
  async function materializeAssetAtPath(options) {
@@ -35186,8 +35301,8 @@ async function materializeAssetAtPath(options) {
35186
35301
  download: { success: false, error: `Asset download failed: HTTP ${response.status}` }
35187
35302
  };
35188
35303
  }
35189
- fs15.mkdirSync(path16.dirname(absolutePath), { recursive: true });
35190
- fs15.writeFileSync(absolutePath, Buffer.from(await response.arrayBuffer()));
35304
+ fs16.mkdirSync(path17.dirname(absolutePath), { recursive: true });
35305
+ fs16.writeFileSync(absolutePath, Buffer.from(await response.arrayBuffer()));
35191
35306
  return { localPath: options.relativePath, absolutePath, download: { success: true } };
35192
35307
  } catch (error2) {
35193
35308
  return {
@@ -35199,9 +35314,9 @@ async function materializeAssetAtPath(options) {
35199
35314
  }
35200
35315
  }
35201
35316
  function findFileByExtension(directory, extension) {
35202
- const entries = fs15.readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));
35317
+ const entries = fs16.readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));
35203
35318
  for (const entry of entries) {
35204
- const absolutePath = path16.join(directory, entry.name);
35319
+ const absolutePath = path17.join(directory, entry.name);
35205
35320
  if (entry.isDirectory()) {
35206
35321
  const nested = findFileByExtension(absolutePath, extension);
35207
35322
  if (nested) return nested;
@@ -35214,7 +35329,7 @@ function findFileByExtension(directory, extension) {
35214
35329
  function findExistingCreate3dAssetDelivery(options) {
35215
35330
  const registry2 = readGeneratedAssetRegistry(options.targetDir);
35216
35331
  const match = Object.entries(registry2).find(([, record3]) => {
35217
- return record3.tool === CREATE_3D_ASSET_PROXY_TOOL_NAME && record3.assetId === options.assetId && record3.cdnUrl === options.remoteUrl && typeof record3.absolutePath === "string" && fs15.existsSync(record3.absolutePath);
35332
+ return record3.tool === CREATE_3D_ASSET_PROXY_TOOL_NAME && record3.assetId === options.assetId && record3.cdnUrl === options.remoteUrl && typeof record3.absolutePath === "string" && fs16.existsSync(record3.absolutePath);
35218
35333
  });
35219
35334
  if (!match) {
35220
35335
  return void 0;
@@ -35313,8 +35428,8 @@ async function materializeAsset(options) {
35313
35428
  };
35314
35429
  }
35315
35430
  const bytes = Buffer.from(await response.arrayBuffer());
35316
- fs15.mkdirSync(path16.dirname(absolutePath), { recursive: true });
35317
- fs15.writeFileSync(absolutePath, bytes);
35431
+ fs16.mkdirSync(path17.dirname(absolutePath), { recursive: true });
35432
+ fs16.writeFileSync(absolutePath, bytes);
35318
35433
  return { localPath: relativePath, absolutePath, download: { success: true } };
35319
35434
  } catch (error2) {
35320
35435
  return {
@@ -35328,12 +35443,12 @@ async function materializeAsset(options) {
35328
35443
  function createUniqueAssetPath(options) {
35329
35444
  const stem = `${sanitizeAssetBaseName(options.baseName)}_${formatAssetTimestamp(options.now)}`;
35330
35445
  for (let index = 1; index <= 9999; index += 1) {
35331
- const relativePath = path16.posix.join(
35446
+ const relativePath = path17.posix.join(
35332
35447
  options.relativeDir,
35333
35448
  `${stem}${index === 1 ? "" : `_${index}`}.${options.extension}`
35334
35449
  );
35335
- const absolutePath = path16.join(options.targetDir, ...relativePath.split("/"));
35336
- if (!fs15.existsSync(absolutePath)) {
35450
+ const absolutePath = path17.join(options.targetDir, ...relativePath.split("/"));
35451
+ if (!fs16.existsSync(absolutePath)) {
35337
35452
  return { relativePath, absolutePath };
35338
35453
  }
35339
35454
  }
@@ -35387,7 +35502,7 @@ function normalizeBatchImageReferenceAssetArgs(targetDir, args) {
35387
35502
  return {
35388
35503
  ...args,
35389
35504
  images: args.images.map(
35390
- (item) => isRecord(item) ? normalizeImageReferenceAssetArgs(targetDir, item) : item
35505
+ (item) => isRecord2(item) ? normalizeImageReferenceAssetArgs(targetDir, item) : item
35391
35506
  )
35392
35507
  };
35393
35508
  }
@@ -35413,7 +35528,7 @@ function rewriteVideoReferenceAssetArgs(targetDir, args) {
35413
35528
  };
35414
35529
  }
35415
35530
  function rewriteCreate3dAssetArgs(targetDir, args) {
35416
- if (!isRecord(args.payload) || !isRecord(args.payload.images)) {
35531
+ if (!isRecord2(args.payload) || !isRecord2(args.payload.images)) {
35417
35532
  return args;
35418
35533
  }
35419
35534
  const registry2 = readGeneratedAssetRegistry(targetDir);
@@ -35444,13 +35559,13 @@ function rewriteTextToDialogueArgs(targetDir, args) {
35444
35559
  const registry2 = readGeneratedAssetRegistry(targetDir);
35445
35560
  const localElevenLabsMapping = readLocalElevenLabsVoiceMapping(targetDir);
35446
35561
  const localDoubaoMapping = args.inputs.some(
35447
- (value) => isRecord(value) && normalizeOptionalDialogueReference(value.reference_audio) === void 0 && normalizeOptionalDialogueReference(value.reference_audio_path) === void 0
35562
+ (value) => isRecord2(value) && normalizeOptionalDialogueReference(value.reference_audio) === void 0 && normalizeOptionalDialogueReference(value.reference_audio_path) === void 0
35448
35563
  ) ? readLocalDoubaoVoiceMapping(targetDir) : void 0;
35449
35564
  let referenceAudioInputBytes = 0;
35450
35565
  return {
35451
35566
  ...args,
35452
35567
  inputs: args.inputs.map((value, index) => {
35453
- if (!isRecord(value)) {
35568
+ if (!isRecord2(value)) {
35454
35569
  return value;
35455
35570
  }
35456
35571
  let canonicalReference = normalizeOptionalDialogueReference(value.reference_audio);
@@ -35505,33 +35620,33 @@ async function prepareRemoteProxyToolArgsAsync(options) {
35505
35620
  return prepareRemoteProxyToolArgs(options);
35506
35621
  }
35507
35622
  function readLocalDoubaoVoiceMapping(targetDir) {
35508
- const mappingPath = path16.join(targetDir, ".project", "audio-voice-mapping.json");
35509
- if (!fs15.existsSync(mappingPath)) return void 0;
35510
- assertProjectDirectory(targetDir, path16.dirname(mappingPath));
35623
+ const mappingPath = path17.join(targetDir, ".project", "audio-voice-mapping.json");
35624
+ if (!fs16.existsSync(mappingPath)) return void 0;
35625
+ assertProjectDirectory(targetDir, path17.dirname(mappingPath));
35511
35626
  const mapping = readJsonFile2(mappingPath);
35512
35627
  return (mapping == null ? void 0 : mapping.provider) === "doubao" ? mapping : void 0;
35513
35628
  }
35514
35629
  function readLocalElevenLabsVoiceMapping(targetDir) {
35515
- const mappingPath = path16.join(targetDir, ".project", "elevenlabs-voice-mapping.json");
35516
- if (!fs15.existsSync(mappingPath)) return void 0;
35517
- assertProjectDirectory(targetDir, path16.dirname(mappingPath));
35630
+ const mappingPath = path17.join(targetDir, ".project", "elevenlabs-voice-mapping.json");
35631
+ if (!fs16.existsSync(mappingPath)) return void 0;
35632
+ assertProjectDirectory(targetDir, path17.dirname(mappingPath));
35518
35633
  const mapping = readJsonFile2(mappingPath);
35519
35634
  return (mapping == null ? void 0 : mapping.provider) === "elevenlabs" ? mapping : void 0;
35520
35635
  }
35521
35636
  function resolveLocalElevenLabsVoiceId(characterName, mapping) {
35522
35637
  if (typeof characterName !== "string" || !mapping) return void 0;
35523
35638
  const characters = mapping.characters;
35524
- if (!isRecord(characters)) return void 0;
35639
+ if (!isRecord2(characters)) return void 0;
35525
35640
  const character = characters[characterName];
35526
- if (!isRecord(character) || character.provider !== "elevenlabs") return void 0;
35641
+ if (!isRecord2(character) || character.provider !== "elevenlabs") return void 0;
35527
35642
  return stringField2(character.voice_id);
35528
35643
  }
35529
35644
  function resolveLocalDoubaoMappingReference(options) {
35530
35645
  if (typeof options.characterName !== "string" || !options.mapping) return void 0;
35531
35646
  const characters = options.mapping.characters;
35532
- if (!isRecord(characters)) return void 0;
35647
+ if (!isRecord2(characters)) return void 0;
35533
35648
  const character = characters[options.characterName];
35534
- if (!isRecord(character) || character.provider !== "doubao") return void 0;
35649
+ if (!isRecord2(character) || character.provider !== "doubao") return void 0;
35535
35650
  const referencePath = stringField2(character.reference_audio_path);
35536
35651
  if (!referencePath) return void 0;
35537
35652
  try {
@@ -35581,13 +35696,13 @@ function localDialogueAudioReferenceToDataUrl(options) {
35581
35696
  if (!absolutePath) {
35582
35697
  throw new Error(`local reference audio file was not found: ${options.value}`);
35583
35698
  }
35584
- const projectRoot = fs15.realpathSync(path16.resolve(options.targetDir));
35585
- const realFile = fs15.realpathSync(absolutePath);
35586
- const relative = path16.relative(projectRoot, realFile);
35587
- if (relative === ".." || relative.startsWith(`..${path16.sep}`) || path16.isAbsolute(relative)) {
35699
+ const projectRoot = fs16.realpathSync(path17.resolve(options.targetDir));
35700
+ const realFile = fs16.realpathSync(absolutePath);
35701
+ const relative = path17.relative(projectRoot, realFile);
35702
+ if (relative === ".." || relative.startsWith(`..${path17.sep}`) || path17.isAbsolute(relative)) {
35588
35703
  throw new Error("local dialogue reference resolves outside the project target directory");
35589
35704
  }
35590
- const stat = fs15.statSync(realFile);
35705
+ const stat = fs16.statSync(realFile);
35591
35706
  if (!stat.isFile()) {
35592
35707
  throw new Error(`local reference audio path is not a file: ${options.value}`);
35593
35708
  }
@@ -35598,26 +35713,26 @@ function localDialogueAudioReferenceToDataUrl(options) {
35598
35713
  if (!mime) {
35599
35714
  throw new Error("local reference audio format is unsupported.");
35600
35715
  }
35601
- return `data:${mime};base64,${fs15.readFileSync(realFile).toString("base64")}`;
35716
+ return `data:${mime};base64,${fs16.readFileSync(realFile).toString("base64")}`;
35602
35717
  }
35603
35718
  function normalizeDialogueProjectReference(targetDir, value, registry2, index) {
35604
35719
  if (typeof value !== "string" || !value.trim()) {
35605
35720
  throw new Error(`inputs[${index}].reference_audio must be a non-empty project audio path.`);
35606
35721
  }
35607
35722
  let normalized = value.trim().replace(/^workspace\//, "");
35608
- if (path16.isAbsolute(normalized)) {
35609
- const relative = path16.relative(path16.resolve(targetDir), path16.resolve(normalized));
35610
- if (relative === ".." || relative.startsWith(`..${path16.sep}`) || path16.isAbsolute(relative)) {
35723
+ if (path17.isAbsolute(normalized)) {
35724
+ const relative = path17.relative(path17.resolve(targetDir), path17.resolve(normalized));
35725
+ if (relative === ".." || relative.startsWith(`..${path17.sep}`) || path17.isAbsolute(relative)) {
35611
35726
  throw new Error(`inputs[${index}].reference_audio must stay inside project assets/audio.`);
35612
35727
  }
35613
- normalized = relative.split(path16.sep).join("/");
35728
+ normalized = relative.split(path17.sep).join("/");
35614
35729
  }
35615
35730
  const localPath = resolveLocalAssetReference(targetDir, normalized, registry2, AUDIO_ASSET_DIRS);
35616
35731
  if (localPath) {
35617
35732
  normalized = localPath;
35618
35733
  }
35619
35734
  const segments = normalized.split("/");
35620
- const extension = path16.extname(normalized).toLowerCase();
35735
+ const extension = path17.extname(normalized).toLowerCase();
35621
35736
  if (segments.some((segment) => segment === "" || segment === "." || segment === "..") || !isKnownAssetPath(normalized, AUDIO_ASSET_DIRS) || !AUDIO_MIME_BY_EXTENSION[extension]) {
35622
35737
  throw new Error(`inputs[${index}].reference_audio must be an audio path under assets/audio.`);
35623
35738
  }
@@ -35647,7 +35762,7 @@ function rewriteUrlObjectArray(targetDir, value, registry2, options) {
35647
35762
  return value;
35648
35763
  }
35649
35764
  return value.map(
35650
- (item) => isRecord(item) ? {
35765
+ (item) => isRecord2(item) ? {
35651
35766
  ...item,
35652
35767
  url: rewriteGeneratedAssetReference(targetDir, item.url, registry2, options)
35653
35768
  } : item
@@ -35697,7 +35812,7 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
35697
35812
  if (!isKnownAssetPath(localPath, assetDirs)) {
35698
35813
  return false;
35699
35814
  }
35700
- const basename = path16.posix.basename(localPath);
35815
+ const basename = path17.posix.basename(localPath);
35701
35816
  const stem = basename.replace(/\.[^.]+$/, "");
35702
35817
  return basename === value || stem === value || record2.name === value || record2.taskId === value;
35703
35818
  });
@@ -35710,13 +35825,13 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
35710
35825
  }
35711
35826
  function findLocalAssetByName(targetDir, value, assetDirs) {
35712
35827
  var _a3;
35713
- const hasExtension = Boolean(path16.extname(value));
35828
+ const hasExtension = Boolean(path17.extname(value));
35714
35829
  const candidates = [];
35715
35830
  for (const assetDir of assetDirs) {
35716
- const absoluteDir = path16.join(targetDir, ...assetDir.split("/"));
35831
+ const absoluteDir = path17.join(targetDir, ...assetDir.split("/"));
35717
35832
  let entries;
35718
35833
  try {
35719
- entries = fs15.readdirSync(absoluteDir);
35834
+ entries = fs16.readdirSync(absoluteDir);
35720
35835
  } catch {
35721
35836
  continue;
35722
35837
  }
@@ -35725,11 +35840,11 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
35725
35840
  if (hasExtension ? entry !== value : stem !== value && !stem.startsWith(`${value}_`)) {
35726
35841
  continue;
35727
35842
  }
35728
- const absolutePath = path16.join(absoluteDir, entry);
35843
+ const absolutePath = path17.join(absoluteDir, entry);
35729
35844
  try {
35730
35845
  candidates.push({
35731
- localPath: path16.posix.join(assetDir, entry),
35732
- mtimeMs: fs15.statSync(absolutePath).mtimeMs
35846
+ localPath: path17.posix.join(assetDir, entry),
35847
+ mtimeMs: fs16.statSync(absolutePath).mtimeMs
35733
35848
  });
35734
35849
  } catch {
35735
35850
  }
@@ -35739,7 +35854,7 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
35739
35854
  return (_a3 = candidates[0]) == null ? void 0 : _a3.localPath;
35740
35855
  }
35741
35856
  function isKnownAssetPath(relativePath, assetDirs) {
35742
- if (relativePath.startsWith("../") || path16.isAbsolute(relativePath)) {
35857
+ if (relativePath.startsWith("../") || path17.isAbsolute(relativePath)) {
35743
35858
  return false;
35744
35859
  }
35745
35860
  return assetDirs.some(
@@ -35763,14 +35878,14 @@ function localAssetReferenceToDataUrl(options) {
35763
35878
  }
35764
35879
  let stat;
35765
35880
  try {
35766
- stat = fs15.statSync(absolutePath);
35881
+ stat = fs16.statSync(absolutePath);
35767
35882
  } catch {
35768
35883
  return void 0;
35769
35884
  }
35770
35885
  if (!stat.isFile() || stat.size > options.maxBytes) {
35771
35886
  return void 0;
35772
35887
  }
35773
- const bytes = fs15.readFileSync(absolutePath);
35888
+ const bytes = fs16.readFileSync(absolutePath);
35774
35889
  return `data:${mime};base64,${bytes.toString("base64")}`;
35775
35890
  }
35776
35891
  function resolveLocalAssetAbsolutePath(targetDir, options) {
@@ -35781,7 +35896,7 @@ function resolveLocalAssetAbsolutePath(targetDir, options) {
35781
35896
  candidates.push(localPath);
35782
35897
  }
35783
35898
  }
35784
- if (path16.isAbsolute(options.value)) {
35899
+ if (path17.isAbsolute(options.value)) {
35785
35900
  candidates.push(options.value);
35786
35901
  } else {
35787
35902
  const localPath = resolveProjectRelativePath(targetDir, options.value);
@@ -35790,67 +35905,67 @@ function resolveLocalAssetAbsolutePath(targetDir, options) {
35790
35905
  }
35791
35906
  }
35792
35907
  for (const candidate of candidates) {
35793
- if (fs15.existsSync(candidate)) {
35908
+ if (fs16.existsSync(candidate)) {
35794
35909
  return candidate;
35795
35910
  }
35796
35911
  }
35797
35912
  return void 0;
35798
35913
  }
35799
35914
  function resolveProjectRelativePath(targetDir, value) {
35800
- const root = path16.resolve(targetDir);
35801
- const absolutePath = path16.resolve(root, value);
35802
- const relativePath = path16.relative(root, absolutePath);
35803
- const escapesRoot = relativePath === ".." || relativePath.startsWith(`..${path16.sep}`) || path16.isAbsolute(relativePath);
35915
+ const root = path17.resolve(targetDir);
35916
+ const absolutePath = path17.resolve(root, value);
35917
+ const relativePath = path17.relative(root, absolutePath);
35918
+ const escapesRoot = relativePath === ".." || relativePath.startsWith(`..${path17.sep}`) || path17.isAbsolute(relativePath);
35804
35919
  if (!escapesRoot) {
35805
35920
  return absolutePath;
35806
35921
  }
35807
35922
  return void 0;
35808
35923
  }
35809
35924
  function assertProjectDirectory(targetDir, directory) {
35810
- const projectRoot = fs15.realpathSync(path16.resolve(targetDir));
35811
- const realDirectory = fs15.realpathSync(directory);
35812
- const relative = path16.relative(projectRoot, realDirectory);
35813
- if (relative === ".." || relative.startsWith(`..${path16.sep}`) || path16.isAbsolute(relative)) {
35925
+ const projectRoot = fs16.realpathSync(path17.resolve(targetDir));
35926
+ const realDirectory = fs16.realpathSync(directory);
35927
+ const relative = path17.relative(projectRoot, realDirectory);
35928
+ if (relative === ".." || relative.startsWith(`..${path17.sep}`) || path17.isAbsolute(relative)) {
35814
35929
  throw new Error("resolved directory escapes the project target directory");
35815
35930
  }
35816
35931
  }
35817
35932
  function isPathWithinDirectory(rootDir, candidatePath) {
35818
- const relativePath = path16.relative(path16.resolve(rootDir), path16.resolve(candidatePath));
35819
- return relativePath === "" || relativePath !== ".." && !relativePath.startsWith(`..${path16.sep}`) && !path16.isAbsolute(relativePath);
35933
+ const relativePath = path17.relative(path17.resolve(rootDir), path17.resolve(candidatePath));
35934
+ return relativePath === "" || relativePath !== ".." && !relativePath.startsWith(`..${path17.sep}`) && !path17.isAbsolute(relativePath);
35820
35935
  }
35821
35936
  function dataUrlMimeForPath(filePath, mediaKind) {
35822
- return DATA_URL_MIME_BY_EXTENSION[mediaKind][path16.extname(filePath).toLowerCase()];
35937
+ return DATA_URL_MIME_BY_EXTENSION[mediaKind][path17.extname(filePath).toLowerCase()];
35823
35938
  }
35824
35939
  function upsertGeneratedAssetRecord(targetDir, localPath, record2) {
35825
35940
  const registryPath = getGeneratedAssetRegistryPath(targetDir);
35826
- const registryDirectory = path16.dirname(registryPath);
35827
- fs15.mkdirSync(registryDirectory, { recursive: true });
35941
+ const registryDirectory = path17.dirname(registryPath);
35942
+ fs16.mkdirSync(registryDirectory, { recursive: true });
35828
35943
  assertProjectDirectory(targetDir, registryDirectory);
35829
35944
  assertFileIsNotSymlink(registryPath);
35830
35945
  const registry2 = readGeneratedAssetRegistry(targetDir);
35831
35946
  registry2[localPath] = record2;
35832
- fs15.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
35947
+ fs16.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
35833
35948
  `, "utf8");
35834
35949
  }
35835
35950
  function readGeneratedAssetRegistry(targetDir) {
35836
35951
  const registryPath = getGeneratedAssetRegistryPath(targetDir);
35837
35952
  assertFileIsNotSymlink(registryPath);
35838
- if (!fs15.existsSync(registryPath)) {
35953
+ if (!fs16.existsSync(registryPath)) {
35839
35954
  return {};
35840
35955
  }
35841
35956
  try {
35842
- const parsed = JSON.parse(fs15.readFileSync(registryPath, "utf8"));
35843
- return isRecord(parsed) ? parsed : {};
35957
+ const parsed = JSON.parse(fs16.readFileSync(registryPath, "utf8"));
35958
+ return isRecord2(parsed) ? parsed : {};
35844
35959
  } catch {
35845
35960
  return {};
35846
35961
  }
35847
35962
  }
35848
35963
  function getGeneratedAssetRegistryPath(targetDir) {
35849
- return path16.join(targetDir, ".maker", "assets", "generated-assets.json");
35964
+ return path17.join(targetDir, ".maker", "assets", "generated-assets.json");
35850
35965
  }
35851
35966
  function isSymlink(filePath) {
35852
35967
  try {
35853
- return fs15.lstatSync(filePath).isSymbolicLink();
35968
+ return fs16.lstatSync(filePath).isSymbolicLink();
35854
35969
  } catch {
35855
35970
  return false;
35856
35971
  }
@@ -35864,10 +35979,10 @@ function normalizeAssetRegistryKey(targetDir, value) {
35864
35979
  if (/^https?:\/\//i.test(value) || value.startsWith("data:")) {
35865
35980
  return void 0;
35866
35981
  }
35867
- const relative = path16.isAbsolute(value) ? path16.relative(targetDir, value) : value;
35868
- return relative.split(path16.sep).join("/");
35982
+ const relative = path17.isAbsolute(value) ? path17.relative(targetDir, value) : value;
35983
+ return relative.split(path17.sep).join("/");
35869
35984
  }
35870
- function isRecord(value) {
35985
+ function isRecord2(value) {
35871
35986
  return typeof value === "object" && value !== null && !Array.isArray(value);
35872
35987
  }
35873
35988
  function stringField2(value) {
@@ -35904,13 +36019,137 @@ function extensionFromUrl(url2) {
35904
36019
  }
35905
36020
  try {
35906
36021
  const pathname = new URL(url2).pathname;
35907
- const extension = path16.extname(pathname).replace(/^\./, "").toLowerCase();
36022
+ const extension = path17.extname(pathname).replace(/^\./, "").toLowerCase();
35908
36023
  return extension || void 0;
35909
36024
  } catch {
35910
36025
  return void 0;
35911
36026
  }
35912
36027
  }
35913
36028
 
36029
+ // src/maker/server/toolDescriptions.ts
36030
+ var MAKER_STATUS_LITE_PUBLIC_DESCRIPTION = [
36031
+ "Compatibility tool for clients that cannot read the maker://status resource; prefer the resource when it is available.",
36032
+ "Use it when starting or resuming Maker work, or when the current project context and readiness are uncertain.",
36033
+ "Pass target_dir when the project cannot be resolved from MCP Roots or the server working directory; if multiple Maker projects remain ambiguous, ask the user instead of guessing.",
36034
+ "By default the check may perform remote Git, package, dev-kit, proxy, and authentication probes. skip_remote_sync skips only remote Git and dev-kit freshness checks; it is not an offline or read-only mode.",
36035
+ "Follow the returned next_action and next_step."
36036
+ ].join(" ");
36037
+ var MAKER_BUILD_CURRENT_DIRECTORY_PUBLIC_DESCRIPTION = [
36038
+ "Submit and remotely build the current bound Maker project. First read maker://status or maker_status_lite and resolve exactly one bound Maker project.",
36039
+ "Use this tool for explicit Maker build, preview, submit, or push requests. Code tests and lint do not trigger this remote workflow unless the user also explicitly asks to build, run, or preview the Maker game.",
36040
+ "Normal mode commits local changes when needed, pushes existing or new commits, and then starts the remote build; a clean workspace creates the required wake-up commit.",
36041
+ "Unsafe remote-sync or branch states stop before commit and push. A push failure stops before build, while a build failure after a successful push means the code is already on Maker remote; follow the structured result for recovery.",
36042
+ "After a successful build, read runtime_logs.local_file for gameplay diagnostics and runtime_logs.state_file for watcher health when those fields are returned.",
36043
+ "Do not combine Maker submission with generic branch, PR/MR, or separate commit/push workflows.",
36044
+ "Set confirm_remote_build_without_submit=true only after the user explicitly requests building the already committed remote version without submitting local changes."
36045
+ ].join(" ");
36046
+ var MAKER_REMOTE_PROXY_PUBLIC_DESCRIPTIONS = {
36047
+ generate_image: [
36048
+ "Generate one new image asset for a Maker game. Use batch_generate_images for multiple new images and edit_image to modify an existing image.",
36049
+ "Optional reference images may guide style or content; supported sources, generation controls, and final target_size requirements are defined by the input schema.",
36050
+ "Keep each reference image supplied through local paths or data URLs at 10 MiB or less.",
36051
+ "The local proxy attempts to materialize successful results into the Maker project and retain remote mapping; use returned workspace/local paths when present."
36052
+ ].join(" "),
36053
+ batch_generate_images: [
36054
+ "Generate two or more new image assets in parallel in one call. Use generate_image for one new image and edit_image to modify an existing image.",
36055
+ "Each image request uses the fields and constraints defined by the input schema.",
36056
+ "Keep each reference image supplied through local paths or data URLs at 10 MiB or less. A batch may partially succeed; preserve successful images and report failed items with their returned errors.",
36057
+ "The local proxy attempts to materialize successful results into the Maker project and retain remote mapping; use returned workspace/local paths when present."
36058
+ ].join(" "),
36059
+ edit_image: [
36060
+ "Modify an existing image from text instructions. Use generate_image for one new image and batch_generate_images for multiple new images.",
36061
+ "The required original image accepts a local Maker project path, an HTTP(S) URL, or an image data URL. Additional reference images and output controls are defined by the input schema.",
36062
+ "Keep each local-path or data URL image at 10 MiB or less.",
36063
+ "The local proxy attempts to materialize successful results into the Maker project and retain remote mapping; use returned workspace/local paths when present."
36064
+ ].join(" "),
36065
+ create_video_task: [
36066
+ "Create a video generation task. The remote service normally performs server-side polling and waits for the final result in this call.",
36067
+ "If the wait budget expires, the result returns a task_id; continue other work and use query_video_task no sooner than 120 seconds later.",
36068
+ "Mode-specific inputs and limits are defined by the input schema. Image, video, and audio references may use local project files, HTTP(S) URLs, or data URLs supported by the schema.",
36069
+ "Keep image references at 30 MiB or less, video references at 50 MiB or less, and audio references at 15 MiB or less.",
36070
+ "The local proxy attempts to materialize successful video results into the Maker project; prefer returned workspace paths when present, unless the user needs an external share URL."
36071
+ ].join(" "),
36072
+ query_video_task: [
36073
+ "Query video task status by task_id after create_video_task returns a pending task or reports a concurrency limit.",
36074
+ "If the task is still pending or running, continue other work and query again no sooner than 120 seconds later; do not poll continuously.",
36075
+ "Querying a completed task releases its task quota. The local proxy attempts to materialize successful video and last-frame results into the Maker project.",
36076
+ "Prefer workspace_video_path and workspace_last_frame_path when present; mention CDN URLs only when the user needs an external share link."
36077
+ ].join(" "),
36078
+ text_to_music: [
36079
+ "Generate AI music for a Maker game, including background music or vocal tracks; do not use this tool for sound effects.",
36080
+ "The remote call polls server-side every 20 seconds and may wait up to 50 minutes. If generation is still running when the call times out, the result includes the task ID for operational tracking.",
36081
+ "Simple and custom generation controls are defined by the input schema.",
36082
+ "The local proxy attempts to materialize successful audio and metadata into the Maker project and record them for later Maker references; use returned local paths when present."
36083
+ ].join(" "),
36084
+ text_to_sound_effect: [
36085
+ "Generate one game sound effect from a Chinese or English description.",
36086
+ "For the current Seed Audio provider, each call produces one output of at most 120 seconds. Split longer audio across multiple generations because this tool does not stitch outputs.",
36087
+ "duration_seconds is an approximate target and the actual duration may differ.",
36088
+ "The local proxy attempts to materialize successful audio in the provider original format under assets/audio/sfx and record it for later Maker references; use returned local paths when present."
36089
+ ].join(" "),
36090
+ batch_sound_effects: [
36091
+ "Generate multiple game sound effects in one batch.",
36092
+ "For the current Seed Audio provider, each item is an independent output of at most 120 seconds. Split longer audio across items or calls because this tool does not stitch outputs.",
36093
+ "The result preserves per-item failures while the local proxy attempts to materialize successful audio in the provider original format under assets/audio/sfx and record it for later Maker references; use returned local paths when present."
36094
+ ].join(" "),
36095
+ text_to_dialogue: [
36096
+ "Generate final character dialogue audio for a Maker game.",
36097
+ "Each input needs a confirmed voice mapping or a reference_audio override. When neither is available, call audition_voices_for_character and then confirm_character_voice before retrying.",
36098
+ "When reference_audio is omitted, the local proxy automatically reuses a confirmed local Doubao reference; the legacy provider still requires its confirmed voice mapping. Supported reference inputs and line-specific delivery controls are defined by the input schema.",
36099
+ "For Doubao, each input produces at most 120 seconds of audio. Split longer dialogue across inputs or calls because this tool does not stitch outputs.",
36100
+ "The local proxy attempts to materialize successful dialogue under assets/audio/voice; use returned local paths when present."
36101
+ ].join(" "),
36102
+ audition_voices_for_character: [
36103
+ "Create temporary voice previews for one game character.",
36104
+ "Before calling, inspect the available character definition and relevant project context, then prepare a representative audition line that matches the character personality and speaking style.",
36105
+ "voice_profile.gender is required and must be passed explicitly as male or female.",
36106
+ "Doubao returns exactly three previews; the legacy provider follows candidate_count. Show every returned preview to the user and wait for an explicit choice before calling confirm_character_voice.",
36107
+ "Complete audition and confirmation for one character before starting another in the same project; do not run them in parallel.",
36108
+ "Preview files are temporary and are not saved as final game assets."
36109
+ ].join(" "),
36110
+ confirm_character_voice: [
36111
+ "Confirm a voice selection and persist the character voice mapping for later text_to_dialogue calls.",
36112
+ "Call this tool only after audition_voices_for_character and only after the user explicitly selects a candidate or explicitly accepts the recommended candidate.",
36113
+ "Omit selected_index only after the user explicitly accepts the recommendation; absence of a user choice is not acceptance.",
36114
+ "Process one character at a time and do not call this tool in parallel for the same project."
36115
+ ].join(" "),
36116
+ create_3d_asset: [
36117
+ 'Manage the complete Maker 3D asset lifecycle. Use action="start" to begin, action="query" to check progress, action="get_options" to inspect step options, action="continue" after review, and action="post_process" for supported follow-up operations.',
36118
+ "Use direct generation when no review checkpoint is needed, and reviewed generation when the user needs a preview before final generation.",
36119
+ 'For reviewed generation, show every returned preview and wait for explicit user approval before action="continue"; never approve a review step automatically.',
36120
+ "Supported prompt, image, strategy, quality, and post-processing fields are defined by the input schema.",
36121
+ "Local image inputs are normalized for the remote service. The local proxy attempts to materialize completed model delivery under assets/model and review images under assets/image; use local_delivery, preview_assets, and other returned local paths when present."
36122
+ ].join(" "),
36123
+ generate_test_qrcode: [
36124
+ "Generate a mobile test QR code only when the user explicitly requests a test QR code or scan test, or when get_ad_config reports missing app_id or developer_id and requests this recovery step.",
36125
+ "Do not call this tool automatically during initialization, build, or publish workflows. When an explicit build is needed, use maker_build_current_directory separately.",
36126
+ "Call without confirmed_screen_orientation first. Reuse an existing project orientation; only when the tool reports it missing, ask the user in a separate conversation turn to choose landscape or portrait and then retry.",
36127
+ "An existing orientation is immutable. This operation may upload a test version, create the TapTap app identity, and return a displayable QR code."
36128
+ ].join(" "),
36129
+ add_test_whitelist: [
36130
+ "Add one TapTap user to the current game test whitelist.",
36131
+ "Use this only after maker_build_current_directory has initialized the project and generate_test_qrcode has established the TapTap app identity.",
36132
+ "Call it only with the TapTap user_id explicitly provided by the user; never infer an account ID."
36133
+ ].join(" "),
36134
+ get_ad_config: [
36135
+ "After Maker project status confirms the primary local project configs are initialized, use this as the first remote step for ad-related requests.",
36136
+ "It is the source of truth for current ad activation and configuration, and synchronizes the result into .project/settings.json at @runtime.ad.",
36137
+ "The local preflight does not call the remote tool while project.json or settings.json is missing. Missing local configs do not authorize an automatic build.",
36138
+ "Use maker_build_current_directory only for an explicit user build, submit, or preview request, then check project status again. If configs remain missing, report the limitation and do not rebuild automatically.",
36139
+ "Do not infer ad readiness from local SDK docs, .maker-mcp/config.json, or runtime callbacks, and only implement or test ad behavior after the returned configuration is usable.",
36140
+ "If app_id or developer_id is missing, call generate_test_qrcode once and then retry this tool. If ad.status != 1, report warning and ad.url, follow the returned next_action, and retry only after the user completes that step."
36141
+ ].join(" "),
36142
+ get_debug_feedbacks: [
36143
+ "Fetch online player feedback for the current Maker project, or query server and Lua session logs when game_session_id is provided.",
36144
+ "The default feedback mode fetches unprocessed records and marks the returned records as processed. For a read-only feedback query, set fetch_and_mark_processed=false; use the input schema to select other filters or an exact feedback record.",
36145
+ "Downloaded feedback attachments are saved in the local project. Read only the returned local_dir, local_log_paths, and local_screenshot_paths; do not treat remote attachment paths as local files.",
36146
+ "Session-log mode returns its own saved paths and progress information; use the returned result to continue when more history is available."
36147
+ ].join(" ")
36148
+ };
36149
+ function getMakerRemoteProxyPublicDescriptionOverride(toolName) {
36150
+ return MAKER_REMOTE_PROXY_PUBLIC_DESCRIPTIONS[toolName];
36151
+ }
36152
+
35914
36153
  // src/mcp-proxy/config.ts
35915
36154
  var DEFAULT_TOOL_CALL_TIMEOUT_MS = 60 * 60 * 1e3;
35916
36155
  function readStdin() {
@@ -36054,8 +36293,88 @@ function applyDefaults(config2) {
36054
36293
  };
36055
36294
  }
36056
36295
 
36296
+ // src/maker/tracking.ts
36297
+ var MAKER_MCP_TRACKING_ACTION = "tapmaker_mcp_call";
36298
+ var MAKER_MCP_TRACKING_SOURCE = "local_mcp";
36299
+ var MAKER_MCP_TRACKING_TIMEOUT_MS = 1500;
36300
+ var MAKER_MCP_VERSION = "0.0.26-beta.3".trim() ? "0.0.26-beta.3".trim() : "dev";
36301
+ var TRACKING_ERROR_MAX_LENGTH = 500;
36302
+ function buildMakerMcpTrackingPayload(event) {
36303
+ var _a3, _b, _c;
36304
+ const userId = event.context.userId.trim();
36305
+ const projectId = event.context.projectId.trim();
36306
+ const toolName = event.toolName.trim();
36307
+ if (!userId || !projectId || !toolName) {
36308
+ return null;
36309
+ }
36310
+ const args = {
36311
+ user_id: userId,
36312
+ project_id: projectId,
36313
+ tool_name: toolName,
36314
+ source: MAKER_MCP_TRACKING_SOURCE,
36315
+ mcp_version: MAKER_MCP_VERSION
36316
+ };
36317
+ if (event.requestId !== void 0 && String(event.requestId).trim()) {
36318
+ args.tool_id = String(event.requestId);
36319
+ }
36320
+ if (event.durationMs !== void 0 && Number.isFinite(event.durationMs) && event.durationMs >= 0) {
36321
+ args.duration_ms = Math.round(event.durationMs);
36322
+ }
36323
+ if (event.success !== void 0) {
36324
+ args.success = event.success;
36325
+ }
36326
+ if ((_a3 = event.errorCode) == null ? void 0 : _a3.trim()) {
36327
+ args.error_code = event.errorCode.trim();
36328
+ }
36329
+ if ((_b = event.errorMessage) == null ? void 0 : _b.trim()) {
36330
+ args.error_message = sanitizeMakerMcpTrackingError(event.errorMessage);
36331
+ }
36332
+ return {
36333
+ action: MAKER_MCP_TRACKING_ACTION,
36334
+ ...((_c = event.userAgent) == null ? void 0 : _c.trim()) ? { user_agent: event.userAgent.trim() } : {},
36335
+ args
36336
+ };
36337
+ }
36338
+ function isMakerBuildActivitySuccessful(mode) {
36339
+ return mode === "remote_build";
36340
+ }
36341
+ function sanitizeMakerMcpTrackingError(message) {
36342
+ return message.replace(/Bearer\s+[^,\s"'}<]+/gi, "<redacted>").replace(
36343
+ /((?:authorization|access[_-]?token|refresh[_-]?token|mac[_\s-]?key|\bpat\b|token)\s*[:=]\s*)(["']?)[^,\s"'}<]+/gi,
36344
+ "$1$2<redacted>"
36345
+ ).replace(/(https?:\/\/[^:\s/@]+:)[^@\s]+@/gi, "$1<redacted>@").replace(/(https?:\/\/)[^:/\s@]+@/gi, "$1<redacted>@").trim().slice(0, TRACKING_ERROR_MAX_LENGTH);
36346
+ }
36347
+ async function reportMakerMcpActivity(event) {
36348
+ var _a3;
36349
+ const payload = buildMakerMcpTrackingPayload(event);
36350
+ if (!payload) {
36351
+ return;
36352
+ }
36353
+ const fetchImpl = event.fetchImpl || fetch;
36354
+ const controller = new AbortController();
36355
+ const timeout = setTimeout(
36356
+ () => controller.abort(),
36357
+ event.timeoutMs ?? MAKER_MCP_TRACKING_TIMEOUT_MS
36358
+ );
36359
+ try {
36360
+ const response = await fetchImpl(`${getMakerApiBaseUrl()}/tracking`, {
36361
+ method: "POST",
36362
+ headers: { "Content-Type": "application/json" },
36363
+ body: JSON.stringify(payload),
36364
+ signal: controller.signal
36365
+ });
36366
+ await ((_a3 = response.body) == null ? void 0 : _a3.cancel());
36367
+ if (!response.ok) {
36368
+ throw new Error(`tracking request failed with HTTP ${response.status}`);
36369
+ }
36370
+ } catch {
36371
+ } finally {
36372
+ clearTimeout(timeout);
36373
+ }
36374
+ }
36375
+
36057
36376
  // src/maker/server/mcp.ts
36058
- var VERSION = true ? "0.0.26-beta.1" : "dev";
36377
+ var VERSION = true ? "0.0.26-beta.3" : "dev";
36059
36378
  var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
36060
36379
  var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
36061
36380
  var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
@@ -36077,12 +36396,13 @@ var MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES = [
36077
36396
  "confirm_character_voice",
36078
36397
  CREATE_3D_ASSET_PROXY_TOOL_NAME,
36079
36398
  "generate_test_qrcode",
36399
+ "add_test_whitelist",
36080
36400
  "get_ad_config",
36081
36401
  "get_debug_feedbacks"
36082
36402
  ];
36083
36403
  var MAKER_BUILD_MULTIPLAYER_SCHEMA = {
36084
36404
  type: "object",
36085
- description: "Optional Maker multiplayer config forwarded to remote build and written by maker-tools to .project/settings.json @runtime.multiplayer. If omitted and no .project/settings.json exists, Maker MCP sends { enabled: false } for first single-player build initialization. First multiplayer build with entry_client/entry_server should pass multiplayer.enabled=true and any needed match/world fields in the same call. Later builds update only the provided fields and keep existing config for omitted fields. Runtime defaults: enabled=false, max_players=4, background_match=false.",
36405
+ description: "Optional Maker multiplayer config forwarded only when explicitly provided and written by maker-tools to .project/settings.json @runtime.multiplayer. Missing local .project/settings.json does not imply single-player mode and does not inject enabled=false. First multiplayer build with entry_client/entry_server should pass multiplayer.enabled=true and any needed match/world fields in the same call. Explicit enabled=false remains supported for a user-confirmed single-player configuration. Later builds update only the provided fields and keep existing config for omitted fields. Runtime defaults: enabled=false, max_players=4, background_match=false.",
36086
36406
  properties: {
36087
36407
  enabled: {
36088
36408
  type: "boolean",
@@ -36147,7 +36467,7 @@ var MakerCloneFailedError = class extends Error {
36147
36467
  var tools = [
36148
36468
  {
36149
36469
  name: "maker_status_lite",
36150
- description: "Compatibility status surface for clients using tool output instead of the maker://status resource. Prefer reading maker://status when resources are available. Shows local Maker status for the user current working directory, including Git, Python runtime readiness, maker-lua-lsp readiness for local Lua diagnostics, PAT/TapTap auth, project binding, AI dev kit status, Maker proxy tools status and failures, Maker Git Workflow Policy guidance, Maker Creative Asset Tool Policy guidance to prefer Maker MCP proxy tools for bound game assets, supported local path/remote URL/data URL inputs, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init. Standard init/clone/download flow: show the Maker app list first and let the user choose an existing app or 0/new. Create-new-project flow: use taptap-maker init --create only when the user clearly asks to create a new Maker project.",
36470
+ description: MAKER_STATUS_LITE_PUBLIC_DESCRIPTION,
36151
36471
  inputSchema: {
36152
36472
  type: "object",
36153
36473
  additionalProperties: false,
@@ -36165,7 +36485,7 @@ var tools = [
36165
36485
  },
36166
36486
  {
36167
36487
  name: "maker_build_current_directory",
36168
- description: 'Sync and build the current Maker game. First read maker://status or maker_status_lite and use this tool only when the current workspace is a bound Maker project. Trigger it for Maker game requests like "构建", "build", "跑一下", "预览", "查看结果", "看看效果", "验证游戏效果", "提交", "提交代码", "推送", or "push". Do not treat generic code validation requests such as "验证一下代码", "跑测试", "lint", or "检查实现" as Maker remote build unless the user explicitly asks to build/run/preview the Maker game. Preview/build intent does not select or change the service environment. Do not add environment parameters to this tool call; use the default Maker service configuration. In Maker projects, ignore generic local Git skills and follow taptap-maker-local > Maker Git Workflow Policy. Before build, check the Python environment section and Lua LSP environment section; if Python or maker-lua-lsp is missing, run taptap-maker python setup when local Lua diagnostics are needed, because it prepares Python and best-effort installs maker-lua-lsp. Missing Python or Lua LSP must not block the remote build flow. Do not create branches, do not use generic git commit/push, and do not create PR/MR for Maker project submit/build requests. Before creating a commit, this tool checks Maker remote sync; if local main is behind/diverged, not on main, or remote sync cannot be verified, it stops before commit/push and returns recovery details. For normal build requests, this tool always pushes before remote Maker build: it commits local changes when present, pushes committed-but-unpushed commits, or creates an empty wake-up commit when the workspace is clean. Maker generated .gitignore changes are required project files and are submitted even if files selects a smaller change set. If push fails, build is not started and the result includes recovery details for the local Agent to handle merge/conflict resolution. If push succeeds but remote build fails, report that code is already on Maker remote and include build failure details. After a successful build, a local runtime log watcher is started; for gameplay/runtime diagnostics, read runtime_logs.local_file, and for watcher health read runtime_logs.state_file. Only set confirm_remote_build_without_submit=true when the user explicitly says they do not want to submit local changes and wants to build the current remote version; this mode does not submit local changes and does not auto-open Maker pages.',
36488
+ description: MAKER_BUILD_CURRENT_DIRECTORY_PUBLIC_DESCRIPTION,
36169
36489
  inputSchema: {
36170
36490
  type: "object",
36171
36491
  additionalProperties: false,
@@ -36251,11 +36571,12 @@ function filterExposedRemoteProxyTools(toolsToFilter) {
36251
36571
  return toolsToFilter.filter((tool) => exposedToolNames.has(tool.name));
36252
36572
  }
36253
36573
  function decorateRemoteProxyToolDefinition(tool) {
36574
+ const publicDescription = getMakerRemoteProxyPublicDescriptionOverride(tool.name);
36254
36575
  const guidance = remoteProxyToolGuidance(tool.name);
36255
36576
  return {
36256
36577
  ...tool,
36257
36578
  inputSchema: decorateRemoteProxyToolInputSchema(tool.inputSchema, tool.name),
36258
- description: [tool.description, guidance].filter(Boolean).join("\n\n")
36579
+ description: publicDescription || [tool.description, guidance].filter(Boolean).join("\n\n")
36259
36580
  };
36260
36581
  }
36261
36582
  function decorateRemoteProxyToolInputSchema(inputSchema, toolName) {
@@ -36263,12 +36584,20 @@ function decorateRemoteProxyToolInputSchema(inputSchema, toolName) {
36263
36584
  const properties = isPlainRecord(schema.properties) ? schema.properties : {};
36264
36585
  const decoratedProperties = toolName === "text_to_dialogue" ? decorateTextToDialogueInputProperties(properties) : toolName === "audition_voices_for_character" ? decorateVoiceAuditionInputProperties(properties) : properties;
36265
36586
  const required2 = Array.isArray(schema.required) ? schema.required : [];
36587
+ const decoratedRequired = toolName === "audition_voices_for_character" ? [.../* @__PURE__ */ new Set([...required2, "voice_profile"])] : required2;
36266
36588
  return {
36267
36589
  ...schema,
36268
36590
  type: schema.type || "object",
36269
- ...toolName === "audition_voices_for_character" ? { required: [.../* @__PURE__ */ new Set([...required2, "voice_profile"])] } : {},
36591
+ required: decoratedRequired,
36270
36592
  properties: {
36271
36593
  ...decoratedProperties,
36594
+ ...toolName === "generate_test_qrcode" ? {
36595
+ confirmed_screen_orientation: {
36596
+ type: "string",
36597
+ enum: ["landscape", "portrait"],
36598
+ description: "Local-only first-time orientation choice. Omit this when the project already has screen_orientation. Supply it only after the tool reports that orientation is missing and the user selects a value in a separate conversation turn. Existing project orientation is immutable and takes precedence. This value is not forwarded to the remote Maker tool."
36599
+ }
36600
+ } : {},
36272
36601
  target_dir: {
36273
36602
  type: "string",
36274
36603
  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."
@@ -36414,12 +36743,17 @@ function remoteProxyToolGuidance(toolName) {
36414
36743
  ].join(" ");
36415
36744
  case "get_ad_config":
36416
36745
  return [
36417
- "**Maker hint:** Trigger this tool for any ad-related request (广告, 激励视频, 播放广告, ad ID, ad placement, ShowRewardVideoAd, ad status, or ad config). Call it first to get the current Maker project ad activation status and ad config; do not infer ad readiness from local SDK docs, .maker-mcp/config.json, or runtime callbacks. If .project/project.json is missing, build the project once with maker_build_current_directory to initialize it, then call this tool again. If this tool says app_id or developer_id is missing, call generate_test_qrcode once to generate test QR code metadata, then call this tool again.",
36746
+ "**Maker hint:** Trigger this tool for ad-related requests only after Maker project status shows the primary local configs are initialized. The local preflight keeps ad config unavailable and does not call the remote tool while project.json or settings.json is missing. Build only for an explicit user build, submit, or preview request; if local configs remain missing after a successful build, explain the known limitation and do not rebuild automatically. Do not infer ad readiness from local SDK docs, .maker-mcp/config.json, or runtime callbacks. If this tool says app_id or developer_id is missing after configs are ready, call generate_test_qrcode once to generate test QR code metadata, then call this tool again.",
36418
36747
  failurePolicy
36419
36748
  ].join(" ");
36420
36749
  case "generate_test_qrcode":
36421
36750
  return [
36422
- "**Maker hint:** Use this only when the user explicitly asks for a test QR code/mobile scan test, or as the recovery step after get_ad_config reports missing app_id or developer_id. It has no business parameters; follow the remote schema and report the returned QR code or failure payload.",
36751
+ "**Maker hint:** Use this only when the user explicitly asks for a test QR code/mobile scan test, or as the recovery step after get_ad_config reports missing app_id or developer_id. Call it without confirmed_screen_orientation first. If .project/project.json already has screen_orientation, reuse it and do not ask the user again. Only if it is missing, ask the user in a separate conversation turn to choose landscape or portrait, then retry with confirmed_screen_orientation. The local proxy records this first choice; an already configured orientation is immutable and always takes precedence. The private parameter is not forwarded to the remote Maker tool. Report the returned QR code or failure payload.",
36752
+ failurePolicy
36753
+ ].join(" ");
36754
+ case "add_test_whitelist":
36755
+ return [
36756
+ "**Maker hint:** Use this after the project has been built and generate_test_qrcode has created the TapTap app identity. Call it only with the TapTap user_id explicitly provided by the user; do not infer an account ID.",
36423
36757
  failurePolicy
36424
36758
  ].join(" ");
36425
36759
  case "get_debug_feedbacks":
@@ -36548,11 +36882,22 @@ function createRemoteProxyProgressHandler(progressToken, extra) {
36548
36882
  };
36549
36883
  }
36550
36884
  function inspectMakerProxyToolPreflight(toolName, targetDir) {
36551
- if (toolName !== "generate_test_qrcode") {
36885
+ if (toolName !== "generate_test_qrcode" && toolName !== "get_ad_config" && toolName !== "add_test_whitelist") {
36552
36886
  return void 0;
36553
36887
  }
36554
36888
  const identify = identifyMakerProject({ cwd: targetDir });
36555
- return inspectMakerProjectHealth(identify.projectRoot || path17.resolve(targetDir), "qrcode");
36889
+ return inspectMakerProjectHealth(
36890
+ identify.projectRoot || path18.resolve(targetDir),
36891
+ toolName === "generate_test_qrcode" ? "qrcode" : "status"
36892
+ );
36893
+ }
36894
+ function inspectMakerQrcodeToolPreflight(targetDir, confirmedOrientation) {
36895
+ const projectHealth = inspectMakerProxyToolPreflight("generate_test_qrcode", targetDir);
36896
+ if (!projectHealth.canGenerateTestQrcode) {
36897
+ return { ok: false, message: formatMakerProjectHealthStatus(projectHealth) };
36898
+ }
36899
+ const identify = identifyMakerProject({ cwd: targetDir });
36900
+ return inspectMakerQrcodePreflight(identify.projectRoot || targetDir, confirmedOrientation);
36556
36901
  }
36557
36902
  function createRemoteProxyCallToolOptions(progressToken, extra) {
36558
36903
  return {
@@ -36572,34 +36917,72 @@ async function startMakerMcpServer() {
36572
36917
  capabilities: {
36573
36918
  tools: {},
36574
36919
  resources: {}
36575
- }
36920
+ },
36921
+ instructions: MAKER_CAPABILITY_ROUTING_INDEX
36576
36922
  }
36577
36923
  );
36578
36924
  const listClientRoots = createServerClientRootsProvider(server);
36579
- server.setRequestHandler(ListToolsRequestSchema, async () => listMakerTools({ listClientRoots }));
36580
- server.setRequestHandler(ListResourcesRequestSchema, async () => ({ resources }));
36581
- server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
36925
+ const startupReportedProjects = /* @__PURE__ */ new Set();
36926
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
36927
+ const contextPromise = resolveMakerMcpTrackingContext({ listClientRoots });
36928
+ void reportMakerMcpStartupFromPromise(contextPromise, startupReportedProjects);
36929
+ return listMakerTools({ listClientRoots });
36930
+ });
36931
+ server.setRequestHandler(ListResourcesRequestSchema, async () => {
36932
+ const contextPromise = resolveMakerMcpTrackingContext({ listClientRoots });
36933
+ void reportMakerMcpStartupFromPromise(contextPromise, startupReportedProjects);
36934
+ return { resources };
36935
+ });
36936
+ server.setRequestHandler(ReadResourceRequestSchema, async (request, extra) => {
36582
36937
  const uri = request.params.uri;
36583
36938
  if (uri !== "maker://status") {
36584
36939
  throw new McpError(ErrorCode.InvalidParams, `Unknown Maker resource: ${uri}`);
36585
36940
  }
36586
- return {
36587
- contents: [
36588
- {
36589
- uri,
36590
- mimeType: "text/plain",
36591
- text: await formatStatus({ listClientRoots })
36592
- }
36593
- ]
36594
- };
36941
+ const startedAt = Date.now();
36942
+ const contextPromise = resolveMakerMcpTrackingContext({ listClientRoots });
36943
+ void reportMakerMcpStartupFromPromise(contextPromise, startupReportedProjects);
36944
+ try {
36945
+ const result = {
36946
+ contents: [
36947
+ {
36948
+ uri,
36949
+ mimeType: "text/plain",
36950
+ text: await formatStatus({ listClientRoots })
36951
+ }
36952
+ ]
36953
+ };
36954
+ void reportMakerMcpActivityFromPromise(contextPromise, {
36955
+ toolName: uri,
36956
+ requestId: extra.requestId,
36957
+ durationMs: Date.now() - startedAt,
36958
+ success: true
36959
+ });
36960
+ return result;
36961
+ } catch (error2) {
36962
+ void reportMakerMcpActivityFromPromise(contextPromise, {
36963
+ toolName: uri,
36964
+ requestId: extra.requestId,
36965
+ durationMs: Date.now() - startedAt,
36966
+ success: false,
36967
+ errorCode: error2 instanceof Error ? error2.name : void 0,
36968
+ errorMessage: error2 instanceof Error ? error2.message : void 0
36969
+ });
36970
+ throw error2;
36971
+ }
36595
36972
  });
36596
36973
  server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
36597
36974
  var _a3, _b;
36598
36975
  const name = request.params.name;
36976
+ const startedAt = Date.now();
36977
+ const rawArgs = request.params.arguments || {};
36978
+ const hasInvalidTargetDir = rawArgs.target_dir !== void 0 && (typeof rawArgs.target_dir !== "string" || !rawArgs.target_dir.trim());
36979
+ const targetDir = !hasInvalidTargetDir && (rawArgs.target_dir === void 0 || typeof rawArgs.target_dir === "string") ? rawArgs.target_dir : void 0;
36980
+ const contextPromise = hasInvalidTargetDir ? Promise.resolve(null) : resolveMakerMcpTrackingContext({ targetDir, listClientRoots });
36981
+ void reportMakerMcpStartupFromPromise(contextPromise, startupReportedProjects);
36599
36982
  try {
36600
36983
  if (name === "maker_status_lite") {
36601
36984
  const args = request.params.arguments || {};
36602
- return {
36985
+ const toolResult = {
36603
36986
  content: [
36604
36987
  {
36605
36988
  type: "text",
@@ -36611,6 +36994,13 @@ async function startMakerMcpServer() {
36611
36994
  }
36612
36995
  ]
36613
36996
  };
36997
+ void reportMakerMcpActivityFromPromise(contextPromise, {
36998
+ toolName: name,
36999
+ requestId: extra.requestId,
37000
+ durationMs: Date.now() - startedAt,
37001
+ success: true
37002
+ });
37003
+ return toolResult;
36614
37004
  }
36615
37005
  if (name === "maker_build_current_directory") {
36616
37006
  const args = request.params.arguments || {};
@@ -36645,7 +37035,7 @@ async function startMakerMcpServer() {
36645
37035
  progressReporter.finish();
36646
37036
  throw error2;
36647
37037
  }
36648
- return {
37038
+ const toolResult = {
36649
37039
  content: [
36650
37040
  {
36651
37041
  type: "text",
@@ -36653,20 +37043,44 @@ async function startMakerMcpServer() {
36653
37043
  }
36654
37044
  ]
36655
37045
  };
37046
+ void reportMakerMcpActivityFromPromise(contextPromise, {
37047
+ toolName: name,
37048
+ requestId: extra.requestId,
37049
+ durationMs: Date.now() - startedAt,
37050
+ success: isMakerBuildActivitySuccessful(result.mode)
37051
+ });
37052
+ return toolResult;
36656
37053
  }
36657
37054
  if (isExposedRemoteProxyTool(name)) {
36658
- const { targetDir, remoteArgs } = splitRemoteProxyToolPrivateArgs(
36659
- request.params.arguments || {}
36660
- );
37055
+ const requestArgs = request.params.arguments || {};
37056
+ const { targetDir: targetDir2, remoteArgs } = splitRemoteProxyToolPrivateArgs(requestArgs, name);
36661
37057
  const context = await resolveMakerProjectContext({
36662
- targetDir,
37058
+ targetDir: targetDir2,
36663
37059
  listClientRoots,
36664
37060
  allowFallbackOnAmbiguousRoots: false
36665
37061
  });
36666
37062
  if (name === "generate_test_qrcode") {
37063
+ const preflight = inspectMakerQrcodeToolPreflight(
37064
+ context.targetDir,
37065
+ requestArgs.confirmed_screen_orientation
37066
+ );
37067
+ if (!preflight.ok) {
37068
+ const result2 = {
37069
+ isError: true,
37070
+ content: [{ type: "text", text: preflight.message }]
37071
+ };
37072
+ void reportMakerMcpActivityFromPromise(contextPromise, {
37073
+ toolName: name,
37074
+ requestId: extra.requestId,
37075
+ durationMs: Date.now() - startedAt,
37076
+ success: false
37077
+ });
37078
+ return result2;
37079
+ }
37080
+ } else if (name === "get_ad_config" || name === "add_test_whitelist") {
36667
37081
  const projectHealth = inspectMakerProxyToolPreflight(name, context.targetDir);
36668
- if (!projectHealth.canGenerateTestQrcode) {
36669
- return {
37082
+ if (projectHealth && (projectHealth.status === "not_initialized" || !projectHealth.canBuild)) {
37083
+ const result2 = {
36670
37084
  isError: true,
36671
37085
  content: [
36672
37086
  {
@@ -36675,18 +37089,40 @@ async function startMakerMcpServer() {
36675
37089
  }
36676
37090
  ]
36677
37091
  };
37092
+ void reportMakerMcpActivityFromPromise(contextPromise, {
37093
+ toolName: name,
37094
+ requestId: extra.requestId,
37095
+ durationMs: Date.now() - startedAt,
37096
+ success: false
37097
+ });
37098
+ return result2;
36678
37099
  }
36679
37100
  }
36680
- return await callRemoteProxyTool({
37101
+ const result = await callRemoteProxyTool({
36681
37102
  targetDir: context.targetDir,
36682
37103
  name,
36683
37104
  args: remoteArgs,
36684
37105
  progressToken: (_b = request.params._meta) == null ? void 0 : _b.progressToken,
36685
37106
  extra
36686
37107
  });
37108
+ void reportMakerMcpActivityFromPromise(contextPromise, {
37109
+ toolName: name,
37110
+ requestId: extra.requestId,
37111
+ durationMs: Date.now() - startedAt,
37112
+ success: !result.isError
37113
+ });
37114
+ return result;
36687
37115
  }
36688
37116
  throw new McpError(ErrorCode.MethodNotFound, `Unknown Maker tool: ${name}`);
36689
37117
  } catch (error2) {
37118
+ void reportMakerMcpActivityFromPromise(contextPromise, {
37119
+ toolName: name,
37120
+ requestId: extra.requestId,
37121
+ durationMs: Date.now() - startedAt,
37122
+ success: false,
37123
+ errorCode: error2 instanceof Error ? error2.name : void 0,
37124
+ errorMessage: error2 instanceof Error ? error2.message : void 0
37125
+ });
36690
37126
  return {
36691
37127
  isError: true,
36692
37128
  content: [
@@ -36702,6 +37138,55 @@ async function startMakerMcpServer() {
36702
37138
  await server.connect(transport);
36703
37139
  installMakerServerExitHandlers();
36704
37140
  }
37141
+ async function resolveMakerMcpTrackingContext(options) {
37142
+ var _a3, _b;
37143
+ try {
37144
+ const context = await resolveMakerProjectContext({
37145
+ targetDir: options.targetDir,
37146
+ listClientRoots: options.listClientRoots,
37147
+ allowFallbackOnAmbiguousRoots: false
37148
+ });
37149
+ const identify = identifyMakerProject({ cwd: context.targetDir });
37150
+ const projectConfig = identify.projectRoot ? loadProjectConfig(identify.projectRoot) : null;
37151
+ const userId = (_a3 = projectConfig == null ? void 0 : projectConfig.user_id) == null ? void 0 : _a3.trim();
37152
+ const projectId = (_b = projectConfig == null ? void 0 : projectConfig.project_id) == null ? void 0 : _b.trim();
37153
+ if (!userId || !projectId) {
37154
+ return null;
37155
+ }
37156
+ return { userId, projectId };
37157
+ } catch {
37158
+ return null;
37159
+ }
37160
+ }
37161
+ async function reportMakerMcpActivityFromPromise(contextPromise, event) {
37162
+ try {
37163
+ const context = await contextPromise;
37164
+ if (!context) {
37165
+ return;
37166
+ }
37167
+ await reportMakerMcpActivity({ context, ...event });
37168
+ } catch {
37169
+ }
37170
+ }
37171
+ async function reportMakerMcpStartupFromPromise(contextPromise, reportedProjects) {
37172
+ try {
37173
+ const context = await contextPromise;
37174
+ if (!context) {
37175
+ return;
37176
+ }
37177
+ const key = `${context.userId}\0${context.projectId}`;
37178
+ if (reportedProjects.has(key)) {
37179
+ return;
37180
+ }
37181
+ reportedProjects.add(key);
37182
+ await reportMakerMcpActivity({
37183
+ context,
37184
+ toolName: `@taptap/maker@${VERSION}`,
37185
+ success: true
37186
+ });
37187
+ } catch {
37188
+ }
37189
+ }
36705
37190
  var MAKER_SERVER_SHUTDOWN_TIMEOUT_MS = 3e3;
36706
37191
  function installMakerServerExitHandlers() {
36707
37192
  let exiting = false;
@@ -36743,7 +37228,7 @@ async function formatStatus(options = {}) {
36743
37228
  const env = getMakerEnvironment(void 0, targetDir);
36744
37229
  const identify = identifyMakerProject({ cwd: targetDir });
36745
37230
  const mcpCwd = process.cwd();
36746
- const mcpCwdIdentify = path17.resolve(mcpCwd) === path17.resolve(targetDir) ? identify : identifyMakerProject({ cwd: mcpCwd });
37231
+ const mcpCwdIdentify = path18.resolve(mcpCwd) === path18.resolve(targetDir) ? identify : identifyMakerProject({ cwd: mcpCwd });
36747
37232
  const gitDirectoryStatus = inspectMakerDirectoryGitStatus(targetDir);
36748
37233
  const remoteSyncText = identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo && !options.skipRemoteSync ? await formatMakerRemoteSyncStatusSafely(identify.projectRoot) : identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo ? formatMakerRemoteSyncSkipped() : "";
36749
37234
  const pat = loadPat();
@@ -36881,10 +37366,10 @@ function formatMakerToolRegistrationCwdStatus(options) {
36881
37366
  if (!options.projectRoot) {
36882
37367
  return "";
36883
37368
  }
36884
- const mcpCwd = path17.resolve(options.mcpCwd);
36885
- const targetDir = path17.resolve(options.targetDir);
36886
- const projectRoot = path17.resolve(options.projectRoot);
36887
- const mcpProjectRoot = options.mcpProjectRoot ? path17.resolve(options.mcpProjectRoot) : void 0;
37369
+ const mcpCwd = path18.resolve(options.mcpCwd);
37370
+ const targetDir = path18.resolve(options.targetDir);
37371
+ const projectRoot = path18.resolve(options.projectRoot);
37372
+ const mcpProjectRoot = options.mcpProjectRoot ? path18.resolve(options.mcpProjectRoot) : void 0;
36888
37373
  if (mcpProjectRoot === projectRoot) {
36889
37374
  return "";
36890
37375
  }
@@ -37057,7 +37542,7 @@ function createServerClientRootsProvider(server) {
37057
37542
  async function resolveMakerProjectContext(options = {}) {
37058
37543
  if (options.targetDir) {
37059
37544
  return {
37060
- targetDir: path17.resolve(options.targetDir),
37545
+ targetDir: path18.resolve(options.targetDir),
37061
37546
  source: "explicit_target_dir",
37062
37547
  roots: { status: "not_requested", roots: [] }
37063
37548
  };
@@ -37152,7 +37637,7 @@ function rootToLocalPath(root) {
37152
37637
  if (url2.protocol !== "file:") {
37153
37638
  return void 0;
37154
37639
  }
37155
- return path17.resolve(fileURLToPath2(url2));
37640
+ return path18.resolve(fileURLToPath2(url2));
37156
37641
  } catch {
37157
37642
  return void 0;
37158
37643
  }
@@ -37166,14 +37651,14 @@ function uniquePaths(values) {
37166
37651
  continue;
37167
37652
  }
37168
37653
  seen.add(normalized);
37169
- result.push(path17.resolve(value));
37654
+ result.push(path18.resolve(value));
37170
37655
  }
37171
37656
  return result;
37172
37657
  }
37173
37658
  function normalizePathForCompare2(value) {
37174
- const resolved = path17.resolve(value);
37659
+ const resolved = path18.resolve(value);
37175
37660
  try {
37176
- return fs16.realpathSync.native(resolved);
37661
+ return fs17.realpathSync.native(resolved);
37177
37662
  } catch {
37178
37663
  return resolved;
37179
37664
  }
@@ -37207,10 +37692,13 @@ function formatMakerClientRootsStatus(roots) {
37207
37692
  }
37208
37693
  return lines.join("\n");
37209
37694
  }
37210
- function splitRemoteProxyToolPrivateArgs(args) {
37695
+ function splitRemoteProxyToolPrivateArgs(args, toolName) {
37211
37696
  const remoteArgs = { ...args };
37212
37697
  const targetDir = remoteArgs.target_dir;
37213
37698
  delete remoteArgs.target_dir;
37699
+ if (toolName === "generate_test_qrcode") {
37700
+ delete remoteArgs.confirmed_screen_orientation;
37701
+ }
37214
37702
  if (targetDir === void 0) {
37215
37703
  return { remoteArgs };
37216
37704
  }
@@ -37322,14 +37810,14 @@ function formatStatusProjectList(projects) {
37322
37810
  ].filter((line) => line !== void 0).join("\n");
37323
37811
  }
37324
37812
  function formatClonePartialStateLines(targetDir) {
37325
- const resolvedTargetDir = path17.resolve(targetDir);
37813
+ const resolvedTargetDir = path18.resolve(targetDir);
37326
37814
  const identify = identifyMakerProject({ cwd: resolvedTargetDir });
37327
37815
  const gitStatus = inspectMakerDirectoryGitStatus(resolvedTargetDir);
37328
37816
  const devKitStatus = inspectAiDevKit(resolvedTargetDir);
37329
- const stagedDevKitGitignorePath = path17.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
37817
+ const stagedDevKitGitignorePath = path18.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
37330
37818
  const projectBound = Boolean(identify.projectId);
37331
37819
  const gitInitialized = Boolean(
37332
- gitStatus.isOwnGitRoot || fs16.existsSync(path17.join(resolvedTargetDir, ".git"))
37820
+ gitStatus.isOwnGitRoot || fs17.existsSync(path18.join(resolvedTargetDir, ".git"))
37333
37821
  );
37334
37822
  const safeToRetry = !projectBound;
37335
37823
  return [
@@ -37343,7 +37831,7 @@ function formatClonePartialStateLines(targetDir) {
37343
37831
  identify.configPath ? `- config: ${identify.configPath}` : "",
37344
37832
  `- ai_dev_kit_present: ${devKitStatus.ready ? "yes" : "no"}`,
37345
37833
  `- ai_dev_kit_missing_entries: ${devKitStatus.missingEntries.join(", ") || "(none)"}`,
37346
- `- staged_dev_kit_gitignore: ${fs16.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
37834
+ `- staged_dev_kit_gitignore: ${fs17.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
37347
37835
  `- safe_to_retry: ${safeToRetry ? "yes" : "no"}`,
37348
37836
  safeToRetry ? "- next_step: 可以直接重试 taptap-maker init;如果连续失败,建议换一个全新的独立目录重新 clone。" : "- next_step: 当前目录已经有 Maker 绑定信息;先运行 taptap-maker doctor 或读取 maker://status 确认状态。"
37349
37837
  ].filter(Boolean);
@@ -37419,12 +37907,12 @@ function resolveEmbeddedProxyCommand(options) {
37419
37907
  }
37420
37908
  return {
37421
37909
  command: process.execPath,
37422
- args: [path17.resolve(makerEntry), "__maker-proxy"]
37910
+ args: [path18.resolve(makerEntry), "__maker-proxy"]
37423
37911
  };
37424
37912
  }
37425
37913
  function resolveBundledMakerEntry() {
37426
- const bundledEntry = path17.resolve(__dirname, "../../../bin/taptap-maker");
37427
- return fs16.existsSync(bundledEntry) ? bundledEntry : void 0;
37914
+ const bundledEntry = path18.resolve(__dirname, "../../../bin/taptap-maker");
37915
+ return fs17.existsSync(bundledEntry) ? bundledEntry : void 0;
37428
37916
  }
37429
37917
  function isUsableEmbeddedMakerEntry(entry) {
37430
37918
  if (!entry) {
@@ -37771,18 +38259,18 @@ async function attachRuntimeLogWatch(buildResult, startWatch) {
37771
38259
  }
37772
38260
  }
37773
38261
  async function startRuntimeLogWatch(buildResult) {
37774
- const runtimeDir = path17.join(buildResult.projectRoot, ".maker", "logs", "runtime");
37775
- fs16.mkdirSync(runtimeDir, { recursive: true });
37776
- const stdoutLog = path17.join(runtimeDir, "watcher.out.log");
37777
- const stderrLog = path17.join(runtimeDir, "watcher.err.log");
37778
- const pidFile = path17.join(runtimeDir, "watcher.pid");
38262
+ const runtimeDir = path18.join(buildResult.projectRoot, ".maker", "logs", "runtime");
38263
+ fs17.mkdirSync(runtimeDir, { recursive: true });
38264
+ const stdoutLog = path18.join(runtimeDir, "watcher.out.log");
38265
+ const stderrLog = path18.join(runtimeDir, "watcher.err.log");
38266
+ const pidFile = path18.join(runtimeDir, "watcher.pid");
37779
38267
  const previous = stopExistingRuntimeLogWatcher(pidFile);
37780
- const outFd = fs16.openSync(stdoutLog, "a");
37781
- const errFd = fs16.openSync(stderrLog, "a");
38268
+ const outFd = fs17.openSync(stdoutLog, "a");
38269
+ const errFd = fs17.openSync(stderrLog, "a");
37782
38270
  const command = formatRuntimeLogWatchCommand(buildResult);
37783
38271
  if (previous.previousStopError) {
37784
- fs16.closeSync(outFd);
37785
- fs16.closeSync(errFd);
38272
+ fs17.closeSync(outFd);
38273
+ fs17.closeSync(errFd);
37786
38274
  return {
37787
38275
  started: false,
37788
38276
  command: command.text,
@@ -37845,18 +38333,18 @@ async function startRuntimeLogWatch(buildResult) {
37845
38333
  ...previous
37846
38334
  };
37847
38335
  } finally {
37848
- fs16.closeSync(outFd);
37849
- fs16.closeSync(errFd);
38336
+ fs17.closeSync(outFd);
38337
+ fs17.closeSync(errFd);
37850
38338
  }
37851
38339
  }
37852
38340
  function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
37853
- if (!fs16.existsSync(pidFile)) {
38341
+ if (!fs17.existsSync(pidFile)) {
37854
38342
  return {};
37855
38343
  }
37856
38344
  const pidState = readRuntimeLogWatcherPidState(pidFile);
37857
38345
  const pid = pidState == null ? void 0 : pidState.pid;
37858
38346
  if (!Number.isInteger(pid) || pid <= 0) {
37859
- fs16.rmSync(pidFile, { force: true });
38347
+ fs17.rmSync(pidFile, { force: true });
37860
38348
  return {};
37861
38349
  }
37862
38350
  try {
@@ -37864,7 +38352,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
37864
38352
  const processCommand = (options.getProcessCommand || getProcessCommand)(pid);
37865
38353
  const verifiedCommand = getVerifiedRuntimeLogWatcherCommand(processCommand, pidState);
37866
38354
  if (!verifiedCommand) {
37867
- fs16.rmSync(pidFile, { force: true });
38355
+ fs17.rmSync(pidFile, { force: true });
37868
38356
  return {
37869
38357
  previousPid: pid,
37870
38358
  previousStopped: false,
@@ -37874,7 +38362,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
37874
38362
  process.kill(pid, "SIGTERM");
37875
38363
  const stopped = (options.waitForExit || waitForProcessExit)(pid, WATCHER_STOP_TIMEOUT_MS);
37876
38364
  if (stopped) {
37877
- fs16.rmSync(pidFile, { force: true });
38365
+ fs17.rmSync(pidFile, { force: true });
37878
38366
  return { previousPid: pid, previousStopped: true };
37879
38367
  }
37880
38368
  return {
@@ -37883,7 +38371,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
37883
38371
  previousStopError: `process ${pid} did not exit after SIGTERM within ${WATCHER_STOP_TIMEOUT_MS}ms`
37884
38372
  };
37885
38373
  } catch (error2) {
37886
- fs16.rmSync(pidFile, { force: true });
38374
+ fs17.rmSync(pidFile, { force: true });
37887
38375
  const code = error2 && typeof error2 === "object" && "code" in error2 ? String(error2.code) : "";
37888
38376
  if (code === "ESRCH") {
37889
38377
  return { previousPid: pid, previousStopped: false };
@@ -37896,7 +38384,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
37896
38384
  }
37897
38385
  }
37898
38386
  function readRuntimeLogWatcherPidState(pidFile) {
37899
- const raw = fs16.readFileSync(pidFile, "utf8").trim();
38387
+ const raw = fs17.readFileSync(pidFile, "utf8").trim();
37900
38388
  if (!raw) {
37901
38389
  return null;
37902
38390
  }
@@ -37912,7 +38400,7 @@ function readRuntimeLogWatcherPidState(pidFile) {
37912
38400
  }
37913
38401
  }
37914
38402
  function writeRuntimeLogWatcherPidFile(pidFile, state) {
37915
- fs16.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
38403
+ fs17.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
37916
38404
  `, "utf8");
37917
38405
  }
37918
38406
  function getProcessCommand(pid) {
@@ -37998,10 +38486,10 @@ function formatRuntimeLogWatchCommand(buildResult) {
37998
38486
  };
37999
38487
  }
38000
38488
  function resolveMakerCliEntry() {
38001
- return process.argv[1] || path17.resolve(process.cwd(), "dist", "maker.js");
38489
+ return process.argv[1] || path18.resolve(process.cwd(), "dist", "maker.js");
38002
38490
  }
38003
38491
  function getRuntimeLogFilePath(projectRoot) {
38004
- return path17.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
38492
+ return path18.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
38005
38493
  }
38006
38494
  async function refreshMakerPreview(buildResult) {
38007
38495
  const makerEnv = buildResult.env === "rnd" || buildResult.env === "production" ? buildResult.env : void 0;
@@ -38135,7 +38623,7 @@ function createBuildArgs(projectRoot, options) {
38135
38623
  if (options.scriptsPath) {
38136
38624
  buildArgs.scriptsPath = options.scriptsPath;
38137
38625
  }
38138
- if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs16.existsSync(path17.join(projectRoot, "scripts", "main.lua"))) {
38626
+ if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs17.existsSync(path18.join(projectRoot, "scripts", "main.lua"))) {
38139
38627
  buildArgs.entry = "main.lua";
38140
38628
  buildArgs.scriptsPath = "scripts";
38141
38629
  }
@@ -38147,8 +38635,6 @@ function createBuildArgs(projectRoot, options) {
38147
38635
  }
38148
38636
  if (options.multiplayer) {
38149
38637
  buildArgs.multiplayer = options.multiplayer;
38150
- } else if (!options.entryClient && !options.entryServer && !fs16.existsSync(path17.join(projectRoot, ".project", "settings.json"))) {
38151
- buildArgs.multiplayer = { enabled: false };
38152
38638
  }
38153
38639
  return buildArgs;
38154
38640
  }
@@ -38328,11 +38814,11 @@ function formatRuntimeLogWatchNextActionLines(result) {
38328
38814
  ((_a3 = result.runtimeLogWatch) == null ? void 0 : _a3.pid) ? `- watch_pid: ${result.runtimeLogWatch.pid}` : "",
38329
38815
  `- watch_command: ${command}`,
38330
38816
  ((_b = result.runtimeLogWatch) == null ? void 0 : _b.command) ? `- actual_watch_command: ${result.runtimeLogWatch.command}` : "",
38331
- `- local_file: ${path17.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
38817
+ `- local_file: ${path18.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
38332
38818
  ((_c = result.runtimeLogWatch) == null ? void 0 : _c.stdoutLog) ? `- watcher_stdout: ${result.runtimeLogWatch.stdoutLog}` : "",
38333
38819
  ((_d = result.runtimeLogWatch) == null ? void 0 : _d.stderrLog) ? `- watcher_stderr: ${result.runtimeLogWatch.stderrLog}` : "",
38334
38820
  ((_e = result.runtimeLogWatch) == null ? void 0 : _e.pidFile) ? `- watcher_pid_file: ${result.runtimeLogWatch.pidFile}` : "",
38335
- `- state_file: ${path17.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
38821
+ `- state_file: ${path18.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
38336
38822
  ((_f = result.runtimeLogWatch) == null ? void 0 : _f.previousPid) ? `- previous_watch_pid: ${result.runtimeLogWatch.previousPid}` : "",
38337
38823
  ((_g = result.runtimeLogWatch) == null ? void 0 : _g.previousStopped) !== void 0 ? `- previous_watch_stopped: ${result.runtimeLogWatch.previousStopped ? "yes" : "no"}` : "",
38338
38824
  ((_h = result.runtimeLogWatch) == null ? void 0 : _h.previousStopError) ? `- previous_watch_stop_error: ${result.runtimeLogWatch.previousStopError}` : "",
@@ -38593,9 +39079,9 @@ function indent2(value) {
38593
39079
  // src/maker/cli/commands.ts
38594
39080
  import { spawnSync as spawnSync7 } from "node:child_process";
38595
39081
  import crypto3 from "node:crypto";
38596
- import fs17 from "node:fs";
39082
+ import fs18 from "node:fs";
38597
39083
  import os4 from "node:os";
38598
- import path18 from "node:path";
39084
+ import path19 from "node:path";
38599
39085
  import readline from "node:readline/promises";
38600
39086
  import { stdin as input, stdout as output } from "node:process";
38601
39087
 
@@ -38741,7 +39227,7 @@ function formatError2(error2) {
38741
39227
  }
38742
39228
 
38743
39229
  // src/maker/cli/commands.ts
38744
- var VERSION2 = true ? "0.0.26-beta.1" : "dev";
39230
+ var VERSION2 = true ? "0.0.26-beta.3" : "dev";
38745
39231
  var DEFAULT_MCP_NAME = "taptap-maker";
38746
39232
  var MAKER_NPM_PACKAGE = "@taptap/maker";
38747
39233
  var TWO_PART_COMMANDS = /* @__PURE__ */ new Set(["pat", "mcp", "dev-kit", "logs", "python", "lua-lsp", "agents"]);
@@ -38876,7 +39362,7 @@ function toOptionKey(value) {
38876
39362
  }
38877
39363
  async function runInit(parsed, ctx) {
38878
39364
  rejectPackageOption(parsed);
38879
- const targetDir = path18.resolve(stringOption(parsed, "target_dir") || process.cwd());
39365
+ const targetDir = path19.resolve(stringOption(parsed, "target_dir") || process.cwd());
38880
39366
  const env = makerEnvOption(parsed);
38881
39367
  const skipConfirm = booleanOption(parsed, "skip_confirm");
38882
39368
  const skipMcpInstall = booleanOption(parsed, "skip_mcp_install");
@@ -38969,7 +39455,7 @@ async function runInit(parsed, ctx) {
38969
39455
  }
38970
39456
  async function runDoctor(parsed, ctx) {
38971
39457
  var _a3, _b;
38972
- const targetDir = path18.resolve(stringOption(parsed, "target_dir") || process.cwd());
39458
+ const targetDir = path19.resolve(stringOption(parsed, "target_dir") || process.cwd());
38973
39459
  const env = makerEnvOption(parsed);
38974
39460
  const git = checkGitEnvironment();
38975
39461
  const python = checkMakerPythonEnvironment();
@@ -39063,9 +39549,9 @@ async function runDoctor(parsed, ctx) {
39063
39549
  );
39064
39550
  }
39065
39551
  function inspectMakerMcpToolsAvailability(options) {
39066
- const aiPwd = path18.resolve(process.cwd());
39552
+ const aiPwd = path19.resolve(process.cwd());
39067
39553
  const aiPwdIdentify = identifyMakerProject({ cwd: aiPwd });
39068
- const makerProjectDir = options.makerProjectDir ? path18.resolve(options.makerProjectDir) : void 0;
39554
+ const makerProjectDir = options.makerProjectDir ? path19.resolve(options.makerProjectDir) : void 0;
39069
39555
  if (!makerProjectDir) {
39070
39556
  return {
39071
39557
  tools_visibility: "refresh_ai_client_if_missing",
@@ -39107,9 +39593,9 @@ function samePath2(left, right) {
39107
39593
  return normalizePathForCompare3(left) === normalizePathForCompare3(right);
39108
39594
  }
39109
39595
  function normalizePathForCompare3(value) {
39110
- const resolved = path18.resolve(value);
39596
+ const resolved = path19.resolve(value);
39111
39597
  try {
39112
- return fs17.realpathSync.native(resolved);
39598
+ return fs18.realpathSync.native(resolved);
39113
39599
  } catch {
39114
39600
  return resolved;
39115
39601
  }
@@ -39427,7 +39913,7 @@ async function runPatSet(parsed, ctx) {
39427
39913
  }
39428
39914
  async function resolvePatSet(parsed, ctx) {
39429
39915
  if (booleanOption(parsed, "pat_stdin") || booleanOption(parsed, "pat_from_stdin")) {
39430
- const pat = fs17.readFileSync(0, "utf8").trim();
39916
+ const pat = fs18.readFileSync(0, "utf8").trim();
39431
39917
  if (!pat) {
39432
39918
  throw new Error("No PAT found on stdin.");
39433
39919
  }
@@ -39457,7 +39943,7 @@ async function runMcpInstall(parsed, ctx) {
39457
39943
  env: makerEnvOption(parsed),
39458
39944
  pkg: MAKER_NPM_PACKAGE,
39459
39945
  mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
39460
- cwd: explicitTargetDir ? path18.resolve(explicitTargetDir) : void 0
39946
+ cwd: explicitTargetDir ? path19.resolve(explicitTargetDir) : void 0
39461
39947
  });
39462
39948
  if (ctx.json) {
39463
39949
  writeJson(results);
@@ -39516,7 +40002,7 @@ ${indent3(payload.stderr)}` : "",
39516
40002
  );
39517
40003
  }
39518
40004
  async function runAgentsUpdate(parsed, ctx) {
39519
- const targetDir = path18.resolve(stringOption(parsed, "target_dir") || process.cwd());
40005
+ const targetDir = path19.resolve(stringOption(parsed, "target_dir") || process.cwd());
39520
40006
  const result = updateMakerAgentsPolicy(targetDir);
39521
40007
  if (ctx.json) {
39522
40008
  writeJson(result);
@@ -39535,7 +40021,7 @@ async function runAgentsUpdate(parsed, ctx) {
39535
40021
  async function runUpgrade(parsed, ctx) {
39536
40022
  rejectPackageOption(parsed);
39537
40023
  const explicitTargetDir = stringOption(parsed, "target_dir");
39538
- const targetDir = path18.resolve(explicitTargetDir || process.cwd());
40024
+ const targetDir = path19.resolve(explicitTargetDir || process.cwd());
39539
40025
  const env = makerEnvOption(parsed);
39540
40026
  const ides = parseIdeList(stringOption(parsed, "ide") || stringOption(parsed, "ides") || "");
39541
40027
  const installResults = installMcpConfigs({
@@ -39620,7 +40106,7 @@ function getMcpVerifyNextSteps(mode, commandText) {
39620
40106
  ];
39621
40107
  }
39622
40108
  async function runDevKitUpdate(parsed, ctx) {
39623
- const targetDir = path18.resolve(stringOption(parsed, "target_dir") || process.cwd());
40109
+ const targetDir = path19.resolve(stringOption(parsed, "target_dir") || process.cwd());
39624
40110
  const result = await installAiDevKit({
39625
40111
  targetDir,
39626
40112
  preserveExisting: false,
@@ -39632,7 +40118,7 @@ async function runDevKitUpdate(parsed, ctx) {
39632
40118
  emitDevKitSkillInstallerFailure(ctx, result.skillInstaller, "AI skills install failed");
39633
40119
  }
39634
40120
  async function runLogsWatch(parsed, ctx) {
39635
- const targetDir = path18.resolve(stringOption(parsed, "target_dir") || process.cwd());
40121
+ const targetDir = path19.resolve(stringOption(parsed, "target_dir") || process.cwd());
39636
40122
  const intervalMs = parseDurationMs(stringOption(parsed, "interval") || "5s");
39637
40123
  const timeoutMs = numberOption(parsed, "timeout_ms") ?? DEFAULT_TOOL_CALL_TIMEOUT_MS;
39638
40124
  const maxPolls = numberOption(parsed, "max_polls");
@@ -39642,9 +40128,9 @@ async function runLogsWatch(parsed, ctx) {
39642
40128
  serverUrl: stringOption(parsed, "server_url"),
39643
40129
  env: makerEnvOption(parsed)
39644
40130
  });
39645
- const runtimeDir = path18.join(proxy.projectRoot, ".maker", "logs", "runtime");
39646
- const runtimeLog = path18.join(runtimeDir, "runtime.log");
39647
- const pidFile = path18.join(runtimeDir, "watcher.pid");
40131
+ const runtimeDir = path19.join(proxy.projectRoot, ".maker", "logs", "runtime");
40132
+ const runtimeLog = path19.join(runtimeDir, "runtime.log");
40133
+ const pidFile = path19.join(runtimeDir, "watcher.pid");
39648
40134
  const replacedWatcher = registerRuntimeLogWatcherProcess(pidFile);
39649
40135
  const runtimeLogClient = createRemoteRuntimeLogClient(proxy, timeoutMs);
39650
40136
  emit(ctx, "logs_watch_start", "Maker runtime log watcher started", {
@@ -39689,10 +40175,10 @@ async function runLogsWatch(parsed, ctx) {
39689
40175
  }
39690
40176
  }
39691
40177
  function registerRuntimeLogWatcherProcess(pidFile) {
39692
- fs17.mkdirSync(path18.dirname(pidFile), { recursive: true });
40178
+ fs18.mkdirSync(path19.dirname(pidFile), { recursive: true });
39693
40179
  const existingPid = readPidFile(pidFile);
39694
40180
  const previous = existingPid && existingPid !== process.pid ? stopExistingRuntimeLogWatcher(pidFile) : {};
39695
- fs17.writeFileSync(
40181
+ fs18.writeFileSync(
39696
40182
  pidFile,
39697
40183
  `${JSON.stringify(
39698
40184
  {
@@ -39710,10 +40196,10 @@ function registerRuntimeLogWatcherProcess(pidFile) {
39710
40196
  return previous;
39711
40197
  }
39712
40198
  function readPidFile(pidFile) {
39713
- if (!fs17.existsSync(pidFile)) {
40199
+ if (!fs18.existsSync(pidFile)) {
39714
40200
  return void 0;
39715
40201
  }
39716
- const raw = fs17.readFileSync(pidFile, "utf8").trim();
40202
+ const raw = fs18.readFileSync(pidFile, "utf8").trim();
39717
40203
  let pid = Number(raw);
39718
40204
  if (!Number.isInteger(pid) || pid <= 0) {
39719
40205
  try {
@@ -39733,7 +40219,7 @@ function installRuntimeLogWatcherPidCleanup(pidFile) {
39733
40219
  }
39734
40220
  cleaned = true;
39735
40221
  if (readPidFile(pidFile) === process.pid) {
39736
- fs17.rmSync(pidFile, { force: true });
40222
+ fs18.rmSync(pidFile, { force: true });
39737
40223
  }
39738
40224
  };
39739
40225
  process.once("exit", cleanup);
@@ -39884,7 +40370,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
39884
40370
  onStart: (event) => emitSkillInstallerStart(ctx, event)
39885
40371
  });
39886
40372
  writeDevKitStagedGitignore(
39887
- path18.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
40373
+ path19.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
39888
40374
  listPresentDevKitManagedEntries(targetDir)
39889
40375
  );
39890
40376
  if (options.finalizeGitignore) {
@@ -39901,7 +40387,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
39901
40387
  );
39902
40388
  } catch (error2) {
39903
40389
  writeDevKitStagedGitignore(
39904
- path18.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
40390
+ path19.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
39905
40391
  listPresentDevKitManagedEntries(targetDir)
39906
40392
  );
39907
40393
  if (options.finalizeGitignore) {
@@ -39991,12 +40477,12 @@ function installMcpConfig(ide, options) {
39991
40477
  }
39992
40478
  function installMcpConfigUnsafe(ide, options) {
39993
40479
  if (ide === "codex") {
39994
- const configPath = path18.join(os4.homedir(), ".codex", "config.toml");
40480
+ const configPath = path19.join(os4.homedir(), ".codex", "config.toml");
39995
40481
  const write = mergeCodexMcpConfig(configPath, withClientIde(options, "codex"));
39996
40482
  return [createMcpInstallResult(ide, "Codex", configPath, write)];
39997
40483
  }
39998
40484
  if (ide === "cursor") {
39999
- const configPath = path18.join(os4.homedir(), ".cursor", "mcp.json");
40485
+ const configPath = path19.join(os4.homedir(), ".cursor", "mcp.json");
40000
40486
  const write = mergeJsonMcpConfig(configPath, withClientIde(options, "cursor"));
40001
40487
  return [createMcpInstallResult(ide, "Cursor", configPath, write)];
40002
40488
  }
@@ -40014,7 +40500,7 @@ function installMcpConfigUnsafe(ide, options) {
40014
40500
  ];
40015
40501
  }
40016
40502
  }
40017
- const configPath = path18.join(os4.homedir(), ".claude.json");
40503
+ const configPath = path19.join(os4.homedir(), ".claude.json");
40018
40504
  const write = mergeJsonMcpConfig(configPath, claudeOptions);
40019
40505
  return [createMcpInstallResult(ide, "Claude fallback", configPath, write)];
40020
40506
  }
@@ -40028,7 +40514,7 @@ function installMcpConfigUnsafe(ide, options) {
40028
40514
  }
40029
40515
  if (ide === "opencode") {
40030
40516
  const configPath = getOpenCodeMcpConfigPath();
40031
- if (!fs17.existsSync(configPath)) {
40517
+ if (!fs18.existsSync(configPath)) {
40032
40518
  return [{ ide, ok: false, message: "Skipped OpenCode: no supported config file found" }];
40033
40519
  }
40034
40520
  const write = mergeOpenCodeMcpConfig(configPath, withClientIde(options, "opencode"));
@@ -40096,7 +40582,7 @@ function getDefaultMcpInstallIdes() {
40096
40582
  if (getTraeMcpInstallPaths().length > 0) {
40097
40583
  ides.push("trae");
40098
40584
  }
40099
- if (fs17.existsSync(getOpenCodeMcpConfigPath())) {
40585
+ if (fs18.existsSync(getOpenCodeMcpConfigPath())) {
40100
40586
  ides.push("opencode");
40101
40587
  }
40102
40588
  if (getWorkBuddyMcpInstallPaths().length > 0) {
@@ -40113,7 +40599,7 @@ function getExistingTraeUserConfigPaths(paths) {
40113
40599
  const seen = /* @__PURE__ */ new Set();
40114
40600
  return paths.filter((configPath) => {
40115
40601
  const key = normalizeConfigPathKey(configPath);
40116
- if (seen.has(key) || !fs17.existsSync(path18.dirname(configPath))) {
40602
+ if (seen.has(key) || !fs18.existsSync(path19.dirname(configPath))) {
40117
40603
  return false;
40118
40604
  }
40119
40605
  seen.add(key);
@@ -40124,7 +40610,7 @@ function getExistingConfigPaths(paths) {
40124
40610
  const seen = /* @__PURE__ */ new Set();
40125
40611
  return paths.filter((configPath) => {
40126
40612
  const key = normalizeConfigPathKey(configPath);
40127
- if (seen.has(key) || !fs17.existsSync(configPath)) {
40613
+ if (seen.has(key) || !fs18.existsSync(configPath)) {
40128
40614
  return false;
40129
40615
  }
40130
40616
  seen.add(key);
@@ -40132,65 +40618,65 @@ function getExistingConfigPaths(paths) {
40132
40618
  });
40133
40619
  }
40134
40620
  function normalizeConfigPathKey(configPath) {
40135
- const resolved = path18.resolve(configPath);
40621
+ const resolved = path19.resolve(configPath);
40136
40622
  return process.platform === "win32" || process.platform === "darwin" ? resolved.toLowerCase() : resolved;
40137
40623
  }
40138
40624
  function getTraeSoloMcpConfigPaths() {
40139
40625
  if (process.platform === "win32") {
40140
- const roaming = process.env.APPDATA || path18.join(os4.homedir(), "AppData", "Roaming");
40626
+ const roaming = process.env.APPDATA || path19.join(os4.homedir(), "AppData", "Roaming");
40141
40627
  return [
40142
- path18.join(roaming, "TRAE SOLO", "User", "mcp.json"),
40143
- path18.join(roaming, "TRAE SOLO CN", "User", "mcp.json")
40628
+ path19.join(roaming, "TRAE SOLO", "User", "mcp.json"),
40629
+ path19.join(roaming, "TRAE SOLO CN", "User", "mcp.json")
40144
40630
  ];
40145
40631
  }
40146
- const appSupport = path18.join(os4.homedir(), "Library", "Application Support");
40632
+ const appSupport = path19.join(os4.homedir(), "Library", "Application Support");
40147
40633
  return [
40148
- path18.join(appSupport, "TRAE SOLO CN", "User", "mcp.json"),
40149
- path18.join(appSupport, "TRAE SOLO", "User", "mcp.json")
40634
+ path19.join(appSupport, "TRAE SOLO CN", "User", "mcp.json"),
40635
+ path19.join(appSupport, "TRAE SOLO", "User", "mcp.json")
40150
40636
  ];
40151
40637
  }
40152
40638
  function getTraeUnverifiedMcpConfigPaths() {
40153
40639
  if (process.platform === "win32") {
40154
- const roaming = process.env.APPDATA || path18.join(os4.homedir(), "AppData", "Roaming");
40640
+ const roaming = process.env.APPDATA || path19.join(os4.homedir(), "AppData", "Roaming");
40155
40641
  return [
40156
- path18.join(roaming, "Trae", "User", "mcp.json"),
40157
- path18.join(roaming, "TRAE", "User", "mcp.json"),
40158
- path18.join(roaming, "Trae CN", "User", "mcp.json")
40642
+ path19.join(roaming, "Trae", "User", "mcp.json"),
40643
+ path19.join(roaming, "TRAE", "User", "mcp.json"),
40644
+ path19.join(roaming, "Trae CN", "User", "mcp.json")
40159
40645
  ];
40160
40646
  }
40161
- const appSupport = path18.join(os4.homedir(), "Library", "Application Support");
40647
+ const appSupport = path19.join(os4.homedir(), "Library", "Application Support");
40162
40648
  return [
40163
- path18.join(appSupport, "Trae", "User", "mcp.json"),
40164
- path18.join(appSupport, "TRAE", "User", "mcp.json"),
40165
- path18.join(appSupport, "Trae CN", "User", "mcp.json")
40649
+ path19.join(appSupport, "Trae", "User", "mcp.json"),
40650
+ path19.join(appSupport, "TRAE", "User", "mcp.json"),
40651
+ path19.join(appSupport, "Trae CN", "User", "mcp.json")
40166
40652
  ];
40167
40653
  }
40168
40654
  function getOpenCodeMcpConfigPath() {
40169
- return path18.join(os4.homedir(), ".config", "opencode", "opencode.jsonc");
40655
+ return path19.join(os4.homedir(), ".config", "opencode", "opencode.jsonc");
40170
40656
  }
40171
40657
  function getWorkBuddyHome() {
40172
- return path18.join(os4.homedir(), ".workbuddy");
40658
+ return path19.join(os4.homedir(), ".workbuddy");
40173
40659
  }
40174
40660
  function shouldShowWorkBuddyTrustInspection() {
40175
- return fs17.existsSync(getWorkBuddyHome());
40661
+ return fs18.existsSync(getWorkBuddyHome());
40176
40662
  }
40177
40663
  function getWorkBuddyMcpInstallPaths(options = {}) {
40178
- const primary = path18.join(getWorkBuddyHome(), "mcp.json");
40179
- if (fs17.existsSync(primary) || options.createPrimary) {
40664
+ const primary = path19.join(getWorkBuddyHome(), "mcp.json");
40665
+ if (fs18.existsSync(primary) || options.createPrimary) {
40180
40666
  return [primary];
40181
40667
  }
40182
- const legacy = path18.join(getWorkBuddyHome(), ".mcp.json");
40183
- if (fs17.existsSync(legacy)) {
40668
+ const legacy = path19.join(getWorkBuddyHome(), ".mcp.json");
40669
+ if (fs18.existsSync(legacy)) {
40184
40670
  return [legacy];
40185
40671
  }
40186
40672
  return [];
40187
40673
  }
40188
40674
  function inspectWorkBuddyTrustState(mcpName) {
40189
40675
  const workbuddyHome = getWorkBuddyHome();
40190
- const connectorsDir = path18.join(workbuddyHome, "connectors");
40676
+ const connectorsDir = path19.join(workbuddyHome, "connectors");
40191
40677
  const accounts = [];
40192
40678
  const stateFiles = [];
40193
- if (!fs17.existsSync(connectorsDir)) {
40679
+ if (!fs18.existsSync(connectorsDir)) {
40194
40680
  return {
40195
40681
  status: "not_found",
40196
40682
  mcp_name: mcpName,
@@ -40200,12 +40686,12 @@ function inspectWorkBuddyTrustState(mcpName) {
40200
40686
  accounts
40201
40687
  };
40202
40688
  }
40203
- for (const entry of fs17.readdirSync(connectorsDir, { withFileTypes: true })) {
40689
+ for (const entry of fs18.readdirSync(connectorsDir, { withFileTypes: true })) {
40204
40690
  if (!entry.isDirectory()) {
40205
40691
  continue;
40206
40692
  }
40207
- const statePath = path18.join(connectorsDir, entry.name, "connector-states.json");
40208
- if (!fs17.existsSync(statePath)) {
40693
+ const statePath = path19.join(connectorsDir, entry.name, "connector-states.json");
40694
+ if (!fs18.existsSync(statePath)) {
40209
40695
  continue;
40210
40696
  }
40211
40697
  stateFiles.push(statePath);
@@ -40280,7 +40766,7 @@ function mergeJsonMcpConfig(configPath, options) {
40280
40766
  );
40281
40767
  }
40282
40768
  function mergeOpenCodeMcpConfig(configPath, options) {
40283
- const rawContent = fs17.readFileSync(configPath, "utf8");
40769
+ const rawContent = fs18.readFileSync(configPath, "utf8");
40284
40770
  const rewroteJsonc = normalizeJsonConfigContent(rawContent, { jsonc: true }) !== rawContent;
40285
40771
  const existing = readJsonObject(configPath, { jsonc: true });
40286
40772
  const mcp = asObject(existing.mcp);
@@ -40307,7 +40793,7 @@ function mergeOpenCodeMcpConfig(configPath, options) {
40307
40793
  return { ...write, rewroteJsonc: write.changed && rewroteJsonc };
40308
40794
  }
40309
40795
  function mergeCodexMcpConfig(configPath, options) {
40310
- const existing = fs17.existsSync(configPath) ? fs17.readFileSync(configPath, "utf8") : "";
40796
+ const existing = fs18.existsSync(configPath) ? fs18.readFileSync(configPath, "utf8") : "";
40311
40797
  const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
40312
40798
  const withoutOld = existing.replace(sectionPattern, "").trimEnd();
40313
40799
  const launch = getNpxCliCommand(options.pkg);
@@ -40477,10 +40963,10 @@ function rejectPackageOption(parsed) {
40477
40963
  }
40478
40964
  }
40479
40965
  function readJsonObject(filePath, options = {}) {
40480
- if (!fs17.existsSync(filePath)) {
40966
+ if (!fs18.existsSync(filePath)) {
40481
40967
  return {};
40482
40968
  }
40483
- const raw = fs17.readFileSync(filePath, "utf8");
40969
+ const raw = fs18.readFileSync(filePath, "utf8");
40484
40970
  try {
40485
40971
  const normalized = normalizeJsonConfigContent(raw, options);
40486
40972
  const parsed = JSON.parse(normalized);
@@ -40500,25 +40986,25 @@ function asObject(value) {
40500
40986
  return {};
40501
40987
  }
40502
40988
  function writeConfigWithTapTapBackupIfChanged(filePath, nextContent, validate) {
40503
- const existed = fs17.existsSync(filePath);
40504
- const previousContent = existed ? fs17.readFileSync(filePath, "utf8") : void 0;
40989
+ const existed = fs18.existsSync(filePath);
40990
+ const previousContent = existed ? fs18.readFileSync(filePath, "utf8") : void 0;
40505
40991
  if (previousContent === nextContent) {
40506
40992
  return { changed: false };
40507
40993
  }
40508
40994
  const backupPath = existed ? `${filePath}.taptap-maker.bak.latest` : void 0;
40509
- fs17.mkdirSync(path18.dirname(filePath), { recursive: true });
40995
+ fs18.mkdirSync(path19.dirname(filePath), { recursive: true });
40510
40996
  if (previousContent !== void 0 && backupPath) {
40511
- fs17.writeFileSync(backupPath, previousContent, "utf8");
40997
+ fs18.writeFileSync(backupPath, previousContent, "utf8");
40512
40998
  }
40513
40999
  try {
40514
- fs17.writeFileSync(filePath, nextContent, "utf8");
40515
- validate == null ? void 0 : validate(fs17.readFileSync(filePath, "utf8"));
41000
+ fs18.writeFileSync(filePath, nextContent, "utf8");
41001
+ validate == null ? void 0 : validate(fs18.readFileSync(filePath, "utf8"));
40516
41002
  return { changed: true, backupPath };
40517
41003
  } catch (error2) {
40518
41004
  if (previousContent !== void 0) {
40519
- fs17.writeFileSync(filePath, previousContent, "utf8");
41005
+ fs18.writeFileSync(filePath, previousContent, "utf8");
40520
41006
  } else {
40521
- fs17.rmSync(filePath, { force: true });
41007
+ fs18.rmSync(filePath, { force: true });
40522
41008
  }
40523
41009
  throw error2;
40524
41010
  }
@@ -40665,10 +41151,10 @@ function formatMcpInstallMessage(label, configPath, write) {
40665
41151
  ].filter(Boolean).join("\n");
40666
41152
  }
40667
41153
  function saveInitState(targetDir, state) {
40668
- fs17.mkdirSync(getMakerHome(), { recursive: true });
40669
- const key = crypto3.createHash("sha256").update(path18.resolve(targetDir)).digest("hex").slice(0, 16);
40670
- fs17.writeFileSync(
40671
- path18.join(getMakerHome(), `init-state-${key}.json`),
41154
+ fs18.mkdirSync(getMakerHome(), { recursive: true });
41155
+ const key = crypto3.createHash("sha256").update(path19.resolve(targetDir)).digest("hex").slice(0, 16);
41156
+ fs18.writeFileSync(
41157
+ path19.join(getMakerHome(), `init-state-${key}.json`),
40672
41158
  `${JSON.stringify({ ...state, updated_at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)}
40673
41159
  `,
40674
41160
  "utf8"
@@ -40816,7 +41302,7 @@ function makerEnvOption(parsed) {
40816
41302
  return env;
40817
41303
  }
40818
41304
  const targetDir = stringOption(parsed, "target_dir");
40819
- return getMakerEnvironment(void 0, targetDir ? path18.resolve(targetDir) : process.cwd());
41305
+ return getMakerEnvironment(void 0, targetDir ? path19.resolve(targetDir) : process.cwd());
40820
41306
  }
40821
41307
  function mcpVerifyModeOption(parsed) {
40822
41308
  const mode = stringOption(parsed, "mode") || "npx";
@@ -42318,7 +42804,7 @@ var StreamableHTTPClientTransport = class {
42318
42804
  };
42319
42805
 
42320
42806
  // src/mcp-proxy/proxy.ts
42321
- import * as path20 from "node:path";
42807
+ import * as path21 from "node:path";
42322
42808
  import * as crypto6 from "node:crypto";
42323
42809
 
42324
42810
  // src/mcp-proxy/cookieJar.ts
@@ -42500,8 +42986,8 @@ function createCookieFetch(cookieJar) {
42500
42986
  }
42501
42987
 
42502
42988
  // src/core/utils/logWriter.ts
42503
- import * as fs18 from "node:fs";
42504
- import * as path19 from "node:path";
42989
+ import * as fs19 from "node:fs";
42990
+ import * as path20 from "node:path";
42505
42991
  import * as crypto5 from "node:crypto";
42506
42992
 
42507
42993
  // src/core/types/log.ts
@@ -42542,7 +43028,7 @@ var LogWriter = class {
42542
43028
  return;
42543
43029
  }
42544
43030
  try {
42545
- await fs18.promises.mkdir(this.config.logDir, { recursive: true });
43031
+ await fs19.promises.mkdir(this.config.logDir, { recursive: true });
42546
43032
  await this.cleanupOldLogs();
42547
43033
  this.initialized = true;
42548
43034
  } catch (error2) {
@@ -42565,7 +43051,7 @@ var LogWriter = class {
42565
43051
  */
42566
43052
  getLogFilePath(date5) {
42567
43053
  const d = date5 || this.getCurrentDate();
42568
- return path19.join(this.config.logDir, `${this.config.prefix}-${d}.log`);
43054
+ return path20.join(this.config.logDir, `${this.config.prefix}-${d}.log`);
42569
43055
  }
42570
43056
  /**
42571
43057
  * 获取或创建写入流
@@ -42580,7 +43066,7 @@ var LogWriter = class {
42580
43066
  }
42581
43067
  this.currentDate = date5;
42582
43068
  try {
42583
- this.writeStream = fs18.createWriteStream(this.getLogFilePath(date5), {
43069
+ this.writeStream = fs19.createWriteStream(this.getLogFilePath(date5), {
42584
43070
  flags: "a",
42585
43071
  encoding: "utf8"
42586
43072
  });
@@ -42632,11 +43118,11 @@ var LogWriter = class {
42632
43118
  if (this.shouldWriteToFile(level) && this.initialized && this.config.enabled) {
42633
43119
  try {
42634
43120
  const filePath = this.getLogFilePath();
42635
- const dir = path19.dirname(filePath);
42636
- if (!fs18.existsSync(dir)) {
42637
- fs18.mkdirSync(dir, { recursive: true });
43121
+ const dir = path20.dirname(filePath);
43122
+ if (!fs19.existsSync(dir)) {
43123
+ fs19.mkdirSync(dir, { recursive: true });
42638
43124
  }
42639
- fs18.appendFileSync(filePath, message, "utf8");
43125
+ fs19.appendFileSync(filePath, message, "utf8");
42640
43126
  } catch {
42641
43127
  }
42642
43128
  }
@@ -42647,7 +43133,7 @@ var LogWriter = class {
42647
43133
  async cleanupOldLogs() {
42648
43134
  if (this.config.maxDays <= 0) return;
42649
43135
  try {
42650
- const files = await fs18.promises.readdir(this.config.logDir);
43136
+ const files = await fs19.promises.readdir(this.config.logDir);
42651
43137
  const cutoffDate = /* @__PURE__ */ new Date();
42652
43138
  cutoffDate.setDate(cutoffDate.getDate() - this.config.maxDays);
42653
43139
  const prefix = this.config.prefix;
@@ -42662,7 +43148,7 @@ var LogWriter = class {
42662
43148
  if (!Number.isNaN(year) && !Number.isNaN(month) && !Number.isNaN(day)) {
42663
43149
  const fileDate = new Date(year, month - 1, day);
42664
43150
  if (fileDate < cutoffDate) {
42665
- await fs18.promises.unlink(path19.join(this.config.logDir, file2));
43151
+ await fs19.promises.unlink(path20.join(this.config.logDir, file2));
42666
43152
  process.stderr.write(`[LogWriter] Deleted old log: ${file2}
42667
43153
  `);
42668
43154
  }
@@ -42736,10 +43222,10 @@ var TapTapMCPProxy = class {
42736
43222
  const { user_id, project_id } = this.config.tenant;
42737
43223
  let logDir;
42738
43224
  if (user_id && project_id) {
42739
- logDir = path20.join(logRoot, "proxy", user_id, project_id);
43225
+ logDir = path21.join(logRoot, "proxy", user_id, project_id);
42740
43226
  } else {
42741
43227
  const kidHash = crypto6.createHash("sha256").update(this.config.auth.kid).digest("hex").substring(0, 8);
42742
- logDir = path20.join(logRoot, "proxy", kidHash);
43228
+ logDir = path21.join(logRoot, "proxy", kidHash);
42743
43229
  }
42744
43230
  return new LogWriter({
42745
43231
  logDir,