@chrrxs/robloxstudio-mcp-inspector 3.4.2 → 3.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +332 -105
- package/package.json +1 -1
- package/studio-plugin/MCPInspectorPlugin.rbxmx +310 -70
package/dist/index.js
CHANGED
|
@@ -9725,6 +9725,9 @@ var MAX_PRICE_ROBUX2 = 1e9;
|
|
|
9725
9725
|
var MAX_NAME_SCAN_PAGES = 200;
|
|
9726
9726
|
var MAX_ICON_BYTES = 10 * 1024 * 1024;
|
|
9727
9727
|
var PNG_SIGNATURE2 = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
9728
|
+
var UNKNOWN_CREATE_WINDOW_MS = 10 * 60 * 1e3;
|
|
9729
|
+
var UNKNOWN_CREATE_HINT = "An item may have been created; run list (or get) before retrying create.";
|
|
9730
|
+
var PENDING_UNKNOWN_CREATE_HINT = "No item with this name is listed yet. If list still shows none, create can be retried after retry_after.";
|
|
9728
9731
|
var SCOPE_PREFIX = {
|
|
9729
9732
|
developer_product: "developer-product",
|
|
9730
9733
|
game_pass: "game-pass"
|
|
@@ -9865,19 +9868,111 @@ function itemLabel(kind) {
|
|
|
9865
9868
|
function comparableName(name) {
|
|
9866
9869
|
return name.trim().toLowerCase();
|
|
9867
9870
|
}
|
|
9868
|
-
|
|
9871
|
+
function nameKey(universeId, kind, name) {
|
|
9872
|
+
return `${universeId}:${kind}:${comparableName(name)}`;
|
|
9873
|
+
}
|
|
9874
|
+
var nameLocks = /* @__PURE__ */ new Map();
|
|
9875
|
+
async function withNameLock(key, run2) {
|
|
9876
|
+
const previous = nameLocks.get(key) ?? Promise.resolve();
|
|
9877
|
+
const { promise: released, resolve: release } = Promise.withResolvers();
|
|
9878
|
+
const tail = previous.then(() => released);
|
|
9879
|
+
nameLocks.set(key, tail);
|
|
9880
|
+
await previous;
|
|
9881
|
+
try {
|
|
9882
|
+
return await run2();
|
|
9883
|
+
} finally {
|
|
9884
|
+
release();
|
|
9885
|
+
if (nameLocks.get(key) === tail)
|
|
9886
|
+
nameLocks.delete(key);
|
|
9887
|
+
}
|
|
9888
|
+
}
|
|
9889
|
+
var unknownCreates = /* @__PURE__ */ new Map();
|
|
9890
|
+
function rememberUnknownCreate(key) {
|
|
9891
|
+
const now = Date.now();
|
|
9892
|
+
for (const [other, failedAt] of unknownCreates) {
|
|
9893
|
+
if (now - failedAt >= UNKNOWN_CREATE_WINDOW_MS)
|
|
9894
|
+
unknownCreates.delete(other);
|
|
9895
|
+
}
|
|
9896
|
+
unknownCreates.set(key, now);
|
|
9897
|
+
return now;
|
|
9898
|
+
}
|
|
9899
|
+
function unknownCreateRetryAfter(key) {
|
|
9900
|
+
const failedAt = unknownCreates.get(key);
|
|
9901
|
+
if (failedAt === void 0)
|
|
9902
|
+
return void 0;
|
|
9903
|
+
if (Date.now() - failedAt < UNKNOWN_CREATE_WINDOW_MS)
|
|
9904
|
+
return retryAfter(failedAt);
|
|
9905
|
+
unknownCreates.delete(key);
|
|
9906
|
+
return void 0;
|
|
9907
|
+
}
|
|
9908
|
+
function retryAfter(failedAt) {
|
|
9909
|
+
return new Date(failedAt + UNKNOWN_CREATE_WINDOW_MS).toISOString();
|
|
9910
|
+
}
|
|
9911
|
+
function pendingUnknownCreate(kind, universeId, name, retryAfterTime, action) {
|
|
9912
|
+
return new MonetizationError("create_outcome_unknown", `A recent create of the ${itemLabel(kind)} "${name}" in universe ${universeId} may have succeeded, but no item with that name is listed yet, so nothing was ${action}.`, { hint: PENDING_UNKNOWN_CREATE_HINT, retry_after: retryAfterTime });
|
|
9913
|
+
}
|
|
9914
|
+
function forgetUnknownCreates(items) {
|
|
9915
|
+
for (const item of items)
|
|
9916
|
+
unknownCreates.delete(nameKey(item.universeId, item.kind, item.name));
|
|
9917
|
+
}
|
|
9918
|
+
async function findItemNamed(client, kind, universeId, name, excludeId) {
|
|
9869
9919
|
const wanted = comparableName(name);
|
|
9870
9920
|
let pageToken;
|
|
9871
9921
|
for (let page = 0; page < MAX_NAME_SCAN_PAGES; page++) {
|
|
9872
9922
|
const result = await client.listMonetizationItems(kind, universeId, pageToken);
|
|
9873
|
-
|
|
9923
|
+
forgetUnknownCreates(result.items);
|
|
9924
|
+
const match = result.items.find((candidate) => candidate.id !== excludeId && comparableName(candidate.name) === wanted);
|
|
9874
9925
|
if (match)
|
|
9875
9926
|
return match;
|
|
9876
9927
|
if (!result.nextPageToken)
|
|
9877
9928
|
return void 0;
|
|
9878
9929
|
pageToken = result.nextPageToken;
|
|
9879
9930
|
}
|
|
9880
|
-
throw new MonetizationError("duplicate_check_incomplete", `Stopped looking for an existing ${itemLabel(kind)} named "${name}" after ${MAX_NAME_SCAN_PAGES} pages, so nothing was created.`);
|
|
9931
|
+
throw new MonetizationError("duplicate_check_incomplete", `Stopped looking for an existing ${itemLabel(kind)} named "${name}" after ${MAX_NAME_SCAN_PAGES} pages, so nothing was ${excludeId === void 0 ? "created" : "changed"}.`);
|
|
9932
|
+
}
|
|
9933
|
+
function duplicateName(kind, universeId, existing) {
|
|
9934
|
+
return new MonetizationError("duplicate_name", `A ${itemLabel(kind)} named "${existing.name}" already exists in universe ${universeId}. Update it or choose another name.`, { existing: publicItem(existing) });
|
|
9935
|
+
}
|
|
9936
|
+
async function createNamed(client, kind, universeId, item) {
|
|
9937
|
+
const { name } = item;
|
|
9938
|
+
const key = nameKey(universeId, kind, name);
|
|
9939
|
+
return withNameLock(key, async () => {
|
|
9940
|
+
const existing = await findItemNamed(client, kind, universeId, name);
|
|
9941
|
+
if (existing)
|
|
9942
|
+
throw duplicateName(kind, universeId, existing);
|
|
9943
|
+
const pendingRetryAfter = unknownCreateRetryAfter(key);
|
|
9944
|
+
if (pendingRetryAfter)
|
|
9945
|
+
throw pendingUnknownCreate(kind, universeId, name, pendingRetryAfter, "created");
|
|
9946
|
+
let created;
|
|
9947
|
+
try {
|
|
9948
|
+
created = await client.createMonetizationItem(kind, universeId, item);
|
|
9949
|
+
} catch (error) {
|
|
9950
|
+
if (error instanceof OpenCloudRequestError && error.status < 500)
|
|
9951
|
+
throw error;
|
|
9952
|
+
const failedAt = rememberUnknownCreate(key);
|
|
9953
|
+
const reason = error instanceof OpenCloudRequestError ? `HTTP ${error.status}: ${error.message}` : error instanceof Error ? error.message : String(error);
|
|
9954
|
+
throw new MonetizationError("create_outcome_unknown", `Could not confirm whether the ${itemLabel(kind)} "${name}" was created in universe ${universeId}: ${reason}`, { hint: UNKNOWN_CREATE_HINT, retry_after: retryAfter(failedAt) });
|
|
9955
|
+
}
|
|
9956
|
+
unknownCreates.delete(key);
|
|
9957
|
+
return created;
|
|
9958
|
+
});
|
|
9959
|
+
}
|
|
9960
|
+
async function updateItem(client, kind, universeId, id, changes) {
|
|
9961
|
+
const { name } = changes;
|
|
9962
|
+
if (name === void 0) {
|
|
9963
|
+
await client.updateMonetizationItem(kind, universeId, id, changes);
|
|
9964
|
+
return;
|
|
9965
|
+
}
|
|
9966
|
+
const key = nameKey(universeId, kind, name);
|
|
9967
|
+
await withNameLock(key, async () => {
|
|
9968
|
+
const existing = await findItemNamed(client, kind, universeId, name, id);
|
|
9969
|
+
if (existing)
|
|
9970
|
+
throw duplicateName(kind, universeId, existing);
|
|
9971
|
+
const pendingRetryAfter = unknownCreateRetryAfter(key);
|
|
9972
|
+
if (pendingRetryAfter)
|
|
9973
|
+
throw pendingUnknownCreate(kind, universeId, name, pendingRetryAfter, "renamed");
|
|
9974
|
+
await client.updateMonetizationItem(kind, universeId, id, changes);
|
|
9975
|
+
});
|
|
9881
9976
|
}
|
|
9882
9977
|
function requiredScopes2(request) {
|
|
9883
9978
|
const prefix = SCOPE_PREFIX[request.kind];
|
|
@@ -9942,6 +10037,7 @@ async function runAction2(request, universeId, client, icon) {
|
|
|
9942
10037
|
switch (request.action) {
|
|
9943
10038
|
case "list": {
|
|
9944
10039
|
const page = await client.listMonetizationItems(kind, universeId, request.pageToken);
|
|
10040
|
+
forgetUnknownCreates(page.items);
|
|
9945
10041
|
return {
|
|
9946
10042
|
kind,
|
|
9947
10043
|
universe_id: universeId,
|
|
@@ -9949,24 +10045,22 @@ async function runAction2(request, universeId, client, icon) {
|
|
|
9949
10045
|
...page.nextPageToken ? { next_page_token: page.nextPageToken } : {}
|
|
9950
10046
|
};
|
|
9951
10047
|
}
|
|
9952
|
-
case "get":
|
|
9953
|
-
|
|
10048
|
+
case "get": {
|
|
10049
|
+
const found = await client.getMonetizationItem(kind, universeId, requiredId(request));
|
|
10050
|
+
forgetUnknownCreates([found]);
|
|
10051
|
+
return { item: publicItem(found) };
|
|
10052
|
+
}
|
|
9954
10053
|
case "create": {
|
|
9955
|
-
const
|
|
9956
|
-
const existing = await findItemNamed(client, kind, universeId, name);
|
|
9957
|
-
if (existing) {
|
|
9958
|
-
throw new MonetizationError("duplicate_name", `A ${itemLabel(kind)} named "${existing.name}" already exists in universe ${universeId}. Update it or choose another name.`, { existing: publicItem(existing) });
|
|
9959
|
-
}
|
|
9960
|
-
const created = await client.createMonetizationItem(kind, universeId, {
|
|
10054
|
+
const created = await createNamed(client, kind, universeId, {
|
|
9961
10055
|
...changes,
|
|
9962
|
-
name,
|
|
10056
|
+
name: requiredName(request),
|
|
9963
10057
|
forSale: request.forSale ?? false
|
|
9964
10058
|
});
|
|
9965
10059
|
return { created: true, item: publicItem(created) };
|
|
9966
10060
|
}
|
|
9967
10061
|
case "update": {
|
|
9968
10062
|
const id = requiredId(request);
|
|
9969
|
-
await client
|
|
10063
|
+
await updateItem(client, kind, universeId, id, changes);
|
|
9970
10064
|
try {
|
|
9971
10065
|
return { updated: true, item: publicItem(await client.getMonetizationItem(kind, universeId, id)) };
|
|
9972
10066
|
} catch (error) {
|
|
@@ -10028,6 +10122,24 @@ async function runManageMonetization(request, context) {
|
|
|
10028
10122
|
}
|
|
10029
10123
|
}
|
|
10030
10124
|
|
|
10125
|
+
// ../core/dist/tools/playtest-start-errors.js
|
|
10126
|
+
var TEST_IN_PROGRESS = /previous one is still in progress/i;
|
|
10127
|
+
function describePlaytestStartFailure(studioError, subject) {
|
|
10128
|
+
if (TEST_IN_PROGRESS.test(studioError)) {
|
|
10129
|
+
return {
|
|
10130
|
+
error: "studio_test_in_progress",
|
|
10131
|
+
message: `Studio refused to start the ${subject} because it still considers a previous test in progress.`,
|
|
10132
|
+
studioError,
|
|
10133
|
+
recoveryHint: "If a test is still starting or running, end it first (solo_playtest stop or multiplayer_playtest end). If none is running, Studio is stuck in this state and stop/end cannot clear it: reopen the place (or restart Studio), then start the test again."
|
|
10134
|
+
};
|
|
10135
|
+
}
|
|
10136
|
+
return {
|
|
10137
|
+
error: "studio_start_failed",
|
|
10138
|
+
message: `Studio refused to start the ${subject}: ${studioError}`,
|
|
10139
|
+
studioError
|
|
10140
|
+
};
|
|
10141
|
+
}
|
|
10142
|
+
|
|
10031
10143
|
// ../core/dist/tools/definitions.js
|
|
10032
10144
|
var OPERATION_ID_PROPERTY = {
|
|
10033
10145
|
type: "string",
|
|
@@ -11531,7 +11643,7 @@ var TOOL_DEFINITIONS = [
|
|
|
11531
11643
|
{
|
|
11532
11644
|
name: "upload_asset",
|
|
11533
11645
|
category: "write",
|
|
11534
|
-
description: "Use to upload a local asset file to a Roblox user or group.",
|
|
11646
|
+
description: "Use to upload a local asset file to a Roblox user or group. Without userId or groupId, ROBLOX_CREATOR_GROUP_ID wins over ROBLOX_CREATOR_USER_ID.",
|
|
11535
11647
|
inputSchema: {
|
|
11536
11648
|
type: "object",
|
|
11537
11649
|
properties: {
|
|
@@ -11554,11 +11666,11 @@ var TOOL_DEFINITIONS = [
|
|
|
11554
11666
|
},
|
|
11555
11667
|
userId: {
|
|
11556
11668
|
type: "string",
|
|
11557
|
-
description: "Creator user ID;
|
|
11669
|
+
description: "Creator user ID; replaces env defaults (groupId wins if both)"
|
|
11558
11670
|
},
|
|
11559
11671
|
groupId: {
|
|
11560
11672
|
type: "string",
|
|
11561
|
-
description: "Creator group ID;
|
|
11673
|
+
description: "Creator group ID; replaces env defaults and wins over userId"
|
|
11562
11674
|
}
|
|
11563
11675
|
},
|
|
11564
11676
|
required: ["filePath", "assetType", "displayName"]
|
|
@@ -19204,6 +19316,7 @@ function analyzeMicroProfilerSession(session, options = {}) {
|
|
|
19204
19316
|
}
|
|
19205
19317
|
|
|
19206
19318
|
// ../core/dist/micro-profiler/capture.js
|
|
19319
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
19207
19320
|
import * as fs5 from "fs";
|
|
19208
19321
|
import * as os5 from "os";
|
|
19209
19322
|
import * as path10 from "path";
|
|
@@ -19265,7 +19378,8 @@ function defaultCaptureDirectory() {
|
|
|
19265
19378
|
function captureFileStamp(date) {
|
|
19266
19379
|
return date.toISOString().replace(/[:.]/g, "-");
|
|
19267
19380
|
}
|
|
19268
|
-
|
|
19381
|
+
var DEFAULT_CAPTURE_PRUNE_GRACE_MS = 10 * 6e4;
|
|
19382
|
+
async function pruneDefaultCaptures(directory, keep = KEPT_DEFAULT_CAPTURES, graceMs = DEFAULT_CAPTURE_PRUNE_GRACE_MS, now = Date.now()) {
|
|
19269
19383
|
let entries;
|
|
19270
19384
|
try {
|
|
19271
19385
|
entries = await fs5.promises.readdir(directory);
|
|
@@ -19273,19 +19387,36 @@ async function pruneDefaultCaptures(directory, keep = KEPT_DEFAULT_CAPTURES) {
|
|
|
19273
19387
|
return;
|
|
19274
19388
|
}
|
|
19275
19389
|
const captures = entries.filter((name) => name.startsWith("micro-profiler-") && name.endsWith(CAPTURE_EXTENSION)).sort();
|
|
19276
|
-
|
|
19390
|
+
const settled = [];
|
|
19391
|
+
for (const name of captures) {
|
|
19392
|
+
try {
|
|
19393
|
+
const stats = await fs5.promises.stat(path10.join(directory, name));
|
|
19394
|
+
if (now - stats.mtimeMs >= graceMs)
|
|
19395
|
+
settled.push(name);
|
|
19396
|
+
} catch {
|
|
19397
|
+
}
|
|
19398
|
+
}
|
|
19399
|
+
for (const name of settled.slice(0, Math.max(0, settled.length - keep))) {
|
|
19277
19400
|
await fs5.promises.rm(path10.join(directory, name), { force: true });
|
|
19278
19401
|
await fs5.promises.rm(path10.join(directory, `${name}${WINDOW_SIDECAR_SUFFIX}`), { force: true });
|
|
19279
19402
|
}
|
|
19280
19403
|
}
|
|
19281
19404
|
async function resolveCapturePath(outputPath, role, now = /* @__PURE__ */ new Date()) {
|
|
19282
19405
|
if (outputPath !== void 0 && outputPath !== "")
|
|
19283
|
-
return path10.resolve(outputPath);
|
|
19406
|
+
return { path: path10.resolve(outputPath), generated: false };
|
|
19284
19407
|
const directory = defaultCaptureDirectory();
|
|
19285
19408
|
await fs5.promises.mkdir(directory, { recursive: true });
|
|
19286
19409
|
await pruneDefaultCaptures(directory, KEPT_DEFAULT_CAPTURES - 1);
|
|
19287
19410
|
const safeRole = role.replace(/[^A-Za-z0-9-]/g, "_");
|
|
19288
|
-
|
|
19411
|
+
const uniqueId = `${process.pid}-${randomUUID5().slice(0, 8)}`;
|
|
19412
|
+
return {
|
|
19413
|
+
path: path10.join(directory, `micro-profiler-${captureFileStamp(now)}-${safeRole}-${uniqueId}${CAPTURE_EXTENSION}`),
|
|
19414
|
+
generated: true
|
|
19415
|
+
};
|
|
19416
|
+
}
|
|
19417
|
+
async function writeCaptureFile(target, bytes) {
|
|
19418
|
+
await fs5.promises.mkdir(path10.dirname(target.path), { recursive: true });
|
|
19419
|
+
await fs5.promises.writeFile(target.path, bytes, { flag: target.generated ? "wx" : "w" });
|
|
19289
19420
|
}
|
|
19290
19421
|
function parseCaptureTransfer(value) {
|
|
19291
19422
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
@@ -19385,7 +19516,7 @@ function windowFromRecording(recording) {
|
|
|
19385
19516
|
}
|
|
19386
19517
|
|
|
19387
19518
|
// ../core/dist/tools/index.js
|
|
19388
|
-
import { createHash as createHash3, randomUUID as
|
|
19519
|
+
import { createHash as createHash3, randomUUID as randomUUID6 } from "crypto";
|
|
19389
19520
|
|
|
19390
19521
|
// ../core/dist/tools/reference-uploads.js
|
|
19391
19522
|
var ReferenceUploadError = class extends Error {
|
|
@@ -19422,17 +19553,25 @@ var ReferenceUploads = class {
|
|
|
19422
19553
|
* The record for operationId after checking this request matches it.
|
|
19423
19554
|
* Undefined when this session has prepared nothing under that ID.
|
|
19424
19555
|
*/
|
|
19425
|
-
lookup(operationId, identityKey, targetPeerId) {
|
|
19426
|
-
const record = this.matching(operationId, identityKey, targetPeerId);
|
|
19556
|
+
lookup(operationId, identityKey, targetPeerId, targetInstanceId) {
|
|
19557
|
+
const record = this.matching(operationId, identityKey, targetPeerId, targetInstanceId);
|
|
19427
19558
|
return record && this.toView(record);
|
|
19428
19559
|
}
|
|
19560
|
+
/**
|
|
19561
|
+
* The Studio Instance an operation was pinned to, so a retry that names no
|
|
19562
|
+
* instance_id returns to it rather than to whichever Studio is connected now.
|
|
19563
|
+
*/
|
|
19564
|
+
pinnedInstance(operationId) {
|
|
19565
|
+
this.prune();
|
|
19566
|
+
return this.records.get(operationId)?.targetInstanceId;
|
|
19567
|
+
}
|
|
19429
19568
|
/**
|
|
19430
19569
|
* The image asset ID for this operation: reuses a finished upload, joins one
|
|
19431
19570
|
* in flight, resumes one Roblox accepted, or starts one. An upload whose
|
|
19432
19571
|
* outcome is unknown and cannot be resumed is refused, never repeated.
|
|
19433
19572
|
*/
|
|
19434
|
-
acquire(operationId, identityKey, targetPeerId, attempt) {
|
|
19435
|
-
let record = this.matching(operationId, identityKey, targetPeerId);
|
|
19573
|
+
acquire(operationId, identityKey, targetPeerId, targetInstanceId, attempt) {
|
|
19574
|
+
let record = this.matching(operationId, identityKey, targetPeerId, targetInstanceId);
|
|
19436
19575
|
if (record) {
|
|
19437
19576
|
if (record.inFlight)
|
|
19438
19577
|
return record.inFlight;
|
|
@@ -19451,7 +19590,16 @@ var ReferenceUploads = class {
|
|
|
19451
19590
|
record.createdAssetId = void 0;
|
|
19452
19591
|
} else {
|
|
19453
19592
|
const now = this.now();
|
|
19454
|
-
record = {
|
|
19593
|
+
record = {
|
|
19594
|
+
operationId,
|
|
19595
|
+
identityKey,
|
|
19596
|
+
targetPeerId,
|
|
19597
|
+
targetInstanceId,
|
|
19598
|
+
stage: "uploading",
|
|
19599
|
+
phase: "local",
|
|
19600
|
+
startedAt: now,
|
|
19601
|
+
updatedAt: now
|
|
19602
|
+
};
|
|
19455
19603
|
this.records.set(operationId, record);
|
|
19456
19604
|
this.prune();
|
|
19457
19605
|
}
|
|
@@ -19522,12 +19670,12 @@ var ReferenceUploads = class {
|
|
|
19522
19670
|
signal?.removeEventListener("abort", onAbort);
|
|
19523
19671
|
}
|
|
19524
19672
|
}
|
|
19525
|
-
matching(operationId, identityKey, targetPeerId) {
|
|
19673
|
+
matching(operationId, identityKey, targetPeerId, targetInstanceId) {
|
|
19526
19674
|
this.prune();
|
|
19527
19675
|
const record = this.records.get(operationId);
|
|
19528
19676
|
if (!record)
|
|
19529
19677
|
return void 0;
|
|
19530
|
-
if (record.identityKey !== identityKey || record.stage === "dispatched" && record.targetPeerId !== targetPeerId) {
|
|
19678
|
+
if (record.identityKey !== identityKey || record.targetInstanceId !== targetInstanceId || record.stage === "dispatched" && record.targetPeerId !== targetPeerId) {
|
|
19531
19679
|
throw new ReferenceUploadError(`Request ${operationId} already identifies a different operation; nothing was uploaded or sent`, "operation_id_collision");
|
|
19532
19680
|
}
|
|
19533
19681
|
return record;
|
|
@@ -19593,6 +19741,7 @@ var ReferenceUploads = class {
|
|
|
19593
19741
|
return {
|
|
19594
19742
|
stage: record.stage,
|
|
19595
19743
|
targetPeerId: record.targetPeerId,
|
|
19744
|
+
targetInstanceId: record.targetInstanceId,
|
|
19596
19745
|
startedAt: record.startedAt,
|
|
19597
19746
|
updatedAt: record.updatedAt,
|
|
19598
19747
|
...record.imageAssetId !== void 0 ? { imageAssetId: record.imageAssetId } : {},
|
|
@@ -19621,6 +19770,19 @@ var DEFAULT_ASSET_PREVIEW_DEPTH = 4;
|
|
|
19621
19770
|
var MAX_ASSET_PREVIEW_HIERARCHY_NODES = 100;
|
|
19622
19771
|
var MAX_SEARCH_ASSET_DESCRIPTION_LENGTH = 240;
|
|
19623
19772
|
var ROBLOX_CREATOR_USER_ID = 1;
|
|
19773
|
+
function resolveUploadCreator(userId, groupId) {
|
|
19774
|
+
if (groupId)
|
|
19775
|
+
return { groupId };
|
|
19776
|
+
if (userId)
|
|
19777
|
+
return { userId };
|
|
19778
|
+
const envGroupId = process.env.ROBLOX_CREATOR_GROUP_ID;
|
|
19779
|
+
if (envGroupId)
|
|
19780
|
+
return { groupId: envGroupId };
|
|
19781
|
+
const envUserId = process.env.ROBLOX_CREATOR_USER_ID;
|
|
19782
|
+
if (envUserId)
|
|
19783
|
+
return { userId: envUserId };
|
|
19784
|
+
return void 0;
|
|
19785
|
+
}
|
|
19624
19786
|
var MAX_DEVICE_MATRIX_ENTRIES = 6;
|
|
19625
19787
|
var MAX_NETWORK_PACKET_LOSS_PERCENT = 0.5;
|
|
19626
19788
|
var GREP_SCRIPTS_TIMEOUT_MS = 12e4;
|
|
@@ -20630,7 +20792,7 @@ var RobloxStudioTools = class {
|
|
|
20630
20792
|
data: this._routingErrorData()
|
|
20631
20793
|
});
|
|
20632
20794
|
}
|
|
20633
|
-
return dispatch(resolved.targetPeerId);
|
|
20795
|
+
return dispatch(resolved.targetPeerId, resolved.targetInstanceId);
|
|
20634
20796
|
}
|
|
20635
20797
|
// A grouped runtime process ID, or its role-suffixed Instance ID, names exactly
|
|
20636
20798
|
// one Peer. Solo playtest Peers share one Instance ID, so it names none of them.
|
|
@@ -20990,7 +21152,7 @@ var RobloxStudioTools = class {
|
|
|
20990
21152
|
const clientCount = this._clientRolesForScope(instanceId).length;
|
|
20991
21153
|
return { ok: false, roles, timedOut: true, extraClients: clientCount > expectedClientCount, clientCount };
|
|
20992
21154
|
}
|
|
20993
|
-
async _waitForRuntimeRolesFresh(instanceId, connectedAfter, requiredRoles, timeoutSec = 60) {
|
|
21155
|
+
async _waitForRuntimeRolesFresh(instanceId, connectedAfter, requiredRoles, timeoutSec = 60, soloStart) {
|
|
20994
21156
|
const deadline = Date.now() + timeoutSec * 1e3;
|
|
20995
21157
|
while (Date.now() < deadline) {
|
|
20996
21158
|
const refresh = this.bridge.refreshTopologyForRouting();
|
|
@@ -21002,6 +21164,12 @@ var RobloxStudioTools = class {
|
|
|
21002
21164
|
if (requiredRoles.every((role) => freshRoles.has(role))) {
|
|
21003
21165
|
return { ok: true, roles, timedOut: false };
|
|
21004
21166
|
}
|
|
21167
|
+
if (soloStart) {
|
|
21168
|
+
const studioError = await this._soloStartFailure(soloStart.editPeerId, soloStart.testId, deadline);
|
|
21169
|
+
if (studioError !== void 0) {
|
|
21170
|
+
return { ok: false, roles: this._rolesForScope(instanceId), timedOut: false, studioError };
|
|
21171
|
+
}
|
|
21172
|
+
}
|
|
21005
21173
|
await sleep2(250);
|
|
21006
21174
|
}
|
|
21007
21175
|
return {
|
|
@@ -21010,6 +21178,21 @@ var RobloxStudioTools = class {
|
|
|
21010
21178
|
timedOut: true
|
|
21011
21179
|
};
|
|
21012
21180
|
}
|
|
21181
|
+
// Studio's error when the edit plugin's Execute*Async call for this start failed.
|
|
21182
|
+
async _soloStartFailure(editPeerId, testId, deadline) {
|
|
21183
|
+
try {
|
|
21184
|
+
const remainingMs = Math.max(1, Math.min(1e3, deadline - Date.now()));
|
|
21185
|
+
const editState = await this._requestPeer("/api/multiplayer-test-state", {}, editPeerId, remainingMs);
|
|
21186
|
+
const solo = editState?.soloSession;
|
|
21187
|
+
if (solo === null || typeof solo !== "object" || !("testId" in solo) || !("phase" in solo))
|
|
21188
|
+
return void 0;
|
|
21189
|
+
if (solo.testId !== testId || solo.phase !== "failed")
|
|
21190
|
+
return void 0;
|
|
21191
|
+
return "error" in solo && typeof solo.error === "string" ? solo.error : "unknown error";
|
|
21192
|
+
} catch {
|
|
21193
|
+
return void 0;
|
|
21194
|
+
}
|
|
21195
|
+
}
|
|
21013
21196
|
async getFileTree(path12 = "", instance_id) {
|
|
21014
21197
|
const response = await this._callSingle("/api/file-tree", { path: path12 }, void 0, instance_id);
|
|
21015
21198
|
return {
|
|
@@ -22199,9 +22382,9 @@ var RobloxStudioTools = class {
|
|
|
22199
22382
|
let capturePath;
|
|
22200
22383
|
let saveError;
|
|
22201
22384
|
try {
|
|
22202
|
-
|
|
22203
|
-
|
|
22204
|
-
await
|
|
22385
|
+
const target2 = await resolveCapturePath(typeof outputPath === "string" ? outputPath : void 0, role);
|
|
22386
|
+
capturePath = target2.path;
|
|
22387
|
+
await writeCaptureFile(target2, bytes);
|
|
22205
22388
|
await writeWindowSidecar(capturePath, role, recording);
|
|
22206
22389
|
} catch (error) {
|
|
22207
22390
|
saveError = `Could not save the capture${capturePath ? ` to ${capturePath}` : ""}: ${errorMessage(error)}`;
|
|
@@ -22745,9 +22928,17 @@ var RobloxStudioTools = class {
|
|
|
22745
22928
|
let wait;
|
|
22746
22929
|
if (response?.success === true) {
|
|
22747
22930
|
const requiredRoles = mode === "play" ? ["server", "client-1"] : ["server"];
|
|
22748
|
-
|
|
22931
|
+
const soloStart = typeof response.testId === "string" ? { editPeerId: resolved.targetPeerId, testId: response.testId } : void 0;
|
|
22932
|
+
wait = await this._waitForRuntimeRolesFresh(resolved.targetInstanceId, startedAt, requiredRoles, timeout, soloStart);
|
|
22749
22933
|
}
|
|
22750
|
-
const body = wait ? {
|
|
22934
|
+
const body = wait?.studioError !== void 0 ? {
|
|
22935
|
+
...response,
|
|
22936
|
+
...describePlaytestStartFailure(wait.studioError, "playtest"),
|
|
22937
|
+
success: false,
|
|
22938
|
+
runtimeReady: false,
|
|
22939
|
+
timedOut: false,
|
|
22940
|
+
roles: wait.roles
|
|
22941
|
+
} : wait ? {
|
|
22751
22942
|
...response,
|
|
22752
22943
|
runtimeReady: wait.ok,
|
|
22753
22944
|
timedOut: wait.timedOut,
|
|
@@ -22965,7 +23156,9 @@ var RobloxStudioTools = class {
|
|
|
22965
23156
|
error: body2.error ?? wait.error ?? "multiplayer_start_not_detected",
|
|
22966
23157
|
message: body2.success === true ? "Multiplayer playtest start was requested, but MCP did not detect the required server/client peers before timeout." : body2.message ?? "Multiplayer playtest did not start.",
|
|
22967
23158
|
multiplayerGroupId: multiplayerGroupId2,
|
|
22968
|
-
roles: Array.isArray(body2.roles) ? body2.roles : void 0
|
|
23159
|
+
roles: Array.isArray(body2.roles) ? body2.roles : void 0,
|
|
23160
|
+
studioError: typeof body2.studioError === "string" ? body2.studioError : void 0,
|
|
23161
|
+
recoveryHint: typeof body2.recoveryHint === "string" ? body2.recoveryHint : void 0
|
|
22969
23162
|
});
|
|
22970
23163
|
}
|
|
22971
23164
|
if (action === "add_players") {
|
|
@@ -23061,6 +23254,7 @@ var RobloxStudioTools = class {
|
|
|
23061
23254
|
const definitelyFailed = state.phase === "failed" && !runtimeStillConnected;
|
|
23062
23255
|
if (definitelyFailed)
|
|
23063
23256
|
await this.bridge.removeMultiplayerGroupEverywhere(groupId);
|
|
23257
|
+
const startFailure = !success && wait.phase === "failed" ? describePlaytestStartFailure(typeof wait.error === "string" ? wait.error : String(wait.error ?? "unknown error"), "multiplayer playtest") : void 0;
|
|
23064
23258
|
return {
|
|
23065
23259
|
content: [{
|
|
23066
23260
|
type: "text",
|
|
@@ -23075,8 +23269,10 @@ var RobloxStudioTools = class {
|
|
|
23075
23269
|
wait,
|
|
23076
23270
|
roles: wait.roles,
|
|
23077
23271
|
state,
|
|
23078
|
-
error: success ? void 0 : wait.error ?? "multiplayer_start_not_detected",
|
|
23079
|
-
message: success ? "Multiplayer Studio test started and runtime peers detected." : "Multiplayer Studio test start was requested, but MCP did not detect the required server/client peers before timeout.",
|
|
23272
|
+
error: success ? void 0 : startFailure?.error ?? wait.error ?? "multiplayer_start_not_detected",
|
|
23273
|
+
message: success ? "Multiplayer Studio test started and runtime peers detected." : startFailure?.message ?? "Multiplayer Studio test start was requested, but MCP did not detect the required server/client peers before timeout.",
|
|
23274
|
+
studioError: startFailure?.studioError,
|
|
23275
|
+
recoveryHint: startFailure?.recoveryHint,
|
|
23080
23276
|
startedAt
|
|
23081
23277
|
})
|
|
23082
23278
|
}]
|
|
@@ -23360,7 +23556,7 @@ var RobloxStudioTools = class {
|
|
|
23360
23556
|
try {
|
|
23361
23557
|
return await this._generateModel(request, instance_id);
|
|
23362
23558
|
} catch (error) {
|
|
23363
|
-
if (error instanceof RoutingFailure)
|
|
23559
|
+
if (error instanceof RoutingFailure || error instanceof RequestFailure || error instanceof StudioOperationError || error instanceof OpenCloudOperationError || error instanceof ReferenceUploadError || error instanceof MultiplayerGroupInUseError)
|
|
23364
23560
|
throw error;
|
|
23365
23561
|
const message = error instanceof Error ? error.message : String(error);
|
|
23366
23562
|
return {
|
|
@@ -23458,23 +23654,32 @@ var RobloxStudioTools = class {
|
|
|
23458
23654
|
const uploadUnavailable = this.referenceUploadUnavailable();
|
|
23459
23655
|
if (uploadUnavailable)
|
|
23460
23656
|
throw new Error(uploadUnavailable);
|
|
23461
|
-
const
|
|
23657
|
+
const pinnedInstanceId = operationId !== void 0 ? this.referenceUploads.pinnedInstance(operationId) : void 0;
|
|
23658
|
+
const { targetPeerId, targetInstanceId } = await this._resolveEditTarget(instance_id ?? pinnedInstanceId).catch((error) => {
|
|
23659
|
+
if (instance_id === void 0 && pinnedInstanceId !== void 0 && error instanceof RoutingFailure) {
|
|
23660
|
+
throw new RoutingFailure({
|
|
23661
|
+
...error.routingError,
|
|
23662
|
+
message: `Operation ${operationId} is tied to Studio instance ${pinnedInstanceId}, which is no longer connected; reconnect that Studio, or start over with a new operation_id.`
|
|
23663
|
+
});
|
|
23664
|
+
}
|
|
23665
|
+
throw error;
|
|
23666
|
+
});
|
|
23462
23667
|
if (submit && !this.bridge.supportsPrimaryFeature("submit")) {
|
|
23463
|
-
throw new
|
|
23668
|
+
throw new RequestFailure("The primary MCP server cannot start a job that outlives the call; call without async, or restart that server on this version. Nothing was uploaded; queued; not_executed", "primary_unsupported", { requestId: operationId ?? randomUUID6(), targetPeerId, stage: "queued", outcome: "not_executed", executionOutcome: "not_executed" });
|
|
23464
23669
|
}
|
|
23465
23670
|
const png = referencePng;
|
|
23466
23671
|
const identity = { ...payload, image: { kind: "png_sha256", sha256: createHash3("sha256").update(png).digest("hex") } };
|
|
23467
23672
|
const attempt = {
|
|
23468
|
-
upload: (progress) => this.uploadGenerateModelReferenceImage(png,
|
|
23469
|
-
resume: (checkpoint, progress) => this.resumeGenerateModelReferenceImage(checkpoint,
|
|
23673
|
+
upload: (progress) => this.uploadGenerateModelReferenceImage(png, targetInstanceId, progress),
|
|
23674
|
+
resume: (checkpoint, progress) => this.resumeGenerateModelReferenceImage(checkpoint, targetInstanceId, progress)
|
|
23470
23675
|
};
|
|
23471
23676
|
if (operationId === void 0 && !submit) {
|
|
23472
23677
|
payload.image = { kind: "asset", asset_id: await attempt.upload(UNTRACKED_UPLOAD) };
|
|
23473
|
-
return this._dispatchGenerateModel(payload,
|
|
23678
|
+
return this._dispatchGenerateModel(payload, targetInstanceId, timeoutMs, false, void 0, identity);
|
|
23474
23679
|
}
|
|
23475
|
-
const jobId = operationId ??
|
|
23680
|
+
const jobId = operationId ?? randomUUID6();
|
|
23476
23681
|
const identityKey = createHash3("sha256").update(JSON.stringify({ endpoint: "/api/generate-model", identity })).digest("hex");
|
|
23477
|
-
const prepared = this.referenceUploads.lookup(jobId, identityKey, targetPeerId);
|
|
23682
|
+
const prepared = this.referenceUploads.lookup(jobId, identityKey, targetPeerId, targetInstanceId);
|
|
23478
23683
|
if (operationId !== void 0 && !prepared) {
|
|
23479
23684
|
const joined = await this.bridge.joinOperation("/api/generate-model", targetPeerId, jobId, identity);
|
|
23480
23685
|
if (joined && submit)
|
|
@@ -23484,13 +23689,16 @@ var RobloxStudioTools = class {
|
|
|
23484
23689
|
}
|
|
23485
23690
|
let dispatchPeerId = targetPeerId;
|
|
23486
23691
|
const generate = async () => {
|
|
23487
|
-
payload.image = {
|
|
23488
|
-
|
|
23692
|
+
payload.image = {
|
|
23693
|
+
kind: "asset",
|
|
23694
|
+
asset_id: await this.referenceUploads.acquire(jobId, identityKey, targetPeerId, targetInstanceId, attempt)
|
|
23695
|
+
};
|
|
23696
|
+
return this._dispatchGenerateModel(payload, targetInstanceId, timeoutMs, submit, jobId, identity, (peerId) => {
|
|
23489
23697
|
dispatchPeerId = peerId;
|
|
23490
23698
|
this.referenceUploads.dispatched(jobId, peerId);
|
|
23491
23699
|
});
|
|
23492
23700
|
};
|
|
23493
|
-
const current = this.referenceUploads.lookup(jobId, identityKey, targetPeerId);
|
|
23701
|
+
const current = this.referenceUploads.lookup(jobId, identityKey, targetPeerId, targetInstanceId);
|
|
23494
23702
|
const job = generate();
|
|
23495
23703
|
this.referenceUploads.attach(jobId, job);
|
|
23496
23704
|
job.catch((error) => {
|
|
@@ -23502,8 +23710,11 @@ var RobloxStudioTools = class {
|
|
|
23502
23710
|
}
|
|
23503
23711
|
return job;
|
|
23504
23712
|
}
|
|
23505
|
-
|
|
23506
|
-
|
|
23713
|
+
// The edit Peer for instance_id and the Studio Instance it belongs to. A
|
|
23714
|
+
// multi-step operation pins the Instance, so a plugin reload in that Studio
|
|
23715
|
+
// still reaches it, but a different Studio never does.
|
|
23716
|
+
_resolveEditTarget(instance_id) {
|
|
23717
|
+
return this._withSinglePeer("edit", instance_id, void 0, async (targetPeerId, targetInstanceId) => ({ targetPeerId, targetInstanceId }));
|
|
23507
23718
|
}
|
|
23508
23719
|
async _dispatchGenerateModel(payload, instance_id, timeoutMs, submit, operationId, identity, onDispatch) {
|
|
23509
23720
|
return this._withSinglePeer("edit", instance_id, void 0, async (targetPeerId) => {
|
|
@@ -23727,7 +23938,7 @@ var RobloxStudioTools = class {
|
|
|
23727
23938
|
if (!this.openCloudClient.hasApiKey()) {
|
|
23728
23939
|
return "image_path and image_base64 require Roblox asset upload credentials because GenerateModelAsync only accepts rbxassetid:// or rbxasset:// image inputs. Set ROBLOX_OPEN_CLOUD_API_KEY plus ROBLOX_CREATOR_USER_ID or ROBLOX_CREATOR_GROUP_ID, or pass image_asset_id.";
|
|
23729
23940
|
}
|
|
23730
|
-
if (!
|
|
23941
|
+
if (!resolveUploadCreator()) {
|
|
23731
23942
|
return "Creator identity required for image upload. Set ROBLOX_CREATOR_USER_ID or ROBLOX_CREATOR_GROUP_ID, or pass image_asset_id.";
|
|
23732
23943
|
}
|
|
23733
23944
|
return void 0;
|
|
@@ -23739,8 +23950,7 @@ var RobloxStudioTools = class {
|
|
|
23739
23950
|
fileName: "generate-model-reference.png",
|
|
23740
23951
|
displayName: STUDIO_ASSISTANT_SOURCE_IMAGE_LABEL,
|
|
23741
23952
|
description: STUDIO_ASSISTANT_SOURCE_IMAGE_LABEL,
|
|
23742
|
-
|
|
23743
|
-
groupId: process.env.ROBLOX_CREATOR_GROUP_ID,
|
|
23953
|
+
...resolveUploadCreator(),
|
|
23744
23954
|
onSending: () => progress.sending(),
|
|
23745
23955
|
onAccepted: (id) => progress.accepted({ provider: "user_auth", id })
|
|
23746
23956
|
});
|
|
@@ -23749,14 +23959,7 @@ var RobloxStudioTools = class {
|
|
|
23749
23959
|
const unavailable = this.referenceUploadUnavailable();
|
|
23750
23960
|
if (unavailable)
|
|
23751
23961
|
throw new Error(unavailable);
|
|
23752
|
-
const
|
|
23753
|
-
const resolvedUserId = process.env.ROBLOX_CREATOR_USER_ID;
|
|
23754
|
-
const creator = {};
|
|
23755
|
-
if (resolvedGroupId) {
|
|
23756
|
-
creator.groupId = resolvedGroupId;
|
|
23757
|
-
} else {
|
|
23758
|
-
creator.userId = resolvedUserId;
|
|
23759
|
-
}
|
|
23962
|
+
const creator = resolveUploadCreator() ?? {};
|
|
23760
23963
|
const result = await this.openCloudClient.createAsset({
|
|
23761
23964
|
assetType: "Decal",
|
|
23762
23965
|
displayName: STUDIO_ASSISTANT_SOURCE_IMAGE_LABEL,
|
|
@@ -23799,16 +24002,14 @@ var RobloxStudioTools = class {
|
|
|
23799
24002
|
}
|
|
23800
24003
|
});
|
|
23801
24004
|
const fileName = path11.basename(filePath);
|
|
23802
|
-
const
|
|
23803
|
-
const resolvedUserId = userId || process.env.ROBLOX_CREATOR_USER_ID;
|
|
24005
|
+
const resolvedCreator = resolveUploadCreator(userId, groupId);
|
|
23804
24006
|
if (assetType === "Decal" && this.cookieClient.hasCookie()) {
|
|
23805
24007
|
const result2 = await this.cookieClient.uploadImage({
|
|
23806
24008
|
fileContent,
|
|
23807
24009
|
fileName,
|
|
23808
24010
|
displayName,
|
|
23809
24011
|
description: description || "",
|
|
23810
|
-
|
|
23811
|
-
groupId: resolvedGroupId
|
|
24012
|
+
...resolvedCreator
|
|
23812
24013
|
});
|
|
23813
24014
|
return {
|
|
23814
24015
|
content: [{
|
|
@@ -23830,15 +24031,10 @@ var RobloxStudioTools = class {
|
|
|
23830
24031
|
const cookieHint = assetType === "Decal" ? " Alternatively, set ROBLOSECURITY to use cookie auth." : "";
|
|
23831
24032
|
throw new Error(`No auth configured for ${assetType} upload. Set ROBLOX_OPEN_CLOUD_API_KEY (needs asset:write scope).${cookieHint}`);
|
|
23832
24033
|
}
|
|
23833
|
-
if (!
|
|
24034
|
+
if (!resolvedCreator) {
|
|
23834
24035
|
throw new Error("Creator identity required for Open Cloud upload. Set ROBLOX_CREATOR_USER_ID or ROBLOX_CREATOR_GROUP_ID, or pass userId/groupId as parameters.");
|
|
23835
24036
|
}
|
|
23836
|
-
const creator =
|
|
23837
|
-
if (resolvedGroupId) {
|
|
23838
|
-
creator.groupId = resolvedGroupId;
|
|
23839
|
-
} else {
|
|
23840
|
-
creator.userId = resolvedUserId;
|
|
23841
|
-
}
|
|
24037
|
+
const creator = resolvedCreator;
|
|
23842
24038
|
const result = await this.openCloudClient.createAsset({
|
|
23843
24039
|
assetType,
|
|
23844
24040
|
displayName,
|
|
@@ -24472,8 +24668,8 @@ manage_monetization lists, reads, creates, and updates developer products and ga
|
|
|
24472
24668
|
|
|
24473
24669
|
- Roblox cannot delete developer products or game passes. To retire one, update it with for_sale=false.
|
|
24474
24670
|
- create keeps new items off sale unless for_sale=true, which also needs a price.
|
|
24475
|
-
- create refuses a name that already exists in the universe and returns the existing item. If a create
|
|
24476
|
-
- update changes only the arguments supplied, then reads the item back.
|
|
24671
|
+
- create refuses a name that already exists in the universe and returns the existing item. If a create returns create_outcome_unknown, list the universe first; if the item never appears, retry after retry_after.
|
|
24672
|
+
- update changes only the arguments supplied, then reads the item back. It refuses to rename an item to a name another item already uses.
|
|
24477
24673
|
- image_path uploads a local PNG, JPEG, or BMP icon. Roblox shows icons at 512x512 inside a circle, so keep details away from the corners.
|
|
24478
24674
|
|
|
24479
24675
|
## Experience settings
|
|
@@ -24651,6 +24847,15 @@ function normalizeToolResult(raw, era) {
|
|
|
24651
24847
|
...isError ? { isError: true } : {}
|
|
24652
24848
|
};
|
|
24653
24849
|
}
|
|
24850
|
+
function withErrorText(result) {
|
|
24851
|
+
if (!result.isError || !result.structuredContent || result.content.some((block) => block.type === "text")) {
|
|
24852
|
+
return result;
|
|
24853
|
+
}
|
|
24854
|
+
return {
|
|
24855
|
+
...result,
|
|
24856
|
+
content: [{ type: "text", text: JSON.stringify(result.structuredContent) }, ...result.content]
|
|
24857
|
+
};
|
|
24858
|
+
}
|
|
24654
24859
|
function publicRoutingError(error) {
|
|
24655
24860
|
return {
|
|
24656
24861
|
error: error.routingError.code,
|
|
@@ -24693,6 +24898,9 @@ function publicToolErrorBody(name, error) {
|
|
|
24693
24898
|
operation_path: error.operationPath
|
|
24694
24899
|
};
|
|
24695
24900
|
}
|
|
24901
|
+
if (error instanceof ReferenceUploadError) {
|
|
24902
|
+
return { error: error.code, message: error.message.slice(0, 500) };
|
|
24903
|
+
}
|
|
24696
24904
|
console.error(`[tool:${name}]`, error);
|
|
24697
24905
|
const message = error instanceof Error ? error.message : typeof error === "string" ? error : "Tool execution failed.";
|
|
24698
24906
|
return { error: "tool_failed", message: message.slice(0, 500) };
|
|
@@ -24797,12 +25005,12 @@ function createToolServer(options) {
|
|
|
24797
25005
|
}, async (args, context) => {
|
|
24798
25006
|
try {
|
|
24799
25007
|
const raw = await options.invoke(options.getTools(), definition.name, args, { signal: context.mcpReq.signal });
|
|
24800
|
-
return normalizeToolResult(raw, options.era);
|
|
25008
|
+
return withErrorText(normalizeToolResult(raw, options.era));
|
|
24801
25009
|
} catch (error) {
|
|
24802
|
-
return normalizeToolResult({
|
|
25010
|
+
return withErrorText(normalizeToolResult({
|
|
24803
25011
|
content: [{ type: "text", text: JSON.stringify(publicToolErrorBody(definition.name, error)) }],
|
|
24804
25012
|
isError: true
|
|
24805
|
-
}, options.era);
|
|
25013
|
+
}, options.era));
|
|
24806
25014
|
}
|
|
24807
25015
|
});
|
|
24808
25016
|
}
|
|
@@ -24818,7 +25026,7 @@ function createToolHttpHandler(options) {
|
|
|
24818
25026
|
// ../core/dist/auth.js
|
|
24819
25027
|
import { randomBytes, createHash as createHash4, timingSafeEqual } from "crypto";
|
|
24820
25028
|
import { mkdirSync as mkdirSync4, readFileSync as readFileSync8, writeFileSync as writeFileSync4, linkSync as linkSync2, unlinkSync as unlinkSync2 } from "fs";
|
|
24821
|
-
import { join as join9, dirname as
|
|
25029
|
+
import { join as join9, dirname as dirname5 } from "path";
|
|
24822
25030
|
import { homedir as homedir3 } from "os";
|
|
24823
25031
|
function authTokenFilePath() {
|
|
24824
25032
|
return join9(homedir3(), ".robloxstudio-mcp", "auth-token");
|
|
@@ -24854,7 +25062,7 @@ function resolveAuthToken() {
|
|
|
24854
25062
|
throw error;
|
|
24855
25063
|
}
|
|
24856
25064
|
const fresh = randomBytes(32).toString("hex");
|
|
24857
|
-
mkdirSync4(
|
|
25065
|
+
mkdirSync4(dirname5(filePath), { recursive: true, mode: 448 });
|
|
24858
25066
|
const stagingPath = `${filePath}.${process.pid}.${randomBytes(16).toString("hex")}.tmp`;
|
|
24859
25067
|
writeFileSync4(stagingPath, fresh + "\n", { encoding: "utf8", mode: 384, flag: "wx" });
|
|
24860
25068
|
try {
|
|
@@ -25777,13 +25985,14 @@ async function listenWithRetry(app, host, startPort, maxAttempts = 5) {
|
|
|
25777
25985
|
return { server, port };
|
|
25778
25986
|
} catch (error) {
|
|
25779
25987
|
if (error !== null && typeof error === "object" && "code" in error && error.code === "EADDRINUSE") {
|
|
25780
|
-
|
|
25988
|
+
if (i + 1 < maxAttempts)
|
|
25989
|
+
console.error(`Port ${port} in use, trying next...`);
|
|
25781
25990
|
continue;
|
|
25782
25991
|
}
|
|
25783
25992
|
throw error;
|
|
25784
25993
|
}
|
|
25785
25994
|
}
|
|
25786
|
-
throw new Error(`All ports ${startPort}-${startPort + maxAttempts - 1} are in use. Stop some MCP server instances and retry.`);
|
|
25995
|
+
throw new Error(maxAttempts === 1 ? `Port ${startPort} is in use.` : `All ports ${startPort}-${startPort + maxAttempts - 1} are in use. Stop some MCP server instances and retry.`);
|
|
25787
25996
|
}
|
|
25788
25997
|
function bindPort(app, host, port) {
|
|
25789
25998
|
const { promise, resolve: resolve7, reject } = Promise.withResolvers();
|
|
@@ -25809,7 +26018,7 @@ function bindPort(app, host, port) {
|
|
|
25809
26018
|
}
|
|
25810
26019
|
|
|
25811
26020
|
// ../core/dist/proxy-bridge-service.js
|
|
25812
|
-
import { randomUUID as
|
|
26021
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
25813
26022
|
var PROXY_RESPONSE_GRACE_MS = 5e3;
|
|
25814
26023
|
function parseRequestStatus(value) {
|
|
25815
26024
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
@@ -25882,13 +26091,17 @@ var ProxyBridgeService = class _ProxyBridgeService extends BridgeService {
|
|
|
25882
26091
|
super();
|
|
25883
26092
|
this.primaryBaseUrl = primaryBaseUrl;
|
|
25884
26093
|
this.authToken = authToken;
|
|
25885
|
-
this.proxyInstanceId =
|
|
26094
|
+
this.proxyInstanceId = randomUUID7();
|
|
25886
26095
|
this.initialRefresh = this.refreshTopology();
|
|
25887
26096
|
this.refreshTimer = setInterval(() => this.refreshTopology(), _ProxyBridgeService.REFRESH_INTERVAL_MS);
|
|
25888
26097
|
}
|
|
25889
26098
|
waitForInitialRefresh() {
|
|
25890
26099
|
return this.initialRefresh;
|
|
25891
26100
|
}
|
|
26101
|
+
/** The port owner's version from its latest topology; undefined before one arrives. */
|
|
26102
|
+
getPrimaryVersion() {
|
|
26103
|
+
return this.primaryVersion;
|
|
26104
|
+
}
|
|
25892
26105
|
authHeaders(extra) {
|
|
25893
26106
|
const headers = { ...extra };
|
|
25894
26107
|
if (this.authToken)
|
|
@@ -26115,7 +26328,7 @@ var ProxyBridgeService = class _ProxyBridgeService extends BridgeService {
|
|
|
26115
26328
|
// The primary admits the operation and answers at once, so the operation
|
|
26116
26329
|
// never depends on this proxy or its caller staying connected.
|
|
26117
26330
|
async submitRequest(endpoint, data, targetPeerId, timeoutMs = this.proxyRequestTimeout, operationId, identity) {
|
|
26118
|
-
const requestId = operationId ??
|
|
26331
|
+
const requestId = operationId ?? randomUUID7();
|
|
26119
26332
|
const status = parseRequestStatus(await this.postProxy({
|
|
26120
26333
|
endpoint,
|
|
26121
26334
|
data,
|
|
@@ -26132,7 +26345,7 @@ var ProxyBridgeService = class _ProxyBridgeService extends BridgeService {
|
|
|
26132
26345
|
async postProxy(request, signal) {
|
|
26133
26346
|
const { endpoint, data, targetPeerId, submit } = request;
|
|
26134
26347
|
let { identity } = request;
|
|
26135
|
-
const requestId = request.operationId ??
|
|
26348
|
+
const requestId = request.operationId ?? randomUUID7();
|
|
26136
26349
|
const details = { requestId, targetPeerId, stage: "queued", outcome: "not_executed", executionOutcome: "not_executed" };
|
|
26137
26350
|
if (!isValidOperationId(requestId)) {
|
|
26138
26351
|
throw new RequestFailure("operationId must be a nonempty string of at most 128 characters", "invalid_operation_id", details);
|
|
@@ -26536,6 +26749,7 @@ var RobloxStudioMCPServer = class {
|
|
|
26536
26749
|
boundPort = result.port;
|
|
26537
26750
|
console.error(`HTTP server listening on ${host}:${boundPort} for Studio plugin (primary mode)`);
|
|
26538
26751
|
console.error(`Streamable HTTP MCP endpoint: http://localhost:${boundPort}/mcp`);
|
|
26752
|
+
await this.installStudioPlugin();
|
|
26539
26753
|
} catch (error) {
|
|
26540
26754
|
await primaryApp?.cleanup().catch(() => {
|
|
26541
26755
|
});
|
|
@@ -26550,8 +26764,13 @@ var RobloxStudioMCPServer = class {
|
|
|
26550
26764
|
this.bridge = proxyBridge;
|
|
26551
26765
|
this.tools = new RobloxStudioTools(this.bridge);
|
|
26552
26766
|
console.error(`Port ${basePort} in use - entering proxy mode (forwarding to localhost:${basePort})`);
|
|
26767
|
+
const primaryVersion = proxyBridge.getPrimaryVersion();
|
|
26768
|
+
if (primaryVersion !== void 0 && primaryVersion !== this.config.version) {
|
|
26769
|
+
console.error(`Port ${basePort} is owned by MCP server v${primaryVersion}; this v${this.config.version} session forwards to it and leaves its Studio plugin installed. Close the older session to use v${this.config.version}; this session takes the port and installs its plugin once it is free.`);
|
|
26770
|
+
}
|
|
26553
26771
|
const promotionIntervalMs = parseInt(process.env.ROBLOX_STUDIO_PROXY_PROMOTION_INTERVAL_MS || "5000");
|
|
26554
26772
|
promotionInterval = setInterval(async () => {
|
|
26773
|
+
let promoted = false;
|
|
26555
26774
|
const candidateBridge = new BridgeService();
|
|
26556
26775
|
const candidateTools = new RobloxStudioTools(candidateBridge);
|
|
26557
26776
|
const candidateApp = createHttpServer(candidateTools, candidateBridge, this.allowedToolNames, this.config, security);
|
|
@@ -26572,11 +26791,14 @@ var RobloxStudioMCPServer = class {
|
|
|
26572
26791
|
console.error(`Promoted from proxy to primary on port ${boundPort}`);
|
|
26573
26792
|
if (promotionInterval)
|
|
26574
26793
|
clearInterval(promotionInterval);
|
|
26794
|
+
promoted = true;
|
|
26575
26795
|
await oldTools.dispose();
|
|
26576
26796
|
} catch {
|
|
26577
26797
|
await candidateApp.cleanup().catch(() => {
|
|
26578
26798
|
});
|
|
26579
26799
|
}
|
|
26800
|
+
if (promoted)
|
|
26801
|
+
await this.installStudioPlugin();
|
|
26580
26802
|
}, promotionIntervalMs);
|
|
26581
26803
|
}
|
|
26582
26804
|
const stdioHandle = serveStdio((context) => createToolServer({
|
|
@@ -26646,13 +26868,23 @@ var RobloxStudioMCPServer = class {
|
|
|
26646
26868
|
process.stdin.on("end", shutdown);
|
|
26647
26869
|
process.stdin.on("close", shutdown);
|
|
26648
26870
|
}
|
|
26871
|
+
/** Never throws: a failed install must not cost this process the port it owns. */
|
|
26872
|
+
async installStudioPlugin() {
|
|
26873
|
+
if (!this.config.installStudioPlugin)
|
|
26874
|
+
return;
|
|
26875
|
+
try {
|
|
26876
|
+
await this.config.installStudioPlugin();
|
|
26877
|
+
} catch (err2) {
|
|
26878
|
+
console.error(`[install-plugin] Auto-install skipped: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
26879
|
+
}
|
|
26880
|
+
}
|
|
26649
26881
|
};
|
|
26650
26882
|
|
|
26651
26883
|
// ../core/dist/install-plugin-helpers.js
|
|
26652
26884
|
var import_saxes = __toESM(require_saxes(), 1);
|
|
26653
26885
|
import { existsSync as existsSync6, lstatSync as lstatSync2, mkdirSync as mkdirSync5, readFileSync as readFileSync9, renameSync, rmSync as rmSync5, rmdirSync, statSync as statSync4, unlinkSync as unlinkSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
26654
26886
|
import { execSync } from "child_process";
|
|
26655
|
-
import { randomUUID as
|
|
26887
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
26656
26888
|
import { basename as basename3, join as join10 } from "path";
|
|
26657
26889
|
import { homedir as homedir4 } from "os";
|
|
26658
26890
|
import { isUtf8 } from "buffer";
|
|
@@ -26737,7 +26969,7 @@ function repairStaleStudioPluginDirectorySetting({ settingsPath, studioPluginsDi
|
|
|
26737
26969
|
return false;
|
|
26738
26970
|
const studioPath = escapeXmlText(studioPluginsDirectory);
|
|
26739
26971
|
const updated = contents.replace(pluginDirectorySettingPattern(), (_match, open4, _value, close) => `${open4}${studioPath}${close}`);
|
|
26740
|
-
const temporaryPath = `${settingsPath}.rsmcp-install-${process.pid}-${
|
|
26972
|
+
const temporaryPath = `${settingsPath}.rsmcp-install-${process.pid}-${randomUUID8()}.tmp`;
|
|
26741
26973
|
try {
|
|
26742
26974
|
writeFileSync5(temporaryPath, updated, {
|
|
26743
26975
|
encoding: "utf8",
|
|
@@ -26843,7 +27075,7 @@ function recoverPluginInstallLock(lockPath, warn) {
|
|
|
26843
27075
|
} catch (error) {
|
|
26844
27076
|
throw pluginInstallLockError(lockPath, errorCode2(error) === "EEXIST" ? "Plugin installation lock recovery is already in progress or was interrupted" : `Could not claim plugin installation lock recovery (${error})`);
|
|
26845
27077
|
}
|
|
26846
|
-
const abandonedPath = `${lockPath}.${
|
|
27078
|
+
const abandonedPath = `${lockPath}.${randomUUID8()}.abandoned`;
|
|
26847
27079
|
let moved = false;
|
|
26848
27080
|
try {
|
|
26849
27081
|
let currentOwner;
|
|
@@ -26880,7 +27112,7 @@ function acquirePluginInstallLock(pluginsFolder, warn) {
|
|
|
26880
27112
|
const ownerPath = join10(lockPath, "owner.json");
|
|
26881
27113
|
const owner = {
|
|
26882
27114
|
pid: process.pid,
|
|
26883
|
-
token:
|
|
27115
|
+
token: randomUUID8(),
|
|
26884
27116
|
createdAt: Date.now()
|
|
26885
27117
|
};
|
|
26886
27118
|
try {
|
|
@@ -27028,7 +27260,7 @@ function installPluginAsset({ pluginsFolder, assetName, otherAssetName, source,
|
|
|
27028
27260
|
try {
|
|
27029
27261
|
let installed = false;
|
|
27030
27262
|
if (!installedFileMatches(configured, destination)) {
|
|
27031
|
-
const staged = join10(pluginsFolder, `.${assetName}.${process.pid}.${
|
|
27263
|
+
const staged = join10(pluginsFolder, `.${assetName}.${process.pid}.${randomUUID8()}.tmp`);
|
|
27032
27264
|
try {
|
|
27033
27265
|
writeFileSync5(staged, configured, { flag: "wx" });
|
|
27034
27266
|
renameSync(staged, destination);
|
|
@@ -27059,7 +27291,7 @@ function installPluginAsset({ pluginsFolder, assetName, otherAssetName, source,
|
|
|
27059
27291
|
|
|
27060
27292
|
// ../core/dist/plugin-installer.js
|
|
27061
27293
|
import { existsSync as existsSync7, readFileSync as readFileSync10 } from "fs";
|
|
27062
|
-
import { dirname as
|
|
27294
|
+
import { dirname as dirname6, join as join11 } from "path";
|
|
27063
27295
|
import { fileURLToPath } from "url";
|
|
27064
27296
|
import { get } from "https";
|
|
27065
27297
|
var REPO = "chrrxs/robloxstudio-mcp";
|
|
@@ -27067,7 +27299,7 @@ var TIMEOUT_MS = 3e4;
|
|
|
27067
27299
|
var MAX_REDIRECTS = 5;
|
|
27068
27300
|
var MAX_ASSET_BYTES = 64 * 1024 * 1024;
|
|
27069
27301
|
function createPluginInstaller(moduleUrl, variant) {
|
|
27070
|
-
const currentDir =
|
|
27302
|
+
const currentDir = dirname6(fileURLToPath(moduleUrl));
|
|
27071
27303
|
const ASSET_NAME = variant === "main" ? "MCPPlugin.rbxmx" : "MCPInspectorPlugin.rbxmx";
|
|
27072
27304
|
const OTHER_VARIANT = variant === "main" ? "MCPInspectorPlugin.rbxmx" : "MCPPlugin.rbxmx";
|
|
27073
27305
|
const userAgent = variant === "main" ? "robloxstudio-mcp" : "robloxstudio-mcp-inspector";
|
|
@@ -27221,23 +27453,18 @@ if (installBundledOnly || installWithFallback) {
|
|
|
27221
27453
|
process.exitCode = 1;
|
|
27222
27454
|
});
|
|
27223
27455
|
} else {
|
|
27224
|
-
|
|
27225
|
-
await installBundledPlugin({
|
|
27226
|
-
sourcePath: pluginPath,
|
|
27227
|
-
log: (message) => console.error(`[install-plugin] ${message}`),
|
|
27228
|
-
warn: (message) => console.error(message)
|
|
27229
|
-
}).catch((err2) => {
|
|
27230
|
-
console.error(
|
|
27231
|
-
`[install-plugin] Auto-install skipped: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
27232
|
-
);
|
|
27233
|
-
});
|
|
27234
|
-
}
|
|
27456
|
+
const autoInstallPlugin = process.argv.includes("--auto-install-plugin");
|
|
27235
27457
|
const require2 = createRequire(import.meta.url);
|
|
27236
27458
|
const { version: VERSION } = require2("../package.json");
|
|
27237
27459
|
const server = new RobloxStudioMCPServer({
|
|
27238
27460
|
name: "robloxstudio-mcp-inspector",
|
|
27239
27461
|
version: VERSION,
|
|
27240
|
-
tools: getReadOnlyTools()
|
|
27462
|
+
tools: getReadOnlyTools(),
|
|
27463
|
+
installStudioPlugin: autoInstallPlugin ? () => installBundledPlugin({
|
|
27464
|
+
sourcePath: pluginPath,
|
|
27465
|
+
log: (message) => console.error(`[install-plugin] ${message}`),
|
|
27466
|
+
warn: (message) => console.error(message)
|
|
27467
|
+
}) : void 0
|
|
27241
27468
|
});
|
|
27242
27469
|
server.run().catch((error) => {
|
|
27243
27470
|
console.error("Server failed to start:", error);
|