dist-mcp / mcp / sourceNotation.js
/**
* aN is LM-Studio-only: it resolves through resolveImg2ImgSourceLMStudio(),
* which reads conversation.json / LM-Studio user-files (see core/tools.ts).
* Bionic has no equivalent, so canvas/moodboard values using aN must be
* rejected before handleGenerateImage/handleUpscale ever see them. Every
* other value (vN/pN/iN, a scratchpad filename, an absolute path) is left
* untouched — core/tools.ts resolves those itself against
* chat_media_state.json in the bound chat working dir (chatContextBridge.ts).
*/
const ATTACHMENT_NOTATION = /^a([1-9]\d*)?$/i;
export class UnsupportedAttachmentNotationError extends Error {
constructor(value) {
super(`Source "${value}" uses LM-Studio attachment notation (aN), which is not supported here. ` +
`Use load_file_attachment first, then pass the resulting scratchpad filename as the source instead.`);
this.name = "UnsupportedAttachmentNotationError";
}
}
function rejectIfAttachmentNotation(value) {
if (typeof value !== "string")
return;
const trimmed = value.trim();
if (ATTACHMENT_NOTATION.test(trimmed)) {
throw new UnsupportedAttachmentNotationError(trimmed);
}
}
export function assertNoAttachmentNotation(args) {
const { canvas, moodboard } = args;
if (Array.isArray(canvas)) {
canvas.forEach(rejectIfAttachmentNotation);
}
else {
rejectIfAttachmentNotation(canvas);
}
if (Array.isArray(moodboard)) {
moodboard.forEach(rejectIfAttachmentNotation);
}
else if (typeof moodboard === "string") {
// moodboard also accepts a comma/space-separated string (see SourceNotationList in schemas.ts).
moodboard.split(/[\s,]+/).forEach(rejectIfAttachmentNotation);
}
}
dist-mcp / mcp / sourceNotation.js
/**
* aN is LM-Studio-only: it resolves through resolveImg2ImgSourceLMStudio(),
* which reads conversation.json / LM-Studio user-files (see core/tools.ts).
* Bionic has no equivalent, so canvas/moodboard values using aN must be
* rejected before handleGenerateImage/handleUpscale ever see them. Every
* other value (vN/pN/iN, a scratchpad filename, an absolute path) is left
* untouched — core/tools.ts resolves those itself against
* chat_media_state.json in the bound chat working dir (chatContextBridge.ts).
*/
const ATTACHMENT_NOTATION = /^a([1-9]\d*)?$/i;
export class UnsupportedAttachmentNotationError extends Error {
constructor(value) {
super(`Source "${value}" uses LM-Studio attachment notation (aN), which is not supported here. ` +
`Use load_file_attachment first, then pass the resulting scratchpad filename as the source instead.`);
this.name = "UnsupportedAttachmentNotationError";
}
}
function rejectIfAttachmentNotation(value) {
if (typeof value !== "string")
return;
const trimmed = value.trim();
if (ATTACHMENT_NOTATION.test(trimmed)) {
throw new UnsupportedAttachmentNotationError(trimmed);
}
}
export function assertNoAttachmentNotation(args) {
const { canvas, moodboard } = args;
if (Array.isArray(canvas)) {
canvas.forEach(rejectIfAttachmentNotation);
}
else {
rejectIfAttachmentNotation(canvas);
}
if (Array.isArray(moodboard)) {
moodboard.forEach(rejectIfAttachmentNotation);
}
else if (typeof moodboard === "string") {
// moodboard also accepts a comma/space-separated string (see SourceNotationList in schemas.ts).
moodboard.split(/[\s,]+/).forEach(rejectIfAttachmentNotation);
}
}