Ship Assistent 0.10.8 cheap-bug sweep for RU intent, VRAM park, and identity.
Silent Generate, pack selection, and loading UI no longer trip on Cyrillic or fake GPU loads; persona title is the assistant, not the user. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+101
-81
@@ -1,81 +1,101 @@
|
||||
/**
|
||||
* Swarm Assistent — patch detection / extraction / alias normalization.
|
||||
* Loaded before assistent.js; mirrors AssistentPatch.cs on the server side.
|
||||
*/
|
||||
window.SA = window.SA || {};
|
||||
|
||||
(function () {
|
||||
const PATCH_KEYS = [
|
||||
'prompt', 'loras', 'width', 'height', 'steps', 'cfg', 'seed', 'sigma_shift', 'sampler',
|
||||
'actions', 'search_query', 'civitai_query',
|
||||
'use_init_image', 'clear_init_image', 'init_creativity', 'denoise',
|
||||
'use_mask_image', 'clear_mask_image', 'mask_blur', 'mask_grow',
|
||||
'look_at', 'vision_from', 'vision_slots', 'slot_to_init', 'slot_to_mask',
|
||||
'snapshot_generate', 'select_slot', 'aspect', 'images', 'batch', 'vary', 'lock_seed',
|
||||
'creativity', 'intensity', 'complexity', 'movement',
|
||||
'clear_prompt_images', 'slot_to_prompt_image', 'pack',
|
||||
'memories', 'memory_query', 'memory_kind', 'tag_query', 'user_prefs',
|
||||
'controls', 'persona_clone', 'persona_shelves', 'persona', 'notes',
|
||||
];
|
||||
|
||||
const FENCE_RE = /```(?:json)?\s*([\s\S]*?)```/gi;
|
||||
|
||||
function has(obj, key) {
|
||||
return obj[key] !== undefined && obj[key] !== null;
|
||||
}
|
||||
|
||||
/** True when the object looks like a generation patch rather than arbitrary JSON. */
|
||||
function isPatchObject(obj) {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return false;
|
||||
}
|
||||
return PATCH_KEYS.some((k) => has(obj, k));
|
||||
}
|
||||
|
||||
/** Maps alias fields onto canonical names, keeping the aliases in place. */
|
||||
function normalizePatch(patch) {
|
||||
if (!patch || typeof patch !== 'object') {
|
||||
return patch;
|
||||
}
|
||||
if (!has(patch, 'search_query') && has(patch, 'civitai_query')) {
|
||||
patch.search_query = patch.civitai_query;
|
||||
}
|
||||
if (!has(patch, 'init_creativity') && has(patch, 'denoise')) {
|
||||
patch.init_creativity = patch.denoise;
|
||||
}
|
||||
if (!has(patch, 'look_at')) {
|
||||
if (has(patch, 'vision_from')) {
|
||||
patch.look_at = patch.vision_from;
|
||||
} else if (has(patch, 'vision_slots')) {
|
||||
patch.look_at = patch.vision_slots;
|
||||
}
|
||||
}
|
||||
return patch;
|
||||
}
|
||||
|
||||
/** Splits a reply into prose and the last fenced patch object found in it. */
|
||||
function extractPatch(text) {
|
||||
if (!text) {
|
||||
return { prose: text || '', patch: null };
|
||||
}
|
||||
const re = new RegExp(FENCE_RE.source, 'gi');
|
||||
let match;
|
||||
let lastPatch = null;
|
||||
let prose = text;
|
||||
while ((match = re.exec(text)) !== null) {
|
||||
try {
|
||||
const obj = JSON.parse(match[1].trim());
|
||||
if (isPatchObject(obj)) {
|
||||
lastPatch = normalizePatch(obj);
|
||||
prose = (text.slice(0, match.index) + text.slice(match.index + match[0].length)).trim();
|
||||
}
|
||||
} catch (e) { /* not json */ }
|
||||
}
|
||||
return { prose, patch: lastPatch };
|
||||
}
|
||||
|
||||
SA.PATCH_KEYS = PATCH_KEYS;
|
||||
SA.isPatchObject = isPatchObject;
|
||||
SA.normalizePatch = normalizePatch;
|
||||
SA.extractPatch = extractPatch;
|
||||
})();
|
||||
/**
|
||||
* Swarm Assistent — patch detection / extraction / alias normalization.
|
||||
* Loaded before assistent.js; mirrors AssistentPatch.cs on the server side.
|
||||
*/
|
||||
window.SA = window.SA || {};
|
||||
|
||||
(function () {
|
||||
const PATCH_KEYS = [
|
||||
'prompt', 'loras', 'width', 'height', 'steps', 'cfg', 'seed', 'sigma_shift', 'sampler',
|
||||
'actions', 'search_query', 'civitai_query',
|
||||
'use_init_image', 'clear_init_image', 'init_creativity', 'denoise',
|
||||
'use_mask_image', 'clear_mask_image', 'mask_blur', 'mask_grow',
|
||||
'look_at', 'vision_from', 'vision_slots', 'slot_to_init', 'slot_to_mask',
|
||||
'snapshot_generate', 'select_slot', 'aspect', 'images', 'batch', 'vary', 'lock_seed',
|
||||
'creativity', 'intensity', 'complexity', 'movement',
|
||||
'clear_prompt_images', 'slot_to_prompt_image', 'pack',
|
||||
'memories', 'memory_query', 'memory_kind', 'tag_query', 'user_prefs',
|
||||
'controls', 'persona_clone', 'persona_shelves', 'persona', 'notes',
|
||||
];
|
||||
|
||||
const FENCE_RE = /```(?:json)?\s*([\s\S]*?)```/gi;
|
||||
|
||||
function has(obj, key) {
|
||||
return obj[key] !== undefined && obj[key] !== null;
|
||||
}
|
||||
|
||||
/** Model-card JSON (catalog_card) — must not be treated as a Generate patch. */
|
||||
function isCardObject(obj) {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return false;
|
||||
}
|
||||
const cardish = !!(obj.kind || obj.triggers || obj.when || obj.prompt_hint);
|
||||
const genish = !!(obj.prompt != null || obj.loras || obj.actions || obj.width || obj.height
|
||||
|| obj.steps || obj.cfg || obj.aspect || obj.seed != null
|
||||
|| obj.search_query || obj.civitai_query || obj.look_at || obj.controls);
|
||||
if (cardish && !genish && (obj.name || obj.triggers || obj.when)) {
|
||||
return true;
|
||||
}
|
||||
return !!(obj.kind && obj.name && (obj.triggers || obj.when || obj.prompt_hint || obj.notes != null));
|
||||
}
|
||||
|
||||
/** True when the object looks like a generation patch rather than a catalog card / arbitrary JSON. */
|
||||
function isPatchObject(obj) {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return false;
|
||||
}
|
||||
if (isCardObject(obj)) {
|
||||
return false;
|
||||
}
|
||||
return PATCH_KEYS.some((k) => has(obj, k));
|
||||
}
|
||||
|
||||
/** Maps alias fields onto canonical names, keeping the aliases in place. */
|
||||
function normalizePatch(patch) {
|
||||
if (!patch || typeof patch !== 'object') {
|
||||
return patch;
|
||||
}
|
||||
if (!has(patch, 'search_query') && has(patch, 'civitai_query')) {
|
||||
patch.search_query = patch.civitai_query;
|
||||
}
|
||||
if (!has(patch, 'init_creativity') && has(patch, 'denoise')) {
|
||||
patch.init_creativity = patch.denoise;
|
||||
}
|
||||
if (!has(patch, 'look_at')) {
|
||||
if (has(patch, 'vision_from')) {
|
||||
patch.look_at = patch.vision_from;
|
||||
} else if (has(patch, 'vision_slots')) {
|
||||
patch.look_at = patch.vision_slots;
|
||||
}
|
||||
}
|
||||
return patch;
|
||||
}
|
||||
|
||||
/** Splits a reply into prose and the last fenced patch object found in it. */
|
||||
function extractPatch(text) {
|
||||
if (!text) {
|
||||
return { prose: text || '', patch: null };
|
||||
}
|
||||
const re = new RegExp(FENCE_RE.source, 'gi');
|
||||
let match;
|
||||
let lastPatch = null;
|
||||
let prose = text;
|
||||
while ((match = re.exec(text)) !== null) {
|
||||
try {
|
||||
const obj = JSON.parse(match[1].trim());
|
||||
if (isPatchObject(obj)) {
|
||||
lastPatch = normalizePatch(obj);
|
||||
prose = (text.slice(0, match.index) + text.slice(match.index + match[0].length)).trim();
|
||||
}
|
||||
} catch (e) { /* not json */ }
|
||||
}
|
||||
return { prose, patch: lastPatch };
|
||||
}
|
||||
|
||||
SA.PATCH_KEYS = PATCH_KEYS;
|
||||
SA.isCardObject = isCardObject;
|
||||
SA.isPatchObject = isPatchObject;
|
||||
SA.normalizePatch = normalizePatch;
|
||||
SA.extractPatch = extractPatch;
|
||||
})();
|
||||
␍
|
||||
Reference in New Issue
Block a user