@dsh-agentic-roleplay/core 0.3.6 → 0.4.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/lib/{tools-Dy1fgP6B.js → authoring-tools-C2BHkEFP.js} +129 -25
- package/lib/authoring.js +7 -5
- package/lib/{child-CFjnaTZt.js → child-DsixtqTw.js} +94 -2
- package/lib/client.js +3758 -2276
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +3 -2
- package/lib/doctor.js +2 -4
- package/lib/{gallery-DIEgETzU.js → gallery-CDYKJf_O.js} +2 -2
- package/lib/{generator-DJ48HxPI.js → generator-BR1ugzln.js} +2 -2
- package/lib/{deliver-BBgciEEK.js → hooks-CHmUksFS.js} +1963 -236
- package/lib/images.js +4 -4
- package/lib/index.js +847 -254
- package/lib/{library-9JB9zw5a.js → library-COIktKBa.js} +4 -3
- package/lib/{lorebook-author-tools-Bj31z1cu.js → lorebook-author-tools-CaT74Q7v.js} +118 -43
- package/lib/lorebook-authoring.js +5 -3
- package/lib/{settings-CA6icLL_.js → narration-DstnwrvX.js} +148 -2
- package/lib/orchestration.js +344 -37
- package/lib/{pack-jail-2XztyYAX.js → pack-jail-CEDDI4Xw.js} +170 -13
- package/lib/{packs-xHRCcGdb.js → packs-DB_9xiCp.js} +7 -4
- package/lib/{presenter-agent-DnNEG_Mn.js → presenter-agent-Gu34bZwd.js} +6 -6
- package/lib/preset-BL1d40oG.js +242 -0
- package/lib/{preset-author-tools-BxycmoAr.js → preset-author-tools-B2wZXKZo.js} +7 -7
- package/lib/preset-authoring.js +6 -3
- package/lib/{presets-gkBWAiVb.js → presets-Dc15L6OU.js} +9 -26
- package/lib/{reflection-q0UpwXlx.js → reflection-BWMVdHhR.js} +51 -17
- package/package.json +2 -2
- package/packs/scene/map.html +1 -0
- package/packs/scene/strip.html +1 -0
- package/prompts/en/import/lorebook.md +2 -1
- package/prompts/en/import/style.md +1 -0
- package/prompts/en/lorebook/procedure.md +1 -1
- package/prompts/en/preset/procedure.md +1 -1
- package/prompts/en/roleplay/character-lookup.md +1 -0
- package/prompts/en/roleplay/game-master.md +1 -1
- package/prompts/en/roleplay/record-keeper.md +3 -3
- package/prompts/en/world/procedure.md +1 -1
- package/prompts/zh/import/lorebook.md +2 -1
- package/prompts/zh/import/style.md +1 -0
- package/prompts/zh/lorebook/procedure.md +1 -1
- package/prompts/zh/preset/procedure.md +1 -1
- package/prompts/zh/roleplay/character-lookup.md +1 -0
- package/prompts/zh/roleplay/game-master.md +1 -1
- package/prompts/zh/roleplay/record-keeper.md +3 -3
- package/prompts/zh/world/procedure.md +1 -1
- package/lib/hooks-DkwFGtNH.js +0 -1060
- package/lib/language-BgyxtB2h.js +0 -38
- package/lib/load-CVwJjIJ5.js +0 -486
- package/lib/narration-DK2kiIjE.js +0 -141
- package/lib/preset-D0FMSeZ9.js +0 -59
package/lib/preset-D0FMSeZ9.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { It as ImportCardError } from "./tools-Dy1fgP6B.js";
|
|
2
|
-
//#region src/host/import/preset.ts
|
|
3
|
-
/** The older preset layout keeps its texts under fixed keys. */
|
|
4
|
-
const LEGACY_KEYS = [
|
|
5
|
-
"main_prompt",
|
|
6
|
-
"nsfw_prompt",
|
|
7
|
-
"jailbreak_prompt",
|
|
8
|
-
"impersonation_prompt",
|
|
9
|
-
"new_chat_prompt",
|
|
10
|
-
"new_group_chat_prompt",
|
|
11
|
-
"new_example_chat_prompt"
|
|
12
|
-
];
|
|
13
|
-
const MAX_PIECES = 60;
|
|
14
|
-
const MAX_PIECE_CHARS = 8e3;
|
|
15
|
-
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16
|
-
const text = (value) => typeof value === "string" ? value.trim() : "";
|
|
17
|
-
/** The order the preset sends its prompts in: the longest list it gives, with what each entry says about being on. */
|
|
18
|
-
function orderOf(root) {
|
|
19
|
-
return ((Array.isArray(root["prompt_order"]) ? root["prompt_order"].flatMap((entry) => isObject(entry) && Array.isArray(entry["order"]) ? [entry["order"]] : []) : []).sort((a, b) => b.length - a.length)[0] ?? []).flatMap((entry) => isObject(entry) && typeof entry["identifier"] === "string" ? [{
|
|
20
|
-
identifier: entry["identifier"],
|
|
21
|
-
enabled: entry["enabled"] !== false
|
|
22
|
-
}] : []);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Reads a preset file. Markers (places where chat history or the card's fields are inserted), switched-off prompts and empty ones are left out.
|
|
26
|
-
* @throws {ImportCardError} when the file is not a preset, with why.
|
|
27
|
-
*/
|
|
28
|
-
function readPreset(file, name) {
|
|
29
|
-
let root;
|
|
30
|
-
try {
|
|
31
|
-
root = JSON.parse(file.toString("utf8").replace(/^/, ""));
|
|
32
|
-
} catch {
|
|
33
|
-
throw new ImportCardError("the file is not JSON: a preset is the .json file SillyTavern exports");
|
|
34
|
-
}
|
|
35
|
-
if (!isObject(root)) throw new ImportCardError("the file is not a preset: it must be a JSON object");
|
|
36
|
-
const pieces = [];
|
|
37
|
-
const prompts = Array.isArray(root["prompts"]) ? root["prompts"].filter(isObject) : [];
|
|
38
|
-
if (prompts.length > 0) {
|
|
39
|
-
const byId = new Map(prompts.flatMap((prompt) => typeof prompt["identifier"] === "string" ? [[prompt["identifier"], prompt]] : []));
|
|
40
|
-
const ordered = orderOf(root);
|
|
41
|
-
const chosen = ordered.length > 0 ? ordered.flatMap((entry) => entry.enabled && byId.has(entry.identifier) ? [byId.get(entry.identifier)] : []) : prompts.filter((prompt) => prompt["enabled"] !== false);
|
|
42
|
-
for (const prompt of chosen) {
|
|
43
|
-
const content = text(prompt["content"]);
|
|
44
|
-
if (prompt["marker"] === true || content === "") continue;
|
|
45
|
-
const title = text(prompt["name"]);
|
|
46
|
-
pieces.push(`${title === "" ? "" : `[${title}]\n`}${content.slice(0, MAX_PIECE_CHARS)}`);
|
|
47
|
-
}
|
|
48
|
-
} else for (const key of LEGACY_KEYS) if (text(root[key]) !== "") pieces.push(`[${key}]\n${text(root[key]).slice(0, MAX_PIECE_CHARS)}`);
|
|
49
|
-
if (pieces.length === 0) throw new ImportCardError("the file holds no instructions this importer can read: a preset has a \"prompts\" list with texts in it");
|
|
50
|
-
const title = text(root["name"]) || text(root["preset_name"]);
|
|
51
|
-
return {
|
|
52
|
-
name: title === "" ? name.replace(/\.json$/i, "") : title,
|
|
53
|
-
pieces: pieces.slice(0, MAX_PIECES)
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
//#endregion
|
|
57
|
-
export { readPreset as t };
|
|
58
|
-
|
|
59
|
-
//# sourceMappingURL=preset-D0FMSeZ9.js.map
|