@taptap/maker 0.0.24-beta.1 → 0.0.24

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(path20) {
3237
- let input2 = path20;
3236
+ function removeDotSegments(path21) {
3237
+ let input2 = path21;
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 [path20, query] = wsComponent.resourceName.split("?");
3437
- wsComponent.path = path20 && path20 !== "/" ? path20 : void 0;
3436
+ const [path21, query] = wsComponent.resourceName.split("?");
3437
+ wsComponent.path = path21 && path21 !== "/" ? path21 : 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, fs18, exportName) {
12494
+ function addFormats(ajv, list, fs19, 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, fs18[f]);
12499
+ ajv.addFormat(f, fs19[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 fs18 = __require("fs");
12513
- function checkPathExt(path20, options) {
12512
+ var fs19 = __require("fs");
12513
+ function checkPathExt(path21, 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 && path20.substr(-p.length).toLowerCase() === p) {
12524
+ if (p && path21.substr(-p.length).toLowerCase() === p) {
12525
12525
  return true;
12526
12526
  }
12527
12527
  }
12528
12528
  return false;
12529
12529
  }
12530
- function checkStat(stat, path20, options) {
12530
+ function checkStat(stat, path21, options) {
12531
12531
  if (!stat.isSymbolicLink() && !stat.isFile()) {
12532
12532
  return false;
12533
12533
  }
12534
- return checkPathExt(path20, options);
12534
+ return checkPathExt(path21, options);
12535
12535
  }
12536
- function isexe(path20, options, cb) {
12537
- fs18.stat(path20, function(er, stat) {
12538
- cb(er, er ? false : checkStat(stat, path20, options));
12536
+ function isexe(path21, options, cb) {
12537
+ fs19.stat(path21, function(er, stat) {
12538
+ cb(er, er ? false : checkStat(stat, path21, options));
12539
12539
  });
12540
12540
  }
12541
- function sync(path20, options) {
12542
- return checkStat(fs18.statSync(path20), path20, options);
12541
+ function sync(path21, options) {
12542
+ return checkStat(fs19.statSync(path21), path21, 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 fs18 = __require("fs");
12553
- function isexe(path20, options, cb) {
12554
- fs18.stat(path20, function(er, stat) {
12552
+ var fs19 = __require("fs");
12553
+ function isexe(path21, options, cb) {
12554
+ fs19.stat(path21, function(er, stat) {
12555
12555
  cb(er, er ? false : checkStat(stat, options));
12556
12556
  });
12557
12557
  }
12558
- function sync(path20, options) {
12559
- return checkStat(fs18.statSync(path20), options);
12558
+ function sync(path21, options) {
12559
+ return checkStat(fs19.statSync(path21), 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 fs18 = __require("fs");
12583
+ var fs19 = __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(path20, options, cb) {
12592
+ function isexe(path21, 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(path20, options || {}, function(er, is) {
12602
+ isexe(path21, 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(path20, options || {}, function(er, is) {
12611
+ core(path21, 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(path20, options) {
12621
+ function sync(path21, options) {
12622
12622
  try {
12623
- return core.sync(path20, options || {});
12623
+ return core.sync(path21, 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 path20 = __require("path");
12639
+ var path21 = __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 = path20.join(pathPart, cmd);
12677
+ const pCmd = path21.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 = path20.join(pathPart, cmd);
12704
+ const pCmd = path21.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 path20 = __require("path");
12752
+ var path21 = __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 ? path20.delimiter : void 0
12770
+ pathExt: withoutPathExt ? path21.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 = path20.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
12779
+ resolved = path21.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 [path20, argument] = match[0].replace(/#! ?/, "").split(" ");
12834
- const binary = path20.split("/").pop();
12833
+ const [path21, argument] = match[0].replace(/#! ?/, "").split(" ");
12834
+ const binary = path21.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 fs18 = __require("fs");
12847
+ var fs19 = __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 = fs18.openSync(command, "r");
12855
- fs18.readSync(fd, buffer, 0, size, 0);
12856
- fs18.closeSync(fd);
12854
+ fd = fs19.openSync(command, "r");
12855
+ fs19.readSync(fd, buffer, 0, size, 0);
12856
+ fs19.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 path20 = __require("path");
12869
+ var path21 = __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 = path20.normalize(parsed.command);
12894
+ parsed.command = path21.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 fs15 from "node:fs";
13007
- import path16 from "node:path";
13006
+ import fs16 from "node:fs";
13007
+ import path17 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: path20, errorMaps, issueData } = params;
13370
- const fullPath = [...path20, ...issueData.path || []];
13369
+ const { data, path: path21, errorMaps, issueData } = params;
13370
+ const fullPath = [...path21, ...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, path20, key) {
13485
+ constructor(parent, value, path21, key) {
13486
13486
  this._cachedPath = [];
13487
13487
  this.parent = parent;
13488
13488
  this.data = value;
13489
- this._path = path20;
13489
+ this._path = path21;
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, path20) {
17139
- if (!path20)
17138
+ function getElementAtPath(obj, path21) {
17139
+ if (!path21)
17140
17140
  return obj;
17141
- return path20.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
17141
+ return path21.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(path20, issues) {
17526
+ function prefixIssues(path21, issues) {
17527
17527
  return issues.map((iss) => {
17528
17528
  var _a3;
17529
17529
  (_a3 = iss).path ?? (_a3.path = []);
17530
- iss.path.unshift(path20);
17530
+ iss.path.unshift(path21);
17531
17531
  return iss;
17532
17532
  });
17533
17533
  }
@@ -33264,7 +33264,7 @@ function inspectMakerProjectInitialization(projectRoot) {
33264
33264
  };
33265
33265
  }
33266
33266
  const missingFields = ["app_id", "developer_id"].filter(
33267
- (field) => !hasNonEmptyField(projectJson, field)
33267
+ (field) => !hasNonEmptyIdentityField(projectJson, field)
33268
33268
  );
33269
33269
  if (missingFields.length > 0) {
33270
33270
  return {
@@ -33305,34 +33305,168 @@ function formatMakerProjectInitializationStatus(status) {
33305
33305
  "- next_action: 检查 .project/project.json 内容;必要时先调用 maker_build_current_directory 重新生成项目配置。"
33306
33306
  ].filter(Boolean).join("\n");
33307
33307
  }
33308
- return [
33309
- "Maker project initialization",
33310
- "",
33311
- "- status: missing_project_json",
33312
- `- config: ${status.projectJsonPath}`,
33313
- "- impact: get_ad_config and other remote project-config tools cannot read project metadata yet.",
33314
- "- next_action: 先调用 maker_build_current_directory 构建一次,生成 .project/project.json 后再重试。"
33315
- ].join("\n");
33308
+ if (status.status === "missing_project_json") {
33309
+ return [
33310
+ "Maker project initialization",
33311
+ "",
33312
+ "- status: missing_project_json",
33313
+ `- config: ${status.projectJsonPath}`,
33314
+ "- impact: get_ad_config and other remote project-config tools cannot read project metadata yet.",
33315
+ "- next_action: 先调用 maker_build_current_directory 构建一次,生成 .project/project.json 后再重试。"
33316
+ ].join("\n");
33317
+ }
33318
+ return "";
33316
33319
  }
33317
- function hasNonEmptyField(value, fieldName) {
33320
+ function hasNonEmptyIdentityField(value, fieldName) {
33318
33321
  if (!value || typeof value !== "object") {
33319
33322
  return false;
33320
33323
  }
33321
- if (Object.prototype.hasOwnProperty.call(value, fieldName)) {
33322
- const fieldValue = value[fieldName];
33323
- if (fieldValue !== void 0 && fieldValue !== null && String(fieldValue).trim() !== "") {
33324
- return true;
33325
- }
33324
+ const record2 = value;
33325
+ if (isNonEmptyStringLike(record2[fieldName])) {
33326
+ return true;
33326
33327
  }
33327
- if (Array.isArray(value)) {
33328
- return value.some((item) => hasNonEmptyField(item, fieldName));
33328
+ const taptapPublish = record2.taptap_publish;
33329
+ if (!taptapPublish || typeof taptapPublish !== "object" || Array.isArray(taptapPublish)) {
33330
+ return false;
33329
33331
  }
33330
- return Object.values(value).some((item) => hasNonEmptyField(item, fieldName));
33332
+ return isNonEmptyStringLike(taptapPublish[fieldName]);
33333
+ }
33334
+ function isNonEmptyStringLike(value) {
33335
+ return value !== void 0 && value !== null && String(value).trim() !== "";
33331
33336
  }
33332
33337
 
33333
- // src/maker/server/proxyAssets.ts
33338
+ // src/maker/projectSettings.ts
33334
33339
  import fs14 from "node:fs";
33335
33340
  import path15 from "node:path";
33341
+ var REQUIRED_SOURCE_TAGS = ["stable"];
33342
+ function inspectMakerProjectSettings(projectRoot) {
33343
+ const resolvedProjectRoot = path15.resolve(projectRoot);
33344
+ const settingsJsonPath = path15.join(resolvedProjectRoot, ".project", "settings.json");
33345
+ const baseStatus = {
33346
+ projectRoot: resolvedProjectRoot,
33347
+ settingsJsonPath
33348
+ };
33349
+ if (!fs14.existsSync(settingsJsonPath)) {
33350
+ return {
33351
+ ...baseStatus,
33352
+ status: "missing_settings_json"
33353
+ };
33354
+ }
33355
+ let settings;
33356
+ try {
33357
+ settings = JSON.parse(fs14.readFileSync(settingsJsonPath, "utf8"));
33358
+ } catch (error2) {
33359
+ return {
33360
+ ...baseStatus,
33361
+ status: "invalid_settings_json",
33362
+ error: error2 instanceof Error ? error2.message : String(error2)
33363
+ };
33364
+ }
33365
+ const issues = validateMakerProjectSettings(settings);
33366
+ if (issues.length > 0) {
33367
+ return {
33368
+ ...baseStatus,
33369
+ status: "invalid_project_settings",
33370
+ issues
33371
+ };
33372
+ }
33373
+ return {
33374
+ ...baseStatus,
33375
+ status: "ready"
33376
+ };
33377
+ }
33378
+ function formatMakerProjectSettingsStatus(status) {
33379
+ var _a3;
33380
+ if (status.status === "ready" || status.status === "missing_settings_json") {
33381
+ return "";
33382
+ }
33383
+ const lines = [
33384
+ "Maker project settings",
33385
+ "",
33386
+ `- status: ${status.status}`,
33387
+ `- config: ${status.settingsJsonPath}`,
33388
+ "- impact: 构建可能失败或游戏黑屏;坏配置不应提交到 Maker 远端。"
33389
+ ];
33390
+ if (status.error) {
33391
+ lines.push(`- error: ${status.error}`);
33392
+ }
33393
+ if ((_a3 = status.issues) == null ? void 0 : _a3.length) {
33394
+ lines.push("- issues:");
33395
+ lines.push(...status.issues.map((issue2) => ` - ${issue2}`));
33396
+ }
33397
+ lines.push(
33398
+ "- next_action: 恢复 .project/settings.json 的构建关键字段后再构建;保留合法的 @runtime 配置。"
33399
+ );
33400
+ return lines.join("\n");
33401
+ }
33402
+ function isMakerProjectSettingsBlocking(status) {
33403
+ return status.status === "invalid_settings_json" || status.status === "invalid_project_settings";
33404
+ }
33405
+ function validateMakerProjectSettings(settings) {
33406
+ const issues = [];
33407
+ if (!isPlainObject3(settings)) {
33408
+ return ["settings.json must be a JSON object"];
33409
+ }
33410
+ expectValue(settings, "$schema", "../schemas/settings.schema.json", issues);
33411
+ const sources = readPath(settings, "sources");
33412
+ if (!isPlainObject3(sources)) {
33413
+ issues.push("sources must be an object");
33414
+ } else {
33415
+ expectOneOf(settings, "sources.engine.tag", REQUIRED_SOURCE_TAGS, issues);
33416
+ expectOneOf(settings, "sources.engine-res.tag", REQUIRED_SOURCE_TAGS, issues);
33417
+ expectOneOf(settings, "sources.official-res.tag", REQUIRED_SOURCE_TAGS, issues);
33418
+ }
33419
+ const build = readPath(settings, "build");
33420
+ if (!isPlainObject3(build)) {
33421
+ issues.push("build must be an object");
33422
+ return issues;
33423
+ }
33424
+ expectValue(settings, "build.generate_fs_path", true, issues);
33425
+ expectValue(settings, "build.output_dir", "../dist", issues);
33426
+ const assetDirs = readPath(build, "asset_dirs");
33427
+ if (!isStringArray(assetDirs) || !sameStringSet(assetDirs, ["../assets", "../scripts"])) {
33428
+ issues.push('build.asset_dirs must contain only "../assets" and "../scripts"');
33429
+ }
33430
+ if (readPath(build, "asset_ignores") === void 0) {
33431
+ issues.push("build.asset_ignores must exist");
33432
+ }
33433
+ return issues;
33434
+ }
33435
+ function expectValue(settings, fieldPath, expected, issues) {
33436
+ if (readPath(settings, fieldPath) !== expected) {
33437
+ issues.push(`${fieldPath} must be ${JSON.stringify(expected)}`);
33438
+ }
33439
+ }
33440
+ function expectOneOf(settings, fieldPath, expectedValues, issues) {
33441
+ if (!expectedValues.includes(String(readPath(settings, fieldPath)))) {
33442
+ issues.push(
33443
+ `${fieldPath} must be ${expectedValues.map((value) => JSON.stringify(value)).join(" or ")}`
33444
+ );
33445
+ }
33446
+ }
33447
+ function readPath(value, fieldPath) {
33448
+ let current = value;
33449
+ for (const segment of fieldPath.split(".")) {
33450
+ if (!isPlainObject3(current)) {
33451
+ return void 0;
33452
+ }
33453
+ current = current[segment];
33454
+ }
33455
+ return current;
33456
+ }
33457
+ function isPlainObject3(value) {
33458
+ return typeof value === "object" && value !== null && !Array.isArray(value);
33459
+ }
33460
+ function isStringArray(value) {
33461
+ return Array.isArray(value) && value.every((item) => typeof item === "string");
33462
+ }
33463
+ function sameStringSet(left, right) {
33464
+ return left.length === right.length && right.every((item) => left.includes(item));
33465
+ }
33466
+
33467
+ // src/maker/server/proxyAssets.ts
33468
+ import fs15 from "node:fs";
33469
+ import path16 from "node:path";
33336
33470
  var IMAGE_ASSET_DIRS = ["assets/image"];
33337
33471
  var VIDEO_ASSET_DIRS = ["assets/video"];
33338
33472
  var AUDIO_ASSET_DIRS = ["assets/audio"];
@@ -33342,6 +33476,7 @@ var IMAGE_REFERENCE_MAX_BYTES = 10 * 1024 * 1024;
33342
33476
  var VIDEO_TASK_IMAGE_REFERENCE_MAX_BYTES = 30 * 1024 * 1024;
33343
33477
  var VIDEO_REFERENCE_MAX_BYTES = 50 * 1024 * 1024;
33344
33478
  var AUDIO_REFERENCE_MAX_BYTES = 15 * 1024 * 1024;
33479
+ var DEBUG_FEEDBACK_PATH_HINT = "Use local_dir/local_log_paths/local_screenshot_paths when they are returned. If only local_candidate_* is present, it is a possible project-relative location and must not be treated as a downloaded local file.";
33345
33480
  var DATA_URL_MIME_BY_EXTENSION = {
33346
33481
  image: {
33347
33482
  ".gif": "image/gif",
@@ -33452,7 +33587,8 @@ function shouldMaterializeRemoteProxyTool(toolName) {
33452
33587
  "query_video_task",
33453
33588
  "text_to_music",
33454
33589
  "create_3d_model_task",
33455
- "query_3d_model_task"
33590
+ "query_3d_model_task",
33591
+ "get_debug_feedbacks"
33456
33592
  ].includes(toolName);
33457
33593
  }
33458
33594
  function isTextContent(item) {
@@ -33501,8 +33637,217 @@ async function materializeParsedProxyResult(options) {
33501
33637
  if (options.toolName === "create_3d_model_task" || options.toolName === "query_3d_model_task") {
33502
33638
  return await materialize3dModelResult(options, options.toolName);
33503
33639
  }
33640
+ if (options.toolName === "get_debug_feedbacks") {
33641
+ return await materializeDebugFeedbackResult(options);
33642
+ }
33504
33643
  return options.payload;
33505
33644
  }
33645
+ async function materializeDebugFeedbackResult(options) {
33646
+ if (options.payload.success !== true) {
33647
+ return options.payload;
33648
+ }
33649
+ const feedbacks = getDebugFeedbackItems(options.payload);
33650
+ const remoteSaveDir = getDebugFeedbackSaveDir(options.payload);
33651
+ if (feedbacks.length === 0 && !remoteSaveDir) {
33652
+ return options.payload;
33653
+ }
33654
+ const nextFeedbacks = [];
33655
+ for (const feedback of feedbacks) {
33656
+ const remoteDir = stringField2(feedback.dir);
33657
+ const localCandidateDir = remoteDir ? resolveDebugFeedbackCandidatePath(options.targetDir, remoteDir) : void 0;
33658
+ const materialized = await materializeDebugFeedbackArtifacts({
33659
+ targetDir: options.targetDir,
33660
+ feedback,
33661
+ fetchImpl: options.fetchImpl
33662
+ });
33663
+ nextFeedbacks.push({
33664
+ ...feedback,
33665
+ ...localCandidateDir ? { local_candidate_dir: localCandidateDir } : {},
33666
+ ...materialized
33667
+ });
33668
+ }
33669
+ const localCandidateSaveDir = remoteSaveDir ? resolveDebugFeedbackCandidatePath(options.targetDir, remoteSaveDir) : feedbacks.some(hasDebugFeedbackArtifactUrls) ? path16.join(options.targetDir, "logs", "feed_back") : void 0;
33670
+ const filesVerifiedLocally = nextFeedbacks.some(
33671
+ (feedback) => numberField2(feedback.artifacts_downloaded) > 0
33672
+ );
33673
+ return {
33674
+ ...replaceDebugFeedbackItems(options.payload, nextFeedbacks),
33675
+ local_path_hint: {
33676
+ remote_save_dir: remoteSaveDir,
33677
+ local_candidate_save_dir: localCandidateSaveDir,
33678
+ local_project_dir: options.targetDir,
33679
+ files_verified_locally: filesVerifiedLocally,
33680
+ note: DEBUG_FEEDBACK_PATH_HINT
33681
+ }
33682
+ };
33683
+ }
33684
+ async function materializeDebugFeedbackArtifacts(options) {
33685
+ const feedbackId = stringField2(options.feedback.feedback_id) ?? (options.feedback.feedback_id != null ? String(options.feedback.feedback_id) : "");
33686
+ if (!feedbackId) {
33687
+ return {};
33688
+ }
33689
+ const logUrls = stringArrayField(options.feedback.log_file_urls);
33690
+ const screenshotUrls = stringArrayField(options.feedback.screenshots);
33691
+ const extraUrls = stringArrayField(options.feedback.download_urls).filter(
33692
+ (url2) => !logUrls.includes(url2) && !screenshotUrls.includes(url2)
33693
+ );
33694
+ if (logUrls.length === 0 && screenshotUrls.length === 0 && extraUrls.length === 0) {
33695
+ return {};
33696
+ }
33697
+ const localDir = path16.join(options.targetDir, "logs", "feed_back", `feedback_${feedbackId}`);
33698
+ const localLogPaths = [];
33699
+ const localScreenshotPaths = [];
33700
+ const localDownloadPaths = [];
33701
+ const errors = [];
33702
+ for (const [index, url2] of logUrls.entries()) {
33703
+ const result = await downloadDebugFeedbackArtifact({
33704
+ url: url2,
33705
+ directory: path16.join(localDir, "logs"),
33706
+ fallbackName: `log_${index + 1}.log`,
33707
+ fetchImpl: options.fetchImpl
33708
+ });
33709
+ if (result.success) {
33710
+ localLogPaths.push(result.path);
33711
+ } else {
33712
+ errors.push(result.error);
33713
+ }
33714
+ }
33715
+ for (const [index, url2] of screenshotUrls.entries()) {
33716
+ const result = await downloadDebugFeedbackArtifact({
33717
+ url: url2,
33718
+ directory: path16.join(localDir, "screenshots"),
33719
+ fallbackName: `screenshot_${index + 1}.png`,
33720
+ fetchImpl: options.fetchImpl
33721
+ });
33722
+ if (result.success) {
33723
+ localScreenshotPaths.push(result.path);
33724
+ } else {
33725
+ errors.push(result.error);
33726
+ }
33727
+ }
33728
+ for (const [index, url2] of extraUrls.entries()) {
33729
+ const result = await downloadDebugFeedbackArtifact({
33730
+ url: url2,
33731
+ directory: path16.join(localDir, "downloads"),
33732
+ fallbackName: `artifact_${index + 1}`,
33733
+ fetchImpl: options.fetchImpl
33734
+ });
33735
+ if (result.success) {
33736
+ localDownloadPaths.push(result.path);
33737
+ } else {
33738
+ errors.push(result.error);
33739
+ }
33740
+ }
33741
+ return {
33742
+ local_dir: localDir,
33743
+ local_log_paths: localLogPaths,
33744
+ local_screenshot_paths: localScreenshotPaths,
33745
+ local_download_paths: localDownloadPaths,
33746
+ artifacts_downloaded: localLogPaths.length + localScreenshotPaths.length + localDownloadPaths.length,
33747
+ artifact_download_errors: errors
33748
+ };
33749
+ }
33750
+ async function downloadDebugFeedbackArtifact(options) {
33751
+ try {
33752
+ const response = await options.fetchImpl(options.url);
33753
+ if (!response.ok) {
33754
+ return {
33755
+ success: false,
33756
+ error: `${options.url}: HTTP ${response.status}`
33757
+ };
33758
+ }
33759
+ fs15.mkdirSync(options.directory, { recursive: true });
33760
+ const filePath = allocateDebugFeedbackArtifactPath(
33761
+ options.directory,
33762
+ options.url,
33763
+ options.fallbackName
33764
+ );
33765
+ const bytes = Buffer.from(await response.arrayBuffer());
33766
+ fs15.writeFileSync(filePath, bytes);
33767
+ return { success: true, path: filePath };
33768
+ } catch (error2) {
33769
+ return {
33770
+ success: false,
33771
+ error: `${options.url}: ${error2 instanceof Error ? error2.message : String(error2)}`
33772
+ };
33773
+ }
33774
+ }
33775
+ function allocateDebugFeedbackArtifactPath(directory, url2, fallbackName) {
33776
+ const rawName = fileNameFromUrl(url2) || fallbackName;
33777
+ const rawExtension = path16.extname(rawName);
33778
+ const finalExtension = rawExtension && rawExtension !== "." ? rawExtension.replace(/[^A-Za-z0-9.]/g, "_") : "";
33779
+ const rawStem = finalExtension ? rawName.slice(0, -rawExtension.length) : rawName;
33780
+ const stem = sanitizeAssetBaseName(rawStem);
33781
+ for (let index = 1; index <= 9999; index += 1) {
33782
+ const suffix = index === 1 ? "" : `_${index}`;
33783
+ const candidate = path16.join(directory, `${stem}${suffix}${finalExtension}`);
33784
+ if (!fs15.existsSync(candidate)) {
33785
+ return candidate;
33786
+ }
33787
+ }
33788
+ throw new Error(`Unable to allocate debug feedback artifact path for ${stem}${finalExtension}`);
33789
+ }
33790
+ function fileNameFromUrl(url2) {
33791
+ try {
33792
+ const pathname = new URL(url2).pathname;
33793
+ const name = decodeURIComponent(path16.basename(pathname));
33794
+ return name && name !== "/" ? name : void 0;
33795
+ } catch {
33796
+ return void 0;
33797
+ }
33798
+ }
33799
+ function hasDebugFeedbackArtifactUrls(feedback) {
33800
+ return stringArrayField(feedback.log_file_urls).length > 0 || stringArrayField(feedback.screenshots).length > 0 || stringArrayField(feedback.download_urls).length > 0;
33801
+ }
33802
+ function getDebugFeedbackSaveDir(payload) {
33803
+ const summary = payload.summary;
33804
+ return stringField2(payload.save_dir) || (isRecord(summary) ? stringField2(summary.save_dir) : void 0);
33805
+ }
33806
+ function resolveDebugFeedbackCandidatePath(targetDir, remotePath) {
33807
+ if (path16.isAbsolute(remotePath)) {
33808
+ return void 0;
33809
+ }
33810
+ const trimmedRemotePath = remotePath.replace(/[\\/]+$/, "");
33811
+ return path16.normalize(path16.join(targetDir, trimmedRemotePath || "."));
33812
+ }
33813
+ function replaceDebugFeedbackItems(payload, nextFeedbacks) {
33814
+ const summary = payload.summary;
33815
+ if (isRecord(summary) && Array.isArray(summary.feedbacks)) {
33816
+ return {
33817
+ ...payload,
33818
+ summary: {
33819
+ ...summary,
33820
+ feedbacks: nextFeedbacks
33821
+ }
33822
+ };
33823
+ }
33824
+ if (Array.isArray(payload.feedbacks)) {
33825
+ return {
33826
+ ...payload,
33827
+ feedbacks: nextFeedbacks
33828
+ };
33829
+ }
33830
+ if (Array.isArray(payload.list)) {
33831
+ return {
33832
+ ...payload,
33833
+ list: nextFeedbacks
33834
+ };
33835
+ }
33836
+ return payload;
33837
+ }
33838
+ function getDebugFeedbackItems(payload) {
33839
+ const summary = payload.summary;
33840
+ if (isRecord(summary) && Array.isArray(summary.feedbacks)) {
33841
+ return summary.feedbacks.filter(isRecord);
33842
+ }
33843
+ if (Array.isArray(payload.feedbacks)) {
33844
+ return payload.feedbacks.filter(isRecord);
33845
+ }
33846
+ if (Array.isArray(payload.list)) {
33847
+ return payload.list.filter(isRecord);
33848
+ }
33849
+ return [];
33850
+ }
33506
33851
  async function materializeSingleImageResult(options, toolName) {
33507
33852
  if (options.payload.success !== true) {
33508
33853
  return options.payload;
@@ -33616,13 +33961,13 @@ function findExistingMaterializedVideo(targetDir, options) {
33616
33961
  function resolveExistingMaterializedAssetPath(targetDir, record2, localPath) {
33617
33962
  const candidates = [];
33618
33963
  const absolutePath = stringField2(record2.absolutePath);
33619
- if (absolutePath && path15.isAbsolute(absolutePath)) {
33964
+ if (absolutePath && path16.isAbsolute(absolutePath)) {
33620
33965
  candidates.push(absolutePath);
33621
33966
  }
33622
- candidates.push(path15.join(targetDir, ...localPath.split("/")));
33967
+ candidates.push(path16.join(targetDir, ...localPath.split("/")));
33623
33968
  for (const candidate of candidates) {
33624
33969
  try {
33625
- if (fs14.statSync(candidate).isFile()) {
33970
+ if (fs15.statSync(candidate).isFile()) {
33626
33971
  return candidate;
33627
33972
  }
33628
33973
  } catch {
@@ -33787,7 +34132,7 @@ async function materialize3dFinalResult(options, toolName) {
33787
34132
  try {
33788
34133
  extractZip(
33789
34134
  mdlMaterialized.absolutePath,
33790
- path15.join(options.targetDir, "assets"),
34135
+ path16.join(options.targetDir, "assets"),
33791
34136
  "3D model asset"
33792
34137
  );
33793
34138
  nextPayload.mdlExtracted = true;
@@ -33894,8 +34239,8 @@ async function materializeAsset(options) {
33894
34239
  };
33895
34240
  }
33896
34241
  const bytes = Buffer.from(await response.arrayBuffer());
33897
- fs14.mkdirSync(path15.dirname(absolutePath), { recursive: true });
33898
- fs14.writeFileSync(absolutePath, bytes);
34242
+ fs15.mkdirSync(path16.dirname(absolutePath), { recursive: true });
34243
+ fs15.writeFileSync(absolutePath, bytes);
33899
34244
  return { localPath: relativePath, absolutePath, download: { success: true } };
33900
34245
  } catch (error2) {
33901
34246
  return {
@@ -33909,12 +34254,12 @@ async function materializeAsset(options) {
33909
34254
  function createUniqueAssetPath(options) {
33910
34255
  const stem = `${sanitizeAssetBaseName(options.baseName)}_${formatAssetTimestamp(options.now)}`;
33911
34256
  for (let index = 1; index <= 9999; index += 1) {
33912
- const relativePath = path15.posix.join(
34257
+ const relativePath = path16.posix.join(
33913
34258
  options.relativeDir,
33914
34259
  `${stem}${index === 1 ? "" : `_${index}`}.${options.extension}`
33915
34260
  );
33916
- const absolutePath = path15.join(options.targetDir, ...relativePath.split("/"));
33917
- if (!fs14.existsSync(absolutePath)) {
34261
+ const absolutePath = path16.join(options.targetDir, ...relativePath.split("/"));
34262
+ if (!fs15.existsSync(absolutePath)) {
33918
34263
  return { relativePath, absolutePath };
33919
34264
  }
33920
34265
  }
@@ -34092,7 +34437,7 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
34092
34437
  if (!isKnownAssetPath(localPath, assetDirs)) {
34093
34438
  return false;
34094
34439
  }
34095
- const basename = path15.posix.basename(localPath);
34440
+ const basename = path16.posix.basename(localPath);
34096
34441
  const stem = basename.replace(/\.[^.]+$/, "");
34097
34442
  return basename === value || stem === value || record2.name === value || record2.taskId === value;
34098
34443
  });
@@ -34105,13 +34450,13 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
34105
34450
  }
34106
34451
  function findLocalAssetByName(targetDir, value, assetDirs) {
34107
34452
  var _a3;
34108
- const hasExtension = Boolean(path15.extname(value));
34453
+ const hasExtension = Boolean(path16.extname(value));
34109
34454
  const candidates = [];
34110
34455
  for (const assetDir of assetDirs) {
34111
- const absoluteDir = path15.join(targetDir, ...assetDir.split("/"));
34456
+ const absoluteDir = path16.join(targetDir, ...assetDir.split("/"));
34112
34457
  let entries;
34113
34458
  try {
34114
- entries = fs14.readdirSync(absoluteDir);
34459
+ entries = fs15.readdirSync(absoluteDir);
34115
34460
  } catch {
34116
34461
  continue;
34117
34462
  }
@@ -34120,11 +34465,11 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
34120
34465
  if (hasExtension ? entry !== value : stem !== value && !stem.startsWith(`${value}_`)) {
34121
34466
  continue;
34122
34467
  }
34123
- const absolutePath = path15.join(absoluteDir, entry);
34468
+ const absolutePath = path16.join(absoluteDir, entry);
34124
34469
  try {
34125
34470
  candidates.push({
34126
- localPath: path15.posix.join(assetDir, entry),
34127
- mtimeMs: fs14.statSync(absolutePath).mtimeMs
34471
+ localPath: path16.posix.join(assetDir, entry),
34472
+ mtimeMs: fs15.statSync(absolutePath).mtimeMs
34128
34473
  });
34129
34474
  } catch {
34130
34475
  }
@@ -34134,7 +34479,7 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
34134
34479
  return (_a3 = candidates[0]) == null ? void 0 : _a3.localPath;
34135
34480
  }
34136
34481
  function isKnownAssetPath(relativePath, assetDirs) {
34137
- if (relativePath.startsWith("../") || path15.isAbsolute(relativePath)) {
34482
+ if (relativePath.startsWith("../") || path16.isAbsolute(relativePath)) {
34138
34483
  return false;
34139
34484
  }
34140
34485
  return assetDirs.some(
@@ -34158,14 +34503,14 @@ function localAssetReferenceToDataUrl(options) {
34158
34503
  }
34159
34504
  let stat;
34160
34505
  try {
34161
- stat = fs14.statSync(absolutePath);
34506
+ stat = fs15.statSync(absolutePath);
34162
34507
  } catch {
34163
34508
  return void 0;
34164
34509
  }
34165
34510
  if (!stat.isFile() || stat.size > options.maxBytes) {
34166
34511
  return void 0;
34167
34512
  }
34168
- const bytes = fs14.readFileSync(absolutePath);
34513
+ const bytes = fs15.readFileSync(absolutePath);
34169
34514
  return `data:${mime};base64,${bytes.toString("base64")}`;
34170
34515
  }
34171
34516
  function resolveLocalAssetAbsolutePath(targetDir, options) {
@@ -34176,7 +34521,7 @@ function resolveLocalAssetAbsolutePath(targetDir, options) {
34176
34521
  candidates.push(localPath);
34177
34522
  }
34178
34523
  }
34179
- if (path15.isAbsolute(options.value)) {
34524
+ if (path16.isAbsolute(options.value)) {
34180
34525
  candidates.push(options.value);
34181
34526
  } else {
34182
34527
  const localPath = resolveProjectRelativePath(targetDir, options.value);
@@ -34185,54 +34530,54 @@ function resolveLocalAssetAbsolutePath(targetDir, options) {
34185
34530
  }
34186
34531
  }
34187
34532
  for (const candidate of candidates) {
34188
- if (fs14.existsSync(candidate)) {
34533
+ if (fs15.existsSync(candidate)) {
34189
34534
  return candidate;
34190
34535
  }
34191
34536
  }
34192
34537
  return void 0;
34193
34538
  }
34194
34539
  function resolveProjectRelativePath(targetDir, value) {
34195
- const root = path15.resolve(targetDir);
34196
- const absolutePath = path15.resolve(root, value);
34197
- const relativePath = path15.relative(root, absolutePath);
34198
- const escapesRoot = relativePath === ".." || relativePath.startsWith(`..${path15.sep}`) || path15.isAbsolute(relativePath);
34540
+ const root = path16.resolve(targetDir);
34541
+ const absolutePath = path16.resolve(root, value);
34542
+ const relativePath = path16.relative(root, absolutePath);
34543
+ const escapesRoot = relativePath === ".." || relativePath.startsWith(`..${path16.sep}`) || path16.isAbsolute(relativePath);
34199
34544
  if (!escapesRoot) {
34200
34545
  return absolutePath;
34201
34546
  }
34202
34547
  return void 0;
34203
34548
  }
34204
34549
  function dataUrlMimeForPath(filePath, mediaKind) {
34205
- return DATA_URL_MIME_BY_EXTENSION[mediaKind][path15.extname(filePath).toLowerCase()];
34550
+ return DATA_URL_MIME_BY_EXTENSION[mediaKind][path16.extname(filePath).toLowerCase()];
34206
34551
  }
34207
34552
  function upsertGeneratedAssetRecord(targetDir, localPath, record2) {
34208
34553
  const registry2 = readGeneratedAssetRegistry(targetDir);
34209
34554
  registry2[localPath] = record2;
34210
34555
  const registryPath = getGeneratedAssetRegistryPath(targetDir);
34211
- fs14.mkdirSync(path15.dirname(registryPath), { recursive: true });
34212
- fs14.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
34556
+ fs15.mkdirSync(path16.dirname(registryPath), { recursive: true });
34557
+ fs15.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
34213
34558
  `, "utf8");
34214
34559
  }
34215
34560
  function readGeneratedAssetRegistry(targetDir) {
34216
34561
  const registryPath = getGeneratedAssetRegistryPath(targetDir);
34217
- if (!fs14.existsSync(registryPath)) {
34562
+ if (!fs15.existsSync(registryPath)) {
34218
34563
  return {};
34219
34564
  }
34220
34565
  try {
34221
- const parsed = JSON.parse(fs14.readFileSync(registryPath, "utf8"));
34566
+ const parsed = JSON.parse(fs15.readFileSync(registryPath, "utf8"));
34222
34567
  return isRecord(parsed) ? parsed : {};
34223
34568
  } catch {
34224
34569
  return {};
34225
34570
  }
34226
34571
  }
34227
34572
  function getGeneratedAssetRegistryPath(targetDir) {
34228
- return path15.join(targetDir, ".maker", "assets", "generated-assets.json");
34573
+ return path16.join(targetDir, ".maker", "assets", "generated-assets.json");
34229
34574
  }
34230
34575
  function normalizeAssetRegistryKey(targetDir, value) {
34231
34576
  if (/^https?:\/\//i.test(value) || value.startsWith("data:")) {
34232
34577
  return void 0;
34233
34578
  }
34234
- const relative = path15.isAbsolute(value) ? path15.relative(targetDir, value) : value;
34235
- return relative.split(path15.sep).join("/");
34579
+ const relative = path16.isAbsolute(value) ? path16.relative(targetDir, value) : value;
34580
+ return relative.split(path16.sep).join("/");
34236
34581
  }
34237
34582
  function isRecord(value) {
34238
34583
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -34240,9 +34585,19 @@ function isRecord(value) {
34240
34585
  function stringField2(value) {
34241
34586
  return typeof value === "string" && value.trim() ? value : void 0;
34242
34587
  }
34588
+ function stringArrayField(value) {
34589
+ return Array.isArray(value) ? value.filter((item) => Boolean(stringField2(item))) : [];
34590
+ }
34591
+ function numberField2(value) {
34592
+ return typeof value === "number" && Number.isFinite(value) ? value : 0;
34593
+ }
34243
34594
  function sanitizeAssetBaseName(value) {
34244
- const sanitized = value.trim().replace(/\s+/g, "_").replace(/[/\\:*?"<>|]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
34245
- return sanitized || "asset";
34595
+ const sanitized = replaceControlCharacters(value).trim().replace(/\s+/g, "_").replace(/[/\\:*?"<>|]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").replace(/[. ]+$/g, "");
34596
+ const safeName = sanitized || "asset";
34597
+ return /^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(safeName) ? `_${safeName}` : safeName;
34598
+ }
34599
+ function replaceControlCharacters(value) {
34600
+ return Array.from(value).map((character) => character.charCodeAt(0) < 32 ? "_" : character).join("");
34246
34601
  }
34247
34602
  function formatAssetTimestamp(date5) {
34248
34603
  const pad = (value) => String(value).padStart(2, "0");
@@ -34261,7 +34616,7 @@ function extensionFromUrl(url2) {
34261
34616
  }
34262
34617
  try {
34263
34618
  const pathname = new URL(url2).pathname;
34264
- const extension = path15.extname(pathname).replace(/^\./, "").toLowerCase();
34619
+ const extension = path16.extname(pathname).replace(/^\./, "").toLowerCase();
34265
34620
  return extension || void 0;
34266
34621
  } catch {
34267
34622
  return void 0;
@@ -34412,7 +34767,7 @@ function applyDefaults(config2) {
34412
34767
  }
34413
34768
 
34414
34769
  // src/maker/server/mcp.ts
34415
- var VERSION = true ? "0.0.24-beta.1" : "dev";
34770
+ var VERSION = true ? "0.0.24" : "dev";
34416
34771
  var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
34417
34772
  var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
34418
34773
  var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
@@ -34433,6 +34788,61 @@ var MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES = [
34433
34788
  "get_ad_config",
34434
34789
  "get_debug_feedbacks"
34435
34790
  ];
34791
+ var MAKER_BUILD_MULTIPLAYER_SCHEMA = {
34792
+ type: "object",
34793
+ 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.",
34794
+ properties: {
34795
+ enabled: {
34796
+ type: "boolean",
34797
+ description: "Enable multiplayer mode. When true, initializes the networking subsystem and lobby. Runtime default: false."
34798
+ },
34799
+ max_players: {
34800
+ type: "number",
34801
+ minimum: 2,
34802
+ maximum: 100,
34803
+ description: "Maximum players allowed in one session (2-100). Actual match size can be smaller via match_info.player_number. Runtime default: 4."
34804
+ },
34805
+ background_match: {
34806
+ type: "boolean",
34807
+ description: "Enable background matching. When true, game scripts load immediately and matching runs in the background; handle the ServerReady event after match success. Runtime default: false."
34808
+ },
34809
+ match_info: {
34810
+ type: "object",
34811
+ description: "Match/session-based gameplay config for lobby, room, or round-based games. Examples: LoL, CS2, PUBG, DotA 2.",
34812
+ properties: {
34813
+ desc_name: {
34814
+ type: "string",
34815
+ enum: ["free_match", "free_match_with_ai"],
34816
+ description: "Matching algorithm: free_match waits without AI fill; free_match_with_ai fills with AI after timeout."
34817
+ },
34818
+ player_number: {
34819
+ type: "number",
34820
+ minimum: 1,
34821
+ description: "Players required to start the match. Must be less than or equal to multiplayer.max_players."
34822
+ },
34823
+ immediately_start: {
34824
+ type: "boolean",
34825
+ description: "Start immediately without waiting for a full match."
34826
+ },
34827
+ match_timeout: {
34828
+ type: "number",
34829
+ minimum: 0,
34830
+ description: "Match timeout in seconds. Only effective for desc_name=free_match_with_ai; AI fills after timeout."
34831
+ }
34832
+ }
34833
+ },
34834
+ persistent_world: {
34835
+ type: "object",
34836
+ description: "Persistent-world config for long-running/shared worlds where players can join an already running world. Examples: Roblox, World of Warcraft, Minecraft.",
34837
+ properties: {
34838
+ enabled: {
34839
+ type: "boolean",
34840
+ description: "Enable persistent-world mode instead of starting a separate match/session first. Runtime default: false."
34841
+ }
34842
+ }
34843
+ }
34844
+ }
34845
+ };
34436
34846
  var MakerCloneFailedError = class extends Error {
34437
34847
  constructor(targetDir, originalError) {
34438
34848
  const message = originalError instanceof Error ? originalError.message : String(originalError);
@@ -34480,16 +34890,13 @@ var tools = [
34480
34890
  },
34481
34891
  entry_client: {
34482
34892
  type: "string",
34483
- description: 'Optional multiplayer client entry relative to scriptsPath, e.g. "client_main.lua".'
34893
+ description: 'Optional multiplayer C/S client entry relative to scriptsPath, e.g. "client_main.lua". Forwarded to maker-tools build and written to project.json as entry@client. On the first multiplayer build, pass multiplayer.enabled=true in the same call; otherwise first-build defaults may initialize multiplayer as disabled.'
34484
34894
  },
34485
34895
  entry_server: {
34486
34896
  type: "string",
34487
- description: 'Optional multiplayer server entry relative to scriptsPath, e.g. "server_main.lua".'
34488
- },
34489
- multiplayer: {
34490
- type: "object",
34491
- description: "Optional multiplayer config forwarded to remote build. If omitted and no .project/settings.json exists, Maker MCP sends { enabled: false } for first single-player build initialization."
34897
+ description: 'Optional multiplayer C/S server entry relative to scriptsPath, e.g. "server_main.lua". Forwarded to maker-tools build and written to project.json as entry@server. On the first multiplayer build, pass multiplayer.enabled=true in the same call; otherwise first-build defaults may initialize multiplayer as disabled.'
34492
34898
  },
34899
+ multiplayer: MAKER_BUILD_MULTIPLAYER_SCHEMA,
34493
34900
  server_url: {
34494
34901
  type: "string",
34495
34902
  description: "Optional remote MCP server URL override. Defaults to the Maker endpoint table for TAPTAP_MCP_ENV."
@@ -34630,7 +35037,7 @@ function remoteProxyToolGuidance(toolName) {
34630
35037
  ].join(" ");
34631
35038
  case "get_debug_feedbacks":
34632
35039
  return [
34633
- "**Maker hint:** Fetch remote player feedback for the current Maker project, including related device logs and screenshots when available.",
35040
+ "**Maker hint:** Fetch online player feedback for the current Maker project. When logs or screenshots can be downloaded, this tool saves them under logs/feed_back/feedback_<id>/ in the local Maker project and returns local_dir/local_log_paths/local_screenshot_paths. Read those returned local paths before diagnosing the issue. Do not guess drive letters or fixed directories; only treat attachments as local files when local_* paths are returned.",
34634
35041
  failurePolicy
34635
35042
  ].join(" ");
34636
35043
  default:
@@ -34930,7 +35337,7 @@ async function formatStatus(options = {}) {
34930
35337
  const env = getMakerEnvironment(void 0, targetDir);
34931
35338
  const identify = identifyMakerProject({ cwd: targetDir });
34932
35339
  const mcpCwd = process.cwd();
34933
- const mcpCwdIdentify = path16.resolve(mcpCwd) === path16.resolve(targetDir) ? identify : identifyMakerProject({ cwd: mcpCwd });
35340
+ const mcpCwdIdentify = path17.resolve(mcpCwd) === path17.resolve(targetDir) ? identify : identifyMakerProject({ cwd: mcpCwd });
34934
35341
  const gitDirectoryStatus = inspectMakerDirectoryGitStatus(targetDir);
34935
35342
  const remoteSyncText = identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo && !options.skipRemoteSync ? await formatMakerRemoteSyncStatusSafely(identify.projectRoot) : identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo ? formatMakerRemoteSyncSkipped() : "";
34936
35343
  const pat = loadPat();
@@ -34962,6 +35369,10 @@ async function formatStatus(options = {}) {
34962
35369
  allowRemoteFetch: false
34963
35370
  })
34964
35371
  );
35372
+ const projectInitializationText = identify.projectRoot ? formatMakerProjectInitializationStatus(
35373
+ inspectMakerProjectInitialization(identify.projectRoot)
35374
+ ) : "";
35375
+ const projectSettingsText = identify.projectRoot ? formatMakerProjectSettingsStatus(inspectMakerProjectSettings(identify.projectRoot)) : "";
34965
35376
  const projectSection = identify.projectId ? [
34966
35377
  "目标目录已绑定 Maker 项目。",
34967
35378
  "请继续在当前绑定项目上执行状态、提交、构建等操作;用户明确要求切换或重新拉取项目时,再进入项目选择流程。",
@@ -34992,11 +35403,8 @@ async function formatStatus(options = {}) {
34992
35403
  packageUpdateText,
34993
35404
  "",
34994
35405
  formatMakerGitDirectoryStatus(gitDirectoryStatus),
34995
- "",
34996
- identify.projectRoot ? formatMakerProjectInitializationStatus(
34997
- inspectMakerProjectInitialization(identify.projectRoot)
34998
- ) : "",
34999
- "",
35406
+ ...projectInitializationText ? ["", projectInitializationText, ""] : [""],
35407
+ ...projectSettingsText ? ["", projectSettingsText, ""] : [""],
35000
35408
  formatMakerClientRootsStatus(projectContext.roots),
35001
35409
  "",
35002
35410
  projectContext.source === "client_roots" ? "" : formatMakerToolRegistrationCwdStatus({
@@ -35067,10 +35475,10 @@ function formatMakerToolRegistrationCwdStatus(options) {
35067
35475
  if (!options.projectRoot) {
35068
35476
  return "";
35069
35477
  }
35070
- const mcpCwd = path16.resolve(options.mcpCwd);
35071
- const targetDir = path16.resolve(options.targetDir);
35072
- const projectRoot = path16.resolve(options.projectRoot);
35073
- const mcpProjectRoot = options.mcpProjectRoot ? path16.resolve(options.mcpProjectRoot) : void 0;
35478
+ const mcpCwd = path17.resolve(options.mcpCwd);
35479
+ const targetDir = path17.resolve(options.targetDir);
35480
+ const projectRoot = path17.resolve(options.projectRoot);
35481
+ const mcpProjectRoot = options.mcpProjectRoot ? path17.resolve(options.mcpProjectRoot) : void 0;
35074
35482
  if (mcpProjectRoot === projectRoot) {
35075
35483
  return "";
35076
35484
  }
@@ -35243,7 +35651,7 @@ function createServerClientRootsProvider(server) {
35243
35651
  async function resolveMakerProjectContext(options = {}) {
35244
35652
  if (options.targetDir) {
35245
35653
  return {
35246
- targetDir: path16.resolve(options.targetDir),
35654
+ targetDir: path17.resolve(options.targetDir),
35247
35655
  source: "explicit_target_dir",
35248
35656
  roots: { status: "not_requested", roots: [] }
35249
35657
  };
@@ -35338,7 +35746,7 @@ function rootToLocalPath(root) {
35338
35746
  if (url2.protocol !== "file:") {
35339
35747
  return void 0;
35340
35748
  }
35341
- return path16.resolve(fileURLToPath2(url2));
35749
+ return path17.resolve(fileURLToPath2(url2));
35342
35750
  } catch {
35343
35751
  return void 0;
35344
35752
  }
@@ -35352,14 +35760,14 @@ function uniquePaths(values) {
35352
35760
  continue;
35353
35761
  }
35354
35762
  seen.add(normalized);
35355
- result.push(path16.resolve(value));
35763
+ result.push(path17.resolve(value));
35356
35764
  }
35357
35765
  return result;
35358
35766
  }
35359
35767
  function normalizePathForCompare2(value) {
35360
- const resolved = path16.resolve(value);
35768
+ const resolved = path17.resolve(value);
35361
35769
  try {
35362
- return fs15.realpathSync.native(resolved);
35770
+ return fs16.realpathSync.native(resolved);
35363
35771
  } catch {
35364
35772
  return resolved;
35365
35773
  }
@@ -35508,14 +35916,14 @@ function formatStatusProjectList(projects) {
35508
35916
  ].filter((line) => line !== void 0).join("\n");
35509
35917
  }
35510
35918
  function formatClonePartialStateLines(targetDir) {
35511
- const resolvedTargetDir = path16.resolve(targetDir);
35919
+ const resolvedTargetDir = path17.resolve(targetDir);
35512
35920
  const identify = identifyMakerProject({ cwd: resolvedTargetDir });
35513
35921
  const gitStatus = inspectMakerDirectoryGitStatus(resolvedTargetDir);
35514
35922
  const devKitStatus = inspectAiDevKit(resolvedTargetDir);
35515
- const stagedDevKitGitignorePath = path16.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
35923
+ const stagedDevKitGitignorePath = path17.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
35516
35924
  const projectBound = Boolean(identify.projectId);
35517
35925
  const gitInitialized = Boolean(
35518
- gitStatus.isOwnGitRoot || fs15.existsSync(path16.join(resolvedTargetDir, ".git"))
35926
+ gitStatus.isOwnGitRoot || fs16.existsSync(path17.join(resolvedTargetDir, ".git"))
35519
35927
  );
35520
35928
  const safeToRetry = !projectBound;
35521
35929
  return [
@@ -35529,7 +35937,7 @@ function formatClonePartialStateLines(targetDir) {
35529
35937
  identify.configPath ? `- config: ${identify.configPath}` : "",
35530
35938
  `- ai_dev_kit_present: ${devKitStatus.ready ? "yes" : "no"}`,
35531
35939
  `- ai_dev_kit_missing_entries: ${devKitStatus.missingEntries.join(", ") || "(none)"}`,
35532
- `- staged_dev_kit_gitignore: ${fs15.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
35940
+ `- staged_dev_kit_gitignore: ${fs16.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
35533
35941
  `- safe_to_retry: ${safeToRetry ? "yes" : "no"}`,
35534
35942
  safeToRetry ? "- next_step: 可以直接重试 taptap-maker init;如果连续失败,建议换一个全新的独立目录重新 clone。" : "- next_step: 当前目录已经有 Maker 绑定信息;先运行 taptap-maker doctor 或读取 maker://status 确认状态。"
35535
35943
  ].filter(Boolean);
@@ -35605,12 +36013,12 @@ function resolveEmbeddedProxyCommand(options) {
35605
36013
  }
35606
36014
  return {
35607
36015
  command: process.execPath,
35608
- args: [path16.resolve(makerEntry), "__maker-proxy"]
36016
+ args: [path17.resolve(makerEntry), "__maker-proxy"]
35609
36017
  };
35610
36018
  }
35611
36019
  function resolveBundledMakerEntry() {
35612
- const bundledEntry = path16.resolve(__dirname, "../../../bin/taptap-maker");
35613
- return fs15.existsSync(bundledEntry) ? bundledEntry : void 0;
36020
+ const bundledEntry = path17.resolve(__dirname, "../../../bin/taptap-maker");
36021
+ return fs16.existsSync(bundledEntry) ? bundledEntry : void 0;
35614
36022
  }
35615
36023
  function isUsableEmbeddedMakerEntry(entry) {
35616
36024
  if (!entry) {
@@ -35715,6 +36123,15 @@ async function buildCurrentDirectory(options) {
35715
36123
  const localChanges = await readMakerProjectLocalChanges(options.targetDir);
35716
36124
  if (!options.confirmRemoteBuildWithoutSubmit) {
35717
36125
  const config2 = loadProjectConfig(localChanges.projectRoot);
36126
+ const settingsStatus = inspectMakerProjectSettings(localChanges.projectRoot);
36127
+ if (isMakerProjectSettingsBlocking(settingsStatus)) {
36128
+ return {
36129
+ mode: "settings_invalid_before_build",
36130
+ projectRoot: localChanges.projectRoot,
36131
+ projectId: (config2 == null ? void 0 : config2.project_id) || "unknown",
36132
+ settingsStatus
36133
+ };
36134
+ }
35718
36135
  (_a3 = options.onProgress) == null ? void 0 : _a3.call(options, {
35719
36136
  progress: 0,
35720
36137
  total: 100,
@@ -35936,18 +36353,18 @@ async function attachRuntimeLogWatch(buildResult, startWatch) {
35936
36353
  }
35937
36354
  }
35938
36355
  async function startRuntimeLogWatch(buildResult) {
35939
- const runtimeDir = path16.join(buildResult.projectRoot, ".maker", "logs", "runtime");
35940
- fs15.mkdirSync(runtimeDir, { recursive: true });
35941
- const stdoutLog = path16.join(runtimeDir, "watcher.out.log");
35942
- const stderrLog = path16.join(runtimeDir, "watcher.err.log");
35943
- const pidFile = path16.join(runtimeDir, "watcher.pid");
36356
+ const runtimeDir = path17.join(buildResult.projectRoot, ".maker", "logs", "runtime");
36357
+ fs16.mkdirSync(runtimeDir, { recursive: true });
36358
+ const stdoutLog = path17.join(runtimeDir, "watcher.out.log");
36359
+ const stderrLog = path17.join(runtimeDir, "watcher.err.log");
36360
+ const pidFile = path17.join(runtimeDir, "watcher.pid");
35944
36361
  const previous = stopExistingRuntimeLogWatcher(pidFile);
35945
- const outFd = fs15.openSync(stdoutLog, "a");
35946
- const errFd = fs15.openSync(stderrLog, "a");
36362
+ const outFd = fs16.openSync(stdoutLog, "a");
36363
+ const errFd = fs16.openSync(stderrLog, "a");
35947
36364
  const command = formatRuntimeLogWatchCommand(buildResult);
35948
36365
  if (previous.previousStopError) {
35949
- fs15.closeSync(outFd);
35950
- fs15.closeSync(errFd);
36366
+ fs16.closeSync(outFd);
36367
+ fs16.closeSync(errFd);
35951
36368
  return {
35952
36369
  started: false,
35953
36370
  command: command.text,
@@ -36010,18 +36427,18 @@ async function startRuntimeLogWatch(buildResult) {
36010
36427
  ...previous
36011
36428
  };
36012
36429
  } finally {
36013
- fs15.closeSync(outFd);
36014
- fs15.closeSync(errFd);
36430
+ fs16.closeSync(outFd);
36431
+ fs16.closeSync(errFd);
36015
36432
  }
36016
36433
  }
36017
36434
  function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
36018
- if (!fs15.existsSync(pidFile)) {
36435
+ if (!fs16.existsSync(pidFile)) {
36019
36436
  return {};
36020
36437
  }
36021
36438
  const pidState = readRuntimeLogWatcherPidState(pidFile);
36022
36439
  const pid = pidState == null ? void 0 : pidState.pid;
36023
36440
  if (!Number.isInteger(pid) || pid <= 0) {
36024
- fs15.rmSync(pidFile, { force: true });
36441
+ fs16.rmSync(pidFile, { force: true });
36025
36442
  return {};
36026
36443
  }
36027
36444
  try {
@@ -36029,7 +36446,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
36029
36446
  const processCommand = (options.getProcessCommand || getProcessCommand)(pid);
36030
36447
  const verifiedCommand = getVerifiedRuntimeLogWatcherCommand(processCommand, pidState);
36031
36448
  if (!verifiedCommand) {
36032
- fs15.rmSync(pidFile, { force: true });
36449
+ fs16.rmSync(pidFile, { force: true });
36033
36450
  return {
36034
36451
  previousPid: pid,
36035
36452
  previousStopped: false,
@@ -36039,7 +36456,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
36039
36456
  process.kill(pid, "SIGTERM");
36040
36457
  const stopped = (options.waitForExit || waitForProcessExit)(pid, WATCHER_STOP_TIMEOUT_MS);
36041
36458
  if (stopped) {
36042
- fs15.rmSync(pidFile, { force: true });
36459
+ fs16.rmSync(pidFile, { force: true });
36043
36460
  return { previousPid: pid, previousStopped: true };
36044
36461
  }
36045
36462
  return {
@@ -36048,7 +36465,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
36048
36465
  previousStopError: `process ${pid} did not exit after SIGTERM within ${WATCHER_STOP_TIMEOUT_MS}ms`
36049
36466
  };
36050
36467
  } catch (error2) {
36051
- fs15.rmSync(pidFile, { force: true });
36468
+ fs16.rmSync(pidFile, { force: true });
36052
36469
  const code = error2 && typeof error2 === "object" && "code" in error2 ? String(error2.code) : "";
36053
36470
  if (code === "ESRCH") {
36054
36471
  return { previousPid: pid, previousStopped: false };
@@ -36061,7 +36478,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
36061
36478
  }
36062
36479
  }
36063
36480
  function readRuntimeLogWatcherPidState(pidFile) {
36064
- const raw = fs15.readFileSync(pidFile, "utf8").trim();
36481
+ const raw = fs16.readFileSync(pidFile, "utf8").trim();
36065
36482
  if (!raw) {
36066
36483
  return null;
36067
36484
  }
@@ -36077,7 +36494,7 @@ function readRuntimeLogWatcherPidState(pidFile) {
36077
36494
  }
36078
36495
  }
36079
36496
  function writeRuntimeLogWatcherPidFile(pidFile, state) {
36080
- fs15.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
36497
+ fs16.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
36081
36498
  `, "utf8");
36082
36499
  }
36083
36500
  function getProcessCommand(pid) {
@@ -36163,10 +36580,10 @@ function formatRuntimeLogWatchCommand(buildResult) {
36163
36580
  };
36164
36581
  }
36165
36582
  function resolveMakerCliEntry() {
36166
- return process.argv[1] || path16.resolve(process.cwd(), "dist", "maker.js");
36583
+ return process.argv[1] || path17.resolve(process.cwd(), "dist", "maker.js");
36167
36584
  }
36168
36585
  function getRuntimeLogFilePath(projectRoot) {
36169
- return path16.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
36586
+ return path17.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
36170
36587
  }
36171
36588
  async function refreshMakerPreview(buildResult) {
36172
36589
  const makerEnv = buildResult.env === "rnd" || buildResult.env === "production" ? buildResult.env : void 0;
@@ -36300,7 +36717,7 @@ function createBuildArgs(projectRoot, options) {
36300
36717
  if (options.scriptsPath) {
36301
36718
  buildArgs.scriptsPath = options.scriptsPath;
36302
36719
  }
36303
- if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs15.existsSync(path16.join(projectRoot, "scripts", "main.lua"))) {
36720
+ if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs16.existsSync(path17.join(projectRoot, "scripts", "main.lua"))) {
36304
36721
  buildArgs.entry = "main.lua";
36305
36722
  buildArgs.scriptsPath = "scripts";
36306
36723
  }
@@ -36312,7 +36729,7 @@ function createBuildArgs(projectRoot, options) {
36312
36729
  }
36313
36730
  if (options.multiplayer) {
36314
36731
  buildArgs.multiplayer = options.multiplayer;
36315
- } else if (!fs15.existsSync(path16.join(projectRoot, ".project", "settings.json"))) {
36732
+ } else if (!options.entryClient && !options.entryServer && !fs16.existsSync(path17.join(projectRoot, ".project", "settings.json"))) {
36316
36733
  buildArgs.multiplayer = { enabled: false };
36317
36734
  }
36318
36735
  return buildArgs;
@@ -36391,6 +36808,17 @@ function formatBuildResult(result, progressSummary) {
36391
36808
  ] : []
36392
36809
  ].filter(Boolean).join("\n");
36393
36810
  }
36811
+ if (result.mode === "settings_invalid_before_build") {
36812
+ return [
36813
+ "✗ Maker project settings are invalid; submit and remote build were not started",
36814
+ "",
36815
+ `- project_root: ${result.projectRoot}`,
36816
+ `- project_id: ${result.projectId}`,
36817
+ ...formatProgressSummary(progressSummary),
36818
+ "",
36819
+ formatMakerProjectSettingsStatus(result.settingsStatus)
36820
+ ].filter(Boolean).join("\n");
36821
+ }
36394
36822
  if (result.mode === "build_failed_after_submit") {
36395
36823
  return [
36396
36824
  "✗ Maker project submitted, but remote Maker build failed",
@@ -36474,11 +36902,11 @@ function formatRuntimeLogWatchNextActionLines(result) {
36474
36902
  ((_a3 = result.runtimeLogWatch) == null ? void 0 : _a3.pid) ? `- watch_pid: ${result.runtimeLogWatch.pid}` : "",
36475
36903
  `- watch_command: ${command}`,
36476
36904
  ((_b = result.runtimeLogWatch) == null ? void 0 : _b.command) ? `- actual_watch_command: ${result.runtimeLogWatch.command}` : "",
36477
- `- local_file: ${path16.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
36905
+ `- local_file: ${path17.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
36478
36906
  ((_c = result.runtimeLogWatch) == null ? void 0 : _c.stdoutLog) ? `- watcher_stdout: ${result.runtimeLogWatch.stdoutLog}` : "",
36479
36907
  ((_d = result.runtimeLogWatch) == null ? void 0 : _d.stderrLog) ? `- watcher_stderr: ${result.runtimeLogWatch.stderrLog}` : "",
36480
36908
  ((_e = result.runtimeLogWatch) == null ? void 0 : _e.pidFile) ? `- watcher_pid_file: ${result.runtimeLogWatch.pidFile}` : "",
36481
- `- state_file: ${path16.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
36909
+ `- state_file: ${path17.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
36482
36910
  ((_f = result.runtimeLogWatch) == null ? void 0 : _f.previousPid) ? `- previous_watch_pid: ${result.runtimeLogWatch.previousPid}` : "",
36483
36911
  ((_g = result.runtimeLogWatch) == null ? void 0 : _g.previousStopped) !== void 0 ? `- previous_watch_stopped: ${result.runtimeLogWatch.previousStopped ? "yes" : "no"}` : "",
36484
36912
  ((_h = result.runtimeLogWatch) == null ? void 0 : _h.previousStopError) ? `- previous_watch_stop_error: ${result.runtimeLogWatch.previousStopError}` : "",
@@ -36669,9 +37097,9 @@ function indent2(value) {
36669
37097
  // src/maker/cli/commands.ts
36670
37098
  import { spawnSync as spawnSync7 } from "node:child_process";
36671
37099
  import crypto3 from "node:crypto";
36672
- import fs16 from "node:fs";
37100
+ import fs17 from "node:fs";
36673
37101
  import os4 from "node:os";
36674
- import path17 from "node:path";
37102
+ import path18 from "node:path";
36675
37103
  import readline from "node:readline/promises";
36676
37104
  import { stdin as input, stdout as output } from "node:process";
36677
37105
 
@@ -36817,7 +37245,7 @@ function formatError2(error2) {
36817
37245
  }
36818
37246
 
36819
37247
  // src/maker/cli/commands.ts
36820
- var VERSION2 = true ? "0.0.24-beta.1" : "dev";
37248
+ var VERSION2 = true ? "0.0.24" : "dev";
36821
37249
  var DEFAULT_MCP_NAME = "taptap-maker";
36822
37250
  var MAKER_NPM_PACKAGE = "@taptap/maker";
36823
37251
  var TWO_PART_COMMANDS = /* @__PURE__ */ new Set(["pat", "mcp", "dev-kit", "logs", "python", "lua-lsp", "agents"]);
@@ -36952,7 +37380,7 @@ function toOptionKey(value) {
36952
37380
  }
36953
37381
  async function runInit(parsed, ctx) {
36954
37382
  rejectPackageOption(parsed);
36955
- const targetDir = path17.resolve(stringOption(parsed, "target_dir") || process.cwd());
37383
+ const targetDir = path18.resolve(stringOption(parsed, "target_dir") || process.cwd());
36956
37384
  const env = makerEnvOption(parsed);
36957
37385
  const skipConfirm = booleanOption(parsed, "skip_confirm");
36958
37386
  const skipMcpInstall = booleanOption(parsed, "skip_mcp_install");
@@ -37045,7 +37473,7 @@ async function runInit(parsed, ctx) {
37045
37473
  }
37046
37474
  async function runDoctor(parsed, ctx) {
37047
37475
  var _a3, _b;
37048
- const targetDir = path17.resolve(stringOption(parsed, "target_dir") || process.cwd());
37476
+ const targetDir = path18.resolve(stringOption(parsed, "target_dir") || process.cwd());
37049
37477
  const env = makerEnvOption(parsed);
37050
37478
  const git = checkGitEnvironment();
37051
37479
  const python = checkMakerPythonEnvironment();
@@ -37068,6 +37496,7 @@ async function runDoctor(parsed, ctx) {
37068
37496
  makerProjectDir: identify.projectRoot
37069
37497
  });
37070
37498
  const projectInitialization = isProjectBound ? inspectMakerProjectInitialization(projectRoot) : void 0;
37499
+ const projectSettings = isProjectBound ? inspectMakerProjectSettings(projectRoot) : void 0;
37071
37500
  const workBuddyTrust = shouldShowWorkBuddyTrustInspection() ? inspectWorkBuddyTrustState(DEFAULT_MCP_NAME) : void 0;
37072
37501
  if (ctx.json) {
37073
37502
  writeJson({
@@ -37085,6 +37514,7 @@ async function runDoctor(parsed, ctx) {
37085
37514
  dev_kit_update: devKitUpdate,
37086
37515
  package_update: packageUpdate,
37087
37516
  project_initialization: projectInitialization,
37517
+ project_settings: projectSettings,
37088
37518
  mcp_tools_availability: mcpToolsAvailability,
37089
37519
  ...workBuddyTrust ? { workbuddy_trust: workBuddyTrust } : {},
37090
37520
  orphan_process_check: orphanProcessCheck
@@ -37113,6 +37543,7 @@ async function runDoctor(parsed, ctx) {
37113
37543
  `- project_id: ${identify.projectId || "(none)"}`,
37114
37544
  identify.configPath ? `- config: ${identify.configPath}` : "",
37115
37545
  projectInitialization ? formatMakerProjectInitializationStatus(projectInitialization) : "",
37546
+ projectSettings ? formatMakerProjectSettingsStatus(projectSettings) : "",
37116
37547
  isProjectBound ? formatMakerAgentsPolicyStatus(projectRoot) : "",
37117
37548
  "",
37118
37549
  "AI dev kit",
@@ -37136,9 +37567,9 @@ async function runDoctor(parsed, ctx) {
37136
37567
  );
37137
37568
  }
37138
37569
  function inspectMakerMcpToolsAvailability(options) {
37139
- const aiPwd = path17.resolve(process.cwd());
37570
+ const aiPwd = path18.resolve(process.cwd());
37140
37571
  const aiPwdIdentify = identifyMakerProject({ cwd: aiPwd });
37141
- const makerProjectDir = options.makerProjectDir ? path17.resolve(options.makerProjectDir) : void 0;
37572
+ const makerProjectDir = options.makerProjectDir ? path18.resolve(options.makerProjectDir) : void 0;
37142
37573
  if (!makerProjectDir) {
37143
37574
  return {
37144
37575
  tools_visibility: "refresh_ai_client_if_missing",
@@ -37180,9 +37611,9 @@ function samePath2(left, right) {
37180
37611
  return normalizePathForCompare3(left) === normalizePathForCompare3(right);
37181
37612
  }
37182
37613
  function normalizePathForCompare3(value) {
37183
- const resolved = path17.resolve(value);
37614
+ const resolved = path18.resolve(value);
37184
37615
  try {
37185
- return fs16.realpathSync.native(resolved);
37616
+ return fs17.realpathSync.native(resolved);
37186
37617
  } catch {
37187
37618
  return resolved;
37188
37619
  }
@@ -37500,7 +37931,7 @@ async function runPatSet(parsed, ctx) {
37500
37931
  }
37501
37932
  async function resolvePatSet(parsed, ctx) {
37502
37933
  if (booleanOption(parsed, "pat_stdin") || booleanOption(parsed, "pat_from_stdin")) {
37503
- const pat = fs16.readFileSync(0, "utf8").trim();
37934
+ const pat = fs17.readFileSync(0, "utf8").trim();
37504
37935
  if (!pat) {
37505
37936
  throw new Error("No PAT found on stdin.");
37506
37937
  }
@@ -37530,7 +37961,7 @@ async function runMcpInstall(parsed, ctx) {
37530
37961
  env: makerEnvOption(parsed),
37531
37962
  pkg: MAKER_NPM_PACKAGE,
37532
37963
  mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
37533
- cwd: explicitTargetDir ? path17.resolve(explicitTargetDir) : void 0
37964
+ cwd: explicitTargetDir ? path18.resolve(explicitTargetDir) : void 0
37534
37965
  });
37535
37966
  if (ctx.json) {
37536
37967
  writeJson(results);
@@ -37589,7 +38020,7 @@ ${indent3(payload.stderr)}` : "",
37589
38020
  );
37590
38021
  }
37591
38022
  async function runAgentsUpdate(parsed, ctx) {
37592
- const targetDir = path17.resolve(stringOption(parsed, "target_dir") || process.cwd());
38023
+ const targetDir = path18.resolve(stringOption(parsed, "target_dir") || process.cwd());
37593
38024
  const result = updateMakerAgentsPolicy(targetDir);
37594
38025
  if (ctx.json) {
37595
38026
  writeJson(result);
@@ -37608,7 +38039,7 @@ async function runAgentsUpdate(parsed, ctx) {
37608
38039
  async function runUpgrade(parsed, ctx) {
37609
38040
  rejectPackageOption(parsed);
37610
38041
  const explicitTargetDir = stringOption(parsed, "target_dir");
37611
- const targetDir = path17.resolve(explicitTargetDir || process.cwd());
38042
+ const targetDir = path18.resolve(explicitTargetDir || process.cwd());
37612
38043
  const env = makerEnvOption(parsed);
37613
38044
  const ides = parseIdeList(stringOption(parsed, "ide") || stringOption(parsed, "ides") || "");
37614
38045
  const installResults = installMcpConfigs({
@@ -37693,7 +38124,7 @@ function getMcpVerifyNextSteps(mode, commandText) {
37693
38124
  ];
37694
38125
  }
37695
38126
  async function runDevKitUpdate(parsed, ctx) {
37696
- const targetDir = path17.resolve(stringOption(parsed, "target_dir") || process.cwd());
38127
+ const targetDir = path18.resolve(stringOption(parsed, "target_dir") || process.cwd());
37697
38128
  const result = await installAiDevKit({
37698
38129
  targetDir,
37699
38130
  preserveExisting: false,
@@ -37705,7 +38136,7 @@ async function runDevKitUpdate(parsed, ctx) {
37705
38136
  emitDevKitSkillInstallerFailure(ctx, result.skillInstaller, "AI skills install failed");
37706
38137
  }
37707
38138
  async function runLogsWatch(parsed, ctx) {
37708
- const targetDir = path17.resolve(stringOption(parsed, "target_dir") || process.cwd());
38139
+ const targetDir = path18.resolve(stringOption(parsed, "target_dir") || process.cwd());
37709
38140
  const intervalMs = parseDurationMs(stringOption(parsed, "interval") || "5s");
37710
38141
  const timeoutMs = numberOption(parsed, "timeout_ms") ?? DEFAULT_TOOL_CALL_TIMEOUT_MS;
37711
38142
  const maxPolls = numberOption(parsed, "max_polls");
@@ -37715,9 +38146,9 @@ async function runLogsWatch(parsed, ctx) {
37715
38146
  serverUrl: stringOption(parsed, "server_url"),
37716
38147
  env: makerEnvOption(parsed)
37717
38148
  });
37718
- const runtimeDir = path17.join(proxy.projectRoot, ".maker", "logs", "runtime");
37719
- const runtimeLog = path17.join(runtimeDir, "runtime.log");
37720
- const pidFile = path17.join(runtimeDir, "watcher.pid");
38149
+ const runtimeDir = path18.join(proxy.projectRoot, ".maker", "logs", "runtime");
38150
+ const runtimeLog = path18.join(runtimeDir, "runtime.log");
38151
+ const pidFile = path18.join(runtimeDir, "watcher.pid");
37721
38152
  const replacedWatcher = registerRuntimeLogWatcherProcess(pidFile);
37722
38153
  const runtimeLogClient = createRemoteRuntimeLogClient(proxy, timeoutMs);
37723
38154
  emit(ctx, "logs_watch_start", "Maker runtime log watcher started", {
@@ -37762,10 +38193,10 @@ async function runLogsWatch(parsed, ctx) {
37762
38193
  }
37763
38194
  }
37764
38195
  function registerRuntimeLogWatcherProcess(pidFile) {
37765
- fs16.mkdirSync(path17.dirname(pidFile), { recursive: true });
38196
+ fs17.mkdirSync(path18.dirname(pidFile), { recursive: true });
37766
38197
  const existingPid = readPidFile(pidFile);
37767
38198
  const previous = existingPid && existingPid !== process.pid ? stopExistingRuntimeLogWatcher(pidFile) : {};
37768
- fs16.writeFileSync(
38199
+ fs17.writeFileSync(
37769
38200
  pidFile,
37770
38201
  `${JSON.stringify(
37771
38202
  {
@@ -37783,10 +38214,10 @@ function registerRuntimeLogWatcherProcess(pidFile) {
37783
38214
  return previous;
37784
38215
  }
37785
38216
  function readPidFile(pidFile) {
37786
- if (!fs16.existsSync(pidFile)) {
38217
+ if (!fs17.existsSync(pidFile)) {
37787
38218
  return void 0;
37788
38219
  }
37789
- const raw = fs16.readFileSync(pidFile, "utf8").trim();
38220
+ const raw = fs17.readFileSync(pidFile, "utf8").trim();
37790
38221
  let pid = Number(raw);
37791
38222
  if (!Number.isInteger(pid) || pid <= 0) {
37792
38223
  try {
@@ -37806,7 +38237,7 @@ function installRuntimeLogWatcherPidCleanup(pidFile) {
37806
38237
  }
37807
38238
  cleaned = true;
37808
38239
  if (readPidFile(pidFile) === process.pid) {
37809
- fs16.rmSync(pidFile, { force: true });
38240
+ fs17.rmSync(pidFile, { force: true });
37810
38241
  }
37811
38242
  };
37812
38243
  process.once("exit", cleanup);
@@ -37957,7 +38388,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
37957
38388
  onStart: (event) => emitSkillInstallerStart(ctx, event)
37958
38389
  });
37959
38390
  writeDevKitStagedGitignore(
37960
- path17.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
38391
+ path18.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
37961
38392
  listPresentDevKitManagedEntries(targetDir)
37962
38393
  );
37963
38394
  if (options.finalizeGitignore) {
@@ -37974,7 +38405,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
37974
38405
  );
37975
38406
  } catch (error2) {
37976
38407
  writeDevKitStagedGitignore(
37977
- path17.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
38408
+ path18.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
37978
38409
  listPresentDevKitManagedEntries(targetDir)
37979
38410
  );
37980
38411
  if (options.finalizeGitignore) {
@@ -38064,12 +38495,12 @@ function installMcpConfig(ide, options) {
38064
38495
  }
38065
38496
  function installMcpConfigUnsafe(ide, options) {
38066
38497
  if (ide === "codex") {
38067
- const configPath = path17.join(os4.homedir(), ".codex", "config.toml");
38498
+ const configPath = path18.join(os4.homedir(), ".codex", "config.toml");
38068
38499
  const write = mergeCodexMcpConfig(configPath, withClientIde(options, "codex"));
38069
38500
  return [createMcpInstallResult(ide, "Codex", configPath, write)];
38070
38501
  }
38071
38502
  if (ide === "cursor") {
38072
- const configPath = path17.join(os4.homedir(), ".cursor", "mcp.json");
38503
+ const configPath = path18.join(os4.homedir(), ".cursor", "mcp.json");
38073
38504
  const write = mergeJsonMcpConfig(configPath, withClientIde(options, "cursor"));
38074
38505
  return [createMcpInstallResult(ide, "Cursor", configPath, write)];
38075
38506
  }
@@ -38087,7 +38518,7 @@ function installMcpConfigUnsafe(ide, options) {
38087
38518
  ];
38088
38519
  }
38089
38520
  }
38090
- const configPath = path17.join(os4.homedir(), ".claude.json");
38521
+ const configPath = path18.join(os4.homedir(), ".claude.json");
38091
38522
  const write = mergeJsonMcpConfig(configPath, claudeOptions);
38092
38523
  return [createMcpInstallResult(ide, "Claude fallback", configPath, write)];
38093
38524
  }
@@ -38101,7 +38532,7 @@ function installMcpConfigUnsafe(ide, options) {
38101
38532
  }
38102
38533
  if (ide === "opencode") {
38103
38534
  const configPath = getOpenCodeMcpConfigPath();
38104
- if (!fs16.existsSync(configPath)) {
38535
+ if (!fs17.existsSync(configPath)) {
38105
38536
  return [{ ide, ok: false, message: "Skipped OpenCode: no supported config file found" }];
38106
38537
  }
38107
38538
  const write = mergeOpenCodeMcpConfig(configPath, withClientIde(options, "opencode"));
@@ -38169,7 +38600,7 @@ function getDefaultMcpInstallIdes() {
38169
38600
  if (getTraeMcpInstallPaths().length > 0) {
38170
38601
  ides.push("trae");
38171
38602
  }
38172
- if (fs16.existsSync(getOpenCodeMcpConfigPath())) {
38603
+ if (fs17.existsSync(getOpenCodeMcpConfigPath())) {
38173
38604
  ides.push("opencode");
38174
38605
  }
38175
38606
  if (getWorkBuddyMcpInstallPaths().length > 0) {
@@ -38186,7 +38617,7 @@ function getExistingTraeUserConfigPaths(paths) {
38186
38617
  const seen = /* @__PURE__ */ new Set();
38187
38618
  return paths.filter((configPath) => {
38188
38619
  const key = normalizeConfigPathKey(configPath);
38189
- if (seen.has(key) || !fs16.existsSync(path17.dirname(configPath))) {
38620
+ if (seen.has(key) || !fs17.existsSync(path18.dirname(configPath))) {
38190
38621
  return false;
38191
38622
  }
38192
38623
  seen.add(key);
@@ -38197,7 +38628,7 @@ function getExistingConfigPaths(paths) {
38197
38628
  const seen = /* @__PURE__ */ new Set();
38198
38629
  return paths.filter((configPath) => {
38199
38630
  const key = normalizeConfigPathKey(configPath);
38200
- if (seen.has(key) || !fs16.existsSync(configPath)) {
38631
+ if (seen.has(key) || !fs17.existsSync(configPath)) {
38201
38632
  return false;
38202
38633
  }
38203
38634
  seen.add(key);
@@ -38205,65 +38636,65 @@ function getExistingConfigPaths(paths) {
38205
38636
  });
38206
38637
  }
38207
38638
  function normalizeConfigPathKey(configPath) {
38208
- const resolved = path17.resolve(configPath);
38639
+ const resolved = path18.resolve(configPath);
38209
38640
  return process.platform === "win32" || process.platform === "darwin" ? resolved.toLowerCase() : resolved;
38210
38641
  }
38211
38642
  function getTraeSoloMcpConfigPaths() {
38212
38643
  if (process.platform === "win32") {
38213
- const roaming = process.env.APPDATA || path17.join(os4.homedir(), "AppData", "Roaming");
38644
+ const roaming = process.env.APPDATA || path18.join(os4.homedir(), "AppData", "Roaming");
38214
38645
  return [
38215
- path17.join(roaming, "TRAE SOLO", "User", "mcp.json"),
38216
- path17.join(roaming, "TRAE SOLO CN", "User", "mcp.json")
38646
+ path18.join(roaming, "TRAE SOLO", "User", "mcp.json"),
38647
+ path18.join(roaming, "TRAE SOLO CN", "User", "mcp.json")
38217
38648
  ];
38218
38649
  }
38219
- const appSupport = path17.join(os4.homedir(), "Library", "Application Support");
38650
+ const appSupport = path18.join(os4.homedir(), "Library", "Application Support");
38220
38651
  return [
38221
- path17.join(appSupport, "TRAE SOLO CN", "User", "mcp.json"),
38222
- path17.join(appSupport, "TRAE SOLO", "User", "mcp.json")
38652
+ path18.join(appSupport, "TRAE SOLO CN", "User", "mcp.json"),
38653
+ path18.join(appSupport, "TRAE SOLO", "User", "mcp.json")
38223
38654
  ];
38224
38655
  }
38225
38656
  function getTraeUnverifiedMcpConfigPaths() {
38226
38657
  if (process.platform === "win32") {
38227
- const roaming = process.env.APPDATA || path17.join(os4.homedir(), "AppData", "Roaming");
38658
+ const roaming = process.env.APPDATA || path18.join(os4.homedir(), "AppData", "Roaming");
38228
38659
  return [
38229
- path17.join(roaming, "Trae", "User", "mcp.json"),
38230
- path17.join(roaming, "TRAE", "User", "mcp.json"),
38231
- path17.join(roaming, "Trae CN", "User", "mcp.json")
38660
+ path18.join(roaming, "Trae", "User", "mcp.json"),
38661
+ path18.join(roaming, "TRAE", "User", "mcp.json"),
38662
+ path18.join(roaming, "Trae CN", "User", "mcp.json")
38232
38663
  ];
38233
38664
  }
38234
- const appSupport = path17.join(os4.homedir(), "Library", "Application Support");
38665
+ const appSupport = path18.join(os4.homedir(), "Library", "Application Support");
38235
38666
  return [
38236
- path17.join(appSupport, "Trae", "User", "mcp.json"),
38237
- path17.join(appSupport, "TRAE", "User", "mcp.json"),
38238
- path17.join(appSupport, "Trae CN", "User", "mcp.json")
38667
+ path18.join(appSupport, "Trae", "User", "mcp.json"),
38668
+ path18.join(appSupport, "TRAE", "User", "mcp.json"),
38669
+ path18.join(appSupport, "Trae CN", "User", "mcp.json")
38239
38670
  ];
38240
38671
  }
38241
38672
  function getOpenCodeMcpConfigPath() {
38242
- return path17.join(os4.homedir(), ".config", "opencode", "opencode.jsonc");
38673
+ return path18.join(os4.homedir(), ".config", "opencode", "opencode.jsonc");
38243
38674
  }
38244
38675
  function getWorkBuddyHome() {
38245
- return path17.join(os4.homedir(), ".workbuddy");
38676
+ return path18.join(os4.homedir(), ".workbuddy");
38246
38677
  }
38247
38678
  function shouldShowWorkBuddyTrustInspection() {
38248
- return fs16.existsSync(getWorkBuddyHome());
38679
+ return fs17.existsSync(getWorkBuddyHome());
38249
38680
  }
38250
38681
  function getWorkBuddyMcpInstallPaths(options = {}) {
38251
- const primary = path17.join(getWorkBuddyHome(), "mcp.json");
38252
- if (fs16.existsSync(primary) || options.createPrimary) {
38682
+ const primary = path18.join(getWorkBuddyHome(), "mcp.json");
38683
+ if (fs17.existsSync(primary) || options.createPrimary) {
38253
38684
  return [primary];
38254
38685
  }
38255
- const legacy = path17.join(getWorkBuddyHome(), ".mcp.json");
38256
- if (fs16.existsSync(legacy)) {
38686
+ const legacy = path18.join(getWorkBuddyHome(), ".mcp.json");
38687
+ if (fs17.existsSync(legacy)) {
38257
38688
  return [legacy];
38258
38689
  }
38259
38690
  return [];
38260
38691
  }
38261
38692
  function inspectWorkBuddyTrustState(mcpName) {
38262
38693
  const workbuddyHome = getWorkBuddyHome();
38263
- const connectorsDir = path17.join(workbuddyHome, "connectors");
38694
+ const connectorsDir = path18.join(workbuddyHome, "connectors");
38264
38695
  const accounts = [];
38265
38696
  const stateFiles = [];
38266
- if (!fs16.existsSync(connectorsDir)) {
38697
+ if (!fs17.existsSync(connectorsDir)) {
38267
38698
  return {
38268
38699
  status: "not_found",
38269
38700
  mcp_name: mcpName,
@@ -38273,12 +38704,12 @@ function inspectWorkBuddyTrustState(mcpName) {
38273
38704
  accounts
38274
38705
  };
38275
38706
  }
38276
- for (const entry of fs16.readdirSync(connectorsDir, { withFileTypes: true })) {
38707
+ for (const entry of fs17.readdirSync(connectorsDir, { withFileTypes: true })) {
38277
38708
  if (!entry.isDirectory()) {
38278
38709
  continue;
38279
38710
  }
38280
- const statePath = path17.join(connectorsDir, entry.name, "connector-states.json");
38281
- if (!fs16.existsSync(statePath)) {
38711
+ const statePath = path18.join(connectorsDir, entry.name, "connector-states.json");
38712
+ if (!fs17.existsSync(statePath)) {
38282
38713
  continue;
38283
38714
  }
38284
38715
  stateFiles.push(statePath);
@@ -38353,7 +38784,7 @@ function mergeJsonMcpConfig(configPath, options) {
38353
38784
  );
38354
38785
  }
38355
38786
  function mergeOpenCodeMcpConfig(configPath, options) {
38356
- const rawContent = fs16.readFileSync(configPath, "utf8");
38787
+ const rawContent = fs17.readFileSync(configPath, "utf8");
38357
38788
  const rewroteJsonc = normalizeJsonConfigContent(rawContent, { jsonc: true }) !== rawContent;
38358
38789
  const existing = readJsonObject(configPath, { jsonc: true });
38359
38790
  const mcp = asObject(existing.mcp);
@@ -38380,7 +38811,7 @@ function mergeOpenCodeMcpConfig(configPath, options) {
38380
38811
  return { ...write, rewroteJsonc: write.changed && rewroteJsonc };
38381
38812
  }
38382
38813
  function mergeCodexMcpConfig(configPath, options) {
38383
- const existing = fs16.existsSync(configPath) ? fs16.readFileSync(configPath, "utf8") : "";
38814
+ const existing = fs17.existsSync(configPath) ? fs17.readFileSync(configPath, "utf8") : "";
38384
38815
  const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
38385
38816
  const withoutOld = existing.replace(sectionPattern, "").trimEnd();
38386
38817
  const launch = getNpxCliCommand(options.pkg);
@@ -38550,10 +38981,10 @@ function rejectPackageOption(parsed) {
38550
38981
  }
38551
38982
  }
38552
38983
  function readJsonObject(filePath, options = {}) {
38553
- if (!fs16.existsSync(filePath)) {
38984
+ if (!fs17.existsSync(filePath)) {
38554
38985
  return {};
38555
38986
  }
38556
- const raw = fs16.readFileSync(filePath, "utf8");
38987
+ const raw = fs17.readFileSync(filePath, "utf8");
38557
38988
  try {
38558
38989
  const normalized = normalizeJsonConfigContent(raw, options);
38559
38990
  const parsed = JSON.parse(normalized);
@@ -38573,25 +39004,25 @@ function asObject(value) {
38573
39004
  return {};
38574
39005
  }
38575
39006
  function writeConfigWithTapTapBackupIfChanged(filePath, nextContent, validate) {
38576
- const existed = fs16.existsSync(filePath);
38577
- const previousContent = existed ? fs16.readFileSync(filePath, "utf8") : void 0;
39007
+ const existed = fs17.existsSync(filePath);
39008
+ const previousContent = existed ? fs17.readFileSync(filePath, "utf8") : void 0;
38578
39009
  if (previousContent === nextContent) {
38579
39010
  return { changed: false };
38580
39011
  }
38581
39012
  const backupPath = existed ? `${filePath}.taptap-maker.bak.latest` : void 0;
38582
- fs16.mkdirSync(path17.dirname(filePath), { recursive: true });
39013
+ fs17.mkdirSync(path18.dirname(filePath), { recursive: true });
38583
39014
  if (previousContent !== void 0 && backupPath) {
38584
- fs16.writeFileSync(backupPath, previousContent, "utf8");
39015
+ fs17.writeFileSync(backupPath, previousContent, "utf8");
38585
39016
  }
38586
39017
  try {
38587
- fs16.writeFileSync(filePath, nextContent, "utf8");
38588
- validate == null ? void 0 : validate(fs16.readFileSync(filePath, "utf8"));
39018
+ fs17.writeFileSync(filePath, nextContent, "utf8");
39019
+ validate == null ? void 0 : validate(fs17.readFileSync(filePath, "utf8"));
38589
39020
  return { changed: true, backupPath };
38590
39021
  } catch (error2) {
38591
39022
  if (previousContent !== void 0) {
38592
- fs16.writeFileSync(filePath, previousContent, "utf8");
39023
+ fs17.writeFileSync(filePath, previousContent, "utf8");
38593
39024
  } else {
38594
- fs16.rmSync(filePath, { force: true });
39025
+ fs17.rmSync(filePath, { force: true });
38595
39026
  }
38596
39027
  throw error2;
38597
39028
  }
@@ -38738,10 +39169,10 @@ function formatMcpInstallMessage(label, configPath, write) {
38738
39169
  ].filter(Boolean).join("\n");
38739
39170
  }
38740
39171
  function saveInitState(targetDir, state) {
38741
- fs16.mkdirSync(getMakerHome(), { recursive: true });
38742
- const key = crypto3.createHash("sha256").update(path17.resolve(targetDir)).digest("hex").slice(0, 16);
38743
- fs16.writeFileSync(
38744
- path17.join(getMakerHome(), `init-state-${key}.json`),
39172
+ fs17.mkdirSync(getMakerHome(), { recursive: true });
39173
+ const key = crypto3.createHash("sha256").update(path18.resolve(targetDir)).digest("hex").slice(0, 16);
39174
+ fs17.writeFileSync(
39175
+ path18.join(getMakerHome(), `init-state-${key}.json`),
38745
39176
  `${JSON.stringify({ ...state, updated_at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)}
38746
39177
  `,
38747
39178
  "utf8"
@@ -38889,7 +39320,7 @@ function makerEnvOption(parsed) {
38889
39320
  return env;
38890
39321
  }
38891
39322
  const targetDir = stringOption(parsed, "target_dir");
38892
- return getMakerEnvironment(void 0, targetDir ? path17.resolve(targetDir) : process.cwd());
39323
+ return getMakerEnvironment(void 0, targetDir ? path18.resolve(targetDir) : process.cwd());
38893
39324
  }
38894
39325
  function mcpVerifyModeOption(parsed) {
38895
39326
  const mode = stringOption(parsed, "mode") || "npx";
@@ -40393,7 +40824,7 @@ var StreamableHTTPClientTransport = class {
40393
40824
  };
40394
40825
 
40395
40826
  // src/mcp-proxy/proxy.ts
40396
- import * as path19 from "node:path";
40827
+ import * as path20 from "node:path";
40397
40828
  import * as crypto6 from "node:crypto";
40398
40829
 
40399
40830
  // src/mcp-proxy/cookieJar.ts
@@ -40575,8 +41006,8 @@ function createCookieFetch(cookieJar) {
40575
41006
  }
40576
41007
 
40577
41008
  // src/core/utils/logWriter.ts
40578
- import * as fs17 from "node:fs";
40579
- import * as path18 from "node:path";
41009
+ import * as fs18 from "node:fs";
41010
+ import * as path19 from "node:path";
40580
41011
  import * as crypto5 from "node:crypto";
40581
41012
 
40582
41013
  // src/core/types/log.ts
@@ -40617,7 +41048,7 @@ var LogWriter = class {
40617
41048
  return;
40618
41049
  }
40619
41050
  try {
40620
- await fs17.promises.mkdir(this.config.logDir, { recursive: true });
41051
+ await fs18.promises.mkdir(this.config.logDir, { recursive: true });
40621
41052
  await this.cleanupOldLogs();
40622
41053
  this.initialized = true;
40623
41054
  } catch (error2) {
@@ -40640,7 +41071,7 @@ var LogWriter = class {
40640
41071
  */
40641
41072
  getLogFilePath(date5) {
40642
41073
  const d = date5 || this.getCurrentDate();
40643
- return path18.join(this.config.logDir, `${this.config.prefix}-${d}.log`);
41074
+ return path19.join(this.config.logDir, `${this.config.prefix}-${d}.log`);
40644
41075
  }
40645
41076
  /**
40646
41077
  * 获取或创建写入流
@@ -40655,7 +41086,7 @@ var LogWriter = class {
40655
41086
  }
40656
41087
  this.currentDate = date5;
40657
41088
  try {
40658
- this.writeStream = fs17.createWriteStream(this.getLogFilePath(date5), {
41089
+ this.writeStream = fs18.createWriteStream(this.getLogFilePath(date5), {
40659
41090
  flags: "a",
40660
41091
  encoding: "utf8"
40661
41092
  });
@@ -40707,11 +41138,11 @@ var LogWriter = class {
40707
41138
  if (this.shouldWriteToFile(level) && this.initialized && this.config.enabled) {
40708
41139
  try {
40709
41140
  const filePath = this.getLogFilePath();
40710
- const dir = path18.dirname(filePath);
40711
- if (!fs17.existsSync(dir)) {
40712
- fs17.mkdirSync(dir, { recursive: true });
41141
+ const dir = path19.dirname(filePath);
41142
+ if (!fs18.existsSync(dir)) {
41143
+ fs18.mkdirSync(dir, { recursive: true });
40713
41144
  }
40714
- fs17.appendFileSync(filePath, message, "utf8");
41145
+ fs18.appendFileSync(filePath, message, "utf8");
40715
41146
  } catch {
40716
41147
  }
40717
41148
  }
@@ -40722,7 +41153,7 @@ var LogWriter = class {
40722
41153
  async cleanupOldLogs() {
40723
41154
  if (this.config.maxDays <= 0) return;
40724
41155
  try {
40725
- const files = await fs17.promises.readdir(this.config.logDir);
41156
+ const files = await fs18.promises.readdir(this.config.logDir);
40726
41157
  const cutoffDate = /* @__PURE__ */ new Date();
40727
41158
  cutoffDate.setDate(cutoffDate.getDate() - this.config.maxDays);
40728
41159
  const prefix = this.config.prefix;
@@ -40737,7 +41168,7 @@ var LogWriter = class {
40737
41168
  if (!Number.isNaN(year) && !Number.isNaN(month) && !Number.isNaN(day)) {
40738
41169
  const fileDate = new Date(year, month - 1, day);
40739
41170
  if (fileDate < cutoffDate) {
40740
- await fs17.promises.unlink(path18.join(this.config.logDir, file2));
41171
+ await fs18.promises.unlink(path19.join(this.config.logDir, file2));
40741
41172
  process.stderr.write(`[LogWriter] Deleted old log: ${file2}
40742
41173
  `);
40743
41174
  }
@@ -40811,10 +41242,10 @@ var TapTapMCPProxy = class {
40811
41242
  const { user_id, project_id } = this.config.tenant;
40812
41243
  let logDir;
40813
41244
  if (user_id && project_id) {
40814
- logDir = path19.join(logRoot, "proxy", user_id, project_id);
41245
+ logDir = path20.join(logRoot, "proxy", user_id, project_id);
40815
41246
  } else {
40816
41247
  const kidHash = crypto6.createHash("sha256").update(this.config.auth.kid).digest("hex").substring(0, 8);
40817
- logDir = path19.join(logRoot, "proxy", kidHash);
41248
+ logDir = path20.join(logRoot, "proxy", kidHash);
40818
41249
  }
40819
41250
  return new LogWriter({
40820
41251
  logDir,