@taptap/maker 0.0.19 → 0.0.21-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/maker.js +1080 -355
- package/package.json +1 -1
- package/skills/taptap-maker-local/SKILL.md +11 -3
- package/skills/update-taptap-mcp/SKILL.md +27 -7
package/dist/maker.js
CHANGED
|
@@ -3233,8 +3233,8 @@ var require_utils = __commonJS({
|
|
|
3233
3233
|
}
|
|
3234
3234
|
return ind;
|
|
3235
3235
|
}
|
|
3236
|
-
function removeDotSegments(
|
|
3237
|
-
let input2 =
|
|
3236
|
+
function removeDotSegments(path19) {
|
|
3237
|
+
let input2 = path19;
|
|
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 [
|
|
3437
|
-
wsComponent.path =
|
|
3436
|
+
const [path19, query] = wsComponent.resourceName.split("?");
|
|
3437
|
+
wsComponent.path = path19 && path19 !== "/" ? path19 : 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,
|
|
12494
|
+
function addFormats(ajv, list, fs17, 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,
|
|
12499
|
+
ajv.addFormat(f, fs17[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
|
|
12513
|
-
function checkPathExt(
|
|
12512
|
+
var fs17 = __require("fs");
|
|
12513
|
+
function checkPathExt(path19, 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 &&
|
|
12524
|
+
if (p && path19.substr(-p.length).toLowerCase() === p) {
|
|
12525
12525
|
return true;
|
|
12526
12526
|
}
|
|
12527
12527
|
}
|
|
12528
12528
|
return false;
|
|
12529
12529
|
}
|
|
12530
|
-
function checkStat(stat,
|
|
12530
|
+
function checkStat(stat, path19, options) {
|
|
12531
12531
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
12532
12532
|
return false;
|
|
12533
12533
|
}
|
|
12534
|
-
return checkPathExt(
|
|
12534
|
+
return checkPathExt(path19, options);
|
|
12535
12535
|
}
|
|
12536
|
-
function isexe(
|
|
12537
|
-
|
|
12538
|
-
cb(er, er ? false : checkStat(stat,
|
|
12536
|
+
function isexe(path19, options, cb) {
|
|
12537
|
+
fs17.stat(path19, function(er, stat) {
|
|
12538
|
+
cb(er, er ? false : checkStat(stat, path19, options));
|
|
12539
12539
|
});
|
|
12540
12540
|
}
|
|
12541
|
-
function sync(
|
|
12542
|
-
return checkStat(
|
|
12541
|
+
function sync(path19, options) {
|
|
12542
|
+
return checkStat(fs17.statSync(path19), path19, 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
|
|
12553
|
-
function isexe(
|
|
12554
|
-
|
|
12552
|
+
var fs17 = __require("fs");
|
|
12553
|
+
function isexe(path19, options, cb) {
|
|
12554
|
+
fs17.stat(path19, function(er, stat) {
|
|
12555
12555
|
cb(er, er ? false : checkStat(stat, options));
|
|
12556
12556
|
});
|
|
12557
12557
|
}
|
|
12558
|
-
function sync(
|
|
12559
|
-
return checkStat(
|
|
12558
|
+
function sync(path19, options) {
|
|
12559
|
+
return checkStat(fs17.statSync(path19), 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
|
|
12583
|
+
var fs17 = __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(
|
|
12592
|
+
function isexe(path19, 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(
|
|
12602
|
+
isexe(path19, 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(
|
|
12611
|
+
core(path19, 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(
|
|
12621
|
+
function sync(path19, options) {
|
|
12622
12622
|
try {
|
|
12623
|
-
return core.sync(
|
|
12623
|
+
return core.sync(path19, 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
|
|
12639
|
+
var path19 = __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 =
|
|
12677
|
+
const pCmd = path19.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 =
|
|
12704
|
+
const pCmd = path19.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
|
|
12752
|
+
var path19 = __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 ?
|
|
12770
|
+
pathExt: withoutPathExt ? path19.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 =
|
|
12779
|
+
resolved = path19.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 [
|
|
12834
|
-
const binary =
|
|
12833
|
+
const [path19, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
12834
|
+
const binary = path19.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
|
|
12847
|
+
var fs17 = __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 =
|
|
12855
|
-
|
|
12856
|
-
|
|
12854
|
+
fd = fs17.openSync(command, "r");
|
|
12855
|
+
fs17.readSync(fd, buffer, 0, size, 0);
|
|
12856
|
+
fs17.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
|
|
12869
|
+
var path19 = __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 =
|
|
12894
|
+
parsed.command = path19.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,9 @@ var require_cross_spawn = __commonJS({
|
|
|
13003
13003
|
|
|
13004
13004
|
// src/maker/server/mcp.ts
|
|
13005
13005
|
import { execFileSync, spawn as spawn4, spawnSync as spawnSync6 } from "node:child_process";
|
|
13006
|
-
import
|
|
13007
|
-
import
|
|
13006
|
+
import fs14 from "node:fs";
|
|
13007
|
+
import path15 from "node:path";
|
|
13008
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
13008
13009
|
|
|
13009
13010
|
// node_modules/zod/v3/helpers/util.js
|
|
13010
13011
|
var util;
|
|
@@ -13365,8 +13366,8 @@ function getErrorMap() {
|
|
|
13365
13366
|
|
|
13366
13367
|
// node_modules/zod/v3/helpers/parseUtil.js
|
|
13367
13368
|
var makeIssue = (params) => {
|
|
13368
|
-
const { data, path:
|
|
13369
|
-
const fullPath = [...
|
|
13369
|
+
const { data, path: path19, errorMaps, issueData } = params;
|
|
13370
|
+
const fullPath = [...path19, ...issueData.path || []];
|
|
13370
13371
|
const fullIssue = {
|
|
13371
13372
|
...issueData,
|
|
13372
13373
|
path: fullPath
|
|
@@ -13481,11 +13482,11 @@ var errorUtil;
|
|
|
13481
13482
|
|
|
13482
13483
|
// node_modules/zod/v3/types.js
|
|
13483
13484
|
var ParseInputLazyPath = class {
|
|
13484
|
-
constructor(parent, value,
|
|
13485
|
+
constructor(parent, value, path19, key) {
|
|
13485
13486
|
this._cachedPath = [];
|
|
13486
13487
|
this.parent = parent;
|
|
13487
13488
|
this.data = value;
|
|
13488
|
-
this._path =
|
|
13489
|
+
this._path = path19;
|
|
13489
13490
|
this._key = key;
|
|
13490
13491
|
}
|
|
13491
13492
|
get path() {
|
|
@@ -17134,10 +17135,10 @@ function mergeDefs(...defs) {
|
|
|
17134
17135
|
function cloneDef(schema) {
|
|
17135
17136
|
return mergeDefs(schema._zod.def);
|
|
17136
17137
|
}
|
|
17137
|
-
function getElementAtPath(obj,
|
|
17138
|
-
if (!
|
|
17138
|
+
function getElementAtPath(obj, path19) {
|
|
17139
|
+
if (!path19)
|
|
17139
17140
|
return obj;
|
|
17140
|
-
return
|
|
17141
|
+
return path19.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
|
|
17141
17142
|
}
|
|
17142
17143
|
function promiseAllObject(promisesObj) {
|
|
17143
17144
|
const keys = Object.keys(promisesObj);
|
|
@@ -17522,11 +17523,11 @@ function aborted(x, startIndex = 0) {
|
|
|
17522
17523
|
}
|
|
17523
17524
|
return false;
|
|
17524
17525
|
}
|
|
17525
|
-
function prefixIssues(
|
|
17526
|
+
function prefixIssues(path19, issues) {
|
|
17526
17527
|
return issues.map((iss) => {
|
|
17527
17528
|
var _a3;
|
|
17528
17529
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
17529
|
-
iss.path.unshift(
|
|
17530
|
+
iss.path.unshift(path19);
|
|
17530
17531
|
return iss;
|
|
17531
17532
|
});
|
|
17532
17533
|
}
|
|
@@ -32702,9 +32703,484 @@ function compactRuntimeLogEntry(entry) {
|
|
|
32702
32703
|
return compact;
|
|
32703
32704
|
}
|
|
32704
32705
|
|
|
32705
|
-
// src/maker/
|
|
32706
|
+
// src/maker/versionCheck.ts
|
|
32706
32707
|
import fs12 from "node:fs";
|
|
32707
32708
|
import path13 from "node:path";
|
|
32709
|
+
var DEFAULT_POLICY_URL = "https://raw.githubusercontent.com/taptap/instant-games-open-mcp/main/config/maker-version-policy.json";
|
|
32710
|
+
var POLICY_URL_ENV = "TAPTAP_MAKER_VERSION_POLICY_URL";
|
|
32711
|
+
var DEFAULT_PACKAGE_VERSION_CHECK_TIMEOUT_MS = 3e3;
|
|
32712
|
+
var PACKAGE_VERSION_CHECK_TTL_MS = 12 * 60 * 60 * 1e3;
|
|
32713
|
+
var PACKAGE_VERSION_CHECK_CACHE_FILE = "package-version-check.json";
|
|
32714
|
+
function decideMakerPackageUpdate(currentVersion, policy) {
|
|
32715
|
+
if (currentVersion === "dev") {
|
|
32716
|
+
return {
|
|
32717
|
+
status: "skipped",
|
|
32718
|
+
current_version: currentVersion,
|
|
32719
|
+
reason: "dev_version",
|
|
32720
|
+
latest: policy.latest,
|
|
32721
|
+
latest_beta: policy.latest_beta,
|
|
32722
|
+
minimum_supported: policy.minimum_supported,
|
|
32723
|
+
message: policy.message,
|
|
32724
|
+
next_action: "Continue normal work; dev builds do not use remote version policy.",
|
|
32725
|
+
restart_required: false
|
|
32726
|
+
};
|
|
32727
|
+
}
|
|
32728
|
+
const current = parseVersion(currentVersion);
|
|
32729
|
+
const latest = parseVersion(policy.latest);
|
|
32730
|
+
const latestBeta = parseVersion(policy.latest_beta);
|
|
32731
|
+
const minimumSupported = parseVersion(policy.minimum_supported);
|
|
32732
|
+
if (!current || !latest || !latestBeta || !minimumSupported) {
|
|
32733
|
+
throw new Error("Invalid version data for Maker package update decision.");
|
|
32734
|
+
}
|
|
32735
|
+
const isPrerelease = current.prerelease.length > 0;
|
|
32736
|
+
if (policy.blacklist.includes(currentVersion)) {
|
|
32737
|
+
return buildDecision("required_upgrade", currentVersion, policy, {
|
|
32738
|
+
reason: "blacklisted",
|
|
32739
|
+
target_version: isPrerelease ? policy.latest_beta : policy.latest,
|
|
32740
|
+
blacklist_match: currentVersion,
|
|
32741
|
+
restart_required: true,
|
|
32742
|
+
next_action: "Ask the user for approval, then run `taptap-maker upgrade --target-dir <PROJECT_DIR>`."
|
|
32743
|
+
});
|
|
32744
|
+
}
|
|
32745
|
+
if (compareVersions(current, minimumSupported) < 0) {
|
|
32746
|
+
return buildDecision("required_upgrade", currentVersion, policy, {
|
|
32747
|
+
reason: "below_minimum_supported",
|
|
32748
|
+
target_version: isPrerelease ? policy.latest_beta : policy.latest,
|
|
32749
|
+
restart_required: true,
|
|
32750
|
+
next_action: "Ask the user for approval, then run `taptap-maker upgrade --target-dir <PROJECT_DIR>`."
|
|
32751
|
+
});
|
|
32752
|
+
}
|
|
32753
|
+
if (isPrerelease && compareVersions(current, latestBeta) < 0) {
|
|
32754
|
+
return buildDecision("required_upgrade", currentVersion, policy, {
|
|
32755
|
+
reason: "beta_outdated",
|
|
32756
|
+
target_version: policy.latest_beta,
|
|
32757
|
+
restart_required: true,
|
|
32758
|
+
next_action: "Ask the user for approval, then run `taptap-maker upgrade --target-dir <PROJECT_DIR>`."
|
|
32759
|
+
});
|
|
32760
|
+
}
|
|
32761
|
+
if (!isPrerelease && compareVersions(current, latest) < 0) {
|
|
32762
|
+
return buildDecision("update_available", currentVersion, policy, {
|
|
32763
|
+
target_version: policy.latest,
|
|
32764
|
+
restart_required: false,
|
|
32765
|
+
next_action: "Tell the user an update is available. Only run `taptap-maker upgrade` after approval."
|
|
32766
|
+
});
|
|
32767
|
+
}
|
|
32768
|
+
return buildDecision("current", currentVersion, policy, {
|
|
32769
|
+
target_version: isPrerelease ? policy.latest_beta : policy.latest,
|
|
32770
|
+
restart_required: false,
|
|
32771
|
+
next_action: "Continue normal work; no package upgrade is required."
|
|
32772
|
+
});
|
|
32773
|
+
}
|
|
32774
|
+
async function checkMakerPackageUpdate(options) {
|
|
32775
|
+
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
32776
|
+
const currentVersion = options.currentVersion;
|
|
32777
|
+
if (currentVersion === "dev") {
|
|
32778
|
+
return {
|
|
32779
|
+
status: "skipped",
|
|
32780
|
+
current_version: currentVersion,
|
|
32781
|
+
reason: "dev_version",
|
|
32782
|
+
checked_at: now.toISOString(),
|
|
32783
|
+
next_action: "Continue normal work; dev builds do not use remote version policy.",
|
|
32784
|
+
restart_required: false
|
|
32785
|
+
};
|
|
32786
|
+
}
|
|
32787
|
+
const policyUrl = resolvePolicyUrl(options.policyUrl);
|
|
32788
|
+
try {
|
|
32789
|
+
const policy = await fetchMakerPackageVersionPolicy({
|
|
32790
|
+
fetchImpl: options.fetchImpl,
|
|
32791
|
+
policyUrl,
|
|
32792
|
+
timeoutMs: options.timeoutMs
|
|
32793
|
+
});
|
|
32794
|
+
const decision = decideMakerPackageUpdate(currentVersion, policy);
|
|
32795
|
+
const status = {
|
|
32796
|
+
...decision,
|
|
32797
|
+
current_version: currentVersion,
|
|
32798
|
+
checked_at: now.toISOString(),
|
|
32799
|
+
policy_url: policyUrl,
|
|
32800
|
+
latest: policy.latest,
|
|
32801
|
+
latest_beta: policy.latest_beta,
|
|
32802
|
+
minimum_supported: policy.minimum_supported,
|
|
32803
|
+
message: policy.message
|
|
32804
|
+
};
|
|
32805
|
+
writeCache({
|
|
32806
|
+
checked_at: status.checked_at,
|
|
32807
|
+
policy_url: policyUrl,
|
|
32808
|
+
policy,
|
|
32809
|
+
decision: status
|
|
32810
|
+
});
|
|
32811
|
+
return status;
|
|
32812
|
+
} catch (error2) {
|
|
32813
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
32814
|
+
const latestCache = readCache();
|
|
32815
|
+
const unavailableStatus = buildUnavailableStatus({
|
|
32816
|
+
cache: latestCache,
|
|
32817
|
+
currentVersion,
|
|
32818
|
+
error: message,
|
|
32819
|
+
policyUrl
|
|
32820
|
+
});
|
|
32821
|
+
writeCache({
|
|
32822
|
+
checked_at: latestCache == null ? void 0 : latestCache.checked_at,
|
|
32823
|
+
policy_url: (latestCache == null ? void 0 : latestCache.policy_url) || policyUrl,
|
|
32824
|
+
policy: latestCache == null ? void 0 : latestCache.policy,
|
|
32825
|
+
decision: latestCache == null ? void 0 : latestCache.decision,
|
|
32826
|
+
error: message,
|
|
32827
|
+
error_checked_at: now.toISOString()
|
|
32828
|
+
});
|
|
32829
|
+
return unavailableStatus;
|
|
32830
|
+
}
|
|
32831
|
+
}
|
|
32832
|
+
async function getMakerPackageUpdateStatus(options) {
|
|
32833
|
+
var _a3, _b;
|
|
32834
|
+
const currentVersion = options.currentVersion;
|
|
32835
|
+
if (currentVersion === "dev") {
|
|
32836
|
+
return {
|
|
32837
|
+
status: "skipped",
|
|
32838
|
+
current_version: currentVersion,
|
|
32839
|
+
reason: "dev_version",
|
|
32840
|
+
checked_at: (options.now ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
32841
|
+
next_action: "Continue normal work; dev builds do not use remote version policy.",
|
|
32842
|
+
restart_required: false
|
|
32843
|
+
};
|
|
32844
|
+
}
|
|
32845
|
+
const cache = readCache();
|
|
32846
|
+
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
32847
|
+
const policyUrl = resolvePolicyUrl(options.policyUrl);
|
|
32848
|
+
const lastSuccessCheckedAt = getLastSuccessCheckedAt(cache);
|
|
32849
|
+
const lastErrorCheckedAt = getLastErrorCheckedAt(cache);
|
|
32850
|
+
const hasCurrentVersionDecision = ((_a3 = cache == null ? void 0 : cache.decision) == null ? void 0 : _a3.current_version) === currentVersion;
|
|
32851
|
+
const hasCurrentPolicyUrl = (cache == null ? void 0 : cache.policy_url) === policyUrl || ((_b = cache == null ? void 0 : cache.decision) == null ? void 0 : _b.policy_url) === policyUrl;
|
|
32852
|
+
const hasFreshErrorOnlyCache = Boolean(cache == null ? void 0 : cache.error) && !(cache == null ? void 0 : cache.decision) && hasCurrentPolicyUrl && lastErrorCheckedAt !== void 0 && isCacheFresh(lastErrorCheckedAt, now);
|
|
32853
|
+
if ((cache == null ? void 0 : cache.decision) && hasCurrentVersionDecision && hasCurrentPolicyUrl && lastSuccessCheckedAt && isCacheFresh(lastSuccessCheckedAt, now)) {
|
|
32854
|
+
return cache.error ? {
|
|
32855
|
+
...cache.decision,
|
|
32856
|
+
error: cache.error
|
|
32857
|
+
} : cache.decision;
|
|
32858
|
+
}
|
|
32859
|
+
if (hasFreshErrorOnlyCache && options.allowRemoteFetch === false) {
|
|
32860
|
+
if (options.backgroundRefresh !== false) {
|
|
32861
|
+
startMakerPackageUpdateCheck(options);
|
|
32862
|
+
}
|
|
32863
|
+
return buildUnavailableStatus({
|
|
32864
|
+
cache,
|
|
32865
|
+
currentVersion,
|
|
32866
|
+
error: (cache == null ? void 0 : cache.error) || "Maker package version check is temporarily unavailable."
|
|
32867
|
+
});
|
|
32868
|
+
}
|
|
32869
|
+
if (options.allowRemoteFetch === false) {
|
|
32870
|
+
const shouldStartBackgroundRefresh = options.backgroundRefresh !== false;
|
|
32871
|
+
if (shouldStartBackgroundRefresh) {
|
|
32872
|
+
startMakerPackageUpdateCheck(options);
|
|
32873
|
+
}
|
|
32874
|
+
return buildUnavailableStatus({
|
|
32875
|
+
cache,
|
|
32876
|
+
currentVersion,
|
|
32877
|
+
error: formatUnavailableNonBlockingError(cache == null ? void 0 : cache.error, shouldStartBackgroundRefresh),
|
|
32878
|
+
checkedAt: now.toISOString(),
|
|
32879
|
+
policyUrl
|
|
32880
|
+
});
|
|
32881
|
+
}
|
|
32882
|
+
return checkMakerPackageUpdate(options);
|
|
32883
|
+
}
|
|
32884
|
+
var backgroundCheck;
|
|
32885
|
+
function startMakerPackageUpdateCheck(options) {
|
|
32886
|
+
const key = `${options.currentVersion}
|
|
32887
|
+
${resolvePolicyUrl(options.policyUrl)}`;
|
|
32888
|
+
if ((backgroundCheck == null ? void 0 : backgroundCheck.key) === key) {
|
|
32889
|
+
return;
|
|
32890
|
+
}
|
|
32891
|
+
const promise2 = checkMakerPackageUpdate(options).then(() => void 0).catch(() => void 0).finally(() => {
|
|
32892
|
+
if ((backgroundCheck == null ? void 0 : backgroundCheck.promise) === promise2) {
|
|
32893
|
+
backgroundCheck = void 0;
|
|
32894
|
+
}
|
|
32895
|
+
});
|
|
32896
|
+
backgroundCheck = { key, promise: promise2 };
|
|
32897
|
+
}
|
|
32898
|
+
function formatMakerPackageUpdateStatus(status) {
|
|
32899
|
+
const lines = ["Maker MCP package update", ""];
|
|
32900
|
+
lines.push(`- status: ${status.status}`);
|
|
32901
|
+
lines.push(`- current_version: ${status.current_version}`);
|
|
32902
|
+
if (status.target_version) {
|
|
32903
|
+
lines.push(`- target_version: ${status.target_version}`);
|
|
32904
|
+
}
|
|
32905
|
+
if (status.reason) {
|
|
32906
|
+
lines.push(`- reason: ${status.reason}`);
|
|
32907
|
+
}
|
|
32908
|
+
if (status.minimum_supported) {
|
|
32909
|
+
lines.push(`- minimum_supported: ${status.minimum_supported}`);
|
|
32910
|
+
}
|
|
32911
|
+
if (status.latest) {
|
|
32912
|
+
lines.push(`- latest: ${status.latest}`);
|
|
32913
|
+
}
|
|
32914
|
+
if (status.latest_beta) {
|
|
32915
|
+
lines.push(`- latest_beta: ${status.latest_beta}`);
|
|
32916
|
+
}
|
|
32917
|
+
if (status.blacklist_match) {
|
|
32918
|
+
lines.push(`- blacklist_match: ${status.blacklist_match}`);
|
|
32919
|
+
} else if (status.status !== "skipped") {
|
|
32920
|
+
lines.push("- blacklist_match: no");
|
|
32921
|
+
}
|
|
32922
|
+
if (status.checked_at) {
|
|
32923
|
+
lines.push(`- checked_at: ${status.checked_at}`);
|
|
32924
|
+
}
|
|
32925
|
+
if (status.policy_url) {
|
|
32926
|
+
lines.push(`- policy_url: ${status.policy_url}`);
|
|
32927
|
+
}
|
|
32928
|
+
if (status.message) {
|
|
32929
|
+
lines.push(`- message: ${status.message}`);
|
|
32930
|
+
}
|
|
32931
|
+
if (status.error) {
|
|
32932
|
+
lines.push(`- error: ${status.error}`);
|
|
32933
|
+
}
|
|
32934
|
+
if (status.last_success_checked_at) {
|
|
32935
|
+
lines.push(`- last_success_checked_at: ${status.last_success_checked_at}`);
|
|
32936
|
+
}
|
|
32937
|
+
if (status.previous_status) {
|
|
32938
|
+
lines.push(`- previous_status: ${status.previous_status}`);
|
|
32939
|
+
}
|
|
32940
|
+
if (status.next_action) {
|
|
32941
|
+
lines.push(`- next_action: ${status.next_action}`);
|
|
32942
|
+
}
|
|
32943
|
+
if (typeof status.restart_required === "boolean") {
|
|
32944
|
+
lines.push(`- restart_required: ${status.restart_required ? "yes" : "no"}`);
|
|
32945
|
+
}
|
|
32946
|
+
return lines.join("\n");
|
|
32947
|
+
}
|
|
32948
|
+
function formatUnavailableNonBlockingError(previousError, backgroundRefresh) {
|
|
32949
|
+
if (backgroundRefresh) {
|
|
32950
|
+
return previousError ? `${previousError}; background retry started.` : "Maker package version check is running in the background.";
|
|
32951
|
+
}
|
|
32952
|
+
return previousError || "Maker package version check is temporarily unavailable.";
|
|
32953
|
+
}
|
|
32954
|
+
async function fetchMakerPackageVersionPolicy(options) {
|
|
32955
|
+
const fetchImpl = options.fetchImpl || fetch;
|
|
32956
|
+
const response = await fetchWithTimeout(
|
|
32957
|
+
fetchImpl,
|
|
32958
|
+
options.policyUrl,
|
|
32959
|
+
{
|
|
32960
|
+
headers: {
|
|
32961
|
+
Accept: "application/json"
|
|
32962
|
+
}
|
|
32963
|
+
},
|
|
32964
|
+
options.timeoutMs ?? DEFAULT_PACKAGE_VERSION_CHECK_TIMEOUT_MS,
|
|
32965
|
+
"Maker package version check"
|
|
32966
|
+
);
|
|
32967
|
+
if (!response.ok) {
|
|
32968
|
+
throw new Error(
|
|
32969
|
+
`Maker package version check failed: HTTP ${response.status} ${response.statusText}`
|
|
32970
|
+
);
|
|
32971
|
+
}
|
|
32972
|
+
const payload = await response.json();
|
|
32973
|
+
return parsePolicy(payload);
|
|
32974
|
+
}
|
|
32975
|
+
function parsePolicy(payload) {
|
|
32976
|
+
if (!payload || typeof payload !== "object") {
|
|
32977
|
+
throw new Error("Invalid Maker package version policy schema: expected an object.");
|
|
32978
|
+
}
|
|
32979
|
+
const policy = payload;
|
|
32980
|
+
if (policy.schema_version !== 1) {
|
|
32981
|
+
throw new Error("Invalid Maker package version policy schema: schema_version must be 1.");
|
|
32982
|
+
}
|
|
32983
|
+
if (!isValidVersionString(policy.latest)) {
|
|
32984
|
+
throw new Error("Invalid Maker package version policy schema: latest must be a semver string.");
|
|
32985
|
+
}
|
|
32986
|
+
if (!isValidVersionString(policy.latest_beta)) {
|
|
32987
|
+
throw new Error(
|
|
32988
|
+
"Invalid Maker package version policy schema: latest_beta must be a semver string."
|
|
32989
|
+
);
|
|
32990
|
+
}
|
|
32991
|
+
if (!isValidVersionString(policy.minimum_supported)) {
|
|
32992
|
+
throw new Error(
|
|
32993
|
+
"Invalid Maker package version policy schema: minimum_supported must be a semver string."
|
|
32994
|
+
);
|
|
32995
|
+
}
|
|
32996
|
+
if (!Array.isArray(policy.blacklist) || policy.blacklist.some((item) => !isValidVersionString(item))) {
|
|
32997
|
+
throw new Error(
|
|
32998
|
+
"Invalid Maker package version policy schema: blacklist must be a semver string array."
|
|
32999
|
+
);
|
|
33000
|
+
}
|
|
33001
|
+
if (typeof policy.updated_at !== "string" || Number.isNaN(Date.parse(policy.updated_at))) {
|
|
33002
|
+
throw new Error(
|
|
33003
|
+
"Invalid Maker package version policy schema: updated_at must be an ISO timestamp string."
|
|
33004
|
+
);
|
|
33005
|
+
}
|
|
33006
|
+
if (policy.message !== void 0 && typeof policy.message !== "string") {
|
|
33007
|
+
throw new Error("Invalid Maker package version policy schema: message must be a string.");
|
|
33008
|
+
}
|
|
33009
|
+
return {
|
|
33010
|
+
schema_version: 1,
|
|
33011
|
+
latest: policy.latest,
|
|
33012
|
+
latest_beta: policy.latest_beta,
|
|
33013
|
+
minimum_supported: policy.minimum_supported,
|
|
33014
|
+
blacklist: [...policy.blacklist],
|
|
33015
|
+
message: policy.message,
|
|
33016
|
+
updated_at: policy.updated_at
|
|
33017
|
+
};
|
|
33018
|
+
}
|
|
33019
|
+
function buildDecision(status, currentVersion, policy, overrides) {
|
|
33020
|
+
return {
|
|
33021
|
+
status,
|
|
33022
|
+
current_version: currentVersion,
|
|
33023
|
+
latest: policy.latest,
|
|
33024
|
+
latest_beta: policy.latest_beta,
|
|
33025
|
+
minimum_supported: policy.minimum_supported,
|
|
33026
|
+
message: policy.message,
|
|
33027
|
+
...overrides
|
|
33028
|
+
};
|
|
33029
|
+
}
|
|
33030
|
+
function buildUnavailableStatus(options) {
|
|
33031
|
+
var _a3, _b, _c, _d;
|
|
33032
|
+
const previousDecision = (_a3 = options.cache) == null ? void 0 : _a3.decision;
|
|
33033
|
+
const hasCurrentVersionDecision = (previousDecision == null ? void 0 : previousDecision.current_version) === options.currentVersion;
|
|
33034
|
+
const hasCurrentPolicyUrl = !options.policyUrl || ((_b = options.cache) == null ? void 0 : _b.policy_url) === options.policyUrl || (previousDecision == null ? void 0 : previousDecision.policy_url) === options.policyUrl;
|
|
33035
|
+
const canUsePreviousDecision = hasCurrentVersionDecision && hasCurrentPolicyUrl;
|
|
33036
|
+
const lastSuccessCheckedAt = canUsePreviousDecision ? getLastSuccessCheckedAt(options.cache) : void 0;
|
|
33037
|
+
const previousPolicy = hasCurrentPolicyUrl ? (_c = options.cache) == null ? void 0 : _c.policy : void 0;
|
|
33038
|
+
return compactStatus({
|
|
33039
|
+
status: "unavailable",
|
|
33040
|
+
current_version: options.currentVersion,
|
|
33041
|
+
target_version: canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.target_version : void 0,
|
|
33042
|
+
reason: canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.reason : void 0,
|
|
33043
|
+
minimum_supported: (canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.minimum_supported : void 0) ?? (previousPolicy == null ? void 0 : previousPolicy.minimum_supported),
|
|
33044
|
+
latest: (canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.latest : void 0) ?? (previousPolicy == null ? void 0 : previousPolicy.latest),
|
|
33045
|
+
latest_beta: (canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.latest_beta : void 0) ?? (previousPolicy == null ? void 0 : previousPolicy.latest_beta),
|
|
33046
|
+
blacklist_match: canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.blacklist_match : void 0,
|
|
33047
|
+
checked_at: options.checkedAt,
|
|
33048
|
+
policy_url: options.policyUrl ?? ((_d = options.cache) == null ? void 0 : _d.policy_url),
|
|
33049
|
+
message: (canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.message : void 0) ?? (previousPolicy == null ? void 0 : previousPolicy.message),
|
|
33050
|
+
error: options.error,
|
|
33051
|
+
last_success_checked_at: lastSuccessCheckedAt,
|
|
33052
|
+
previous_status: canUsePreviousDecision && (previousDecision == null ? void 0 : previousDecision.status) && previousDecision.status !== "unavailable" ? previousDecision.status : void 0,
|
|
33053
|
+
next_action: "Continue normal work; retry status later.",
|
|
33054
|
+
restart_required: false
|
|
33055
|
+
});
|
|
33056
|
+
}
|
|
33057
|
+
function compactStatus(status) {
|
|
33058
|
+
return Object.fromEntries(
|
|
33059
|
+
Object.entries(status).filter(([, value]) => value !== void 0)
|
|
33060
|
+
);
|
|
33061
|
+
}
|
|
33062
|
+
function readCache() {
|
|
33063
|
+
const cachePath = getMakerPackageVersionCheckCachePath();
|
|
33064
|
+
if (!fs12.existsSync(cachePath)) {
|
|
33065
|
+
return void 0;
|
|
33066
|
+
}
|
|
33067
|
+
try {
|
|
33068
|
+
return JSON.parse(fs12.readFileSync(cachePath, "utf8"));
|
|
33069
|
+
} catch {
|
|
33070
|
+
return void 0;
|
|
33071
|
+
}
|
|
33072
|
+
}
|
|
33073
|
+
function writeCache(cache) {
|
|
33074
|
+
const cachePath = getMakerPackageVersionCheckCachePath();
|
|
33075
|
+
fs12.mkdirSync(path13.dirname(cachePath), { recursive: true });
|
|
33076
|
+
fs12.writeFileSync(cachePath, `${JSON.stringify(cache, null, 2)}
|
|
33077
|
+
`, "utf8");
|
|
33078
|
+
}
|
|
33079
|
+
function getMakerPackageVersionCheckCachePath() {
|
|
33080
|
+
return path13.join(getMakerHome(), PACKAGE_VERSION_CHECK_CACHE_FILE);
|
|
33081
|
+
}
|
|
33082
|
+
function getLastSuccessCheckedAt(cache) {
|
|
33083
|
+
var _a3;
|
|
33084
|
+
if (!cache) {
|
|
33085
|
+
return void 0;
|
|
33086
|
+
}
|
|
33087
|
+
if (((_a3 = cache.decision) == null ? void 0 : _a3.status) && cache.decision.status !== "unavailable") {
|
|
33088
|
+
return cache.decision.checked_at || cache.checked_at;
|
|
33089
|
+
}
|
|
33090
|
+
return cache.checked_at;
|
|
33091
|
+
}
|
|
33092
|
+
function getLastErrorCheckedAt(cache) {
|
|
33093
|
+
return cache == null ? void 0 : cache.error_checked_at;
|
|
33094
|
+
}
|
|
33095
|
+
function isCacheFresh(checkedAt, now) {
|
|
33096
|
+
const checkedMs = Date.parse(checkedAt);
|
|
33097
|
+
if (Number.isNaN(checkedMs)) {
|
|
33098
|
+
return false;
|
|
33099
|
+
}
|
|
33100
|
+
return now.getTime() - checkedMs < PACKAGE_VERSION_CHECK_TTL_MS;
|
|
33101
|
+
}
|
|
33102
|
+
function resolvePolicyUrl(policyUrl) {
|
|
33103
|
+
return policyUrl || process.env[POLICY_URL_ENV] || DEFAULT_POLICY_URL;
|
|
33104
|
+
}
|
|
33105
|
+
function isValidVersionString(value) {
|
|
33106
|
+
return typeof value === "string" && parseVersion(value) !== void 0;
|
|
33107
|
+
}
|
|
33108
|
+
function parseVersion(version2) {
|
|
33109
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(version2.trim());
|
|
33110
|
+
if (!match) {
|
|
33111
|
+
return void 0;
|
|
33112
|
+
}
|
|
33113
|
+
return {
|
|
33114
|
+
major: Number(match[1]),
|
|
33115
|
+
minor: Number(match[2]),
|
|
33116
|
+
patch: Number(match[3]),
|
|
33117
|
+
prerelease: match[4] ? match[4].split(".") : []
|
|
33118
|
+
};
|
|
33119
|
+
}
|
|
33120
|
+
function compareVersions(left, right) {
|
|
33121
|
+
if (left.major !== right.major) {
|
|
33122
|
+
return left.major - right.major;
|
|
33123
|
+
}
|
|
33124
|
+
if (left.minor !== right.minor) {
|
|
33125
|
+
return left.minor - right.minor;
|
|
33126
|
+
}
|
|
33127
|
+
if (left.patch !== right.patch) {
|
|
33128
|
+
return left.patch - right.patch;
|
|
33129
|
+
}
|
|
33130
|
+
const leftPre = left.prerelease;
|
|
33131
|
+
const rightPre = right.prerelease;
|
|
33132
|
+
if (leftPre.length === 0 && rightPre.length === 0) {
|
|
33133
|
+
return 0;
|
|
33134
|
+
}
|
|
33135
|
+
if (leftPre.length === 0) {
|
|
33136
|
+
return 1;
|
|
33137
|
+
}
|
|
33138
|
+
if (rightPre.length === 0) {
|
|
33139
|
+
return -1;
|
|
33140
|
+
}
|
|
33141
|
+
const length = Math.max(leftPre.length, rightPre.length);
|
|
33142
|
+
for (let index = 0; index < length; index += 1) {
|
|
33143
|
+
const leftIdentifier = leftPre[index];
|
|
33144
|
+
const rightIdentifier = rightPre[index];
|
|
33145
|
+
if (leftIdentifier === void 0) {
|
|
33146
|
+
return -1;
|
|
33147
|
+
}
|
|
33148
|
+
if (rightIdentifier === void 0) {
|
|
33149
|
+
return 1;
|
|
33150
|
+
}
|
|
33151
|
+
const compared = comparePrereleaseIdentifier(leftIdentifier, rightIdentifier);
|
|
33152
|
+
if (compared !== 0) {
|
|
33153
|
+
return compared;
|
|
33154
|
+
}
|
|
33155
|
+
}
|
|
33156
|
+
return 0;
|
|
33157
|
+
}
|
|
33158
|
+
function comparePrereleaseIdentifier(left, right) {
|
|
33159
|
+
const leftNumeric = /^\d+$/.test(left);
|
|
33160
|
+
const rightNumeric = /^\d+$/.test(right);
|
|
33161
|
+
if (leftNumeric && rightNumeric) {
|
|
33162
|
+
return compareNumericPrereleaseIdentifier(left, right);
|
|
33163
|
+
}
|
|
33164
|
+
if (leftNumeric) {
|
|
33165
|
+
return -1;
|
|
33166
|
+
}
|
|
33167
|
+
if (rightNumeric) {
|
|
33168
|
+
return 1;
|
|
33169
|
+
}
|
|
33170
|
+
return left.localeCompare(right);
|
|
33171
|
+
}
|
|
33172
|
+
function compareNumericPrereleaseIdentifier(left, right) {
|
|
33173
|
+
const normalizedLeft = left.replace(/^0+(?=\d)/, "");
|
|
33174
|
+
const normalizedRight = right.replace(/^0+(?=\d)/, "");
|
|
33175
|
+
if (normalizedLeft.length !== normalizedRight.length) {
|
|
33176
|
+
return normalizedLeft.length - normalizedRight.length;
|
|
33177
|
+
}
|
|
33178
|
+
return normalizedLeft.localeCompare(normalizedRight);
|
|
33179
|
+
}
|
|
33180
|
+
|
|
33181
|
+
// src/maker/server/proxyAssets.ts
|
|
33182
|
+
import fs13 from "node:fs";
|
|
33183
|
+
import path14 from "node:path";
|
|
32708
33184
|
var IMAGE_ASSET_DIRS = ["assets/image"];
|
|
32709
33185
|
var VIDEO_ASSET_DIRS = ["assets/video"];
|
|
32710
33186
|
var AUDIO_ASSET_DIRS = ["assets/audio"];
|
|
@@ -32988,13 +33464,13 @@ function findExistingMaterializedVideo(targetDir, options) {
|
|
|
32988
33464
|
function resolveExistingMaterializedAssetPath(targetDir, record2, localPath) {
|
|
32989
33465
|
const candidates = [];
|
|
32990
33466
|
const absolutePath = stringField2(record2.absolutePath);
|
|
32991
|
-
if (absolutePath &&
|
|
33467
|
+
if (absolutePath && path14.isAbsolute(absolutePath)) {
|
|
32992
33468
|
candidates.push(absolutePath);
|
|
32993
33469
|
}
|
|
32994
|
-
candidates.push(
|
|
33470
|
+
candidates.push(path14.join(targetDir, ...localPath.split("/")));
|
|
32995
33471
|
for (const candidate of candidates) {
|
|
32996
33472
|
try {
|
|
32997
|
-
if (
|
|
33473
|
+
if (fs13.statSync(candidate).isFile()) {
|
|
32998
33474
|
return candidate;
|
|
32999
33475
|
}
|
|
33000
33476
|
} catch {
|
|
@@ -33159,7 +33635,7 @@ async function materialize3dFinalResult(options, toolName) {
|
|
|
33159
33635
|
try {
|
|
33160
33636
|
extractZip(
|
|
33161
33637
|
mdlMaterialized.absolutePath,
|
|
33162
|
-
|
|
33638
|
+
path14.join(options.targetDir, "assets"),
|
|
33163
33639
|
"3D model asset"
|
|
33164
33640
|
);
|
|
33165
33641
|
nextPayload.mdlExtracted = true;
|
|
@@ -33266,8 +33742,8 @@ async function materializeAsset(options) {
|
|
|
33266
33742
|
};
|
|
33267
33743
|
}
|
|
33268
33744
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
33269
|
-
|
|
33270
|
-
|
|
33745
|
+
fs13.mkdirSync(path14.dirname(absolutePath), { recursive: true });
|
|
33746
|
+
fs13.writeFileSync(absolutePath, bytes);
|
|
33271
33747
|
return { localPath: relativePath, absolutePath, download: { success: true } };
|
|
33272
33748
|
} catch (error2) {
|
|
33273
33749
|
return {
|
|
@@ -33281,12 +33757,12 @@ async function materializeAsset(options) {
|
|
|
33281
33757
|
function createUniqueAssetPath(options) {
|
|
33282
33758
|
const stem = `${sanitizeAssetBaseName(options.baseName)}_${formatAssetTimestamp(options.now)}`;
|
|
33283
33759
|
for (let index = 1; index <= 9999; index += 1) {
|
|
33284
|
-
const relativePath =
|
|
33760
|
+
const relativePath = path14.posix.join(
|
|
33285
33761
|
options.relativeDir,
|
|
33286
33762
|
`${stem}${index === 1 ? "" : `_${index}`}.${options.extension}`
|
|
33287
33763
|
);
|
|
33288
|
-
const absolutePath =
|
|
33289
|
-
if (!
|
|
33764
|
+
const absolutePath = path14.join(options.targetDir, ...relativePath.split("/"));
|
|
33765
|
+
if (!fs13.existsSync(absolutePath)) {
|
|
33290
33766
|
return { relativePath, absolutePath };
|
|
33291
33767
|
}
|
|
33292
33768
|
}
|
|
@@ -33464,7 +33940,7 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
|
|
|
33464
33940
|
if (!isKnownAssetPath(localPath, assetDirs)) {
|
|
33465
33941
|
return false;
|
|
33466
33942
|
}
|
|
33467
|
-
const basename =
|
|
33943
|
+
const basename = path14.posix.basename(localPath);
|
|
33468
33944
|
const stem = basename.replace(/\.[^.]+$/, "");
|
|
33469
33945
|
return basename === value || stem === value || record2.name === value || record2.taskId === value;
|
|
33470
33946
|
});
|
|
@@ -33477,13 +33953,13 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
|
|
|
33477
33953
|
}
|
|
33478
33954
|
function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
33479
33955
|
var _a3;
|
|
33480
|
-
const hasExtension = Boolean(
|
|
33956
|
+
const hasExtension = Boolean(path14.extname(value));
|
|
33481
33957
|
const candidates = [];
|
|
33482
33958
|
for (const assetDir of assetDirs) {
|
|
33483
|
-
const absoluteDir =
|
|
33959
|
+
const absoluteDir = path14.join(targetDir, ...assetDir.split("/"));
|
|
33484
33960
|
let entries;
|
|
33485
33961
|
try {
|
|
33486
|
-
entries =
|
|
33962
|
+
entries = fs13.readdirSync(absoluteDir);
|
|
33487
33963
|
} catch {
|
|
33488
33964
|
continue;
|
|
33489
33965
|
}
|
|
@@ -33492,11 +33968,11 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
|
33492
33968
|
if (hasExtension ? entry !== value : stem !== value && !stem.startsWith(`${value}_`)) {
|
|
33493
33969
|
continue;
|
|
33494
33970
|
}
|
|
33495
|
-
const absolutePath =
|
|
33971
|
+
const absolutePath = path14.join(absoluteDir, entry);
|
|
33496
33972
|
try {
|
|
33497
33973
|
candidates.push({
|
|
33498
|
-
localPath:
|
|
33499
|
-
mtimeMs:
|
|
33974
|
+
localPath: path14.posix.join(assetDir, entry),
|
|
33975
|
+
mtimeMs: fs13.statSync(absolutePath).mtimeMs
|
|
33500
33976
|
});
|
|
33501
33977
|
} catch {
|
|
33502
33978
|
}
|
|
@@ -33506,7 +33982,7 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
|
33506
33982
|
return (_a3 = candidates[0]) == null ? void 0 : _a3.localPath;
|
|
33507
33983
|
}
|
|
33508
33984
|
function isKnownAssetPath(relativePath, assetDirs) {
|
|
33509
|
-
if (relativePath.startsWith("../") ||
|
|
33985
|
+
if (relativePath.startsWith("../") || path14.isAbsolute(relativePath)) {
|
|
33510
33986
|
return false;
|
|
33511
33987
|
}
|
|
33512
33988
|
return assetDirs.some(
|
|
@@ -33530,14 +34006,14 @@ function localAssetReferenceToDataUrl(options) {
|
|
|
33530
34006
|
}
|
|
33531
34007
|
let stat;
|
|
33532
34008
|
try {
|
|
33533
|
-
stat =
|
|
34009
|
+
stat = fs13.statSync(absolutePath);
|
|
33534
34010
|
} catch {
|
|
33535
34011
|
return void 0;
|
|
33536
34012
|
}
|
|
33537
34013
|
if (!stat.isFile() || stat.size > options.maxBytes) {
|
|
33538
34014
|
return void 0;
|
|
33539
34015
|
}
|
|
33540
|
-
const bytes =
|
|
34016
|
+
const bytes = fs13.readFileSync(absolutePath);
|
|
33541
34017
|
return `data:${mime};base64,${bytes.toString("base64")}`;
|
|
33542
34018
|
}
|
|
33543
34019
|
function resolveLocalAssetAbsolutePath(targetDir, options) {
|
|
@@ -33548,7 +34024,7 @@ function resolveLocalAssetAbsolutePath(targetDir, options) {
|
|
|
33548
34024
|
candidates.push(localPath);
|
|
33549
34025
|
}
|
|
33550
34026
|
}
|
|
33551
|
-
if (
|
|
34027
|
+
if (path14.isAbsolute(options.value)) {
|
|
33552
34028
|
candidates.push(options.value);
|
|
33553
34029
|
} else {
|
|
33554
34030
|
const localPath = resolveProjectRelativePath(targetDir, options.value);
|
|
@@ -33557,54 +34033,54 @@ function resolveLocalAssetAbsolutePath(targetDir, options) {
|
|
|
33557
34033
|
}
|
|
33558
34034
|
}
|
|
33559
34035
|
for (const candidate of candidates) {
|
|
33560
|
-
if (
|
|
34036
|
+
if (fs13.existsSync(candidate)) {
|
|
33561
34037
|
return candidate;
|
|
33562
34038
|
}
|
|
33563
34039
|
}
|
|
33564
34040
|
return void 0;
|
|
33565
34041
|
}
|
|
33566
34042
|
function resolveProjectRelativePath(targetDir, value) {
|
|
33567
|
-
const root =
|
|
33568
|
-
const absolutePath =
|
|
33569
|
-
const relativePath =
|
|
33570
|
-
const escapesRoot = relativePath === ".." || relativePath.startsWith(`..${
|
|
34043
|
+
const root = path14.resolve(targetDir);
|
|
34044
|
+
const absolutePath = path14.resolve(root, value);
|
|
34045
|
+
const relativePath = path14.relative(root, absolutePath);
|
|
34046
|
+
const escapesRoot = relativePath === ".." || relativePath.startsWith(`..${path14.sep}`) || path14.isAbsolute(relativePath);
|
|
33571
34047
|
if (!escapesRoot) {
|
|
33572
34048
|
return absolutePath;
|
|
33573
34049
|
}
|
|
33574
34050
|
return void 0;
|
|
33575
34051
|
}
|
|
33576
34052
|
function dataUrlMimeForPath(filePath, mediaKind) {
|
|
33577
|
-
return DATA_URL_MIME_BY_EXTENSION[mediaKind][
|
|
34053
|
+
return DATA_URL_MIME_BY_EXTENSION[mediaKind][path14.extname(filePath).toLowerCase()];
|
|
33578
34054
|
}
|
|
33579
34055
|
function upsertGeneratedAssetRecord(targetDir, localPath, record2) {
|
|
33580
34056
|
const registry2 = readGeneratedAssetRegistry(targetDir);
|
|
33581
34057
|
registry2[localPath] = record2;
|
|
33582
34058
|
const registryPath = getGeneratedAssetRegistryPath(targetDir);
|
|
33583
|
-
|
|
33584
|
-
|
|
34059
|
+
fs13.mkdirSync(path14.dirname(registryPath), { recursive: true });
|
|
34060
|
+
fs13.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
|
|
33585
34061
|
`, "utf8");
|
|
33586
34062
|
}
|
|
33587
34063
|
function readGeneratedAssetRegistry(targetDir) {
|
|
33588
34064
|
const registryPath = getGeneratedAssetRegistryPath(targetDir);
|
|
33589
|
-
if (!
|
|
34065
|
+
if (!fs13.existsSync(registryPath)) {
|
|
33590
34066
|
return {};
|
|
33591
34067
|
}
|
|
33592
34068
|
try {
|
|
33593
|
-
const parsed = JSON.parse(
|
|
34069
|
+
const parsed = JSON.parse(fs13.readFileSync(registryPath, "utf8"));
|
|
33594
34070
|
return isRecord(parsed) ? parsed : {};
|
|
33595
34071
|
} catch {
|
|
33596
34072
|
return {};
|
|
33597
34073
|
}
|
|
33598
34074
|
}
|
|
33599
34075
|
function getGeneratedAssetRegistryPath(targetDir) {
|
|
33600
|
-
return
|
|
34076
|
+
return path14.join(targetDir, ".maker", "assets", "generated-assets.json");
|
|
33601
34077
|
}
|
|
33602
34078
|
function normalizeAssetRegistryKey(targetDir, value) {
|
|
33603
34079
|
if (/^https?:\/\//i.test(value) || value.startsWith("data:")) {
|
|
33604
34080
|
return void 0;
|
|
33605
34081
|
}
|
|
33606
|
-
const relative =
|
|
33607
|
-
return relative.split(
|
|
34082
|
+
const relative = path14.isAbsolute(value) ? path14.relative(targetDir, value) : value;
|
|
34083
|
+
return relative.split(path14.sep).join("/");
|
|
33608
34084
|
}
|
|
33609
34085
|
function isRecord(value) {
|
|
33610
34086
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -33633,15 +34109,158 @@ function extensionFromUrl(url2) {
|
|
|
33633
34109
|
}
|
|
33634
34110
|
try {
|
|
33635
34111
|
const pathname = new URL(url2).pathname;
|
|
33636
|
-
const extension =
|
|
34112
|
+
const extension = path14.extname(pathname).replace(/^\./, "").toLowerCase();
|
|
33637
34113
|
return extension || void 0;
|
|
33638
34114
|
} catch {
|
|
33639
34115
|
return void 0;
|
|
33640
34116
|
}
|
|
33641
34117
|
}
|
|
33642
34118
|
|
|
34119
|
+
// src/mcp-proxy/config.ts
|
|
34120
|
+
var DEFAULT_TOOL_CALL_TIMEOUT_MS = 60 * 60 * 1e3;
|
|
34121
|
+
function readStdin() {
|
|
34122
|
+
return new Promise((resolve, reject) => {
|
|
34123
|
+
const chunks = [];
|
|
34124
|
+
process.stdin.on("data", (chunk) => {
|
|
34125
|
+
chunks.push(chunk);
|
|
34126
|
+
});
|
|
34127
|
+
process.stdin.on("end", () => {
|
|
34128
|
+
resolve(Buffer.concat(chunks).toString("utf-8"));
|
|
34129
|
+
});
|
|
34130
|
+
process.stdin.on("error", reject);
|
|
34131
|
+
setTimeout(() => {
|
|
34132
|
+
reject(new Error("Timeout reading from stdin"));
|
|
34133
|
+
}, 5e3);
|
|
34134
|
+
});
|
|
34135
|
+
}
|
|
34136
|
+
async function loadConfig() {
|
|
34137
|
+
let configJson;
|
|
34138
|
+
let source;
|
|
34139
|
+
if (process.argv[2]) {
|
|
34140
|
+
configJson = process.argv[2];
|
|
34141
|
+
source = "command line argument";
|
|
34142
|
+
} else if (process.env.PROXY_CONFIG) {
|
|
34143
|
+
configJson = process.env.PROXY_CONFIG;
|
|
34144
|
+
source = "PROXY_CONFIG environment variable";
|
|
34145
|
+
} else if (!process.stdin.isTTY) {
|
|
34146
|
+
configJson = await readStdin();
|
|
34147
|
+
source = "stdin";
|
|
34148
|
+
} else {
|
|
34149
|
+
throw new Error(
|
|
34150
|
+
`No configuration provided. Please use one of:
|
|
34151
|
+
1. Command line: node index.js '{"server":{...}}'
|
|
34152
|
+
2. Env var: PROXY_CONFIG='{"server":{...}}' node index.js
|
|
34153
|
+
3. Stdin: echo '{"server":{...}}' | node index.js
|
|
34154
|
+
|
|
34155
|
+
See config.example.json for configuration format.`
|
|
34156
|
+
);
|
|
34157
|
+
}
|
|
34158
|
+
console.error(`[Proxy] Loading config from ${source}`);
|
|
34159
|
+
let config2;
|
|
34160
|
+
try {
|
|
34161
|
+
config2 = JSON.parse(configJson);
|
|
34162
|
+
} catch (error2) {
|
|
34163
|
+
throw new Error(
|
|
34164
|
+
`Failed to parse configuration JSON: ${error2 instanceof Error ? error2.message : String(error2)}
|
|
34165
|
+
Received: ${configJson.substring(0, 100)}...`
|
|
34166
|
+
);
|
|
34167
|
+
}
|
|
34168
|
+
validateConfig(config2);
|
|
34169
|
+
return applyDefaults(config2);
|
|
34170
|
+
}
|
|
34171
|
+
function validateConfig(config2) {
|
|
34172
|
+
var _a3;
|
|
34173
|
+
const errors = [];
|
|
34174
|
+
if (!config2.server) {
|
|
34175
|
+
errors.push("- Missing required field: server");
|
|
34176
|
+
} else {
|
|
34177
|
+
if (!config2.server.url) {
|
|
34178
|
+
errors.push("- Missing required field: server.url");
|
|
34179
|
+
}
|
|
34180
|
+
if (config2.server.env && !["rnd", "production"].includes(config2.server.env)) {
|
|
34181
|
+
errors.push('- Invalid server.env: must be "rnd" or "production"');
|
|
34182
|
+
}
|
|
34183
|
+
}
|
|
34184
|
+
if (!config2.tenant) {
|
|
34185
|
+
errors.push("- Missing required field: tenant");
|
|
34186
|
+
} else {
|
|
34187
|
+
if (config2.tenant.custom_fields !== void 0) {
|
|
34188
|
+
const cf = config2.tenant.custom_fields;
|
|
34189
|
+
if (typeof cf !== "object" || cf === null || Array.isArray(cf) || Object.getPrototypeOf(cf) !== Object.prototype) {
|
|
34190
|
+
errors.push("- tenant.custom_fields must be a plain object (Record<string, string>)");
|
|
34191
|
+
} else if (!Object.values(cf).every((v) => typeof v === "string")) {
|
|
34192
|
+
errors.push("- tenant.custom_fields values must all be strings");
|
|
34193
|
+
}
|
|
34194
|
+
}
|
|
34195
|
+
}
|
|
34196
|
+
if (!config2.auth) {
|
|
34197
|
+
errors.push("- Missing required field: auth");
|
|
34198
|
+
} else {
|
|
34199
|
+
if (!config2.auth.kid) {
|
|
34200
|
+
errors.push("- Missing required field: auth.kid");
|
|
34201
|
+
}
|
|
34202
|
+
if (!config2.auth.mac_key) {
|
|
34203
|
+
errors.push("- Missing required field: auth.mac_key");
|
|
34204
|
+
}
|
|
34205
|
+
if (config2.auth.token_type !== "mac") {
|
|
34206
|
+
errors.push('- Invalid auth.token_type: must be "mac"');
|
|
34207
|
+
}
|
|
34208
|
+
if (config2.auth.mac_algorithm !== "hmac-sha-1") {
|
|
34209
|
+
errors.push('- Invalid auth.mac_algorithm: must be "hmac-sha-1"');
|
|
34210
|
+
}
|
|
34211
|
+
}
|
|
34212
|
+
if (((_a3 = config2.options) == null ? void 0 : _a3.exposed_tools) !== void 0) {
|
|
34213
|
+
const exposedTools = config2.options.exposed_tools;
|
|
34214
|
+
if (!Array.isArray(exposedTools)) {
|
|
34215
|
+
errors.push("- options.exposed_tools must be an array of tool names");
|
|
34216
|
+
} else if (!exposedTools.every((toolName) => typeof toolName === "string" && toolName.trim().length > 0)) {
|
|
34217
|
+
errors.push("- options.exposed_tools values must be non-empty strings");
|
|
34218
|
+
}
|
|
34219
|
+
}
|
|
34220
|
+
if (errors.length > 0) {
|
|
34221
|
+
throw new Error("Invalid configuration:\n" + errors.join("\n"));
|
|
34222
|
+
}
|
|
34223
|
+
}
|
|
34224
|
+
var DEFAULT_LOG_ROOT = "/tmp/taptap-mcp/logs";
|
|
34225
|
+
function applyDefaults(config2) {
|
|
34226
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
34227
|
+
const verbose = ((_a3 = config2.options) == null ? void 0 : _a3.verbose) ?? false;
|
|
34228
|
+
return {
|
|
34229
|
+
server: {
|
|
34230
|
+
url: config2.server.url,
|
|
34231
|
+
env: config2.server.env || "rnd"
|
|
34232
|
+
},
|
|
34233
|
+
tenant: {
|
|
34234
|
+
project_path: config2.tenant.project_path || ".",
|
|
34235
|
+
user_id: config2.tenant.user_id,
|
|
34236
|
+
project_id: config2.tenant.project_id,
|
|
34237
|
+
custom_fields: config2.tenant.custom_fields
|
|
34238
|
+
},
|
|
34239
|
+
auth: config2.auth,
|
|
34240
|
+
options: {
|
|
34241
|
+
verbose,
|
|
34242
|
+
reconnect_interval: ((_b = config2.options) == null ? void 0 : _b.reconnect_interval) ?? 5e3,
|
|
34243
|
+
request_timeout: ((_c = config2.options) == null ? void 0 : _c.request_timeout) ?? 3e4,
|
|
34244
|
+
tool_call_timeout: ((_d = config2.options) == null ? void 0 : _d.tool_call_timeout) ?? DEFAULT_TOOL_CALL_TIMEOUT_MS,
|
|
34245
|
+
reset_timeout_on_progress: ((_e = config2.options) == null ? void 0 : _e.reset_timeout_on_progress) ?? true,
|
|
34246
|
+
health_check_interval: ((_f = config2.options) == null ? void 0 : _f.health_check_interval) ?? 3e4,
|
|
34247
|
+
enable_cookie_sticky: ((_g = config2.options) == null ? void 0 : _g.enable_cookie_sticky) ?? true,
|
|
34248
|
+
inject_params_per_call: ((_h = config2.options) == null ? void 0 : _h.inject_params_per_call) ?? true,
|
|
34249
|
+
force_inject_progress_token: ((_i = config2.options) == null ? void 0 : _i.force_inject_progress_token) ?? false,
|
|
34250
|
+
exposed_tools: (_j = config2.options) == null ? void 0 : _j.exposed_tools,
|
|
34251
|
+
log: {
|
|
34252
|
+
root: ((_l = (_k = config2.options) == null ? void 0 : _k.log) == null ? void 0 : _l.root) ?? DEFAULT_LOG_ROOT,
|
|
34253
|
+
enabled: ((_n = (_m = config2.options) == null ? void 0 : _m.log) == null ? void 0 : _n.enabled) ?? false,
|
|
34254
|
+
// verbose=true 时自动使用 debug 级别
|
|
34255
|
+
level: verbose ? "debug" : ((_p = (_o = config2.options) == null ? void 0 : _o.log) == null ? void 0 : _p.level) ?? "info",
|
|
34256
|
+
max_days: ((_r = (_q = config2.options) == null ? void 0 : _q.log) == null ? void 0 : _r.max_days) ?? 7
|
|
34257
|
+
}
|
|
34258
|
+
}
|
|
34259
|
+
};
|
|
34260
|
+
}
|
|
34261
|
+
|
|
33643
34262
|
// src/maker/server/mcp.ts
|
|
33644
|
-
var VERSION = true ? "0.0.
|
|
34263
|
+
var VERSION = true ? "0.0.21-beta.1" : "dev";
|
|
33645
34264
|
var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
33646
34265
|
var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
|
|
33647
34266
|
var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
|
|
@@ -33671,7 +34290,7 @@ var MakerCloneFailedError = class extends Error {
|
|
|
33671
34290
|
var tools = [
|
|
33672
34291
|
{
|
|
33673
34292
|
name: "maker_status_lite",
|
|
33674
|
-
description: "Compatibility status surface for clients using tool output instead of the maker://status resource. Prefer reading maker://status when resources are available. Shows local Maker status for the user current working directory, including Git, Python runtime readiness, maker-lua-lsp readiness for local Lua diagnostics, PAT/TapTap auth, project binding, AI dev kit status, Maker proxy tools status and failures, Maker Git Workflow Policy guidance, Maker Creative Asset Tool Policy guidance to prefer Maker MCP proxy tools for bound game assets, supported local path/remote URL/data URL inputs, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init.
|
|
34293
|
+
description: "Compatibility status surface for clients using tool output instead of the maker://status resource. Prefer reading maker://status when resources are available. Shows local Maker status for the user current working directory, including Git, Python runtime readiness, maker-lua-lsp readiness for local Lua diagnostics, PAT/TapTap auth, project binding, AI dev kit status, Maker proxy tools status and failures, Maker Git Workflow Policy guidance, Maker Creative Asset Tool Policy guidance to prefer Maker MCP proxy tools for bound game assets, supported local path/remote URL/data URL inputs, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init. Standard init/clone/download flow: show the Maker app list first and let the user choose an existing app or 0/new. Create-new-project flow: use taptap-maker init --create only when the user clearly asks to create a new Maker project.",
|
|
33675
34294
|
inputSchema: {
|
|
33676
34295
|
type: "object",
|
|
33677
34296
|
properties: {
|
|
@@ -33750,22 +34369,30 @@ var resources = [
|
|
|
33750
34369
|
{
|
|
33751
34370
|
uri: "maker://status",
|
|
33752
34371
|
name: "Maker status",
|
|
33753
|
-
description: "Local TapTap Maker project status, including Git, PAT/TapTap auth, project binding, AI dev kit status, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init.
|
|
34372
|
+
description: "Local TapTap Maker project status, including Git, PAT/TapTap auth, project binding, AI dev kit status, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init. Standard init/clone/download flow: show the Maker app list first and let the user choose an existing app or 0/new. Create-new-project flow: use taptap-maker init --create only when the user clearly asks to create a new Maker project.",
|
|
33754
34373
|
mimeType: "text/plain"
|
|
33755
34374
|
}
|
|
33756
34375
|
];
|
|
33757
34376
|
async function listMakerTools(options) {
|
|
33758
34377
|
let remoteTools = [];
|
|
33759
34378
|
try {
|
|
34379
|
+
const context = await resolveMakerProjectContext({
|
|
34380
|
+
targetDir: options.targetDir,
|
|
34381
|
+
listClientRoots: options.listClientRoots,
|
|
34382
|
+
allowFallbackOnAmbiguousRoots: false
|
|
34383
|
+
});
|
|
33760
34384
|
const listedRemoteTools = options.listRemoteTools ?? (() => listRemoteProxyTools({
|
|
33761
|
-
targetDir:
|
|
34385
|
+
targetDir: context.targetDir,
|
|
33762
34386
|
serverUrl: options.serverUrl,
|
|
33763
34387
|
env: options.env
|
|
33764
34388
|
}));
|
|
33765
34389
|
remoteTools = filterExposedRemoteProxyTools(await listedRemoteTools()).map(
|
|
33766
34390
|
decorateRemoteProxyToolDefinition
|
|
33767
34391
|
);
|
|
33768
|
-
} catch {
|
|
34392
|
+
} catch (error2) {
|
|
34393
|
+
if (isMakerProjectContextAmbiguousError(error2)) {
|
|
34394
|
+
logLifecycleEvent("maker-tools-list-roots-ambiguous", String(error2));
|
|
34395
|
+
}
|
|
33769
34396
|
remoteTools = [];
|
|
33770
34397
|
}
|
|
33771
34398
|
return {
|
|
@@ -33778,14 +34405,30 @@ function filterExposedRemoteProxyTools(toolsToFilter) {
|
|
|
33778
34405
|
}
|
|
33779
34406
|
function decorateRemoteProxyToolDefinition(tool) {
|
|
33780
34407
|
const guidance = remoteProxyToolGuidance(tool.name);
|
|
33781
|
-
if (!guidance) {
|
|
33782
|
-
return tool;
|
|
33783
|
-
}
|
|
33784
34408
|
return {
|
|
33785
34409
|
...tool,
|
|
34410
|
+
inputSchema: decorateRemoteProxyToolInputSchema(tool.inputSchema),
|
|
33786
34411
|
description: [tool.description, guidance].filter(Boolean).join("\n\n")
|
|
33787
34412
|
};
|
|
33788
34413
|
}
|
|
34414
|
+
function decorateRemoteProxyToolInputSchema(inputSchema) {
|
|
34415
|
+
const schema = isPlainRecord(inputSchema) ? inputSchema : {};
|
|
34416
|
+
const properties = isPlainRecord(schema.properties) ? schema.properties : {};
|
|
34417
|
+
return {
|
|
34418
|
+
...schema,
|
|
34419
|
+
type: schema.type || "object",
|
|
34420
|
+
properties: {
|
|
34421
|
+
...properties,
|
|
34422
|
+
target_dir: {
|
|
34423
|
+
type: "string",
|
|
34424
|
+
description: "Optional local Maker project directory. This is a local Maker MCP private parameter used to resolve the current project for asset materialization and reference rewriting; it is not forwarded to the remote Maker generation tool."
|
|
34425
|
+
}
|
|
34426
|
+
}
|
|
34427
|
+
};
|
|
34428
|
+
}
|
|
34429
|
+
function isPlainRecord(value) {
|
|
34430
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34431
|
+
}
|
|
33789
34432
|
function remoteProxyToolGuidance(toolName) {
|
|
33790
34433
|
const failurePolicy = "If this Maker proxy tool fails or returns isError, include the full remote_result/error payload from the server so developers can diagnose the issue.";
|
|
33791
34434
|
const localMediaSizeHint = "Large local/data URL media can be slow or fail: image inputs are commonly limited to about 10 MB, video-task image inputs to about 30 MB, video inputs to about 50 MB, and audio inputs to about 15 MB.";
|
|
@@ -33942,10 +34585,13 @@ function createRemoteProxyProgressHandler(progressToken, extra) {
|
|
|
33942
34585
|
}
|
|
33943
34586
|
function createRemoteProxyCallToolOptions(progressToken, extra) {
|
|
33944
34587
|
return {
|
|
34588
|
+
timeout: DEFAULT_TOOL_CALL_TIMEOUT_MS,
|
|
34589
|
+
resetTimeoutOnProgress: true,
|
|
33945
34590
|
onprogress: createRemoteProxyProgressHandler(progressToken, extra)
|
|
33946
34591
|
};
|
|
33947
34592
|
}
|
|
33948
34593
|
async function startMakerMcpServer() {
|
|
34594
|
+
startMakerPackageUpdateCheck({ currentVersion: VERSION });
|
|
33949
34595
|
const server = new Server(
|
|
33950
34596
|
{
|
|
33951
34597
|
name: "taptap-maker",
|
|
@@ -33958,10 +34604,8 @@ async function startMakerMcpServer() {
|
|
|
33958
34604
|
}
|
|
33959
34605
|
}
|
|
33960
34606
|
);
|
|
33961
|
-
server
|
|
33962
|
-
|
|
33963
|
-
async () => listMakerTools({ targetDir: process.cwd() })
|
|
33964
|
-
);
|
|
34607
|
+
const listClientRoots = createServerClientRootsProvider(server);
|
|
34608
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => listMakerTools({ listClientRoots }));
|
|
33965
34609
|
server.setRequestHandler(ListResourcesRequestSchema, async () => ({ resources }));
|
|
33966
34610
|
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
33967
34611
|
const uri = request.params.uri;
|
|
@@ -33973,7 +34617,7 @@ async function startMakerMcpServer() {
|
|
|
33973
34617
|
{
|
|
33974
34618
|
uri,
|
|
33975
34619
|
mimeType: "text/plain",
|
|
33976
|
-
text: await formatStatus()
|
|
34620
|
+
text: await formatStatus({ listClientRoots })
|
|
33977
34621
|
}
|
|
33978
34622
|
]
|
|
33979
34623
|
};
|
|
@@ -33990,7 +34634,8 @@ async function startMakerMcpServer() {
|
|
|
33990
34634
|
type: "text",
|
|
33991
34635
|
text: await formatStatus({
|
|
33992
34636
|
targetDir: args.target_dir,
|
|
33993
|
-
skipRemoteSync: args.skip_remote_sync
|
|
34637
|
+
skipRemoteSync: args.skip_remote_sync,
|
|
34638
|
+
listClientRoots
|
|
33994
34639
|
})
|
|
33995
34640
|
}
|
|
33996
34641
|
]
|
|
@@ -34006,8 +34651,13 @@ async function startMakerMcpServer() {
|
|
|
34006
34651
|
let result;
|
|
34007
34652
|
let progressSummary;
|
|
34008
34653
|
try {
|
|
34654
|
+
const context = await resolveMakerProjectContext({
|
|
34655
|
+
targetDir: args.target_dir,
|
|
34656
|
+
listClientRoots,
|
|
34657
|
+
allowFallbackOnAmbiguousRoots: false
|
|
34658
|
+
});
|
|
34009
34659
|
result = await buildCurrentDirectory({
|
|
34010
|
-
targetDir:
|
|
34660
|
+
targetDir: context.targetDir,
|
|
34011
34661
|
entry: args.entry,
|
|
34012
34662
|
scriptsPath: args.scriptsPath,
|
|
34013
34663
|
entryClient: args.entry_client,
|
|
@@ -34036,10 +34686,18 @@ async function startMakerMcpServer() {
|
|
|
34036
34686
|
};
|
|
34037
34687
|
}
|
|
34038
34688
|
if (isExposedRemoteProxyTool(name)) {
|
|
34689
|
+
const { targetDir, remoteArgs } = splitRemoteProxyToolPrivateArgs(
|
|
34690
|
+
request.params.arguments || {}
|
|
34691
|
+
);
|
|
34692
|
+
const context = await resolveMakerProjectContext({
|
|
34693
|
+
targetDir,
|
|
34694
|
+
listClientRoots,
|
|
34695
|
+
allowFallbackOnAmbiguousRoots: false
|
|
34696
|
+
});
|
|
34039
34697
|
return await callRemoteProxyTool({
|
|
34040
|
-
targetDir:
|
|
34698
|
+
targetDir: context.targetDir,
|
|
34041
34699
|
name,
|
|
34042
|
-
args:
|
|
34700
|
+
args: remoteArgs,
|
|
34043
34701
|
progressToken: (_b = request.params._meta) == null ? void 0 : _b.progressToken,
|
|
34044
34702
|
extra
|
|
34045
34703
|
});
|
|
@@ -34093,11 +34751,16 @@ function installMakerServerExitHandlers() {
|
|
|
34093
34751
|
}
|
|
34094
34752
|
async function formatStatus(options = {}) {
|
|
34095
34753
|
var _a3;
|
|
34096
|
-
const
|
|
34754
|
+
const projectContext = await resolveMakerProjectContext({
|
|
34755
|
+
targetDir: options.targetDir,
|
|
34756
|
+
listClientRoots: options.listClientRoots,
|
|
34757
|
+
allowFallbackOnAmbiguousRoots: true
|
|
34758
|
+
});
|
|
34759
|
+
const targetDir = projectContext.targetDir;
|
|
34097
34760
|
const env = getMakerEnvironment(void 0, targetDir);
|
|
34098
34761
|
const identify = identifyMakerProject({ cwd: targetDir });
|
|
34099
34762
|
const mcpCwd = process.cwd();
|
|
34100
|
-
const mcpCwdIdentify =
|
|
34763
|
+
const mcpCwdIdentify = path15.resolve(mcpCwd) === path15.resolve(targetDir) ? identify : identifyMakerProject({ cwd: mcpCwd });
|
|
34101
34764
|
const gitDirectoryStatus = inspectMakerDirectoryGitStatus(targetDir);
|
|
34102
34765
|
const remoteSyncText = identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo && !options.skipRemoteSync ? await formatMakerRemoteSyncStatusSafely(identify.projectRoot) : identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo ? formatMakerRemoteSyncSkipped() : "";
|
|
34103
34766
|
const pat = loadPat();
|
|
@@ -34123,6 +34786,12 @@ async function formatStatus(options = {}) {
|
|
|
34123
34786
|
const git = checkGitEnvironment();
|
|
34124
34787
|
const python = checkMakerPythonEnvironment();
|
|
34125
34788
|
const luaLsp = checkMakerLuaLspEnvironment({ pythonEnvironment: python });
|
|
34789
|
+
const packageUpdateText = formatMakerPackageUpdateStatus(
|
|
34790
|
+
await getMakerPackageUpdateStatus({
|
|
34791
|
+
currentVersion: VERSION,
|
|
34792
|
+
allowRemoteFetch: false
|
|
34793
|
+
})
|
|
34794
|
+
);
|
|
34126
34795
|
const projectSection = identify.projectId ? [
|
|
34127
34796
|
"目标目录已绑定 Maker 项目。",
|
|
34128
34797
|
"请继续在当前绑定项目上执行状态、提交、构建等操作;用户明确要求切换或重新拉取项目时,再进入项目选择流程。",
|
|
@@ -34136,6 +34805,7 @@ async function formatStatus(options = {}) {
|
|
|
34136
34805
|
`- tap_auth: ${tapAuth ? "found" : "missing"} (${getTapAuthPath()})`,
|
|
34137
34806
|
`- pat: ${pat ? "found" : "missing"} (${getPatPath()})`,
|
|
34138
34807
|
`- target_dir: ${targetDir}`,
|
|
34808
|
+
`- project_context_source: ${projectContext.source}`,
|
|
34139
34809
|
`- project_source: ${identify.source}`,
|
|
34140
34810
|
`- project_id: ${identify.projectId || "(none)"}`,
|
|
34141
34811
|
identify.configPath ? `- config: ${identify.configPath}` : "",
|
|
@@ -34149,9 +34819,13 @@ async function formatStatus(options = {}) {
|
|
|
34149
34819
|
"",
|
|
34150
34820
|
formatMakerLuaLspEnvironmentStatus(luaLsp),
|
|
34151
34821
|
"",
|
|
34822
|
+
packageUpdateText,
|
|
34823
|
+
"",
|
|
34152
34824
|
formatMakerGitDirectoryStatus(gitDirectoryStatus),
|
|
34153
34825
|
"",
|
|
34154
|
-
|
|
34826
|
+
formatMakerClientRootsStatus(projectContext.roots),
|
|
34827
|
+
"",
|
|
34828
|
+
projectContext.source === "client_roots" ? "" : formatMakerToolRegistrationCwdStatus({
|
|
34155
34829
|
mcpCwd,
|
|
34156
34830
|
targetDir,
|
|
34157
34831
|
projectRoot: identify.projectRoot,
|
|
@@ -34219,10 +34893,10 @@ function formatMakerToolRegistrationCwdStatus(options) {
|
|
|
34219
34893
|
if (!options.projectRoot) {
|
|
34220
34894
|
return "";
|
|
34221
34895
|
}
|
|
34222
|
-
const mcpCwd =
|
|
34223
|
-
const targetDir =
|
|
34224
|
-
const projectRoot =
|
|
34225
|
-
const mcpProjectRoot = options.mcpProjectRoot ?
|
|
34896
|
+
const mcpCwd = path15.resolve(options.mcpCwd);
|
|
34897
|
+
const targetDir = path15.resolve(options.targetDir);
|
|
34898
|
+
const projectRoot = path15.resolve(options.projectRoot);
|
|
34899
|
+
const mcpProjectRoot = options.mcpProjectRoot ? path15.resolve(options.mcpProjectRoot) : void 0;
|
|
34226
34900
|
if (mcpProjectRoot === projectRoot) {
|
|
34227
34901
|
return "";
|
|
34228
34902
|
}
|
|
@@ -34382,11 +35056,180 @@ function formatAiDialogueDirectoryHint(targetDir) {
|
|
|
34382
35056
|
"- do_not_show_app_selection_here: yes"
|
|
34383
35057
|
].join("\n");
|
|
34384
35058
|
}
|
|
34385
|
-
function
|
|
34386
|
-
|
|
34387
|
-
|
|
35059
|
+
function createServerClientRootsProvider(server) {
|
|
35060
|
+
return async () => {
|
|
35061
|
+
const capabilities = server.getClientCapabilities();
|
|
35062
|
+
if (!(capabilities == null ? void 0 : capabilities.roots)) {
|
|
35063
|
+
return void 0;
|
|
35064
|
+
}
|
|
35065
|
+
const result = await server.listRoots(void 0, { timeout: 2e3 });
|
|
35066
|
+
return result.roots;
|
|
35067
|
+
};
|
|
35068
|
+
}
|
|
35069
|
+
async function resolveMakerProjectContext(options = {}) {
|
|
35070
|
+
if (options.targetDir) {
|
|
35071
|
+
return {
|
|
35072
|
+
targetDir: path15.resolve(options.targetDir),
|
|
35073
|
+
source: "explicit_target_dir",
|
|
35074
|
+
roots: { status: "not_requested", roots: [] }
|
|
35075
|
+
};
|
|
35076
|
+
}
|
|
35077
|
+
const roots = await resolveMakerClientRoots(options.listClientRoots);
|
|
35078
|
+
if (roots.status === "selected") {
|
|
35079
|
+
return {
|
|
35080
|
+
targetDir: roots.selectedProjectRoot || roots.selectedRoot,
|
|
35081
|
+
source: "client_roots",
|
|
35082
|
+
roots
|
|
35083
|
+
};
|
|
35084
|
+
}
|
|
35085
|
+
if (roots.status === "ambiguous" && !options.allowFallbackOnAmbiguousRoots) {
|
|
35086
|
+
throw new MakerProjectContextAmbiguousError(
|
|
35087
|
+
[
|
|
35088
|
+
"Multiple Maker project roots are attached to this MCP session.",
|
|
35089
|
+
`maker_project_roots: ${roots.makerProjectRoots.join(", ") || "(none)"}`,
|
|
35090
|
+
"Open a single Maker workspace, or pass target_dir explicitly for this call."
|
|
35091
|
+
].join("\n")
|
|
35092
|
+
);
|
|
35093
|
+
}
|
|
35094
|
+
return {
|
|
35095
|
+
targetDir: process.cwd(),
|
|
35096
|
+
source: "mcp_cwd_fallback",
|
|
35097
|
+
roots
|
|
35098
|
+
};
|
|
35099
|
+
}
|
|
35100
|
+
var MakerProjectContextAmbiguousError = class extends Error {
|
|
35101
|
+
constructor(message) {
|
|
35102
|
+
super(message);
|
|
35103
|
+
this.name = "MakerProjectContextAmbiguousError";
|
|
35104
|
+
}
|
|
35105
|
+
};
|
|
35106
|
+
function isMakerProjectContextAmbiguousError(error2) {
|
|
35107
|
+
return error2 instanceof MakerProjectContextAmbiguousError;
|
|
35108
|
+
}
|
|
35109
|
+
async function resolveMakerClientRoots(listClientRoots) {
|
|
35110
|
+
if (!listClientRoots) {
|
|
35111
|
+
return { status: "not_requested", roots: [] };
|
|
35112
|
+
}
|
|
35113
|
+
let roots;
|
|
35114
|
+
try {
|
|
35115
|
+
roots = await listClientRoots();
|
|
35116
|
+
} catch (error2) {
|
|
35117
|
+
return {
|
|
35118
|
+
status: "unavailable",
|
|
35119
|
+
roots: [],
|
|
35120
|
+
message: error2 instanceof Error ? error2.message : String(error2)
|
|
35121
|
+
};
|
|
35122
|
+
}
|
|
35123
|
+
if (!roots) {
|
|
35124
|
+
return { status: "unsupported", roots: [] };
|
|
35125
|
+
}
|
|
35126
|
+
const rootPaths = uniquePaths(
|
|
35127
|
+
roots.map(rootToLocalPath).filter((item) => Boolean(item))
|
|
35128
|
+
);
|
|
35129
|
+
if (rootPaths.length === 0) {
|
|
35130
|
+
return { status: "no_roots", roots: [] };
|
|
35131
|
+
}
|
|
35132
|
+
if (rootPaths.length === 1) {
|
|
35133
|
+
const identify = identifyMakerProject({ cwd: rootPaths[0] });
|
|
35134
|
+
return {
|
|
35135
|
+
status: "selected",
|
|
35136
|
+
roots: rootPaths,
|
|
35137
|
+
selectedRoot: rootPaths[0],
|
|
35138
|
+
selectedProjectRoot: identify.projectRoot,
|
|
35139
|
+
reason: "single_root"
|
|
35140
|
+
};
|
|
35141
|
+
}
|
|
35142
|
+
const makerProjectRoots = uniquePaths(
|
|
35143
|
+
rootPaths.map((rootPath) => identifyMakerProject({ cwd: rootPath }).projectRoot).filter((item) => Boolean(item))
|
|
35144
|
+
);
|
|
35145
|
+
if (makerProjectRoots.length === 1) {
|
|
35146
|
+
return {
|
|
35147
|
+
status: "selected",
|
|
35148
|
+
roots: rootPaths,
|
|
35149
|
+
selectedRoot: makerProjectRoots[0],
|
|
35150
|
+
selectedProjectRoot: makerProjectRoots[0],
|
|
35151
|
+
reason: "single_maker_project"
|
|
35152
|
+
};
|
|
35153
|
+
}
|
|
35154
|
+
return {
|
|
35155
|
+
status: "ambiguous",
|
|
35156
|
+
roots: rootPaths,
|
|
35157
|
+
makerProjectRoots,
|
|
35158
|
+
message: makerProjectRoots.length > 1 ? "Multiple attached roots are bound Maker projects." : "Multiple attached roots are present and none is a bound Maker project."
|
|
35159
|
+
};
|
|
35160
|
+
}
|
|
35161
|
+
function rootToLocalPath(root) {
|
|
35162
|
+
try {
|
|
35163
|
+
const url2 = new URL(root.uri);
|
|
35164
|
+
if (url2.protocol !== "file:") {
|
|
35165
|
+
return void 0;
|
|
35166
|
+
}
|
|
35167
|
+
return path15.resolve(fileURLToPath2(url2));
|
|
35168
|
+
} catch {
|
|
35169
|
+
return void 0;
|
|
35170
|
+
}
|
|
35171
|
+
}
|
|
35172
|
+
function uniquePaths(values) {
|
|
35173
|
+
const seen = /* @__PURE__ */ new Set();
|
|
35174
|
+
const result = [];
|
|
35175
|
+
for (const value of values) {
|
|
35176
|
+
const normalized = normalizePathForCompare2(value);
|
|
35177
|
+
if (seen.has(normalized)) {
|
|
35178
|
+
continue;
|
|
35179
|
+
}
|
|
35180
|
+
seen.add(normalized);
|
|
35181
|
+
result.push(path15.resolve(value));
|
|
34388
35182
|
}
|
|
34389
|
-
return
|
|
35183
|
+
return result;
|
|
35184
|
+
}
|
|
35185
|
+
function normalizePathForCompare2(value) {
|
|
35186
|
+
const resolved = path15.resolve(value);
|
|
35187
|
+
try {
|
|
35188
|
+
return fs14.realpathSync.native(resolved);
|
|
35189
|
+
} catch {
|
|
35190
|
+
return resolved;
|
|
35191
|
+
}
|
|
35192
|
+
}
|
|
35193
|
+
function formatMakerClientRootsStatus(roots) {
|
|
35194
|
+
if (roots.status === "not_requested") {
|
|
35195
|
+
return "";
|
|
35196
|
+
}
|
|
35197
|
+
const lines = [
|
|
35198
|
+
"MCP client roots",
|
|
35199
|
+
"",
|
|
35200
|
+
`- status: ${roots.status}`,
|
|
35201
|
+
`- roots: ${roots.roots.join(", ") || "(none)"}`
|
|
35202
|
+
];
|
|
35203
|
+
if (roots.status === "selected") {
|
|
35204
|
+
lines.push(`- selected_root: ${roots.selectedRoot}`);
|
|
35205
|
+
lines.push(`- selected_project_root: ${roots.selectedProjectRoot || "(none)"}`);
|
|
35206
|
+
lines.push(`- reason: ${roots.reason}`);
|
|
35207
|
+
lines.push("- next_action: Continue using the client workspace root as the Maker target.");
|
|
35208
|
+
} else if (roots.status === "ambiguous") {
|
|
35209
|
+
lines.push(`- maker_project_roots: ${roots.makerProjectRoots.join(", ") || "(none)"}`);
|
|
35210
|
+
lines.push(`- issue: ${roots.message}`);
|
|
35211
|
+
lines.push(
|
|
35212
|
+
"- next_action: Open a single Maker workspace, or pass target_dir explicitly for this call."
|
|
35213
|
+
);
|
|
35214
|
+
} else if (roots.status === "unsupported") {
|
|
35215
|
+
lines.push("- next_action: This client did not advertise MCP roots; falling back to MCP cwd.");
|
|
35216
|
+
} else if (roots.status === "unavailable") {
|
|
35217
|
+
lines.push(`- failure_message: ${roots.message || "(unknown)"}`);
|
|
35218
|
+
lines.push("- next_action: Could not read MCP roots; falling back to MCP cwd.");
|
|
35219
|
+
}
|
|
35220
|
+
return lines.join("\n");
|
|
35221
|
+
}
|
|
35222
|
+
function splitRemoteProxyToolPrivateArgs(args) {
|
|
35223
|
+
const remoteArgs = { ...args };
|
|
35224
|
+
const targetDir = remoteArgs.target_dir;
|
|
35225
|
+
delete remoteArgs.target_dir;
|
|
35226
|
+
if (targetDir === void 0) {
|
|
35227
|
+
return { remoteArgs };
|
|
35228
|
+
}
|
|
35229
|
+
if (typeof targetDir !== "string") {
|
|
35230
|
+
throw new Error("target_dir must be a string when provided.");
|
|
35231
|
+
}
|
|
35232
|
+
return { targetDir, remoteArgs };
|
|
34390
35233
|
}
|
|
34391
35234
|
async function formatAiDevKitStatus(projectRoot, options = {}) {
|
|
34392
35235
|
const devKitStatus = inspectAiDevKit(projectRoot);
|
|
@@ -34427,6 +35270,7 @@ async function formatAutoProjectListFromPat() {
|
|
|
34427
35270
|
return [
|
|
34428
35271
|
"本地已有 Maker PAT,当前目录尚未绑定 Maker 项目。",
|
|
34429
35272
|
"绑定项目时必须先提醒用户:0,创建新项目 / 0. Create a new Maker project。",
|
|
35273
|
+
"普通初始化、clone、拉取远端项目的标准流程:先展示 app 列表,让用户选择已有 app;用户明确选择 0/new 或明确要求创建时再创建新项目。",
|
|
34430
35274
|
"即使发现和当前目录同名的 Maker app,也不能只推荐同名 app;必须同时展示创建新项目选项。",
|
|
34431
35275
|
"当前目录未绑定时,先展示下面的 Maker Apps 预览和总数;选择、解释和 clone 顺序请参考 taptap-maker-local workflow guide document。",
|
|
34432
35276
|
"用户选择 0/new 或已有 app 后,next_step: 执行 `taptap-maker init`。",
|
|
@@ -34477,6 +35321,7 @@ function formatStatusProjectList(projects) {
|
|
|
34477
35321
|
hiddenCount > 0 ? "如需完整列表,请运行 taptap-maker apps --json 查看全部 app。" : void 0,
|
|
34478
35322
|
"0,创建新项目 / 0. Create a new Maker project",
|
|
34479
35323
|
"AI 必须把上面这一行作为可选项展示给用户;即使压缩 app 列表,也不要删除创建项目入口。",
|
|
35324
|
+
"AI 标准流程:先让用户从 app 列表选择已有 app;当用户选择 0/new 或明确要求创建新项目时,再进入创建流程。",
|
|
34480
35325
|
"AI 展示建议:如果聊天或客户端宽度足够,可把 app 预览整理成两列紧凑布局;每个 app 保留序号、app_id、名称,以及可用的最近活跃时间或 user_id。窄屏保持单列。选择 app 前先获取用户确认。",
|
|
34481
35326
|
"",
|
|
34482
35327
|
...visibleProjects.map(
|
|
@@ -34489,14 +35334,14 @@ function formatStatusProjectList(projects) {
|
|
|
34489
35334
|
].filter((line) => line !== void 0).join("\n");
|
|
34490
35335
|
}
|
|
34491
35336
|
function formatClonePartialStateLines(targetDir) {
|
|
34492
|
-
const resolvedTargetDir =
|
|
35337
|
+
const resolvedTargetDir = path15.resolve(targetDir);
|
|
34493
35338
|
const identify = identifyMakerProject({ cwd: resolvedTargetDir });
|
|
34494
35339
|
const gitStatus = inspectMakerDirectoryGitStatus(resolvedTargetDir);
|
|
34495
35340
|
const devKitStatus = inspectAiDevKit(resolvedTargetDir);
|
|
34496
|
-
const stagedDevKitGitignorePath =
|
|
35341
|
+
const stagedDevKitGitignorePath = path15.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
|
|
34497
35342
|
const projectBound = Boolean(identify.projectId);
|
|
34498
35343
|
const gitInitialized = Boolean(
|
|
34499
|
-
gitStatus.isOwnGitRoot ||
|
|
35344
|
+
gitStatus.isOwnGitRoot || fs14.existsSync(path15.join(resolvedTargetDir, ".git"))
|
|
34500
35345
|
);
|
|
34501
35346
|
const safeToRetry = !projectBound;
|
|
34502
35347
|
return [
|
|
@@ -34510,7 +35355,7 @@ function formatClonePartialStateLines(targetDir) {
|
|
|
34510
35355
|
identify.configPath ? `- config: ${identify.configPath}` : "",
|
|
34511
35356
|
`- ai_dev_kit_present: ${devKitStatus.ready ? "yes" : "no"}`,
|
|
34512
35357
|
`- ai_dev_kit_missing_entries: ${devKitStatus.missingEntries.join(", ") || "(none)"}`,
|
|
34513
|
-
`- staged_dev_kit_gitignore: ${
|
|
35358
|
+
`- staged_dev_kit_gitignore: ${fs14.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
|
|
34514
35359
|
`- safe_to_retry: ${safeToRetry ? "yes" : "no"}`,
|
|
34515
35360
|
safeToRetry ? "- next_step: 可以直接重试 taptap-maker init;如果连续失败,建议换一个全新的独立目录重新 clone。" : "- next_step: 当前目录已经有 Maker 绑定信息;先运行 taptap-maker doctor 或读取 maker://status 确认状态。"
|
|
34516
35361
|
].filter(Boolean);
|
|
@@ -34586,12 +35431,12 @@ function resolveEmbeddedProxyCommand(options) {
|
|
|
34586
35431
|
}
|
|
34587
35432
|
return {
|
|
34588
35433
|
command: process.execPath,
|
|
34589
|
-
args: [
|
|
35434
|
+
args: [path15.resolve(makerEntry), "__maker-proxy"]
|
|
34590
35435
|
};
|
|
34591
35436
|
}
|
|
34592
35437
|
function resolveBundledMakerEntry() {
|
|
34593
|
-
const bundledEntry =
|
|
34594
|
-
return
|
|
35438
|
+
const bundledEntry = path15.resolve(__dirname, "../../../bin/taptap-maker");
|
|
35439
|
+
return fs14.existsSync(bundledEntry) ? bundledEntry : void 0;
|
|
34595
35440
|
}
|
|
34596
35441
|
function isUsableEmbeddedMakerEntry(entry) {
|
|
34597
35442
|
if (!entry) {
|
|
@@ -34938,18 +35783,18 @@ async function attachRuntimeLogWatch(buildResult, startWatch) {
|
|
|
34938
35783
|
}
|
|
34939
35784
|
}
|
|
34940
35785
|
async function startRuntimeLogWatch(buildResult) {
|
|
34941
|
-
const runtimeDir =
|
|
34942
|
-
|
|
34943
|
-
const stdoutLog =
|
|
34944
|
-
const stderrLog =
|
|
34945
|
-
const pidFile =
|
|
35786
|
+
const runtimeDir = path15.join(buildResult.projectRoot, ".maker", "logs", "runtime");
|
|
35787
|
+
fs14.mkdirSync(runtimeDir, { recursive: true });
|
|
35788
|
+
const stdoutLog = path15.join(runtimeDir, "watcher.out.log");
|
|
35789
|
+
const stderrLog = path15.join(runtimeDir, "watcher.err.log");
|
|
35790
|
+
const pidFile = path15.join(runtimeDir, "watcher.pid");
|
|
34946
35791
|
const previous = stopExistingRuntimeLogWatcher(pidFile);
|
|
34947
|
-
const outFd =
|
|
34948
|
-
const errFd =
|
|
35792
|
+
const outFd = fs14.openSync(stdoutLog, "a");
|
|
35793
|
+
const errFd = fs14.openSync(stderrLog, "a");
|
|
34949
35794
|
const command = formatRuntimeLogWatchCommand(buildResult);
|
|
34950
35795
|
if (previous.previousStopError) {
|
|
34951
|
-
|
|
34952
|
-
|
|
35796
|
+
fs14.closeSync(outFd);
|
|
35797
|
+
fs14.closeSync(errFd);
|
|
34953
35798
|
return {
|
|
34954
35799
|
started: false,
|
|
34955
35800
|
command: command.text,
|
|
@@ -35012,18 +35857,18 @@ async function startRuntimeLogWatch(buildResult) {
|
|
|
35012
35857
|
...previous
|
|
35013
35858
|
};
|
|
35014
35859
|
} finally {
|
|
35015
|
-
|
|
35016
|
-
|
|
35860
|
+
fs14.closeSync(outFd);
|
|
35861
|
+
fs14.closeSync(errFd);
|
|
35017
35862
|
}
|
|
35018
35863
|
}
|
|
35019
35864
|
function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
35020
|
-
if (!
|
|
35865
|
+
if (!fs14.existsSync(pidFile)) {
|
|
35021
35866
|
return {};
|
|
35022
35867
|
}
|
|
35023
35868
|
const pidState = readRuntimeLogWatcherPidState(pidFile);
|
|
35024
35869
|
const pid = pidState == null ? void 0 : pidState.pid;
|
|
35025
35870
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
35026
|
-
|
|
35871
|
+
fs14.rmSync(pidFile, { force: true });
|
|
35027
35872
|
return {};
|
|
35028
35873
|
}
|
|
35029
35874
|
try {
|
|
@@ -35031,7 +35876,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
35031
35876
|
const processCommand = (options.getProcessCommand || getProcessCommand)(pid);
|
|
35032
35877
|
const verifiedCommand = getVerifiedRuntimeLogWatcherCommand(processCommand, pidState);
|
|
35033
35878
|
if (!verifiedCommand) {
|
|
35034
|
-
|
|
35879
|
+
fs14.rmSync(pidFile, { force: true });
|
|
35035
35880
|
return {
|
|
35036
35881
|
previousPid: pid,
|
|
35037
35882
|
previousStopped: false,
|
|
@@ -35041,7 +35886,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
35041
35886
|
process.kill(pid, "SIGTERM");
|
|
35042
35887
|
const stopped = (options.waitForExit || waitForProcessExit)(pid, WATCHER_STOP_TIMEOUT_MS);
|
|
35043
35888
|
if (stopped) {
|
|
35044
|
-
|
|
35889
|
+
fs14.rmSync(pidFile, { force: true });
|
|
35045
35890
|
return { previousPid: pid, previousStopped: true };
|
|
35046
35891
|
}
|
|
35047
35892
|
return {
|
|
@@ -35050,7 +35895,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
35050
35895
|
previousStopError: `process ${pid} did not exit after SIGTERM within ${WATCHER_STOP_TIMEOUT_MS}ms`
|
|
35051
35896
|
};
|
|
35052
35897
|
} catch (error2) {
|
|
35053
|
-
|
|
35898
|
+
fs14.rmSync(pidFile, { force: true });
|
|
35054
35899
|
const code = error2 && typeof error2 === "object" && "code" in error2 ? String(error2.code) : "";
|
|
35055
35900
|
if (code === "ESRCH") {
|
|
35056
35901
|
return { previousPid: pid, previousStopped: false };
|
|
@@ -35063,7 +35908,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
35063
35908
|
}
|
|
35064
35909
|
}
|
|
35065
35910
|
function readRuntimeLogWatcherPidState(pidFile) {
|
|
35066
|
-
const raw =
|
|
35911
|
+
const raw = fs14.readFileSync(pidFile, "utf8").trim();
|
|
35067
35912
|
if (!raw) {
|
|
35068
35913
|
return null;
|
|
35069
35914
|
}
|
|
@@ -35079,7 +35924,7 @@ function readRuntimeLogWatcherPidState(pidFile) {
|
|
|
35079
35924
|
}
|
|
35080
35925
|
}
|
|
35081
35926
|
function writeRuntimeLogWatcherPidFile(pidFile, state) {
|
|
35082
|
-
|
|
35927
|
+
fs14.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
|
|
35083
35928
|
`, "utf8");
|
|
35084
35929
|
}
|
|
35085
35930
|
function getProcessCommand(pid) {
|
|
@@ -35165,10 +36010,10 @@ function formatRuntimeLogWatchCommand(buildResult) {
|
|
|
35165
36010
|
};
|
|
35166
36011
|
}
|
|
35167
36012
|
function resolveMakerCliEntry() {
|
|
35168
|
-
return process.argv[1] ||
|
|
36013
|
+
return process.argv[1] || path15.resolve(process.cwd(), "dist", "maker.js");
|
|
35169
36014
|
}
|
|
35170
36015
|
function getRuntimeLogFilePath(projectRoot) {
|
|
35171
|
-
return
|
|
36016
|
+
return path15.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
|
|
35172
36017
|
}
|
|
35173
36018
|
async function refreshMakerPreview(buildResult) {
|
|
35174
36019
|
const makerEnv = buildResult.env === "rnd" || buildResult.env === "production" ? buildResult.env : void 0;
|
|
@@ -35217,7 +36062,7 @@ async function refreshMakerPreview(buildResult) {
|
|
|
35217
36062
|
clearTimeout(timeout);
|
|
35218
36063
|
}
|
|
35219
36064
|
}
|
|
35220
|
-
function createRemoteRuntimeLogClient(proxy, timeoutMs =
|
|
36065
|
+
function createRemoteRuntimeLogClient(proxy, timeoutMs = DEFAULT_TOOL_CALL_TIMEOUT_MS, options = {}) {
|
|
35221
36066
|
let client;
|
|
35222
36067
|
const createTransport = options.createTransport || (() => trackMakerChildTransport(
|
|
35223
36068
|
new HiddenStdioClientTransport({
|
|
@@ -35301,7 +36146,7 @@ function createBuildArgs(projectRoot, options) {
|
|
|
35301
36146
|
if (options.scriptsPath) {
|
|
35302
36147
|
buildArgs.scriptsPath = options.scriptsPath;
|
|
35303
36148
|
}
|
|
35304
|
-
if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer &&
|
|
36149
|
+
if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs14.existsSync(path15.join(projectRoot, "scripts", "main.lua"))) {
|
|
35305
36150
|
buildArgs.entry = "main.lua";
|
|
35306
36151
|
buildArgs.scriptsPath = "scripts";
|
|
35307
36152
|
}
|
|
@@ -35313,7 +36158,7 @@ function createBuildArgs(projectRoot, options) {
|
|
|
35313
36158
|
}
|
|
35314
36159
|
if (options.multiplayer) {
|
|
35315
36160
|
buildArgs.multiplayer = options.multiplayer;
|
|
35316
|
-
} else if (!
|
|
36161
|
+
} else if (!fs14.existsSync(path15.join(projectRoot, ".project", "settings.json"))) {
|
|
35317
36162
|
buildArgs.multiplayer = { enabled: false };
|
|
35318
36163
|
}
|
|
35319
36164
|
return buildArgs;
|
|
@@ -35488,11 +36333,11 @@ function formatRuntimeLogWatchNextActionLines(result) {
|
|
|
35488
36333
|
((_a3 = result.runtimeLogWatch) == null ? void 0 : _a3.pid) ? `- watch_pid: ${result.runtimeLogWatch.pid}` : "",
|
|
35489
36334
|
`- watch_command: ${command}`,
|
|
35490
36335
|
((_b = result.runtimeLogWatch) == null ? void 0 : _b.command) ? `- actual_watch_command: ${result.runtimeLogWatch.command}` : "",
|
|
35491
|
-
`- local_file: ${
|
|
36336
|
+
`- local_file: ${path15.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
|
|
35492
36337
|
((_c = result.runtimeLogWatch) == null ? void 0 : _c.stdoutLog) ? `- watcher_stdout: ${result.runtimeLogWatch.stdoutLog}` : "",
|
|
35493
36338
|
((_d = result.runtimeLogWatch) == null ? void 0 : _d.stderrLog) ? `- watcher_stderr: ${result.runtimeLogWatch.stderrLog}` : "",
|
|
35494
36339
|
((_e = result.runtimeLogWatch) == null ? void 0 : _e.pidFile) ? `- watcher_pid_file: ${result.runtimeLogWatch.pidFile}` : "",
|
|
35495
|
-
`- state_file: ${
|
|
36340
|
+
`- state_file: ${path15.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
|
|
35496
36341
|
((_f = result.runtimeLogWatch) == null ? void 0 : _f.previousPid) ? `- previous_watch_pid: ${result.runtimeLogWatch.previousPid}` : "",
|
|
35497
36342
|
((_g = result.runtimeLogWatch) == null ? void 0 : _g.previousStopped) !== void 0 ? `- previous_watch_stopped: ${result.runtimeLogWatch.previousStopped ? "yes" : "no"}` : "",
|
|
35498
36343
|
((_h = result.runtimeLogWatch) == null ? void 0 : _h.previousStopError) ? `- previous_watch_stop_error: ${result.runtimeLogWatch.previousStopError}` : "",
|
|
@@ -35670,9 +36515,9 @@ function indent2(value) {
|
|
|
35670
36515
|
// src/maker/cli/commands.ts
|
|
35671
36516
|
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
35672
36517
|
import crypto3 from "node:crypto";
|
|
35673
|
-
import
|
|
36518
|
+
import fs15 from "node:fs";
|
|
35674
36519
|
import os4 from "node:os";
|
|
35675
|
-
import
|
|
36520
|
+
import path16 from "node:path";
|
|
35676
36521
|
import readline from "node:readline/promises";
|
|
35677
36522
|
import { stdin as input, stdout as output } from "node:process";
|
|
35678
36523
|
|
|
@@ -35818,6 +36663,7 @@ function formatError2(error2) {
|
|
|
35818
36663
|
}
|
|
35819
36664
|
|
|
35820
36665
|
// src/maker/cli/commands.ts
|
|
36666
|
+
var VERSION2 = true ? "0.0.21-beta.1" : "dev";
|
|
35821
36667
|
var DEFAULT_MCP_NAME = "taptap-maker";
|
|
35822
36668
|
var MAKER_NPM_PACKAGE = "@taptap/maker";
|
|
35823
36669
|
var TWO_PART_COMMANDS = /* @__PURE__ */ new Set(["pat", "mcp", "dev-kit", "logs", "python", "lua-lsp", "agents"]);
|
|
@@ -35952,7 +36798,7 @@ function toOptionKey(value) {
|
|
|
35952
36798
|
}
|
|
35953
36799
|
async function runInit(parsed, ctx) {
|
|
35954
36800
|
rejectPackageOption(parsed);
|
|
35955
|
-
const targetDir =
|
|
36801
|
+
const targetDir = path16.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
35956
36802
|
const env = makerEnvOption(parsed);
|
|
35957
36803
|
const skipConfirm = booleanOption(parsed, "skip_confirm");
|
|
35958
36804
|
const skipMcpInstall = booleanOption(parsed, "skip_mcp_install");
|
|
@@ -36025,8 +36871,7 @@ async function runInit(parsed, ctx) {
|
|
|
36025
36871
|
ides,
|
|
36026
36872
|
env,
|
|
36027
36873
|
pkg: MAKER_NPM_PACKAGE,
|
|
36028
|
-
mcpName: DEFAULT_MCP_NAME
|
|
36029
|
-
cwd: targetDir
|
|
36874
|
+
mcpName: DEFAULT_MCP_NAME
|
|
36030
36875
|
});
|
|
36031
36876
|
for (const result of installResults) {
|
|
36032
36877
|
emit(ctx, "mcp_install", result.message, result);
|
|
@@ -36046,7 +36891,7 @@ async function runInit(parsed, ctx) {
|
|
|
36046
36891
|
}
|
|
36047
36892
|
async function runDoctor(parsed, ctx) {
|
|
36048
36893
|
var _a3, _b;
|
|
36049
|
-
const targetDir =
|
|
36894
|
+
const targetDir = path16.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
36050
36895
|
const env = makerEnvOption(parsed);
|
|
36051
36896
|
const git = checkGitEnvironment();
|
|
36052
36897
|
const python = checkMakerPythonEnvironment();
|
|
@@ -36058,6 +36903,11 @@ async function runDoctor(parsed, ctx) {
|
|
|
36058
36903
|
const projectRoot = identify.projectRoot || targetDir;
|
|
36059
36904
|
const devKit = inspectAiDevKit(projectRoot);
|
|
36060
36905
|
const devKitUpdate = await checkAiDevKitUpdate(projectRoot, { environment: env });
|
|
36906
|
+
const packageUpdate = await getMakerPackageUpdateStatus({
|
|
36907
|
+
currentVersion: VERSION2,
|
|
36908
|
+
allowRemoteFetch: false,
|
|
36909
|
+
backgroundRefresh: false
|
|
36910
|
+
});
|
|
36061
36911
|
const agentsPolicy = isProjectBound ? inspectMakerAgentsPolicy(projectRoot) : void 0;
|
|
36062
36912
|
const orphanProcessCheck = inspectMakerOrphanProcesses();
|
|
36063
36913
|
const mcpToolsAvailability = inspectMakerMcpToolsAvailability({
|
|
@@ -36077,6 +36927,7 @@ async function runDoctor(parsed, ctx) {
|
|
|
36077
36927
|
agents_policy: agentsPolicy,
|
|
36078
36928
|
dev_kit: devKit,
|
|
36079
36929
|
dev_kit_update: devKitUpdate,
|
|
36930
|
+
package_update: packageUpdate,
|
|
36080
36931
|
mcp_tools_availability: mcpToolsAvailability,
|
|
36081
36932
|
orphan_process_check: orphanProcessCheck
|
|
36082
36933
|
});
|
|
@@ -36113,6 +36964,8 @@ async function runDoctor(parsed, ctx) {
|
|
|
36113
36964
|
`- update_available: ${devKitUpdate.updateAvailable ? "yes" : "no"}`,
|
|
36114
36965
|
devKitUpdate.versionCheckError ? `- version_check: ${devKitUpdate.versionCheckError}` : "",
|
|
36115
36966
|
"",
|
|
36967
|
+
formatMakerPackageUpdateStatus(packageUpdate),
|
|
36968
|
+
"",
|
|
36116
36969
|
formatMakerMcpToolsAvailability(mcpToolsAvailability),
|
|
36117
36970
|
"",
|
|
36118
36971
|
formatMakerOrphanProcessStatus(orphanProcessCheck),
|
|
@@ -36123,9 +36976,9 @@ async function runDoctor(parsed, ctx) {
|
|
|
36123
36976
|
);
|
|
36124
36977
|
}
|
|
36125
36978
|
function inspectMakerMcpToolsAvailability(options) {
|
|
36126
|
-
const aiPwd =
|
|
36979
|
+
const aiPwd = path16.resolve(process.cwd());
|
|
36127
36980
|
const aiPwdIdentify = identifyMakerProject({ cwd: aiPwd });
|
|
36128
|
-
const makerProjectDir = options.makerProjectDir ?
|
|
36981
|
+
const makerProjectDir = options.makerProjectDir ? path16.resolve(options.makerProjectDir) : void 0;
|
|
36129
36982
|
if (!makerProjectDir) {
|
|
36130
36983
|
return {
|
|
36131
36984
|
tools_visibility: "refresh_ai_client_if_missing",
|
|
@@ -36164,12 +37017,12 @@ function formatMakerMcpToolsAvailability(availability) {
|
|
|
36164
37017
|
return lines.join("\n");
|
|
36165
37018
|
}
|
|
36166
37019
|
function samePath2(left, right) {
|
|
36167
|
-
return
|
|
37020
|
+
return normalizePathForCompare3(left) === normalizePathForCompare3(right);
|
|
36168
37021
|
}
|
|
36169
|
-
function
|
|
36170
|
-
const resolved =
|
|
37022
|
+
function normalizePathForCompare3(value) {
|
|
37023
|
+
const resolved = path16.resolve(value);
|
|
36171
37024
|
try {
|
|
36172
|
-
return
|
|
37025
|
+
return fs15.realpathSync.native(resolved);
|
|
36173
37026
|
} catch {
|
|
36174
37027
|
return resolved;
|
|
36175
37028
|
}
|
|
@@ -36487,7 +37340,7 @@ async function runPatSet(parsed, ctx) {
|
|
|
36487
37340
|
}
|
|
36488
37341
|
async function resolvePatSet(parsed, ctx) {
|
|
36489
37342
|
if (booleanOption(parsed, "pat_stdin") || booleanOption(parsed, "pat_from_stdin")) {
|
|
36490
|
-
const pat =
|
|
37343
|
+
const pat = fs15.readFileSync(0, "utf8").trim();
|
|
36491
37344
|
if (!pat) {
|
|
36492
37345
|
throw new Error("No PAT found on stdin.");
|
|
36493
37346
|
}
|
|
@@ -36517,7 +37370,7 @@ async function runMcpInstall(parsed, ctx) {
|
|
|
36517
37370
|
env: makerEnvOption(parsed),
|
|
36518
37371
|
pkg: MAKER_NPM_PACKAGE,
|
|
36519
37372
|
mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
|
|
36520
|
-
cwd: explicitTargetDir ?
|
|
37373
|
+
cwd: explicitTargetDir ? path16.resolve(explicitTargetDir) : void 0
|
|
36521
37374
|
});
|
|
36522
37375
|
if (ctx.json) {
|
|
36523
37376
|
writeJson(results);
|
|
@@ -36576,7 +37429,7 @@ ${indent3(payload.stderr)}` : "",
|
|
|
36576
37429
|
);
|
|
36577
37430
|
}
|
|
36578
37431
|
async function runAgentsUpdate(parsed, ctx) {
|
|
36579
|
-
const targetDir =
|
|
37432
|
+
const targetDir = path16.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
36580
37433
|
const result = updateMakerAgentsPolicy(targetDir);
|
|
36581
37434
|
if (ctx.json) {
|
|
36582
37435
|
writeJson(result);
|
|
@@ -36594,7 +37447,8 @@ async function runAgentsUpdate(parsed, ctx) {
|
|
|
36594
37447
|
}
|
|
36595
37448
|
async function runUpgrade(parsed, ctx) {
|
|
36596
37449
|
rejectPackageOption(parsed);
|
|
36597
|
-
const
|
|
37450
|
+
const explicitTargetDir = stringOption(parsed, "target_dir");
|
|
37451
|
+
const targetDir = path16.resolve(explicitTargetDir || process.cwd());
|
|
36598
37452
|
const env = makerEnvOption(parsed);
|
|
36599
37453
|
const ides = parseIdeList(stringOption(parsed, "ide") || stringOption(parsed, "ides") || "");
|
|
36600
37454
|
const installResults = installMcpConfigs({
|
|
@@ -36602,7 +37456,7 @@ async function runUpgrade(parsed, ctx) {
|
|
|
36602
37456
|
env,
|
|
36603
37457
|
pkg: MAKER_NPM_PACKAGE,
|
|
36604
37458
|
mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
|
|
36605
|
-
cwd: targetDir
|
|
37459
|
+
cwd: explicitTargetDir ? targetDir : void 0
|
|
36606
37460
|
});
|
|
36607
37461
|
const identify = identifyMakerProject({ cwd: targetDir });
|
|
36608
37462
|
const agentsResult = identify.projectRoot ? updateMakerAgentsPolicy(identify.projectRoot) : void 0;
|
|
@@ -36679,7 +37533,7 @@ function getMcpVerifyNextSteps(mode, commandText) {
|
|
|
36679
37533
|
];
|
|
36680
37534
|
}
|
|
36681
37535
|
async function runDevKitUpdate(parsed, ctx) {
|
|
36682
|
-
const targetDir =
|
|
37536
|
+
const targetDir = path16.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
36683
37537
|
const result = await installAiDevKit({
|
|
36684
37538
|
targetDir,
|
|
36685
37539
|
preserveExisting: false,
|
|
@@ -36691,9 +37545,9 @@ async function runDevKitUpdate(parsed, ctx) {
|
|
|
36691
37545
|
emitDevKitSkillInstallerFailure(ctx, result.skillInstaller, "AI skills install failed");
|
|
36692
37546
|
}
|
|
36693
37547
|
async function runLogsWatch(parsed, ctx) {
|
|
36694
|
-
const targetDir =
|
|
37548
|
+
const targetDir = path16.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
36695
37549
|
const intervalMs = parseDurationMs(stringOption(parsed, "interval") || "5s");
|
|
36696
|
-
const timeoutMs = numberOption(parsed, "timeout_ms") ??
|
|
37550
|
+
const timeoutMs = numberOption(parsed, "timeout_ms") ?? DEFAULT_TOOL_CALL_TIMEOUT_MS;
|
|
36697
37551
|
const maxPolls = numberOption(parsed, "max_polls");
|
|
36698
37552
|
const maxConsecutiveFailures = numberOption(parsed, "max_consecutive_failures");
|
|
36699
37553
|
const proxy = createRemoteProxyContext({
|
|
@@ -36701,9 +37555,9 @@ async function runLogsWatch(parsed, ctx) {
|
|
|
36701
37555
|
serverUrl: stringOption(parsed, "server_url"),
|
|
36702
37556
|
env: makerEnvOption(parsed)
|
|
36703
37557
|
});
|
|
36704
|
-
const runtimeDir =
|
|
36705
|
-
const runtimeLog =
|
|
36706
|
-
const pidFile =
|
|
37558
|
+
const runtimeDir = path16.join(proxy.projectRoot, ".maker", "logs", "runtime");
|
|
37559
|
+
const runtimeLog = path16.join(runtimeDir, "runtime.log");
|
|
37560
|
+
const pidFile = path16.join(runtimeDir, "watcher.pid");
|
|
36707
37561
|
const replacedWatcher = registerRuntimeLogWatcherProcess(pidFile);
|
|
36708
37562
|
const runtimeLogClient = createRemoteRuntimeLogClient(proxy, timeoutMs);
|
|
36709
37563
|
emit(ctx, "logs_watch_start", "Maker runtime log watcher started", {
|
|
@@ -36748,10 +37602,10 @@ async function runLogsWatch(parsed, ctx) {
|
|
|
36748
37602
|
}
|
|
36749
37603
|
}
|
|
36750
37604
|
function registerRuntimeLogWatcherProcess(pidFile) {
|
|
36751
|
-
|
|
37605
|
+
fs15.mkdirSync(path16.dirname(pidFile), { recursive: true });
|
|
36752
37606
|
const existingPid = readPidFile(pidFile);
|
|
36753
37607
|
const previous = existingPid && existingPid !== process.pid ? stopExistingRuntimeLogWatcher(pidFile) : {};
|
|
36754
|
-
|
|
37608
|
+
fs15.writeFileSync(
|
|
36755
37609
|
pidFile,
|
|
36756
37610
|
`${JSON.stringify(
|
|
36757
37611
|
{
|
|
@@ -36769,10 +37623,10 @@ function registerRuntimeLogWatcherProcess(pidFile) {
|
|
|
36769
37623
|
return previous;
|
|
36770
37624
|
}
|
|
36771
37625
|
function readPidFile(pidFile) {
|
|
36772
|
-
if (!
|
|
37626
|
+
if (!fs15.existsSync(pidFile)) {
|
|
36773
37627
|
return void 0;
|
|
36774
37628
|
}
|
|
36775
|
-
const raw =
|
|
37629
|
+
const raw = fs15.readFileSync(pidFile, "utf8").trim();
|
|
36776
37630
|
let pid = Number(raw);
|
|
36777
37631
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
36778
37632
|
try {
|
|
@@ -36792,7 +37646,7 @@ function installRuntimeLogWatcherPidCleanup(pidFile) {
|
|
|
36792
37646
|
}
|
|
36793
37647
|
cleaned = true;
|
|
36794
37648
|
if (readPidFile(pidFile) === process.pid) {
|
|
36795
|
-
|
|
37649
|
+
fs15.rmSync(pidFile, { force: true });
|
|
36796
37650
|
}
|
|
36797
37651
|
};
|
|
36798
37652
|
process.once("exit", cleanup);
|
|
@@ -36943,7 +37797,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
|
|
|
36943
37797
|
onStart: (event) => emitSkillInstallerStart(ctx, event)
|
|
36944
37798
|
});
|
|
36945
37799
|
writeDevKitStagedGitignore(
|
|
36946
|
-
|
|
37800
|
+
path16.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
|
|
36947
37801
|
listPresentDevKitManagedEntries(targetDir)
|
|
36948
37802
|
);
|
|
36949
37803
|
if (options.finalizeGitignore) {
|
|
@@ -36960,7 +37814,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
|
|
|
36960
37814
|
);
|
|
36961
37815
|
} catch (error2) {
|
|
36962
37816
|
writeDevKitStagedGitignore(
|
|
36963
|
-
|
|
37817
|
+
path16.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
|
|
36964
37818
|
listPresentDevKitManagedEntries(targetDir)
|
|
36965
37819
|
);
|
|
36966
37820
|
if (options.finalizeGitignore) {
|
|
@@ -37048,7 +37902,7 @@ function installMcpConfig(ide, options) {
|
|
|
37048
37902
|
}
|
|
37049
37903
|
function installMcpConfigUnsafe(ide, options) {
|
|
37050
37904
|
if (ide === "codex") {
|
|
37051
|
-
const configPath =
|
|
37905
|
+
const configPath = path16.join(os4.homedir(), ".codex", "config.toml");
|
|
37052
37906
|
const write = mergeCodexMcpConfig(configPath, options);
|
|
37053
37907
|
return {
|
|
37054
37908
|
ide,
|
|
@@ -37060,7 +37914,7 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
37060
37914
|
};
|
|
37061
37915
|
}
|
|
37062
37916
|
if (ide === "cursor") {
|
|
37063
|
-
const configPath =
|
|
37917
|
+
const configPath = path16.join(os4.homedir(), ".cursor", "mcp.json");
|
|
37064
37918
|
const write = mergeJsonMcpConfig(configPath, options);
|
|
37065
37919
|
return {
|
|
37066
37920
|
ide,
|
|
@@ -37078,7 +37932,7 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
37078
37932
|
return { ide, ok: true, message: "✓ Claude Code MCP config updated with claude mcp add" };
|
|
37079
37933
|
}
|
|
37080
37934
|
}
|
|
37081
|
-
const configPath =
|
|
37935
|
+
const configPath = path16.join(os4.homedir(), ".claude.json");
|
|
37082
37936
|
const write = mergeJsonMcpConfig(configPath, options);
|
|
37083
37937
|
return {
|
|
37084
37938
|
ide,
|
|
@@ -37100,7 +37954,7 @@ function mergeJsonMcpConfig(configPath, options) {
|
|
|
37100
37954
|
`);
|
|
37101
37955
|
}
|
|
37102
37956
|
function mergeCodexMcpConfig(configPath, options) {
|
|
37103
|
-
const existing =
|
|
37957
|
+
const existing = fs15.existsSync(configPath) ? fs15.readFileSync(configPath, "utf8") : "";
|
|
37104
37958
|
const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
|
|
37105
37959
|
const withoutOld = existing.replace(sectionPattern, "").trimEnd();
|
|
37106
37960
|
const launch = getNpxCliCommand(options.pkg);
|
|
@@ -37235,10 +38089,10 @@ function rejectPackageOption(parsed) {
|
|
|
37235
38089
|
}
|
|
37236
38090
|
}
|
|
37237
38091
|
function readJsonObject(filePath) {
|
|
37238
|
-
if (!
|
|
38092
|
+
if (!fs15.existsSync(filePath)) {
|
|
37239
38093
|
return {};
|
|
37240
38094
|
}
|
|
37241
|
-
return JSON.parse(
|
|
38095
|
+
return JSON.parse(fs15.readFileSync(filePath, "utf8"));
|
|
37242
38096
|
}
|
|
37243
38097
|
function asObject(value) {
|
|
37244
38098
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -37247,25 +38101,25 @@ function asObject(value) {
|
|
|
37247
38101
|
return {};
|
|
37248
38102
|
}
|
|
37249
38103
|
function writeConfigWithTapTapBackupIfChanged(filePath, nextContent, validate) {
|
|
37250
|
-
const existed =
|
|
37251
|
-
const previousContent = existed ?
|
|
38104
|
+
const existed = fs15.existsSync(filePath);
|
|
38105
|
+
const previousContent = existed ? fs15.readFileSync(filePath, "utf8") : void 0;
|
|
37252
38106
|
if (previousContent === nextContent) {
|
|
37253
38107
|
return { changed: false };
|
|
37254
38108
|
}
|
|
37255
38109
|
const backupPath = existed ? `${filePath}.taptap-maker.bak.latest` : void 0;
|
|
37256
|
-
|
|
38110
|
+
fs15.mkdirSync(path16.dirname(filePath), { recursive: true });
|
|
37257
38111
|
if (previousContent !== void 0 && backupPath) {
|
|
37258
|
-
|
|
38112
|
+
fs15.writeFileSync(backupPath, previousContent, "utf8");
|
|
37259
38113
|
}
|
|
37260
38114
|
try {
|
|
37261
|
-
|
|
37262
|
-
validate == null ? void 0 : validate(
|
|
38115
|
+
fs15.writeFileSync(filePath, nextContent, "utf8");
|
|
38116
|
+
validate == null ? void 0 : validate(fs15.readFileSync(filePath, "utf8"));
|
|
37263
38117
|
return { changed: true, backupPath };
|
|
37264
38118
|
} catch (error2) {
|
|
37265
38119
|
if (previousContent !== void 0) {
|
|
37266
|
-
|
|
38120
|
+
fs15.writeFileSync(filePath, previousContent, "utf8");
|
|
37267
38121
|
} else {
|
|
37268
|
-
|
|
38122
|
+
fs15.rmSync(filePath, { force: true });
|
|
37269
38123
|
}
|
|
37270
38124
|
throw error2;
|
|
37271
38125
|
}
|
|
@@ -37280,10 +38134,10 @@ function formatMcpInstallMessage(label, configPath, write) {
|
|
|
37280
38134
|
].filter(Boolean).join("\n");
|
|
37281
38135
|
}
|
|
37282
38136
|
function saveInitState(targetDir, state) {
|
|
37283
|
-
|
|
37284
|
-
const key = crypto3.createHash("sha256").update(
|
|
37285
|
-
|
|
37286
|
-
|
|
38137
|
+
fs15.mkdirSync(getMakerHome(), { recursive: true });
|
|
38138
|
+
const key = crypto3.createHash("sha256").update(path16.resolve(targetDir)).digest("hex").slice(0, 16);
|
|
38139
|
+
fs15.writeFileSync(
|
|
38140
|
+
path16.join(getMakerHome(), `init-state-${key}.json`),
|
|
37287
38141
|
`${JSON.stringify({ ...state, updated_at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)}
|
|
37288
38142
|
`,
|
|
37289
38143
|
"utf8"
|
|
@@ -37431,7 +38285,7 @@ function makerEnvOption(parsed) {
|
|
|
37431
38285
|
return env;
|
|
37432
38286
|
}
|
|
37433
38287
|
const targetDir = stringOption(parsed, "target_dir");
|
|
37434
|
-
return getMakerEnvironment(void 0, targetDir ?
|
|
38288
|
+
return getMakerEnvironment(void 0, targetDir ? path16.resolve(targetDir) : process.cwd());
|
|
37435
38289
|
}
|
|
37436
38290
|
function mcpVerifyModeOption(parsed) {
|
|
37437
38291
|
const mode = stringOption(parsed, "mode") || "npx";
|
|
@@ -37473,6 +38327,13 @@ function printHelp() {
|
|
|
37473
38327
|
" [--create --name NAME]",
|
|
37474
38328
|
" [--skip-confirm] [--skip-mcp-install] [--register-mcp codex,cursor,claude]",
|
|
37475
38329
|
" [--json]",
|
|
38330
|
+
"",
|
|
38331
|
+
"Init flows:",
|
|
38332
|
+
" Standard init/clone/download flow: run `taptap-maker init`; the CLI shows",
|
|
38333
|
+
" the Maker app list, then the user chooses an existing app or 0/new.",
|
|
38334
|
+
" Create-new-project flow: add `--create --name NAME` only when the user",
|
|
38335
|
+
" clearly asks to create a new Maker project; NAME is the requested project name.",
|
|
38336
|
+
"",
|
|
37476
38337
|
" taptap-maker doctor [--target-dir DIR] [--env rnd|production] [--json]",
|
|
37477
38338
|
" taptap-maker python doctor [--json]",
|
|
37478
38339
|
" taptap-maker python setup [--json]",
|
|
@@ -37512,149 +38373,6 @@ function formatCliError(error2) {
|
|
|
37512
38373
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
37513
38374
|
}
|
|
37514
38375
|
|
|
37515
|
-
// src/mcp-proxy/config.ts
|
|
37516
|
-
var DEFAULT_TOOL_CALL_TIMEOUT_MS = 60 * 60 * 1e3;
|
|
37517
|
-
function readStdin() {
|
|
37518
|
-
return new Promise((resolve, reject) => {
|
|
37519
|
-
const chunks = [];
|
|
37520
|
-
process.stdin.on("data", (chunk) => {
|
|
37521
|
-
chunks.push(chunk);
|
|
37522
|
-
});
|
|
37523
|
-
process.stdin.on("end", () => {
|
|
37524
|
-
resolve(Buffer.concat(chunks).toString("utf-8"));
|
|
37525
|
-
});
|
|
37526
|
-
process.stdin.on("error", reject);
|
|
37527
|
-
setTimeout(() => {
|
|
37528
|
-
reject(new Error("Timeout reading from stdin"));
|
|
37529
|
-
}, 5e3);
|
|
37530
|
-
});
|
|
37531
|
-
}
|
|
37532
|
-
async function loadConfig() {
|
|
37533
|
-
let configJson;
|
|
37534
|
-
let source;
|
|
37535
|
-
if (process.argv[2]) {
|
|
37536
|
-
configJson = process.argv[2];
|
|
37537
|
-
source = "command line argument";
|
|
37538
|
-
} else if (process.env.PROXY_CONFIG) {
|
|
37539
|
-
configJson = process.env.PROXY_CONFIG;
|
|
37540
|
-
source = "PROXY_CONFIG environment variable";
|
|
37541
|
-
} else if (!process.stdin.isTTY) {
|
|
37542
|
-
configJson = await readStdin();
|
|
37543
|
-
source = "stdin";
|
|
37544
|
-
} else {
|
|
37545
|
-
throw new Error(
|
|
37546
|
-
`No configuration provided. Please use one of:
|
|
37547
|
-
1. Command line: node index.js '{"server":{...}}'
|
|
37548
|
-
2. Env var: PROXY_CONFIG='{"server":{...}}' node index.js
|
|
37549
|
-
3. Stdin: echo '{"server":{...}}' | node index.js
|
|
37550
|
-
|
|
37551
|
-
See config.example.json for configuration format.`
|
|
37552
|
-
);
|
|
37553
|
-
}
|
|
37554
|
-
console.error(`[Proxy] Loading config from ${source}`);
|
|
37555
|
-
let config2;
|
|
37556
|
-
try {
|
|
37557
|
-
config2 = JSON.parse(configJson);
|
|
37558
|
-
} catch (error2) {
|
|
37559
|
-
throw new Error(
|
|
37560
|
-
`Failed to parse configuration JSON: ${error2 instanceof Error ? error2.message : String(error2)}
|
|
37561
|
-
Received: ${configJson.substring(0, 100)}...`
|
|
37562
|
-
);
|
|
37563
|
-
}
|
|
37564
|
-
validateConfig(config2);
|
|
37565
|
-
return applyDefaults(config2);
|
|
37566
|
-
}
|
|
37567
|
-
function validateConfig(config2) {
|
|
37568
|
-
var _a3;
|
|
37569
|
-
const errors = [];
|
|
37570
|
-
if (!config2.server) {
|
|
37571
|
-
errors.push("- Missing required field: server");
|
|
37572
|
-
} else {
|
|
37573
|
-
if (!config2.server.url) {
|
|
37574
|
-
errors.push("- Missing required field: server.url");
|
|
37575
|
-
}
|
|
37576
|
-
if (config2.server.env && !["rnd", "production"].includes(config2.server.env)) {
|
|
37577
|
-
errors.push('- Invalid server.env: must be "rnd" or "production"');
|
|
37578
|
-
}
|
|
37579
|
-
}
|
|
37580
|
-
if (!config2.tenant) {
|
|
37581
|
-
errors.push("- Missing required field: tenant");
|
|
37582
|
-
} else {
|
|
37583
|
-
if (config2.tenant.custom_fields !== void 0) {
|
|
37584
|
-
const cf = config2.tenant.custom_fields;
|
|
37585
|
-
if (typeof cf !== "object" || cf === null || Array.isArray(cf) || Object.getPrototypeOf(cf) !== Object.prototype) {
|
|
37586
|
-
errors.push("- tenant.custom_fields must be a plain object (Record<string, string>)");
|
|
37587
|
-
} else if (!Object.values(cf).every((v) => typeof v === "string")) {
|
|
37588
|
-
errors.push("- tenant.custom_fields values must all be strings");
|
|
37589
|
-
}
|
|
37590
|
-
}
|
|
37591
|
-
}
|
|
37592
|
-
if (!config2.auth) {
|
|
37593
|
-
errors.push("- Missing required field: auth");
|
|
37594
|
-
} else {
|
|
37595
|
-
if (!config2.auth.kid) {
|
|
37596
|
-
errors.push("- Missing required field: auth.kid");
|
|
37597
|
-
}
|
|
37598
|
-
if (!config2.auth.mac_key) {
|
|
37599
|
-
errors.push("- Missing required field: auth.mac_key");
|
|
37600
|
-
}
|
|
37601
|
-
if (config2.auth.token_type !== "mac") {
|
|
37602
|
-
errors.push('- Invalid auth.token_type: must be "mac"');
|
|
37603
|
-
}
|
|
37604
|
-
if (config2.auth.mac_algorithm !== "hmac-sha-1") {
|
|
37605
|
-
errors.push('- Invalid auth.mac_algorithm: must be "hmac-sha-1"');
|
|
37606
|
-
}
|
|
37607
|
-
}
|
|
37608
|
-
if (((_a3 = config2.options) == null ? void 0 : _a3.exposed_tools) !== void 0) {
|
|
37609
|
-
const exposedTools = config2.options.exposed_tools;
|
|
37610
|
-
if (!Array.isArray(exposedTools)) {
|
|
37611
|
-
errors.push("- options.exposed_tools must be an array of tool names");
|
|
37612
|
-
} else if (!exposedTools.every((toolName) => typeof toolName === "string" && toolName.trim().length > 0)) {
|
|
37613
|
-
errors.push("- options.exposed_tools values must be non-empty strings");
|
|
37614
|
-
}
|
|
37615
|
-
}
|
|
37616
|
-
if (errors.length > 0) {
|
|
37617
|
-
throw new Error("Invalid configuration:\n" + errors.join("\n"));
|
|
37618
|
-
}
|
|
37619
|
-
}
|
|
37620
|
-
var DEFAULT_LOG_ROOT = "/tmp/taptap-mcp/logs";
|
|
37621
|
-
function applyDefaults(config2) {
|
|
37622
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
37623
|
-
const verbose = ((_a3 = config2.options) == null ? void 0 : _a3.verbose) ?? false;
|
|
37624
|
-
return {
|
|
37625
|
-
server: {
|
|
37626
|
-
url: config2.server.url,
|
|
37627
|
-
env: config2.server.env || "rnd"
|
|
37628
|
-
},
|
|
37629
|
-
tenant: {
|
|
37630
|
-
project_path: config2.tenant.project_path || ".",
|
|
37631
|
-
user_id: config2.tenant.user_id,
|
|
37632
|
-
project_id: config2.tenant.project_id,
|
|
37633
|
-
custom_fields: config2.tenant.custom_fields
|
|
37634
|
-
},
|
|
37635
|
-
auth: config2.auth,
|
|
37636
|
-
options: {
|
|
37637
|
-
verbose,
|
|
37638
|
-
reconnect_interval: ((_b = config2.options) == null ? void 0 : _b.reconnect_interval) ?? 5e3,
|
|
37639
|
-
request_timeout: ((_c = config2.options) == null ? void 0 : _c.request_timeout) ?? 3e4,
|
|
37640
|
-
tool_call_timeout: ((_d = config2.options) == null ? void 0 : _d.tool_call_timeout) ?? DEFAULT_TOOL_CALL_TIMEOUT_MS,
|
|
37641
|
-
reset_timeout_on_progress: ((_e = config2.options) == null ? void 0 : _e.reset_timeout_on_progress) ?? true,
|
|
37642
|
-
health_check_interval: ((_f = config2.options) == null ? void 0 : _f.health_check_interval) ?? 3e4,
|
|
37643
|
-
enable_cookie_sticky: ((_g = config2.options) == null ? void 0 : _g.enable_cookie_sticky) ?? true,
|
|
37644
|
-
inject_params_per_call: ((_h = config2.options) == null ? void 0 : _h.inject_params_per_call) ?? true,
|
|
37645
|
-
force_inject_progress_token: ((_i = config2.options) == null ? void 0 : _i.force_inject_progress_token) ?? false,
|
|
37646
|
-
exposed_tools: (_j = config2.options) == null ? void 0 : _j.exposed_tools,
|
|
37647
|
-
log: {
|
|
37648
|
-
root: ((_l = (_k = config2.options) == null ? void 0 : _k.log) == null ? void 0 : _l.root) ?? DEFAULT_LOG_ROOT,
|
|
37649
|
-
enabled: ((_n = (_m = config2.options) == null ? void 0 : _m.log) == null ? void 0 : _n.enabled) ?? false,
|
|
37650
|
-
// verbose=true 时自动使用 debug 级别
|
|
37651
|
-
level: verbose ? "debug" : ((_p = (_o = config2.options) == null ? void 0 : _o.log) == null ? void 0 : _p.level) ?? "info",
|
|
37652
|
-
max_days: ((_r = (_q = config2.options) == null ? void 0 : _q.log) == null ? void 0 : _r.max_days) ?? 7
|
|
37653
|
-
}
|
|
37654
|
-
}
|
|
37655
|
-
};
|
|
37656
|
-
}
|
|
37657
|
-
|
|
37658
38376
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
|
|
37659
38377
|
function normalizeHeaders(headers) {
|
|
37660
38378
|
if (!headers)
|
|
@@ -39060,7 +39778,7 @@ var StreamableHTTPClientTransport = class {
|
|
|
39060
39778
|
};
|
|
39061
39779
|
|
|
39062
39780
|
// src/mcp-proxy/proxy.ts
|
|
39063
|
-
import * as
|
|
39781
|
+
import * as path18 from "node:path";
|
|
39064
39782
|
import * as crypto6 from "node:crypto";
|
|
39065
39783
|
|
|
39066
39784
|
// src/mcp-proxy/cookieJar.ts
|
|
@@ -39242,8 +39960,8 @@ function createCookieFetch(cookieJar) {
|
|
|
39242
39960
|
}
|
|
39243
39961
|
|
|
39244
39962
|
// src/core/utils/logWriter.ts
|
|
39245
|
-
import * as
|
|
39246
|
-
import * as
|
|
39963
|
+
import * as fs16 from "node:fs";
|
|
39964
|
+
import * as path17 from "node:path";
|
|
39247
39965
|
import * as crypto5 from "node:crypto";
|
|
39248
39966
|
|
|
39249
39967
|
// src/core/types/log.ts
|
|
@@ -39284,7 +40002,7 @@ var LogWriter = class {
|
|
|
39284
40002
|
return;
|
|
39285
40003
|
}
|
|
39286
40004
|
try {
|
|
39287
|
-
await
|
|
40005
|
+
await fs16.promises.mkdir(this.config.logDir, { recursive: true });
|
|
39288
40006
|
await this.cleanupOldLogs();
|
|
39289
40007
|
this.initialized = true;
|
|
39290
40008
|
} catch (error2) {
|
|
@@ -39307,7 +40025,7 @@ var LogWriter = class {
|
|
|
39307
40025
|
*/
|
|
39308
40026
|
getLogFilePath(date5) {
|
|
39309
40027
|
const d = date5 || this.getCurrentDate();
|
|
39310
|
-
return
|
|
40028
|
+
return path17.join(this.config.logDir, `${this.config.prefix}-${d}.log`);
|
|
39311
40029
|
}
|
|
39312
40030
|
/**
|
|
39313
40031
|
* 获取或创建写入流
|
|
@@ -39322,7 +40040,7 @@ var LogWriter = class {
|
|
|
39322
40040
|
}
|
|
39323
40041
|
this.currentDate = date5;
|
|
39324
40042
|
try {
|
|
39325
|
-
this.writeStream =
|
|
40043
|
+
this.writeStream = fs16.createWriteStream(this.getLogFilePath(date5), {
|
|
39326
40044
|
flags: "a",
|
|
39327
40045
|
encoding: "utf8"
|
|
39328
40046
|
});
|
|
@@ -39374,11 +40092,11 @@ var LogWriter = class {
|
|
|
39374
40092
|
if (this.shouldWriteToFile(level) && this.initialized && this.config.enabled) {
|
|
39375
40093
|
try {
|
|
39376
40094
|
const filePath = this.getLogFilePath();
|
|
39377
|
-
const dir =
|
|
39378
|
-
if (!
|
|
39379
|
-
|
|
40095
|
+
const dir = path17.dirname(filePath);
|
|
40096
|
+
if (!fs16.existsSync(dir)) {
|
|
40097
|
+
fs16.mkdirSync(dir, { recursive: true });
|
|
39380
40098
|
}
|
|
39381
|
-
|
|
40099
|
+
fs16.appendFileSync(filePath, message, "utf8");
|
|
39382
40100
|
} catch {
|
|
39383
40101
|
}
|
|
39384
40102
|
}
|
|
@@ -39389,7 +40107,7 @@ var LogWriter = class {
|
|
|
39389
40107
|
async cleanupOldLogs() {
|
|
39390
40108
|
if (this.config.maxDays <= 0) return;
|
|
39391
40109
|
try {
|
|
39392
|
-
const files = await
|
|
40110
|
+
const files = await fs16.promises.readdir(this.config.logDir);
|
|
39393
40111
|
const cutoffDate = /* @__PURE__ */ new Date();
|
|
39394
40112
|
cutoffDate.setDate(cutoffDate.getDate() - this.config.maxDays);
|
|
39395
40113
|
const prefix = this.config.prefix;
|
|
@@ -39404,7 +40122,7 @@ var LogWriter = class {
|
|
|
39404
40122
|
if (!Number.isNaN(year) && !Number.isNaN(month) && !Number.isNaN(day)) {
|
|
39405
40123
|
const fileDate = new Date(year, month - 1, day);
|
|
39406
40124
|
if (fileDate < cutoffDate) {
|
|
39407
|
-
await
|
|
40125
|
+
await fs16.promises.unlink(path17.join(this.config.logDir, file2));
|
|
39408
40126
|
process.stderr.write(`[LogWriter] Deleted old log: ${file2}
|
|
39409
40127
|
`);
|
|
39410
40128
|
}
|
|
@@ -39439,7 +40157,7 @@ var LogWriter = class {
|
|
|
39439
40157
|
};
|
|
39440
40158
|
|
|
39441
40159
|
// src/mcp-proxy/proxy.ts
|
|
39442
|
-
var
|
|
40160
|
+
var VERSION3 = typeof __PROXY_VERSION__ !== "undefined" ? __PROXY_VERSION__ : "dev";
|
|
39443
40161
|
var LOCAL_PROXY_TAG = "local";
|
|
39444
40162
|
var DEFAULT_RECONNECT_INTERVAL_MS = 5e3;
|
|
39445
40163
|
var MAX_RECONNECT_INTERVAL_MS = 60 * 1e3;
|
|
@@ -39478,10 +40196,10 @@ var TapTapMCPProxy = class {
|
|
|
39478
40196
|
const { user_id, project_id } = this.config.tenant;
|
|
39479
40197
|
let logDir;
|
|
39480
40198
|
if (user_id && project_id) {
|
|
39481
|
-
logDir =
|
|
40199
|
+
logDir = path18.join(logRoot, "proxy", user_id, project_id);
|
|
39482
40200
|
} else {
|
|
39483
40201
|
const kidHash = crypto6.createHash("sha256").update(this.config.auth.kid).digest("hex").substring(0, 8);
|
|
39484
|
-
logDir =
|
|
40202
|
+
logDir = path18.join(logRoot, "proxy", kidHash);
|
|
39485
40203
|
}
|
|
39486
40204
|
return new LogWriter({
|
|
39487
40205
|
logDir,
|
|
@@ -39517,7 +40235,7 @@ var TapTapMCPProxy = class {
|
|
|
39517
40235
|
*/
|
|
39518
40236
|
async start() {
|
|
39519
40237
|
var _a3, _b;
|
|
39520
|
-
this.log("info", `TapTap MCP Proxy v${
|
|
40238
|
+
this.log("info", `TapTap MCP Proxy v${VERSION3}`);
|
|
39521
40239
|
this.log("info", "Starting...");
|
|
39522
40240
|
this.log("info", `Server URL: ${this.config.server.url}`);
|
|
39523
40241
|
this.log("info", `Project Path: ${this.config.tenant.project_path}`);
|
|
@@ -40141,6 +40859,13 @@ function printHelp2() {
|
|
|
40141
40859
|
" [--create --name NAME]",
|
|
40142
40860
|
" [--skip-confirm] [--skip-mcp-install] [--register-mcp codex,cursor,claude]",
|
|
40143
40861
|
" [--json]",
|
|
40862
|
+
"",
|
|
40863
|
+
"Init flows:",
|
|
40864
|
+
" Standard init/clone/download flow: run `taptap-maker init`; the CLI shows",
|
|
40865
|
+
" the Maker app list, then the user chooses an existing app or 0/new.",
|
|
40866
|
+
" Create-new-project flow: add `--create --name NAME` only when the user",
|
|
40867
|
+
" clearly asks to create a new Maker project; NAME is the requested project name.",
|
|
40868
|
+
"",
|
|
40144
40869
|
" taptap-maker doctor [--target-dir DIR] [--env rnd|production] [--json]",
|
|
40145
40870
|
" taptap-maker python doctor [--json]",
|
|
40146
40871
|
" taptap-maker python setup [--json]",
|