@taptap/maker 0.0.22 → 0.0.23-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 +124 -699
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/maker.js
CHANGED
|
@@ -29902,6 +29902,14 @@ function escapeRegExp(value) {
|
|
|
29902
29902
|
}
|
|
29903
29903
|
|
|
29904
29904
|
// src/maker/cli/projects.ts
|
|
29905
|
+
var MAKER_PROJECT_BASE_DIRECTORIES = [
|
|
29906
|
+
"assets",
|
|
29907
|
+
"assets/image",
|
|
29908
|
+
"assets/sprites",
|
|
29909
|
+
"assets/video",
|
|
29910
|
+
"assets/audio",
|
|
29911
|
+
"scripts"
|
|
29912
|
+
];
|
|
29905
29913
|
var MakerGitError = class extends Error {
|
|
29906
29914
|
constructor(failure) {
|
|
29907
29915
|
super(failure.message);
|
|
@@ -30031,6 +30039,11 @@ async function createMakerProject(options) {
|
|
|
30031
30039
|
}
|
|
30032
30040
|
return project;
|
|
30033
30041
|
}
|
|
30042
|
+
function ensureMakerProjectBaseDirectories(targetDir) {
|
|
30043
|
+
for (const relativeDir of MAKER_PROJECT_BASE_DIRECTORIES) {
|
|
30044
|
+
fs7.mkdirSync(path8.join(targetDir, relativeDir), { recursive: true });
|
|
30045
|
+
}
|
|
30046
|
+
}
|
|
30034
30047
|
async function cloneMakerProject(options) {
|
|
30035
30048
|
var _a3, _b, _c, _d, _e, _f, _g, _h;
|
|
30036
30049
|
const target = path8.resolve(options.targetDir);
|
|
@@ -30103,6 +30116,7 @@ async function cloneMakerProject(options) {
|
|
|
30103
30116
|
user_id: options.userId || await resolveMakerProjectUserId(options),
|
|
30104
30117
|
sce_endpoint: options.sceEndpoint
|
|
30105
30118
|
});
|
|
30119
|
+
ensureMakerProjectBaseDirectories(target);
|
|
30106
30120
|
finalizeStagedDevKitGitignore(target);
|
|
30107
30121
|
(_e = options.onProgress) == null ? void 0 : _e.call(options, {
|
|
30108
30122
|
progress: 100,
|
|
@@ -30175,6 +30189,7 @@ async function cloneMakerProject(options) {
|
|
|
30175
30189
|
user_id: options.userId || await resolveMakerProjectUserId(options),
|
|
30176
30190
|
sce_endpoint: options.sceEndpoint
|
|
30177
30191
|
});
|
|
30192
|
+
ensureMakerProjectBaseDirectories(target);
|
|
30178
30193
|
(_h = options.onProgress) == null ? void 0 : _h.call(options, {
|
|
30179
30194
|
progress: 100,
|
|
30180
30195
|
total: 100,
|
|
@@ -34260,13 +34275,8 @@ function applyDefaults(config2) {
|
|
|
34260
34275
|
}
|
|
34261
34276
|
|
|
34262
34277
|
// src/maker/server/mcp.ts
|
|
34263
|
-
var VERSION = true ? "0.0.
|
|
34278
|
+
var VERSION = true ? "0.0.23-beta.1" : "dev";
|
|
34264
34279
|
var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
34265
|
-
var ASYNC_BUILD_POLL_INTERVAL_MS = 5 * 1e3;
|
|
34266
|
-
var ASYNC_BUILD_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
34267
|
-
var DEFAULT_REMOTE_ASYNC_BUILD_PARAM = "async";
|
|
34268
|
-
var DEFAULT_REMOTE_ASYNC_BUILD_QUERY_TOOL = "query_build";
|
|
34269
|
-
var DEFAULT_REMOTE_ASYNC_BUILD_QUERY_TASK_ID_PARAM = "build_id";
|
|
34270
34280
|
var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
|
|
34271
34281
|
var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
|
|
34272
34282
|
var PREVIEW_REFRESH_TIMEOUT_MS = 15 * 1e3;
|
|
@@ -34353,10 +34363,6 @@ var tools = [
|
|
|
34353
34363
|
type: "number",
|
|
34354
34364
|
description: "Optional remote build timeout in milliseconds. Defaults to 10 minutes. If timed out, do not retry blindly; inspect remote build logs first."
|
|
34355
34365
|
},
|
|
34356
|
-
async_build: {
|
|
34357
|
-
type: "boolean",
|
|
34358
|
-
description: "Async remote build preference. If true, Maker MCP forwards remote build async:true in any IDE. If false, it keeps synchronous remote build. If omitted, WorkBuddy defaults to async and other IDEs default to sync. For async builds, this tool keeps the current MCP call open, polls query_build(build_id) every 5 seconds, and returns only after success, failure, replacement by a newer build, or 30 minutes."
|
|
34359
|
-
},
|
|
34360
34366
|
message: {
|
|
34361
34367
|
type: "string",
|
|
34362
34368
|
description: "Optional commit message used when local changes or the empty wake-up commit need to be committed before build."
|
|
@@ -34675,7 +34681,6 @@ async function startMakerMcpServer() {
|
|
|
34675
34681
|
serverUrl: args.server_url,
|
|
34676
34682
|
env: args.env,
|
|
34677
34683
|
timeoutMs: args.timeout_ms,
|
|
34678
|
-
asyncBuild: args.async_build,
|
|
34679
34684
|
message: args.message,
|
|
34680
34685
|
files: args.files,
|
|
34681
34686
|
confirmRemoteBuildWithoutSubmit: args.confirm_remote_build_without_submit,
|
|
@@ -34844,8 +34849,6 @@ async function formatStatus(options = {}) {
|
|
|
34844
34849
|
"",
|
|
34845
34850
|
remoteSyncText,
|
|
34846
34851
|
"",
|
|
34847
|
-
identify.projectRoot ? formatAsyncBuildStatus(identify.projectRoot) : "",
|
|
34848
|
-
"",
|
|
34849
34852
|
identify.projectRoot ? await formatMakerProxyToolsStatusSafely({ targetDir: identify.projectRoot }) : "",
|
|
34850
34853
|
"",
|
|
34851
34854
|
formatAuthNextStep({ hasPat: Boolean(pat), isProjectBound: Boolean(identify.projectRoot) }),
|
|
@@ -34864,29 +34867,6 @@ async function formatStatus(options = {}) {
|
|
|
34864
34867
|
projectSection
|
|
34865
34868
|
].filter(Boolean).join("\n");
|
|
34866
34869
|
}
|
|
34867
|
-
function formatAsyncBuildStatus(projectRoot) {
|
|
34868
|
-
const active = readJsonFile2(getAsyncBuildActiveFilePath(projectRoot));
|
|
34869
|
-
if (!(active == null ? void 0 : active.taskId)) {
|
|
34870
|
-
return ["Maker async build", "", "- status: inactive"].join("\n");
|
|
34871
|
-
}
|
|
34872
|
-
const stale = active.pid !== void 0 && active.pid !== process.pid;
|
|
34873
|
-
const state = active.stateFile ? readJsonFile2(active.stateFile) : void 0;
|
|
34874
|
-
return [
|
|
34875
|
-
"Maker async build",
|
|
34876
|
-
"",
|
|
34877
|
-
`- status: ${stale ? "stale" : "active"}`,
|
|
34878
|
-
`- build_id: ${active.taskId}`,
|
|
34879
|
-
active.reused !== void 0 ? `- reused: ${active.reused ? "yes" : "no"}` : "",
|
|
34880
|
-
active.pid ? `- watcher_pid: ${active.pid}` : "",
|
|
34881
|
-
stale ? "- note: active marker belongs to a previous MCP process; polling is not durable after restart" : "",
|
|
34882
|
-
active.stateFile ? `- state_file: ${active.stateFile}` : "",
|
|
34883
|
-
active.deadlineAt ? `- deadline_at: ${active.deadlineAt}` : "",
|
|
34884
|
-
(state == null ? void 0 : state.status) ? `- last_status: ${state.status}` : "",
|
|
34885
|
-
(state == null ? void 0 : state.updatedAt) ? `- updated_at: ${state.updatedAt}` : "",
|
|
34886
|
-
`- poll_interval_ms: ${ASYNC_BUILD_POLL_INTERVAL_MS}`,
|
|
34887
|
-
`- timeout_ms: ${ASYNC_BUILD_TIMEOUT_MS}`
|
|
34888
|
-
].filter(Boolean).join("\n");
|
|
34889
|
-
}
|
|
34890
34870
|
function formatAuthNextStep(options) {
|
|
34891
34871
|
if (options.hasPat) {
|
|
34892
34872
|
return "";
|
|
@@ -35558,7 +35538,6 @@ function formatDuration(ms) {
|
|
|
35558
35538
|
}
|
|
35559
35539
|
return `${minutes}m ${seconds}s`;
|
|
35560
35540
|
}
|
|
35561
|
-
var activeAsyncBuildWatchers = /* @__PURE__ */ new Map();
|
|
35562
35541
|
function formatMakerAppWebUrl(projectId, env) {
|
|
35563
35542
|
const makerEnv = env === "rnd" || env === "production" ? env : void 0;
|
|
35564
35543
|
const url2 = new URL(`${getMakerWebUrl(makerEnv)}/app/${encodeURIComponent(projectId)}`);
|
|
@@ -35610,22 +35589,6 @@ async function buildCurrentDirectory(options) {
|
|
|
35610
35589
|
buildFailure: toMakerBuildFailure(error2)
|
|
35611
35590
|
};
|
|
35612
35591
|
}
|
|
35613
|
-
if (buildResult.mode === "remote_build_async_started") {
|
|
35614
|
-
try {
|
|
35615
|
-
return {
|
|
35616
|
-
...await attachAndWaitAsyncBuildResult(buildResult, options),
|
|
35617
|
-
submitResult
|
|
35618
|
-
};
|
|
35619
|
-
} catch (error2) {
|
|
35620
|
-
return {
|
|
35621
|
-
mode: "build_failed_after_submit",
|
|
35622
|
-
projectRoot: localChanges.projectRoot,
|
|
35623
|
-
projectId: (config2 == null ? void 0 : config2.project_id) || "unknown",
|
|
35624
|
-
submitResult,
|
|
35625
|
-
buildFailure: toMakerBuildFailure(error2)
|
|
35626
|
-
};
|
|
35627
|
-
}
|
|
35628
|
-
}
|
|
35629
35592
|
return {
|
|
35630
35593
|
...buildResult,
|
|
35631
35594
|
submitResult
|
|
@@ -35633,9 +35596,6 @@ async function buildCurrentDirectory(options) {
|
|
|
35633
35596
|
}
|
|
35634
35597
|
try {
|
|
35635
35598
|
const buildResult = await runRemoteBuildCurrentDirectory(options, options.targetDir);
|
|
35636
|
-
if (buildResult.mode === "remote_build_async_started") {
|
|
35637
|
-
return await attachAndWaitAsyncBuildResult(buildResult, options);
|
|
35638
|
-
}
|
|
35639
35599
|
return buildResult;
|
|
35640
35600
|
} catch (error2) {
|
|
35641
35601
|
if (error2 instanceof RemoteBuildFailedError) {
|
|
@@ -35653,9 +35613,6 @@ async function buildCurrentDirectory(options) {
|
|
|
35653
35613
|
async function runRemoteBuildCurrentDirectory(options, targetDir) {
|
|
35654
35614
|
if (options.callRemoteBuild) {
|
|
35655
35615
|
const injectedResult = await options.callRemoteBuild(targetDir);
|
|
35656
|
-
if (injectedResult.mode === "remote_build_async_started") {
|
|
35657
|
-
return injectedResult;
|
|
35658
|
-
}
|
|
35659
35616
|
return attachBuildSuccessSideEffects(injectedResult, {
|
|
35660
35617
|
refreshPreview: options.refreshPreview || skipPreviewRefresh,
|
|
35661
35618
|
startRuntimeLogWatch: options.startRuntimeLogWatch
|
|
@@ -35667,7 +35624,6 @@ async function runRemoteBuildCurrentDirectory(options, targetDir) {
|
|
|
35667
35624
|
env: options.env
|
|
35668
35625
|
});
|
|
35669
35626
|
const buildArgs = createBuildArgs(proxy.projectRoot, options);
|
|
35670
|
-
const asyncBuildForwarded = shouldForwardAsyncBuild(options.asyncBuild);
|
|
35671
35627
|
const timeoutMs = options.timeoutMs || DEFAULT_BUILD_TIMEOUT_MS;
|
|
35672
35628
|
const result = await retryMakerProxyOperation(
|
|
35673
35629
|
async () => {
|
|
@@ -35739,36 +35695,14 @@ async function runRemoteBuildCurrentDirectory(options, targetDir) {
|
|
|
35739
35695
|
env: proxy.env,
|
|
35740
35696
|
timeoutMs,
|
|
35741
35697
|
buildArgs,
|
|
35742
|
-
resultText
|
|
35743
|
-
asyncBuild: asyncBuildForwarded
|
|
35698
|
+
resultText
|
|
35744
35699
|
});
|
|
35745
|
-
if (buildCallResult.mode === "remote_build_async_started") {
|
|
35746
|
-
return buildCallResult;
|
|
35747
|
-
}
|
|
35748
35700
|
return attachBuildSuccessSideEffects(buildCallResult, {
|
|
35749
35701
|
refreshPreview: options.refreshPreview,
|
|
35750
35702
|
startRuntimeLogWatch: options.startRuntimeLogWatch || startRuntimeLogWatch
|
|
35751
35703
|
});
|
|
35752
35704
|
}
|
|
35753
35705
|
function createRemoteBuildCallResult(options) {
|
|
35754
|
-
const asyncReceipt = options.asyncBuild ? extractAsyncBuildReceipt(options.resultText) : void 0;
|
|
35755
|
-
const taskId = asyncReceipt == null ? void 0 : asyncReceipt.taskId;
|
|
35756
|
-
if (taskId) {
|
|
35757
|
-
return {
|
|
35758
|
-
mode: "remote_build_async_started",
|
|
35759
|
-
projectRoot: options.projectRoot,
|
|
35760
|
-
projectId: options.projectId,
|
|
35761
|
-
projectPath: options.projectPath,
|
|
35762
|
-
serverUrl: options.serverUrl,
|
|
35763
|
-
env: options.env,
|
|
35764
|
-
makerUrl: formatMakerAppWebUrl(options.projectId, options.env),
|
|
35765
|
-
timeoutMs: options.timeoutMs,
|
|
35766
|
-
buildArgs: options.buildArgs,
|
|
35767
|
-
taskId,
|
|
35768
|
-
reused: asyncReceipt.reused,
|
|
35769
|
-
resultText: options.resultText
|
|
35770
|
-
};
|
|
35771
|
-
}
|
|
35772
35706
|
return {
|
|
35773
35707
|
mode: "remote_build",
|
|
35774
35708
|
projectRoot: options.projectRoot,
|
|
@@ -35782,244 +35716,6 @@ function createRemoteBuildCallResult(options) {
|
|
|
35782
35716
|
resultText: options.resultText
|
|
35783
35717
|
};
|
|
35784
35718
|
}
|
|
35785
|
-
function extractAsyncBuildReceipt(resultText) {
|
|
35786
|
-
const parsed = parseJsonObjectFromText(resultText);
|
|
35787
|
-
const taskId = (parsed == null ? void 0 : parsed.build_id) || (parsed == null ? void 0 : parsed.buildId) || (parsed == null ? void 0 : parsed.task_id) || (parsed == null ? void 0 : parsed.taskId) || (parsed == null ? void 0 : parsed.build_task_id) || (parsed == null ? void 0 : parsed.buildTaskId);
|
|
35788
|
-
if (typeof taskId !== "string" || !taskId.trim()) {
|
|
35789
|
-
return void 0;
|
|
35790
|
-
}
|
|
35791
|
-
return {
|
|
35792
|
-
taskId: taskId.trim(),
|
|
35793
|
-
...typeof (parsed == null ? void 0 : parsed.reused) === "boolean" ? { reused: parsed.reused } : {}
|
|
35794
|
-
};
|
|
35795
|
-
}
|
|
35796
|
-
function parseJsonObjectFromText(text) {
|
|
35797
|
-
const trimmed = text.trim();
|
|
35798
|
-
if (!trimmed) {
|
|
35799
|
-
return void 0;
|
|
35800
|
-
}
|
|
35801
|
-
for (const candidate of extractJsonObjectCandidates(trimmed)) {
|
|
35802
|
-
try {
|
|
35803
|
-
const parsed = JSON.parse(candidate);
|
|
35804
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
35805
|
-
return parsed;
|
|
35806
|
-
}
|
|
35807
|
-
} catch {
|
|
35808
|
-
}
|
|
35809
|
-
}
|
|
35810
|
-
return void 0;
|
|
35811
|
-
}
|
|
35812
|
-
function extractJsonObjectCandidates(text) {
|
|
35813
|
-
var _a3;
|
|
35814
|
-
const candidates = /* @__PURE__ */ new Set([text]);
|
|
35815
|
-
const fencedJsonPattern = /```(?:json)?\s*([\s\S]*?)```/gi;
|
|
35816
|
-
let fencedMatch;
|
|
35817
|
-
while ((fencedMatch = fencedJsonPattern.exec(text)) !== null) {
|
|
35818
|
-
const candidate = (_a3 = fencedMatch[1]) == null ? void 0 : _a3.trim();
|
|
35819
|
-
if (candidate) {
|
|
35820
|
-
candidates.add(candidate);
|
|
35821
|
-
}
|
|
35822
|
-
}
|
|
35823
|
-
let start = -1;
|
|
35824
|
-
let depth = 0;
|
|
35825
|
-
let inString = false;
|
|
35826
|
-
let escaping = false;
|
|
35827
|
-
for (let index = 0; index < text.length; index += 1) {
|
|
35828
|
-
const char = text[index];
|
|
35829
|
-
if (inString) {
|
|
35830
|
-
if (escaping) {
|
|
35831
|
-
escaping = false;
|
|
35832
|
-
} else if (char === "\\") {
|
|
35833
|
-
escaping = true;
|
|
35834
|
-
} else if (char === '"') {
|
|
35835
|
-
inString = false;
|
|
35836
|
-
}
|
|
35837
|
-
continue;
|
|
35838
|
-
}
|
|
35839
|
-
if (char === '"') {
|
|
35840
|
-
inString = true;
|
|
35841
|
-
continue;
|
|
35842
|
-
}
|
|
35843
|
-
if (char === "{") {
|
|
35844
|
-
if (depth === 0) {
|
|
35845
|
-
start = index;
|
|
35846
|
-
}
|
|
35847
|
-
depth += 1;
|
|
35848
|
-
continue;
|
|
35849
|
-
}
|
|
35850
|
-
if (char === "}" && depth > 0) {
|
|
35851
|
-
depth -= 1;
|
|
35852
|
-
if (depth === 0 && start >= 0) {
|
|
35853
|
-
candidates.add(text.slice(start, index + 1));
|
|
35854
|
-
start = -1;
|
|
35855
|
-
}
|
|
35856
|
-
}
|
|
35857
|
-
}
|
|
35858
|
-
return [...candidates].map((candidate) => candidate.trim()).filter(Boolean);
|
|
35859
|
-
}
|
|
35860
|
-
function attachAsyncBuildWatcher(buildResult, options) {
|
|
35861
|
-
const remoteQueryRunner = options.queryAsyncBuildResult ? void 0 : createRemoteAsyncBuildQueryRunner(buildResult);
|
|
35862
|
-
const queryBuildResult = options.queryAsyncBuildResult || ((taskId) => (remoteQueryRunner == null ? void 0 : remoteQueryRunner.query(taskId)) || Promise.reject(new Error("Async build query runner is not available")));
|
|
35863
|
-
return {
|
|
35864
|
-
...buildResult,
|
|
35865
|
-
asyncBuildWatch: startAsyncBuildResultWatcher({
|
|
35866
|
-
projectRoot: buildResult.projectRoot,
|
|
35867
|
-
projectId: buildResult.projectId,
|
|
35868
|
-
projectPath: buildResult.projectPath,
|
|
35869
|
-
serverUrl: buildResult.serverUrl,
|
|
35870
|
-
env: buildResult.env,
|
|
35871
|
-
taskId: buildResult.taskId,
|
|
35872
|
-
reused: buildResult.reused,
|
|
35873
|
-
sourceBuildResult: buildResult,
|
|
35874
|
-
queryBuildResult: () => queryBuildResult(buildResult.taskId),
|
|
35875
|
-
refreshPreview: options.refreshPreview || refreshMakerPreview,
|
|
35876
|
-
startRuntimeLogWatch: options.startRuntimeLogWatch || startRuntimeLogWatch,
|
|
35877
|
-
pollIntervalMs: options.asyncBuildPollIntervalMs,
|
|
35878
|
-
onProgress: options.onProgress,
|
|
35879
|
-
onStop: () => remoteQueryRunner == null ? void 0 : remoteQueryRunner.close()
|
|
35880
|
-
})
|
|
35881
|
-
};
|
|
35882
|
-
}
|
|
35883
|
-
async function attachAndWaitAsyncBuildResult(buildResult, options) {
|
|
35884
|
-
var _a3, _b;
|
|
35885
|
-
const watched = attachAsyncBuildWatcher(buildResult, options);
|
|
35886
|
-
const activeFile = (_a3 = watched.asyncBuildWatch) == null ? void 0 : _a3.activeFile;
|
|
35887
|
-
const completion = activeFile ? (_b = activeAsyncBuildWatchers.get(activeFile)) == null ? void 0 : _b.completion : void 0;
|
|
35888
|
-
if (!completion) {
|
|
35889
|
-
throw new Error("Async build watcher did not start");
|
|
35890
|
-
}
|
|
35891
|
-
const finalState = await completion;
|
|
35892
|
-
const finalResult = asyncWatcherStateToRemoteBuildResult(finalState, buildResult);
|
|
35893
|
-
if (finalState.status === "succeeded") {
|
|
35894
|
-
return finalResult;
|
|
35895
|
-
}
|
|
35896
|
-
if (finalState.status === "failed") {
|
|
35897
|
-
throw new RemoteBuildFailedError(finalResult);
|
|
35898
|
-
}
|
|
35899
|
-
throw new RemoteBuildFailedError({
|
|
35900
|
-
...finalResult,
|
|
35901
|
-
resultText: finalResult.resultText || `Async Maker build did not finish successfully: ${finalState.status}${finalState.error ? `: ${formatAsyncBuildDiagnostic(finalState.error)}` : ""}`
|
|
35902
|
-
});
|
|
35903
|
-
}
|
|
35904
|
-
function formatAsyncBuildDiagnostic(value) {
|
|
35905
|
-
if (typeof value === "string") {
|
|
35906
|
-
return value;
|
|
35907
|
-
}
|
|
35908
|
-
try {
|
|
35909
|
-
return JSON.stringify(value);
|
|
35910
|
-
} catch {
|
|
35911
|
-
return String(value);
|
|
35912
|
-
}
|
|
35913
|
-
}
|
|
35914
|
-
function createRemoteAsyncBuildQueryRunner(buildResult, options = {}) {
|
|
35915
|
-
var _a3, _b;
|
|
35916
|
-
const proxy = createRemoteProxyContext({
|
|
35917
|
-
targetDir: buildResult.projectRoot,
|
|
35918
|
-
serverUrl: buildResult.serverUrl,
|
|
35919
|
-
env: buildResult.env === "rnd" || buildResult.env === "production" ? buildResult.env : void 0
|
|
35920
|
-
});
|
|
35921
|
-
const queryToolName = ((_a3 = process.env.TAPTAP_MAKER_REMOTE_ASYNC_BUILD_QUERY_TOOL) == null ? void 0 : _a3.trim()) || DEFAULT_REMOTE_ASYNC_BUILD_QUERY_TOOL;
|
|
35922
|
-
const taskIdParam = ((_b = process.env.TAPTAP_MAKER_REMOTE_ASYNC_BUILD_QUERY_TASK_ID_PARAM) == null ? void 0 : _b.trim()) || DEFAULT_REMOTE_ASYNC_BUILD_QUERY_TASK_ID_PARAM;
|
|
35923
|
-
let client;
|
|
35924
|
-
const createTransport = options.createTransport || (() => trackMakerChildTransport(
|
|
35925
|
-
new HiddenStdioClientTransport({
|
|
35926
|
-
command: proxy.command,
|
|
35927
|
-
args: proxy.args,
|
|
35928
|
-
env: mergeStringEnv(process.env, proxy.envVars),
|
|
35929
|
-
stderr: "pipe"
|
|
35930
|
-
})
|
|
35931
|
-
));
|
|
35932
|
-
const createClient = options.createClient || (() => new Client(
|
|
35933
|
-
{
|
|
35934
|
-
name: "taptap-maker-async-build-query-forwarder",
|
|
35935
|
-
version: VERSION
|
|
35936
|
-
},
|
|
35937
|
-
{
|
|
35938
|
-
capabilities: {}
|
|
35939
|
-
}
|
|
35940
|
-
));
|
|
35941
|
-
const ensureClient = async () => {
|
|
35942
|
-
if (client) {
|
|
35943
|
-
return client;
|
|
35944
|
-
}
|
|
35945
|
-
const nextClient = createClient();
|
|
35946
|
-
await nextClient.connect(createTransport());
|
|
35947
|
-
client = nextClient;
|
|
35948
|
-
return nextClient;
|
|
35949
|
-
};
|
|
35950
|
-
const close = async () => {
|
|
35951
|
-
const activeClient = client;
|
|
35952
|
-
client = void 0;
|
|
35953
|
-
if (activeClient) {
|
|
35954
|
-
await activeClient.close();
|
|
35955
|
-
}
|
|
35956
|
-
};
|
|
35957
|
-
return {
|
|
35958
|
-
query: async (taskId) => {
|
|
35959
|
-
const activeClient = await ensureClient();
|
|
35960
|
-
let result;
|
|
35961
|
-
try {
|
|
35962
|
-
result = await activeClient.callTool(
|
|
35963
|
-
{
|
|
35964
|
-
name: queryToolName,
|
|
35965
|
-
arguments: { [taskIdParam]: taskId }
|
|
35966
|
-
},
|
|
35967
|
-
void 0,
|
|
35968
|
-
{
|
|
35969
|
-
timeout: DEFAULT_BUILD_TIMEOUT_MS
|
|
35970
|
-
}
|
|
35971
|
-
);
|
|
35972
|
-
} catch (error2) {
|
|
35973
|
-
await close().catch(() => {
|
|
35974
|
-
});
|
|
35975
|
-
throw error2;
|
|
35976
|
-
}
|
|
35977
|
-
return normalizeAsyncBuildQueryResult(result);
|
|
35978
|
-
},
|
|
35979
|
-
close: async () => {
|
|
35980
|
-
await close().catch(() => {
|
|
35981
|
-
});
|
|
35982
|
-
}
|
|
35983
|
-
};
|
|
35984
|
-
}
|
|
35985
|
-
function normalizeAsyncBuildQueryResult(result) {
|
|
35986
|
-
const resultText = formatRemoteToolResult(result);
|
|
35987
|
-
const parsed = parseJsonObjectFromText(resultText);
|
|
35988
|
-
const status = normalizeAsyncBuildStatus((parsed == null ? void 0 : parsed.status) || (parsed == null ? void 0 : parsed.state) || (parsed == null ? void 0 : parsed.phase));
|
|
35989
|
-
if (status) {
|
|
35990
|
-
return {
|
|
35991
|
-
status,
|
|
35992
|
-
resultText,
|
|
35993
|
-
result: parsed,
|
|
35994
|
-
error: parsed == null ? void 0 : parsed.error
|
|
35995
|
-
};
|
|
35996
|
-
}
|
|
35997
|
-
return {
|
|
35998
|
-
status: isRemoteToolError(result) ? "failed" : "running",
|
|
35999
|
-
resultText,
|
|
36000
|
-
result: parsed || result,
|
|
36001
|
-
...isRemoteToolError(result) ? { error: resultText } : {}
|
|
36002
|
-
};
|
|
36003
|
-
}
|
|
36004
|
-
function normalizeAsyncBuildStatus(status) {
|
|
36005
|
-
if (typeof status !== "string") {
|
|
36006
|
-
return void 0;
|
|
36007
|
-
}
|
|
36008
|
-
const normalized = status.trim().toLowerCase();
|
|
36009
|
-
if (["queued", "pending", "created"].includes(normalized)) {
|
|
36010
|
-
return "queued";
|
|
36011
|
-
}
|
|
36012
|
-
if (["running", "building", "in_progress", "processing"].includes(normalized)) {
|
|
36013
|
-
return "running";
|
|
36014
|
-
}
|
|
36015
|
-
if (["succeeded", "success", "done", "completed", "finished"].includes(normalized)) {
|
|
36016
|
-
return "succeeded";
|
|
36017
|
-
}
|
|
36018
|
-
if (["failed", "failure", "error", "cancelled", "canceled"].includes(normalized)) {
|
|
36019
|
-
return "failed";
|
|
36020
|
-
}
|
|
36021
|
-
return void 0;
|
|
36022
|
-
}
|
|
36023
35719
|
async function attachBuildSuccessSideEffects(buildResult, options) {
|
|
36024
35720
|
if (isRemoteBuildFailureResult(buildResult)) {
|
|
36025
35721
|
throw new RemoteBuildFailedError(buildResult);
|
|
@@ -36159,315 +35855,6 @@ async function startRuntimeLogWatch(buildResult) {
|
|
|
36159
35855
|
fs14.closeSync(errFd);
|
|
36160
35856
|
}
|
|
36161
35857
|
}
|
|
36162
|
-
function startAsyncBuildResultWatcher(options) {
|
|
36163
|
-
const pollIntervalMs = options.pollIntervalMs || ASYNC_BUILD_POLL_INTERVAL_MS;
|
|
36164
|
-
const timeoutMs = options.timeoutMs || ASYNC_BUILD_TIMEOUT_MS;
|
|
36165
|
-
const paths = getAsyncBuildWatcherPaths(options.projectRoot, options.taskId);
|
|
36166
|
-
const previous = stopExistingAsyncBuildResultWatcher(
|
|
36167
|
-
options.projectRoot,
|
|
36168
|
-
"cancelled_by_new_build"
|
|
36169
|
-
);
|
|
36170
|
-
const now = /* @__PURE__ */ new Date();
|
|
36171
|
-
const state = {
|
|
36172
|
-
mode: "remote_build_async",
|
|
36173
|
-
taskId: options.taskId,
|
|
36174
|
-
reused: options.reused,
|
|
36175
|
-
projectId: options.projectId,
|
|
36176
|
-
projectPath: options.projectPath,
|
|
36177
|
-
projectRoot: options.projectRoot,
|
|
36178
|
-
serverUrl: options.serverUrl,
|
|
36179
|
-
env: options.env,
|
|
36180
|
-
status: "queued",
|
|
36181
|
-
startedAt: now.toISOString(),
|
|
36182
|
-
updatedAt: now.toISOString(),
|
|
36183
|
-
deadlineAt: new Date(now.getTime() + timeoutMs).toISOString(),
|
|
36184
|
-
pollIntervalMs
|
|
36185
|
-
};
|
|
36186
|
-
let completeWatcher = () => {
|
|
36187
|
-
};
|
|
36188
|
-
const completion = new Promise((resolve) => {
|
|
36189
|
-
completeWatcher = resolve;
|
|
36190
|
-
});
|
|
36191
|
-
const watcher = {
|
|
36192
|
-
state,
|
|
36193
|
-
sourceBuildResult: options.sourceBuildResult,
|
|
36194
|
-
activeFile: paths.activeFile,
|
|
36195
|
-
stateFile: paths.stateFile,
|
|
36196
|
-
onStop: options.onStop,
|
|
36197
|
-
completion,
|
|
36198
|
-
complete: completeWatcher
|
|
36199
|
-
};
|
|
36200
|
-
fs14.mkdirSync(path15.dirname(paths.activeFile), { recursive: true });
|
|
36201
|
-
writeJsonFile2(paths.stateFile, state);
|
|
36202
|
-
writeJsonFile2(paths.activeFile, {
|
|
36203
|
-
taskId: options.taskId,
|
|
36204
|
-
reused: options.reused,
|
|
36205
|
-
projectId: options.projectId,
|
|
36206
|
-
pid: process.pid,
|
|
36207
|
-
startedAt: state.startedAt,
|
|
36208
|
-
deadlineAt: state.deadlineAt,
|
|
36209
|
-
stateFile: paths.stateFile
|
|
36210
|
-
});
|
|
36211
|
-
activeAsyncBuildWatchers.set(paths.activeFile, watcher);
|
|
36212
|
-
const poll = async () => {
|
|
36213
|
-
var _a3, _b, _c;
|
|
36214
|
-
if (!activeAsyncBuildWatchers.has(paths.activeFile)) {
|
|
36215
|
-
return;
|
|
36216
|
-
}
|
|
36217
|
-
try {
|
|
36218
|
-
const result = await options.queryBuildResult();
|
|
36219
|
-
updateAsyncBuildWatcherState(watcher, {
|
|
36220
|
-
status: result.status,
|
|
36221
|
-
resultText: result.resultText,
|
|
36222
|
-
result: result.result,
|
|
36223
|
-
error: result.error,
|
|
36224
|
-
lastPollError: void 0
|
|
36225
|
-
});
|
|
36226
|
-
emitAsyncBuildPollProgress(watcher, result, options.onProgress);
|
|
36227
|
-
if (result.status === "succeeded" || result.status === "failed") {
|
|
36228
|
-
if (result.status === "succeeded") {
|
|
36229
|
-
await finishAsyncBuildSuccessSideEffects(watcher, options);
|
|
36230
|
-
}
|
|
36231
|
-
stopAsyncBuildWatcherRuntime(watcher);
|
|
36232
|
-
(_a3 = watcher.complete) == null ? void 0 : _a3.call(watcher, watcher.state);
|
|
36233
|
-
return;
|
|
36234
|
-
}
|
|
36235
|
-
} catch (error2) {
|
|
36236
|
-
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
36237
|
-
if (isAsyncBuildExpiredErrorMessage(message)) {
|
|
36238
|
-
updateAsyncBuildWatcherState(watcher, {
|
|
36239
|
-
status: "expired",
|
|
36240
|
-
error: message,
|
|
36241
|
-
lastPollError: message
|
|
36242
|
-
});
|
|
36243
|
-
stopAsyncBuildWatcherRuntime(watcher);
|
|
36244
|
-
(_b = watcher.complete) == null ? void 0 : _b.call(watcher, watcher.state);
|
|
36245
|
-
return;
|
|
36246
|
-
}
|
|
36247
|
-
const nextStatus = "running";
|
|
36248
|
-
updateAsyncBuildWatcherState(watcher, {
|
|
36249
|
-
status: nextStatus,
|
|
36250
|
-
lastPollError: message
|
|
36251
|
-
});
|
|
36252
|
-
emitAsyncBuildPollProgress(
|
|
36253
|
-
watcher,
|
|
36254
|
-
{ status: nextStatus, error: message },
|
|
36255
|
-
options.onProgress
|
|
36256
|
-
);
|
|
36257
|
-
}
|
|
36258
|
-
if (Date.now() >= Date.parse(watcher.state.deadlineAt)) {
|
|
36259
|
-
updateAsyncBuildWatcherState(watcher, { status: "timeout" });
|
|
36260
|
-
stopAsyncBuildWatcherRuntime(watcher);
|
|
36261
|
-
(_c = watcher.complete) == null ? void 0 : _c.call(watcher, watcher.state);
|
|
36262
|
-
return;
|
|
36263
|
-
}
|
|
36264
|
-
watcher.timer = setTimeout(() => {
|
|
36265
|
-
void poll();
|
|
36266
|
-
}, pollIntervalMs);
|
|
36267
|
-
};
|
|
36268
|
-
watcher.timer = setTimeout(() => {
|
|
36269
|
-
void poll();
|
|
36270
|
-
}, pollIntervalMs);
|
|
36271
|
-
return {
|
|
36272
|
-
started: true,
|
|
36273
|
-
taskId: options.taskId,
|
|
36274
|
-
reused: options.reused,
|
|
36275
|
-
activeFile: paths.activeFile,
|
|
36276
|
-
stateFile: paths.stateFile,
|
|
36277
|
-
pollIntervalMs,
|
|
36278
|
-
timeoutMs,
|
|
36279
|
-
previousTaskId: previous.previousTaskId,
|
|
36280
|
-
previousStopped: previous.previousStopped
|
|
36281
|
-
};
|
|
36282
|
-
}
|
|
36283
|
-
function stopAsyncBuildWatcherRuntime(watcher) {
|
|
36284
|
-
var _a3;
|
|
36285
|
-
if (watcher.stopped) {
|
|
36286
|
-
return;
|
|
36287
|
-
}
|
|
36288
|
-
watcher.stopped = true;
|
|
36289
|
-
if (watcher.timer) {
|
|
36290
|
-
clearTimeout(watcher.timer);
|
|
36291
|
-
watcher.timer = void 0;
|
|
36292
|
-
}
|
|
36293
|
-
activeAsyncBuildWatchers.delete(watcher.activeFile);
|
|
36294
|
-
fs14.rmSync(watcher.activeFile, { force: true });
|
|
36295
|
-
void Promise.resolve((_a3 = watcher.onStop) == null ? void 0 : _a3.call(watcher)).catch((error2) => {
|
|
36296
|
-
updateAsyncBuildWatcherState(watcher, {
|
|
36297
|
-
sideEffectError: `async query runner close failed: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
36298
|
-
});
|
|
36299
|
-
});
|
|
36300
|
-
}
|
|
36301
|
-
function isAsyncBuildExpiredErrorMessage(message) {
|
|
36302
|
-
const normalized = message.trim().toLowerCase();
|
|
36303
|
-
return [
|
|
36304
|
-
"not found",
|
|
36305
|
-
"not_found",
|
|
36306
|
-
"not exist",
|
|
36307
|
-
"unknown build",
|
|
36308
|
-
"unknown build_id",
|
|
36309
|
-
"expired",
|
|
36310
|
-
"restart",
|
|
36311
|
-
"restarted",
|
|
36312
|
-
"未找到",
|
|
36313
|
-
"不存在",
|
|
36314
|
-
"过期",
|
|
36315
|
-
"服务重启"
|
|
36316
|
-
].some((pattern) => normalized.includes(pattern));
|
|
36317
|
-
}
|
|
36318
|
-
function emitAsyncBuildPollProgress(watcher, result, onProgress) {
|
|
36319
|
-
if (!onProgress) {
|
|
36320
|
-
return;
|
|
36321
|
-
}
|
|
36322
|
-
const payload = result.result && typeof result.result === "object" && !Array.isArray(result.result) ? result.result : {};
|
|
36323
|
-
const remoteProgress = typeof payload.progress === "number" ? payload.progress : void 0;
|
|
36324
|
-
const remotePhase = typeof payload.phase === "string" && payload.phase.trim() ? payload.phase.trim() : void 0;
|
|
36325
|
-
const elapsedSeconds = typeof payload.elapsed_seconds === "number" ? payload.elapsed_seconds : void 0;
|
|
36326
|
-
onProgress({
|
|
36327
|
-
progress: remoteProgress,
|
|
36328
|
-
total: remoteProgress === void 0 ? void 0 : 100,
|
|
36329
|
-
phase: "async_build_poll",
|
|
36330
|
-
message: [
|
|
36331
|
-
`build_id=${watcher.state.taskId}`,
|
|
36332
|
-
`status=${result.status}`,
|
|
36333
|
-
remotePhase ? `phase=${remotePhase}` : "",
|
|
36334
|
-
elapsedSeconds !== void 0 ? `elapsed=${elapsedSeconds}s` : "",
|
|
36335
|
-
result.error ? `error=${formatAsyncBuildDiagnostic(result.error)}` : ""
|
|
36336
|
-
].filter(Boolean).join(" ")
|
|
36337
|
-
});
|
|
36338
|
-
}
|
|
36339
|
-
function stopExistingAsyncBuildResultWatcher(projectRoot, reason = "cancelled") {
|
|
36340
|
-
var _a3;
|
|
36341
|
-
const activeFile = getAsyncBuildActiveFilePath(projectRoot);
|
|
36342
|
-
const active = readJsonFile2(activeFile);
|
|
36343
|
-
const watcher = activeAsyncBuildWatchers.get(activeFile);
|
|
36344
|
-
if (!active && !watcher) {
|
|
36345
|
-
return {};
|
|
36346
|
-
}
|
|
36347
|
-
const stateFile = (active == null ? void 0 : active.stateFile) || (watcher == null ? void 0 : watcher.stateFile);
|
|
36348
|
-
const taskId = (active == null ? void 0 : active.taskId) || (watcher == null ? void 0 : watcher.state.taskId);
|
|
36349
|
-
if (stateFile && fs14.existsSync(stateFile)) {
|
|
36350
|
-
const existing = readJsonFile2(stateFile) || {};
|
|
36351
|
-
writeJsonFile2(stateFile, {
|
|
36352
|
-
...existing,
|
|
36353
|
-
status: reason,
|
|
36354
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
36355
|
-
});
|
|
36356
|
-
}
|
|
36357
|
-
if (watcher) {
|
|
36358
|
-
updateAsyncBuildWatcherState(watcher, {
|
|
36359
|
-
status: reason,
|
|
36360
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
36361
|
-
});
|
|
36362
|
-
stopAsyncBuildWatcherRuntime(watcher);
|
|
36363
|
-
(_a3 = watcher.complete) == null ? void 0 : _a3.call(watcher, watcher.state);
|
|
36364
|
-
} else {
|
|
36365
|
-
fs14.rmSync(activeFile, { force: true });
|
|
36366
|
-
}
|
|
36367
|
-
return {
|
|
36368
|
-
previousTaskId: taskId,
|
|
36369
|
-
previousStopped: Boolean(taskId)
|
|
36370
|
-
};
|
|
36371
|
-
}
|
|
36372
|
-
async function finishAsyncBuildSuccessSideEffects(watcher, options) {
|
|
36373
|
-
const buildResult = asyncWatcherStateToRemoteBuildResult(
|
|
36374
|
-
watcher.state,
|
|
36375
|
-
watcher.sourceBuildResult
|
|
36376
|
-
);
|
|
36377
|
-
if (options.refreshPreview) {
|
|
36378
|
-
try {
|
|
36379
|
-
updateAsyncBuildWatcherState(watcher, {
|
|
36380
|
-
previewRefresh: await options.refreshPreview(buildResult)
|
|
36381
|
-
});
|
|
36382
|
-
} catch (error2) {
|
|
36383
|
-
updateAsyncBuildWatcherState(watcher, {
|
|
36384
|
-
previewRefresh: {
|
|
36385
|
-
ok: false,
|
|
36386
|
-
status: 0,
|
|
36387
|
-
url: "",
|
|
36388
|
-
error: error2 instanceof Error ? error2.message : String(error2)
|
|
36389
|
-
}
|
|
36390
|
-
});
|
|
36391
|
-
}
|
|
36392
|
-
}
|
|
36393
|
-
if (options.startRuntimeLogWatch) {
|
|
36394
|
-
try {
|
|
36395
|
-
updateAsyncBuildWatcherState(watcher, {
|
|
36396
|
-
runtimeLogWatch: await options.startRuntimeLogWatch(buildResult)
|
|
36397
|
-
});
|
|
36398
|
-
} catch (error2) {
|
|
36399
|
-
updateAsyncBuildWatcherState(watcher, {
|
|
36400
|
-
runtimeLogWatch: {
|
|
36401
|
-
started: false,
|
|
36402
|
-
command: "",
|
|
36403
|
-
runtimeLog: "",
|
|
36404
|
-
error: error2 instanceof Error ? error2.message : String(error2)
|
|
36405
|
-
}
|
|
36406
|
-
});
|
|
36407
|
-
}
|
|
36408
|
-
}
|
|
36409
|
-
}
|
|
36410
|
-
function asyncWatcherStateToRemoteBuildResult(state, originalBuildResult) {
|
|
36411
|
-
return {
|
|
36412
|
-
mode: "remote_build",
|
|
36413
|
-
projectRoot: state.projectRoot,
|
|
36414
|
-
projectId: state.projectId,
|
|
36415
|
-
projectPath: state.projectPath,
|
|
36416
|
-
serverUrl: state.serverUrl,
|
|
36417
|
-
env: state.env,
|
|
36418
|
-
makerUrl: formatMakerAppWebUrl(state.projectId, state.env),
|
|
36419
|
-
timeoutMs: (originalBuildResult == null ? void 0 : originalBuildResult.timeoutMs) || DEFAULT_BUILD_TIMEOUT_MS,
|
|
36420
|
-
buildArgs: (originalBuildResult == null ? void 0 : originalBuildResult.buildArgs) || {},
|
|
36421
|
-
resultText: state.resultText || "",
|
|
36422
|
-
previewRefresh: state.previewRefresh,
|
|
36423
|
-
runtimeLogWatch: state.runtimeLogWatch
|
|
36424
|
-
};
|
|
36425
|
-
}
|
|
36426
|
-
function updateAsyncBuildWatcherState(watcher, patch) {
|
|
36427
|
-
watcher.state = {
|
|
36428
|
-
...watcher.state,
|
|
36429
|
-
...patch,
|
|
36430
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
36431
|
-
};
|
|
36432
|
-
writeJsonFile2(watcher.stateFile, watcher.state);
|
|
36433
|
-
}
|
|
36434
|
-
function getAsyncBuildWatcherPaths(projectRoot, taskId) {
|
|
36435
|
-
const normalizedProjectRoot = normalizeExistingProjectPath(projectRoot);
|
|
36436
|
-
const buildDir = path15.join(normalizedProjectRoot, ".maker", "builds");
|
|
36437
|
-
return {
|
|
36438
|
-
activeFile: getAsyncBuildActiveFilePath(projectRoot),
|
|
36439
|
-
stateFile: path15.join(buildDir, `${sanitizeAsyncBuildTaskId(taskId)}.json`)
|
|
36440
|
-
};
|
|
36441
|
-
}
|
|
36442
|
-
function getAsyncBuildActiveFilePath(projectRoot) {
|
|
36443
|
-
const normalizedProjectRoot = normalizeExistingProjectPath(projectRoot);
|
|
36444
|
-
return path15.join(normalizedProjectRoot, ".maker", "builds", "active-build.json");
|
|
36445
|
-
}
|
|
36446
|
-
function normalizeExistingProjectPath(projectRoot) {
|
|
36447
|
-
try {
|
|
36448
|
-
return fs14.realpathSync(projectRoot);
|
|
36449
|
-
} catch {
|
|
36450
|
-
return path15.resolve(projectRoot);
|
|
36451
|
-
}
|
|
36452
|
-
}
|
|
36453
|
-
function sanitizeAsyncBuildTaskId(taskId) {
|
|
36454
|
-
return taskId.replace(/[^A-Za-z0-9_.-]/g, "_") || "unknown-task";
|
|
36455
|
-
}
|
|
36456
|
-
function writeJsonFile2(filePath, value) {
|
|
36457
|
-
fs14.mkdirSync(path15.dirname(filePath), { recursive: true });
|
|
36458
|
-
fs14.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}
|
|
36459
|
-
`, "utf8");
|
|
36460
|
-
}
|
|
36461
|
-
function readJsonFile2(filePath) {
|
|
36462
|
-
if (!fs14.existsSync(filePath)) {
|
|
36463
|
-
return void 0;
|
|
36464
|
-
}
|
|
36465
|
-
try {
|
|
36466
|
-
return JSON.parse(fs14.readFileSync(filePath, "utf8"));
|
|
36467
|
-
} catch {
|
|
36468
|
-
return void 0;
|
|
36469
|
-
}
|
|
36470
|
-
}
|
|
36471
35858
|
function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
36472
35859
|
if (!fs14.existsSync(pidFile)) {
|
|
36473
35860
|
return {};
|
|
@@ -36769,41 +36156,8 @@ function createBuildArgs(projectRoot, options) {
|
|
|
36769
36156
|
} else if (!fs14.existsSync(path15.join(projectRoot, ".project", "settings.json"))) {
|
|
36770
36157
|
buildArgs.multiplayer = { enabled: false };
|
|
36771
36158
|
}
|
|
36772
|
-
if (shouldForwardAsyncBuild(options.asyncBuild, options.clientIde)) {
|
|
36773
|
-
buildArgs[getRemoteAsyncBuildParamName()] = getRemoteAsyncBuildParamValue();
|
|
36774
|
-
}
|
|
36775
36159
|
return buildArgs;
|
|
36776
36160
|
}
|
|
36777
|
-
function shouldForwardAsyncBuild(asyncBuild, clientIde) {
|
|
36778
|
-
if (asyncBuild === true) {
|
|
36779
|
-
return true;
|
|
36780
|
-
}
|
|
36781
|
-
if (asyncBuild === false) {
|
|
36782
|
-
return false;
|
|
36783
|
-
}
|
|
36784
|
-
return normalizeClientIde(clientIde || process.env.TAPTAP_MCP_CLIENT_IDE) === "workbuddy";
|
|
36785
|
-
}
|
|
36786
|
-
function normalizeClientIde(clientIde) {
|
|
36787
|
-
return (clientIde || "").trim().toLowerCase();
|
|
36788
|
-
}
|
|
36789
|
-
function getRemoteAsyncBuildParamName() {
|
|
36790
|
-
var _a3;
|
|
36791
|
-
const paramName = (_a3 = process.env.TAPTAP_MAKER_REMOTE_ASYNC_BUILD_PARAM) == null ? void 0 : _a3.trim();
|
|
36792
|
-
return paramName || DEFAULT_REMOTE_ASYNC_BUILD_PARAM;
|
|
36793
|
-
}
|
|
36794
|
-
function getRemoteAsyncBuildParamValue() {
|
|
36795
|
-
const rawValue = process.env.TAPTAP_MAKER_REMOTE_ASYNC_BUILD_VALUE_JSON;
|
|
36796
|
-
if (!rawValue) {
|
|
36797
|
-
return true;
|
|
36798
|
-
}
|
|
36799
|
-
try {
|
|
36800
|
-
return JSON.parse(rawValue);
|
|
36801
|
-
} catch (error2) {
|
|
36802
|
-
throw new Error(
|
|
36803
|
-
`Invalid TAPTAP_MAKER_REMOTE_ASYNC_BUILD_VALUE_JSON: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
36804
|
-
);
|
|
36805
|
-
}
|
|
36806
|
-
}
|
|
36807
36161
|
function mergeStringEnv(...sources) {
|
|
36808
36162
|
const result = {};
|
|
36809
36163
|
for (const source of sources) {
|
|
@@ -36834,7 +36188,6 @@ function formatRemoteToolResult(result) {
|
|
|
36834
36188
|
}).join("\n");
|
|
36835
36189
|
}
|
|
36836
36190
|
function formatBuildResult(result, progressSummary) {
|
|
36837
|
-
var _a3, _b;
|
|
36838
36191
|
if (result.mode === "remote_build_failed") {
|
|
36839
36192
|
return [
|
|
36840
36193
|
"✗ Remote Maker build failed",
|
|
@@ -36897,35 +36250,6 @@ function formatBuildResult(result, progressSummary) {
|
|
|
36897
36250
|
...formatMakerBuildFailureLines(result.buildFailure)
|
|
36898
36251
|
].filter(Boolean).join("\n");
|
|
36899
36252
|
}
|
|
36900
|
-
if (result.mode === "remote_build_async_started") {
|
|
36901
|
-
return [
|
|
36902
|
-
result.submitResult ? "✓ Maker project submitted, then remote Maker async build started" : "✓ Remote Maker async build started",
|
|
36903
|
-
"",
|
|
36904
|
-
`- project_root: ${result.projectRoot}`,
|
|
36905
|
-
`- project_id: ${result.projectId}`,
|
|
36906
|
-
`- maker_url: ${result.makerUrl || formatMakerAppWebUrl(result.projectId, result.env)}`,
|
|
36907
|
-
`- project_path: ${result.projectPath}`,
|
|
36908
|
-
`- server_url: ${result.serverUrl}`,
|
|
36909
|
-
`- env: ${result.env}`,
|
|
36910
|
-
`- build_id: ${result.taskId}`,
|
|
36911
|
-
result.reused !== void 0 ? `- reused: ${result.reused ? "yes" : "no"}` : "",
|
|
36912
|
-
`- timeout_ms: ${result.timeoutMs}`,
|
|
36913
|
-
`- build_args: ${JSON.stringify(result.buildArgs)}`,
|
|
36914
|
-
result.asyncBuildWatch ? `- async_watch_started: ${result.asyncBuildWatch.started ? "yes" : "no"}` : "",
|
|
36915
|
-
result.asyncBuildWatch ? `- async_watch_state_file: ${result.asyncBuildWatch.stateFile}` : "",
|
|
36916
|
-
result.asyncBuildWatch ? `- async_watch_active_file: ${result.asyncBuildWatch.activeFile}` : "",
|
|
36917
|
-
result.asyncBuildWatch ? `- async_watch_poll_interval_ms: ${result.asyncBuildWatch.pollIntervalMs}` : "",
|
|
36918
|
-
result.asyncBuildWatch ? `- async_watch_timeout_ms: ${result.asyncBuildWatch.timeoutMs}` : "",
|
|
36919
|
-
((_a3 = result.asyncBuildWatch) == null ? void 0 : _a3.previousTaskId) ? `- previous_async_build_id: ${result.asyncBuildWatch.previousTaskId}` : "",
|
|
36920
|
-
((_b = result.asyncBuildWatch) == null ? void 0 : _b.previousStopped) !== void 0 ? `- previous_async_watch_stopped: ${result.asyncBuildWatch.previousStopped ? "yes" : "no"}` : "",
|
|
36921
|
-
...formatProgressSummary(progressSummary),
|
|
36922
|
-
"",
|
|
36923
|
-
"note: 远端异步构建已启动;本地每 5 秒查询一次结果,最多轮询 30 分钟。",
|
|
36924
|
-
"note: 如果同一 Maker 项目再次触发构建,上一轮异步轮询会被取消。",
|
|
36925
|
-
"remote_result:",
|
|
36926
|
-
indent2(result.resultText)
|
|
36927
|
-
].filter(Boolean).join("\n");
|
|
36928
|
-
}
|
|
36929
36253
|
const submitLines = result.submitResult ? [
|
|
36930
36254
|
"submit_result:",
|
|
36931
36255
|
` - branch: ${result.submitResult.branch}`,
|
|
@@ -37334,7 +36658,7 @@ function formatError2(error2) {
|
|
|
37334
36658
|
}
|
|
37335
36659
|
|
|
37336
36660
|
// src/maker/cli/commands.ts
|
|
37337
|
-
var VERSION2 = true ? "0.0.
|
|
36661
|
+
var VERSION2 = true ? "0.0.23-beta.1" : "dev";
|
|
37338
36662
|
var DEFAULT_MCP_NAME = "taptap-maker";
|
|
37339
36663
|
var MAKER_NPM_PACKAGE = "@taptap/maker";
|
|
37340
36664
|
var TWO_PART_COMMANDS = /* @__PURE__ */ new Set(["pat", "mcp", "dev-kit", "logs", "python", "lua-lsp", "agents"]);
|
|
@@ -37584,6 +36908,7 @@ async function runDoctor(parsed, ctx) {
|
|
|
37584
36908
|
const mcpToolsAvailability = inspectMakerMcpToolsAvailability({
|
|
37585
36909
|
makerProjectDir: identify.projectRoot
|
|
37586
36910
|
});
|
|
36911
|
+
const workBuddyTrust = shouldShowWorkBuddyTrustInspection() ? inspectWorkBuddyTrustState(DEFAULT_MCP_NAME) : void 0;
|
|
37587
36912
|
if (ctx.json) {
|
|
37588
36913
|
writeJson({
|
|
37589
36914
|
env,
|
|
@@ -37600,6 +36925,7 @@ async function runDoctor(parsed, ctx) {
|
|
|
37600
36925
|
dev_kit_update: devKitUpdate,
|
|
37601
36926
|
package_update: packageUpdate,
|
|
37602
36927
|
mcp_tools_availability: mcpToolsAvailability,
|
|
36928
|
+
...workBuddyTrust ? { workbuddy_trust: workBuddyTrust } : {},
|
|
37603
36929
|
orphan_process_check: orphanProcessCheck
|
|
37604
36930
|
});
|
|
37605
36931
|
return;
|
|
@@ -37639,6 +36965,7 @@ async function runDoctor(parsed, ctx) {
|
|
|
37639
36965
|
"",
|
|
37640
36966
|
formatMakerMcpToolsAvailability(mcpToolsAvailability),
|
|
37641
36967
|
"",
|
|
36968
|
+
workBuddyTrust ? formatWorkBuddyTrustInspection(workBuddyTrust) : "",
|
|
37642
36969
|
formatMakerOrphanProcessStatus(orphanProcessCheck),
|
|
37643
36970
|
"",
|
|
37644
36971
|
formatMakerSkillStatus({ projectRoot }),
|
|
@@ -38623,15 +37950,24 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
38623
37950
|
return [result];
|
|
38624
37951
|
}
|
|
38625
37952
|
if (ide === "workbuddy") {
|
|
38626
|
-
|
|
37953
|
+
const results = installJsonMcpConfigTargets(
|
|
38627
37954
|
ide,
|
|
38628
37955
|
getWorkBuddyMcpInstallPaths({ createPrimary: true }),
|
|
38629
37956
|
"WorkBuddy",
|
|
38630
37957
|
{
|
|
38631
37958
|
...options,
|
|
38632
|
-
clientIde: "workbuddy"
|
|
37959
|
+
clientIde: "workbuddy",
|
|
37960
|
+
disabled: false
|
|
38633
37961
|
}
|
|
38634
37962
|
);
|
|
37963
|
+
const trust = inspectWorkBuddyTrustState(options.mcpName);
|
|
37964
|
+
return results.map(
|
|
37965
|
+
(result) => result.ok ? {
|
|
37966
|
+
...result,
|
|
37967
|
+
message: `${result.message}
|
|
37968
|
+
${formatWorkBuddyTrustInspection(trust)}`
|
|
37969
|
+
} : result
|
|
37970
|
+
);
|
|
38635
37971
|
}
|
|
38636
37972
|
return [{ ide, ok: false, message: `Skipped unknown IDE: ${ide}` }];
|
|
38637
37973
|
}
|
|
@@ -38743,17 +38079,105 @@ function getTraeUnverifiedMcpConfigPaths() {
|
|
|
38743
38079
|
function getOpenCodeMcpConfigPath() {
|
|
38744
38080
|
return path16.join(os4.homedir(), ".config", "opencode", "opencode.jsonc");
|
|
38745
38081
|
}
|
|
38082
|
+
function getWorkBuddyHome() {
|
|
38083
|
+
return path16.join(os4.homedir(), ".workbuddy");
|
|
38084
|
+
}
|
|
38085
|
+
function shouldShowWorkBuddyTrustInspection() {
|
|
38086
|
+
return fs15.existsSync(getWorkBuddyHome());
|
|
38087
|
+
}
|
|
38746
38088
|
function getWorkBuddyMcpInstallPaths(options = {}) {
|
|
38747
|
-
const primary = path16.join(
|
|
38089
|
+
const primary = path16.join(getWorkBuddyHome(), "mcp.json");
|
|
38748
38090
|
if (fs15.existsSync(primary) || options.createPrimary) {
|
|
38749
38091
|
return [primary];
|
|
38750
38092
|
}
|
|
38751
|
-
const legacy = path16.join(
|
|
38093
|
+
const legacy = path16.join(getWorkBuddyHome(), ".mcp.json");
|
|
38752
38094
|
if (fs15.existsSync(legacy)) {
|
|
38753
38095
|
return [legacy];
|
|
38754
38096
|
}
|
|
38755
38097
|
return [];
|
|
38756
38098
|
}
|
|
38099
|
+
function inspectWorkBuddyTrustState(mcpName) {
|
|
38100
|
+
const workbuddyHome = getWorkBuddyHome();
|
|
38101
|
+
const connectorsDir = path16.join(workbuddyHome, "connectors");
|
|
38102
|
+
const accounts = [];
|
|
38103
|
+
const stateFiles = [];
|
|
38104
|
+
if (!fs15.existsSync(connectorsDir)) {
|
|
38105
|
+
return {
|
|
38106
|
+
status: "not_found",
|
|
38107
|
+
mcp_name: mcpName,
|
|
38108
|
+
workbuddy_home: workbuddyHome,
|
|
38109
|
+
connectors_dir: connectorsDir,
|
|
38110
|
+
state_files: [],
|
|
38111
|
+
accounts
|
|
38112
|
+
};
|
|
38113
|
+
}
|
|
38114
|
+
for (const entry of fs15.readdirSync(connectorsDir, { withFileTypes: true })) {
|
|
38115
|
+
if (!entry.isDirectory()) {
|
|
38116
|
+
continue;
|
|
38117
|
+
}
|
|
38118
|
+
const statePath = path16.join(connectorsDir, entry.name, "connector-states.json");
|
|
38119
|
+
if (!fs15.existsSync(statePath)) {
|
|
38120
|
+
continue;
|
|
38121
|
+
}
|
|
38122
|
+
stateFiles.push(statePath);
|
|
38123
|
+
let state;
|
|
38124
|
+
try {
|
|
38125
|
+
state = readJsonObject(statePath);
|
|
38126
|
+
} catch {
|
|
38127
|
+
continue;
|
|
38128
|
+
}
|
|
38129
|
+
accounts.push({
|
|
38130
|
+
account_id: entry.name,
|
|
38131
|
+
path: statePath,
|
|
38132
|
+
enabled: asStringArray(state.enabled).includes(mcpName),
|
|
38133
|
+
ever_connected: asStringArray(state.everConnected).includes(mcpName),
|
|
38134
|
+
user_disabled: asStringArray(state.userDisabled).includes(mcpName)
|
|
38135
|
+
});
|
|
38136
|
+
}
|
|
38137
|
+
const trusted = accounts.some((account) => account.enabled && !account.user_disabled);
|
|
38138
|
+
return {
|
|
38139
|
+
status: trusted ? "trusted" : stateFiles.length > 0 ? "pending" : "not_found",
|
|
38140
|
+
mcp_name: mcpName,
|
|
38141
|
+
workbuddy_home: workbuddyHome,
|
|
38142
|
+
connectors_dir: connectorsDir,
|
|
38143
|
+
state_files: stateFiles,
|
|
38144
|
+
accounts
|
|
38145
|
+
};
|
|
38146
|
+
}
|
|
38147
|
+
function asStringArray(value) {
|
|
38148
|
+
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
|
|
38149
|
+
}
|
|
38150
|
+
function formatWorkBuddyTrustInspection(inspection) {
|
|
38151
|
+
const lines = [
|
|
38152
|
+
"WorkBuddy MCP trust",
|
|
38153
|
+
`- config_server: ${inspection.mcp_name}`,
|
|
38154
|
+
'- config_requirement: mcp.json mcpServers entry must include "disabled": false.',
|
|
38155
|
+
`- trust_storage: ${getReadableWorkBuddyTrustPath()}`
|
|
38156
|
+
];
|
|
38157
|
+
if (inspection.status === "trusted") {
|
|
38158
|
+
const trustedAccounts = inspection.accounts.filter((account) => account.enabled && !account.user_disabled).map((account) => account.account_id);
|
|
38159
|
+
lines.push(`- status: trusted (${trustedAccounts.join(", ")})`);
|
|
38160
|
+
lines.push("- next_action: none");
|
|
38161
|
+
return lines.join("\n");
|
|
38162
|
+
}
|
|
38163
|
+
if (inspection.status === "pending") {
|
|
38164
|
+
lines.push("- status: pending_user_trust");
|
|
38165
|
+
lines.push(`- state_files: ${inspection.state_files.join(", ")}`);
|
|
38166
|
+
} else {
|
|
38167
|
+
lines.push("- status: trust_state_not_found");
|
|
38168
|
+
lines.push(`- checked: ${inspection.connectors_dir}`);
|
|
38169
|
+
}
|
|
38170
|
+
lines.push(
|
|
38171
|
+
`- expected_state: enabled includes "${inspection.mcp_name}" and userDisabled does not include it.`
|
|
38172
|
+
);
|
|
38173
|
+
lines.push(
|
|
38174
|
+
`- next_action: Open WorkBuddy MCP settings, enable/trust ${inspection.mcp_name}, then reconnect or restart WorkBuddy.`
|
|
38175
|
+
);
|
|
38176
|
+
return lines.join("\n");
|
|
38177
|
+
}
|
|
38178
|
+
function getReadableWorkBuddyTrustPath() {
|
|
38179
|
+
return process.platform === "win32" ? "%USERPROFILE%\\.workbuddy\\connectors\\<account-id>\\connector-states.json" : "~/.workbuddy/connectors/<account-id>/connector-states.json";
|
|
38180
|
+
}
|
|
38757
38181
|
function mergeJsonMcpConfig(configPath, options) {
|
|
38758
38182
|
const existing = readJsonObject(configPath);
|
|
38759
38183
|
const mcpServers = asObject(existing.mcpServers);
|
|
@@ -38896,7 +38320,8 @@ function createJsonMcpServerConfig(options) {
|
|
|
38896
38320
|
command: launch.command,
|
|
38897
38321
|
args: launch.args,
|
|
38898
38322
|
...options.cwd ? { cwd: options.cwd } : {},
|
|
38899
|
-
...createOptionalMcpEnvironment(options.env, "env", options.clientIde)
|
|
38323
|
+
...createOptionalMcpEnvironment(options.env, "env", options.clientIde),
|
|
38324
|
+
...options.disabled !== void 0 ? { disabled: options.disabled } : {}
|
|
38900
38325
|
};
|
|
38901
38326
|
}
|
|
38902
38327
|
function createOpenCodeMcpServerConfig(options) {
|