@dsh-agentic-roleplay/core 0.8.1 → 0.8.2

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.
Files changed (35) hide show
  1. package/lib/{access-DtOxFKBK.js → access-CfQWbNZP.js} +4 -7
  2. package/lib/{authoring-tools-DNnx0Nts.js → authoring-tools-BgmC2oqU.js} +223 -106
  3. package/lib/authoring.js +15 -22
  4. package/lib/{child-D6mpkkCE.js → child-lYYeOwl2.js} +28 -51
  5. package/lib/client.js +615 -778
  6. package/lib/client.js.map +1 -1
  7. package/lib/compaction.js +8 -13
  8. package/lib/{doctor-chat-ByDfCMeo.js → doctor-chat-hL1a61hp.js} +2 -3
  9. package/lib/doctor.js +6 -8
  10. package/lib/{gallery-D9nG3C78.js → gallery-D1V4h8vh.js} +3 -4
  11. package/lib/{generator-r1Czm7oi.js → generator-CLPosooC.js} +3 -4
  12. package/lib/helper.js +2 -3
  13. package/lib/{hooks-BQCzgggH.js → hooks-rQTTeOC4.js} +69 -97
  14. package/lib/images.js +4 -4
  15. package/lib/index.js +194 -264
  16. package/lib/{library-zI-2tG7h.js → library-Dfu0dgRj.js} +9 -15
  17. package/lib/{lorebook-author-tools-ywaYicwd.js → lorebook-author-tools-BAaAqZZm.js} +10 -13
  18. package/lib/lorebook-authoring.js +5 -6
  19. package/lib/{narration-CnBlVure.js → narration-CjB_KwwY.js} +9 -15
  20. package/lib/orchestration.js +53 -64
  21. package/lib/{pack-jail-5EJ-WYyW.js → pack-jail-CN-314ln.js} +76 -81
  22. package/lib/{packs-Cv8hanXJ.js → packs-DIj5BEfq.js} +6 -10
  23. package/lib/{presenter-agent-BSaMSd3G.js → presenter-agent-DR0KvLE0.js} +12 -18
  24. package/lib/{preset-CWI3-0r1.js → preset-CscHj1-Y.js} +5 -6
  25. package/lib/{preset-author-tools-BrJYa2cr.js → preset-author-tools-CxluF8qc.js} +12 -14
  26. package/lib/preset-authoring.js +6 -7
  27. package/lib/{presets-MwOSMMyu.js → presets-HB8kJTaE.js} +51 -56
  28. package/lib/{reflection-zSaMsjKj.js → reflection-Dg1xtOTW.js} +19 -30
  29. package/lib/{text-BzudpQLS.js → text-DyRN4nDP.js} +6 -8
  30. package/lib/{turn-guard-Cv8pfHEA.js → turn-guard-g_hDn0jR.js} +6 -11
  31. package/package.json +29 -29
  32. package/prompts/en/import/casting.md +1 -1
  33. package/prompts/en/import/character.md +1 -0
  34. package/prompts/zh/import/casting.md +1 -1
  35. package/prompts/zh/import/character.md +1 -0
@@ -1,14 +1,14 @@
1
- import { a as chatSessionId } from "./access-DtOxFKBK.js";
2
- import { $ as knowsCharacter, A as alternateOpenings, At as loadCharacters, Bt as authoredWorldOf, C as addressKey, Dt as loadCalendar, E as fetchPictures, F as WORLD_FILE_NAME, I as parseWorldFile, M as openingMessage, N as writePortrait, O as mergeReports, P as serialized, Q as loadValidatedWorld, St as loadFactions, T as candidateUrls, Vt as authoringChatSessionId, _t as LOCATIONS_DIR, at as populateItems, bt as loadItems, c as importPhase, dt as populateVariables, gt as loadLore, h as writeSnapshot, ht as LORE_DIR, i as contextOf, j as cardCharacter, jt as subfolders, kt as CHARACTERS_DIR, m as editsSince, mt as loadTriggers, p as recordProvenance, pt as TRIGGERS_FILE_NAME, s as worldOf, st as populateLocations, tt as populateCharacters, vt as loadLocations, w as addressesToFetch, xt as FACTIONS_DIR, yt as ITEMS_DIR } from "./authoring-tools-DNnx0Nts.js";
3
- import { $ as writeChoices, G as withPlayer, K as IMPORT_FOLDER, O as findEntity, Q as readImportFolder, T as sourcesFor, U as itemise, V as writeWorldPrompt, X as openingText, Y as PICTURE_FILE, _t as parseCharacterFile, bt as InvalidEditProblems, ct as LOCATION_FILE_NAME, ft as parseItemFile, gt as CHARACTER_FILE_NAME, ht as parseFactionFile, lt as parseLocationFile, mt as FACTION_FILE_NAME, ot as LORE_FILE_NAME, rt as loadVariables, st as parseLoreFile, ut as ITEM_FILE_NAME, v as extractStyleFrom } from "./presets-MwOSMMyu.js";
4
- import { l as atomicWrite, m as parseSwitchboard, n as encodeOutput, u as atomicWriteJson } from "./narration-CnBlVure.js";
5
- import { B as PLOTS_FILE_NAME, F as LANGUAGE_NAMES, H as parsePlotsFile, I as STORY_LANGUAGES, J as formatIssue, L as isStoryLanguage, R as textLanguage, U as plotReferenceProblems, V as loadPlots, Z as PROMPTS_FOLDER, it as shippedLanguages, lt as InvalidWorldError, pt as WorldNotFoundError, st as AgentUnavailableError } from "./hooks-BQCzgggH.js";
6
- import { i as translator, r as languageOf } from "./text-BzudpQLS.js";
7
- import { u as parseSampling } from "./child-D6mpkkCE.js";
8
- import { b as mapLimit, h as readImageFileMetadata, u as referenceImagePath, x as norm } from "./library-zI-2tG7h.js";
9
- import { n as readPreset } from "./preset-CWI3-0r1.js";
10
- import { _ as API_PREFIX, a as packIds, d as packPath, f as readPack, h as PACK_MEDIA_TYPES, l as isPackId } from "./packs-Cv8hanXJ.js";
11
- import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-r1Czm7oi.js";
1
+ import { a as chatSessionId } from "./access-CfQWbNZP.js";
2
+ import { $ as loadValidatedWorld, At as CHARACTERS_DIR, Ct as loadFactions, D as fetchPictures, E as candidateUrls, F as serialized, Ht as authoringChatSessionId, I as WORLD_FILE_NAME, L as parseWorldFile, M as cardCharacter, Mt as subfolders, N as openingMessage, Ot as loadCalendar, P as writePortrait, St as FACTIONS_DIR, T as addressesToFetch, Vt as authoredWorldOf, _t as loadLore, bt as ITEMS_DIR, c as importPhase, ct as populateLocations, et as knowsCharacter, ft as populateVariables, g as writeSnapshot, gt as LORE_DIR, h as editsSince, ht as loadTriggers, i as contextOf, j as alternateOpenings, jt as loadCharacters, k as mergeReports, m as recordProvenance, mt as TRIGGERS_FILE_NAME, nt as populateCharacters, ot as populateItems, s as worldOf, vt as LOCATIONS_DIR, w as addressKey, xt as loadItems, yt as loadLocations } from "./authoring-tools-BgmC2oqU.js";
3
+ import { A as sourcesFor, Ct as parseCharacterFile, Et as InvalidEditProblems, N as findEntity, Q as IMPORT_FOLDER, St as CHARACTER_FILE_NAME, Y as itemise, Z as withPlayer, at as writeChoices, bt as FACTION_FILE_NAME, ft as LORE_FILE_NAME, gt as ITEM_FILE_NAME, ht as parseLocationFile, it as readImportFolder, lt as loadVariables, mt as LOCATION_FILE_NAME, nt as openingText, pt as parseLoreFile, q as writeWorldPrompt, tt as PICTURE_FILE, vt as parseItemFile, x as extractStyleFrom, xt as parseFactionFile } from "./presets-HB8kJTaE.js";
4
+ import { l as atomicWrite, m as parseSwitchboard, n as encodeOutput, u as atomicWriteJson } from "./narration-CjB_KwwY.js";
5
+ import { B as loadPlots, F as STORY_LANGUAGES, H as plotReferenceProblems, I as isStoryLanguage, J as formatIssue, L as textLanguage, P as LANGUAGE_NAMES, V as parsePlotsFile, Z as PROMPTS_FOLDER, it as shippedLanguages, lt as InvalidWorldError, pt as WorldNotFoundError, st as AgentUnavailableError, z as PLOTS_FILE_NAME } from "./hooks-rQTTeOC4.js";
6
+ import { i as translator, r as languageOf } from "./text-DyRN4nDP.js";
7
+ import { u as parseSampling } from "./child-lYYeOwl2.js";
8
+ import { b as mapLimit, h as readImageFileMetadata, u as referenceImagePath, x as norm } from "./library-Dfu0dgRj.js";
9
+ import { n as readPreset } from "./preset-CscHj1-Y.js";
10
+ import { _ as API_PREFIX, a as packIds, d as packPath, f as readPack, h as PACK_MEDIA_TYPES, l as isPackId } from "./packs-DIj5BEfq.js";
11
+ import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-CLPosooC.js";
12
12
  import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
13
13
  import { existsSync, lstatSync, statSync } from "node:fs";
14
14
  import { randomUUID } from "node:crypto";
@@ -18,7 +18,7 @@ import { ToolCallId, createMessage, createSystemMessage, createToolResultMessage
18
18
  import { setApprovalPolicy } from "@deepseek-ai/dsh-user-approval";
19
19
  import { defineTool } from "@deepseek-ai/dsh-tools";
20
20
  import { createSessionStore, readTriggerDefinition, triggerReferenceProblems, writeCalendar } from "@dsh-agentic-roleplay/state";
21
- //#region src/host/agent/opening.ts
21
+ // src/host/agent/opening.ts
22
22
  /** What the opening is reported to come from, where a chat shows the source of a message. */
23
23
  const OPENING_SOURCE = {
24
24
  provider: "roleplay",
@@ -195,11 +195,8 @@ function authoringOpeningEvents(welcome, source = AUTHORING_OPENING_SOURCE) {
195
195
  async function storeOpening(persistence, chat, segments, events = openingEvents(segments)) {
196
196
  await storeInitialEvents(persistence, chat, events);
197
197
  }
198
- async function storeAuthoringOpening(persistence, chat, welcome) {
199
- await storeInitialEvents(persistence, chat, authoringOpeningEvents(welcome));
200
- }
201
- async function storeDoctorOpening(persistence, chat, welcome) {
202
- await storeInitialEvents(persistence, chat, authoringOpeningEvents(welcome, DOCTOR_OPENING_SOURCE));
198
+ async function storeAuthoringOpening(persistence, chat, welcome, source) {
199
+ await storeInitialEvents(persistence, chat, authoringOpeningEvents(welcome, source));
203
200
  }
204
201
  async function storeInitialEvents(persistence, chat, events) {
205
202
  const header = {
@@ -218,8 +215,7 @@ async function storeInitialEvents(persistence, chat, events) {
218
215
  await handle.close();
219
216
  }
220
217
  }
221
- //#endregion
222
- //#region src/host/agent/agent-sessions.ts
218
+ // src/host/agent/agent-sessions.ts
223
219
  /** Title of the DSH project that groups every roleplay chat. */
224
220
  const PROJECT_TITLE = "Roleplay";
225
221
  /** The agent preset roleplay chats run under; it is declared by the bundle. */
@@ -394,10 +390,42 @@ var AgentSessions = class {
394
390
  }
395
391
  }
396
392
  };
397
- //#endregion
398
- //#region src/host/agent/authoring-sessions.ts
399
- const AUTHORING_PROJECT_TITLE = "World Authoring";
400
- const AUTHORING_AGENT_PRESET = "world-authoring";
393
+ // src/host/agent/ensure-authoring-chat.ts
394
+ /**
395
+ * Creates or reopens the authoring chat of a subject in the project of its kind: its language is kept, its opening is stored before the chat is made (a stored chat not yet in the project is adopted,
396
+ * not made again), and the chat is made or adopted.
397
+ * @throws {AgentUnavailableError} when the profile cannot store an opening.
398
+ */
399
+ async function ensureAuthoringChat(services, roleplayRoot, prompts, languages, kind, subject) {
400
+ if (subject.languageKey !== void 0) languages?.set(subject.languageKey, subject.language);
401
+ const language = subject.languageKey === void 0 ? subject.language : languages?.get(subject.languageKey);
402
+ const projectPath = join(roleplayRoot, kind.folder);
403
+ const project = await services.registry.create(projectPath, kind.projectTitle);
404
+ const existed = project.sessionIds.includes(subject.chatId);
405
+ const stored = !existed && await isStored(services.persistence, subject.chatId);
406
+ if (!existed && !stored) {
407
+ if (services.persistence === void 0) throw new AgentUnavailableError("this DSH profile cannot store the opening of an authoring chat");
408
+ await storeAuthoringOpening(services.persistence, {
409
+ id: subject.chatId,
410
+ cwd: project.path,
411
+ agentPreset: kind.agentPreset
412
+ }, prompts.text(kind.welcome, language, subject.welcome), kind.openingSource);
413
+ }
414
+ return await ensureAgentChat(services, {
415
+ projectPath,
416
+ projectTitle: kind.projectTitle,
417
+ sessionId: subject.chatId,
418
+ agentPreset: kind.agentPreset,
419
+ title: subject.title,
420
+ renameExisting: subject.renameExisting
421
+ }, project);
422
+ }
423
+ const KIND = {
424
+ folder: "worlds",
425
+ projectTitle: "World Authoring",
426
+ agentPreset: "world-authoring",
427
+ welcome: "world/welcome"
428
+ };
401
429
  /** The title of a world's authoring chat, in the language of the person who opened it. */
402
430
  function authoringTitle(worldName, language) {
403
431
  return translator(languageOf(language))("Authoring {name}", { name: worldName });
@@ -415,30 +443,14 @@ var AuthoringSessions = class {
415
443
  this.languages = languages;
416
444
  }
417
445
  async ensure(worldId, worldName, title, language) {
418
- const chatTitle = title ?? authoringTitle(worldName, language);
419
- this.languages.set(worldId, language);
420
- const services = this.services();
421
- const projectPath = join(this.roleplayRoot(), "worlds");
422
- const project = await services.registry.create(projectPath, AUTHORING_PROJECT_TITLE);
423
- const sessionId = authoringChatSessionId(worldId);
424
- const existed = project.sessionIds.includes(sessionId);
425
- const stored = !existed && await isStored(services.persistence, sessionId);
426
- if (!existed && !stored) {
427
- if (services.persistence === void 0) throw new AgentUnavailableError("this DSH profile cannot store the opening of an authoring chat");
428
- await storeAuthoringOpening(services.persistence, {
429
- id: sessionId,
430
- cwd: project.path,
431
- agentPreset: AUTHORING_AGENT_PRESET
432
- }, this.prompts.text("world/welcome", this.languages.get(worldId), { world: worldName }));
433
- }
434
- return await ensureAgentChat(services, {
435
- projectPath,
436
- projectTitle: AUTHORING_PROJECT_TITLE,
437
- sessionId,
438
- agentPreset: AUTHORING_AGENT_PRESET,
439
- title: chatTitle,
446
+ return await ensureAuthoringChat(this.services(), this.roleplayRoot(), this.prompts, this.languages, KIND, {
447
+ chatId: authoringChatSessionId(worldId),
448
+ languageKey: worldId,
449
+ title: title ?? authoringTitle(worldName, language),
450
+ language,
451
+ welcome: { world: worldName },
440
452
  renameExisting: true
441
- }, project);
453
+ });
442
454
  }
443
455
  /** Sends a message into a chat as if the person had written it. */
444
456
  async send(sessionId, text) {
@@ -453,8 +465,7 @@ var AuthoringSessions = class {
453
465
  }, new AbortController().signal);
454
466
  }
455
467
  };
456
- //#endregion
457
- //#region src/host/import/card-tools.ts
468
+ // src/host/import/card-tools.ts
458
469
  /** The most of a piece one `card_read` returns; a long lorebook entry is read in turns. */
459
470
  const READ_CHARS = 6e3;
460
471
  const SNIPPET_CHARS = 240;
@@ -823,8 +834,7 @@ function originOf(card, choices, pieces, records, name) {
823
834
  }];
824
835
  });
825
836
  }
826
- //#endregion
827
- //#region src/host/import/card-diff.ts
837
+ // src/host/import/card-diff.ts
828
838
  const MAX_SEGMENTS = 1500;
829
839
  const MAX_HUNK_CHARS = 700;
830
840
  /** Entries that kept neither their title nor their keys count as the same one only when this much of their words is shared. */
@@ -996,8 +1006,7 @@ function worldFieldChanges(before, after) {
996
1006
  });
997
1007
  return changes;
998
1008
  }
999
- //#endregion
1000
- //#region src/host/import/update.ts
1009
+ // src/host/import/update.ts
1001
1010
  const PREVIOUS_FOLDER = "previous";
1002
1011
  const CLASSIFICATION = "classification.json";
1003
1012
  const sameName = (a, b) => a.normalize("NFKC").trim().toLowerCase() === b.normalize("NFKC").trim().toLowerCase();
@@ -1262,8 +1271,7 @@ async function refreshPortrait(directory, picture, cardName) {
1262
1271
  }))) return "kept";
1263
1272
  return await writePortrait(directory, picture, documents, cardName) ? "replaced" : "kept";
1264
1273
  }
1265
- //#endregion
1266
- //#region src/host/translate/terms.ts
1274
+ // src/host/translate/terms.ts
1267
1275
  const STOP = /* @__PURE__ */ new Set([
1268
1276
  "the",
1269
1277
  "and",
@@ -1351,8 +1359,7 @@ function usesTerm(text, term) {
1351
1359
  const escaped = term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1352
1360
  return new RegExp(`(?<![\\p{L}\\p{N}])${escaped}(?![\\p{L}\\p{N}])`, "u").test(text);
1353
1361
  }
1354
- //#endregion
1355
- //#region src/host/translate/prose.ts
1362
+ // src/host/translate/prose.ts
1356
1363
  const rooted = (roots, paths) => roots.flatMap((root) => paths.map((path) => `${root}${path}`));
1357
1364
  const INTENT = [
1358
1365
  ".name",
@@ -1577,8 +1584,7 @@ async function readWorldDocuments(directory) {
1577
1584
  }
1578
1585
  return found;
1579
1586
  }
1580
- //#endregion
1581
- //#region src/host/translate/translate-world.ts
1587
+ // src/host/translate/translate-world.ts
1582
1588
  /** What is not carried over to a translation: the removed things of the editor and the card import's working files. */
1583
1589
  const NOT_COPIED = /* @__PURE__ */ new Set([".trash", ".import"]);
1584
1590
  const TERMS_PER_JOB = 40;
@@ -1825,8 +1831,7 @@ async function translateWorld(ctx, worlds, source, to, told) {
1825
1831
  ])
1826
1832
  };
1827
1833
  }
1828
- //#endregion
1829
- //#region src/host/translate/tools.ts
1834
+ // src/host/translate/tools.ts
1830
1835
  const TRANSLATE_TOOL = "translate_world";
1831
1836
  /** The message that has the authoring chat translate its world, in the language of the person who asked. */
1832
1837
  function translateMessage(text, to, language) {
@@ -1865,8 +1870,7 @@ function translateTools(worlds, settings, prompting) {
1865
1870
  }
1866
1871
  })];
1867
1872
  }
1868
- //#endregion
1869
- //#region src/host/worlds/world-info.ts
1873
+ // src/host/worlds/world-info.ts
1870
1874
  const textOf$1 = (value) => typeof value === "string" ? value : "";
1871
1875
  const toolsOf = (value) => {
1872
1876
  const board = value === void 0 ? {} : parseSwitchboard(value, "tools");
@@ -1981,8 +1985,7 @@ async function changeWorldInfo(directory, edit) {
1981
1985
  await atomicWrite(join(directory, WORLD_FILE_NAME), next);
1982
1986
  return infoOf(document);
1983
1987
  }
1984
- //#endregion
1985
- //#region src/host/import/preset-tools.ts
1988
+ // src/host/import/preset-tools.ts
1986
1989
  const PRESET_TOOL = "import_preset";
1987
1990
  const PRESET_FILE = "preset.json";
1988
1991
  const PRESET_PATH = `${IMPORT_FOLDER}/${PRESET_FILE}`;
@@ -2040,8 +2043,7 @@ function presetTools(worlds, settings, prompting) {
2040
2043
  }
2041
2044
  })];
2042
2045
  }
2043
- //#endregion
2044
- //#region src/host/triggers/parts.ts
2046
+ // src/host/triggers/parts.ts
2045
2047
  /** What the files of a world say it has, for checking what a trigger names. @throws {InvalidEditProblems} when those files have problems of their own: they are fixed first. */
2046
2048
  async function loadWorldParts(directory) {
2047
2049
  const { characters, problems: characterProblems } = await loadCharacters(directory);
@@ -2069,8 +2071,7 @@ async function loadWorldParts(directory) {
2069
2071
  calendar
2070
2072
  };
2071
2073
  }
2072
- //#endregion
2073
- //#region src/host/triggers/check.ts
2074
+ // src/host/triggers/check.ts
2074
2075
  /**
2075
2076
  * What each trigger names that the world does not have (a character, place, item or variable in its condition, its cues or the words of a
2076
2077
  * cue), found as a session start finds it: against a scratch story made from the world's files. Triggers that wait for each other count
@@ -2109,8 +2110,7 @@ function triggerProblemsOf(parts, definitions) {
2109
2110
  }
2110
2111
  return found;
2111
2112
  }
2112
- //#endregion
2113
- //#region src/host/triggers/files.ts
2113
+ // src/host/triggers/files.ts
2114
2114
  /** The fields of a trigger in the file; any other is a mistake that would otherwise be dropped without a word. */
2115
2115
  const FIELDS = /* @__PURE__ */ new Set([
2116
2116
  "key",
@@ -2203,8 +2203,7 @@ async function deleteTriggerDocument(directory, key) {
2203
2203
  await writeDocuments(directory, documents.filter((entry) => entry !== found));
2204
2204
  return kept;
2205
2205
  }
2206
- //#endregion
2207
- //#region src/host/worlds/world-editor.ts
2206
+ // src/host/worlds/world-editor.ts
2208
2207
  function stateOf(world, definition, names) {
2209
2208
  const { start } = definition;
2210
2209
  const portrait = referenceImagePath(world.directory, {
@@ -3092,8 +3091,7 @@ async function removeWorldTrigger(world, key) {
3092
3091
  await deleteTriggerDocument(world.directory, key);
3093
3092
  return await readWorldEditor(world);
3094
3093
  }
3095
- //#endregion
3096
- //#region src/host/authoring/documents.ts
3094
+ // src/host/authoring/documents.ts
3097
3095
  const AUTHORED_ENTITY_KINDS = [
3098
3096
  "character",
3099
3097
  "location",
@@ -3199,8 +3197,7 @@ async function deleteAuthoredEntity(world, kind, key) {
3199
3197
  await rename(dirname(found.file), destination);
3200
3198
  return destination;
3201
3199
  }
3202
- //#endregion
3203
- //#region src/host/interface/world-packs.ts
3200
+ // src/host/interface/world-packs.ts
3204
3201
  /** The kinds of file an assistant may write, as text. */
3205
3202
  const TEXT_EXTENSIONS = [
3206
3203
  "html",
@@ -3252,8 +3249,7 @@ async function deleteWorldPackFile(directory, pack, path) {
3252
3249
  }]
3253
3250
  };
3254
3251
  }
3255
- //#endregion
3256
- //#region src/host/authoring/pack-jail.ts
3252
+ // src/host/authoring/pack-jail.ts
3257
3253
  /** DSH's own file tools, which the world authoring chat uses on the interface packs and nothing else. */
3258
3254
  const PACK_FILE_TOOLS = [
3259
3255
  "read",
@@ -3343,7 +3339,6 @@ async function packJail(exec, next, deps) {
3343
3339
  function registerPackJail(ctx, deps) {
3344
3340
  ctx.on("tools/pre-execute", (exec, next) => packJail(exec, next, deps), { prepend: true });
3345
3341
  }
3346
- //#endregion
3347
- export { matchPieces as $, worldEntityImageFile as A, readWorldInfo as B, readWorldEditor as C, uploadWorldCharacterPortrait as D, replaceFile as E, loadWorldParts as F, findTargets as G, translateTools as H, PRESET_FILE as I, revertUpdate as J, finishUpdate as K, presetMessage as L, deleteTriggerDocument as M, readTriggerDocuments as N, uploadWorldEntityImage as O, writeTriggerDocument as P, diffText as Q, presetTools as R, generateWorldEntityImage as S, removeWorldTrigger as T, languageOfDocuments as U, translateMessage as V, readWorldDocuments as W, updateStatus as X, startUpdate as Y, cardChanges as Z, editWorldPlots as _, deleteWorldPackFile as a, authoringTitle as at, entityFolder as b, createAuthoredEntity as c, ensureAgentChat as ct, replaceAuthoredEntity as d, appendNarratedTurn as dt, worldFieldChanges as et, editWorldCharacter as f, storeAuthoringOpening as ft, editWorldPlace as g, editWorldNarrationVoice as h, checkWorldPack as i, AuthoringSessions as it, writeWorldTrigger as j, worldCharacterPortraitFile as k, deleteAuthoredEntity as l, isStored as lt, editWorldLore as m, packFileProblem as n, entitiesByPiece as nt, listWorldPacks as o, AgentSessions as ot, editWorldFaction as p, storeDoctorOpening as pt, pendingUpdate as q, registerPackJail as r, readSource as rt, AUTHORED_ENTITY_KINDS as s, agentServicesOf as st, MAX_PACK_TEXT as t, cardTools as tt, readAuthoredEntityDocument as u, appendEmptyTurn as ut, editWorldRelation as v, readWorldTrigger as w, generateWorldCharacterPortrait as x, editWorldThing as y, editWorldInfo as z };
3342
+ export { matchPieces as $, worldEntityImageFile as A, readWorldInfo as B, readWorldEditor as C, uploadWorldCharacterPortrait as D, replaceFile as E, loadWorldParts as F, findTargets as G, translateTools as H, PRESET_FILE as I, revertUpdate as J, finishUpdate as K, presetMessage as L, deleteTriggerDocument as M, readTriggerDocuments as N, uploadWorldEntityImage as O, writeTriggerDocument as P, diffText as Q, presetTools as R, generateWorldEntityImage as S, removeWorldTrigger as T, languageOfDocuments as U, translateMessage as V, readWorldDocuments as W, updateStatus as X, startUpdate as Y, cardChanges as Z, editWorldPlots as _, deleteWorldPackFile as a, authoringTitle as at, entityFolder as b, createAuthoredEntity as c, agentServicesOf as ct, replaceAuthoredEntity as d, appendNarratedTurn as dt, worldFieldChanges as et, editWorldCharacter as f, editWorldPlace as g, editWorldNarrationVoice as h, checkWorldPack as i, AuthoringSessions as it, writeWorldTrigger as j, worldCharacterPortraitFile as k, deleteAuthoredEntity as l, DOCTOR_OPENING_SOURCE as lt, editWorldLore as m, packFileProblem as n, entitiesByPiece as nt, listWorldPacks as o, ensureAuthoringChat as ot, editWorldFaction as p, pendingUpdate as q, registerPackJail as r, readSource as rt, AUTHORED_ENTITY_KINDS as s, AgentSessions as st, MAX_PACK_TEXT as t, cardTools as tt, readAuthoredEntityDocument as u, appendEmptyTurn as ut, editWorldRelation as v, readWorldTrigger as w, generateWorldCharacterPortrait as x, editWorldThing as y, editWorldInfo as z };
3348
3343
 
3349
- //# sourceMappingURL=pack-jail-5EJ-WYyW.js.map
3344
+ //# sourceMappingURL=pack-jail-CN-314ln.js.map
@@ -1,12 +1,11 @@
1
- import { q as Reader } from "./hooks-BQCzgggH.js";
1
+ import { q as Reader } from "./hooks-rQTTeOC4.js";
2
2
  import { dirname, extname, join, posix, sep } from "node:path";
3
3
  import { copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync } from "node:fs";
4
4
  import { createHash } from "node:crypto";
5
- //#region src/shared/worlds.ts
5
+ // src/shared/worlds.ts
6
6
  /** Path prefix of the plugin's HTTP API. Relative, so a mounted deployment resolves it against the page. */
7
7
  const API_PREFIX = "roleplay-api";
8
- //#endregion
9
- //#region src/shared/interface-pack.ts
8
+ // src/shared/interface-pack.ts
10
9
  /** What a surface may do for the player; a pack lists the ones it uses. */
11
10
  const PACK_ACTIONS = [
12
11
  "say",
@@ -75,8 +74,7 @@ const PACK_MEDIA_TYPES = {
75
74
  ogg: "audio/ogg",
76
75
  wav: "audio/wav"
77
76
  };
78
- //#endregion
79
- //#region src/host/interface/skin.ts
77
+ // src/host/interface/skin.ts
80
78
  const NESTABLE = /* @__PURE__ */ new Set(["media", "supports"]);
81
79
  const FORBIDDEN_TEXT = [
82
80
  "expression(",
@@ -382,8 +380,7 @@ function checkSkin(css, url) {
382
380
  problems: context.problems
383
381
  };
384
382
  }
385
- //#endregion
386
- //#region src/host/interface/pack.ts
383
+ // src/host/interface/pack.ts
387
384
  const ID = /^[\p{L}\p{N}][\p{L}\p{N}_-]{0,59}$/u;
388
385
  const SEGMENT = /^[\p{L}\p{N}_.-]+$/u;
389
386
  const TOKEN_NAME = /^--dsw-alias-[a-z0-9-]+$/;
@@ -837,7 +834,6 @@ function anyTab(bases) {
837
834
  }
838
835
  }));
839
836
  }
840
- //#endregion
841
837
  export { API_PREFIX as _, packIds as a, describePack as c, packPath as d, readPack as f, SURFACE_NAMES as g, PACK_MEDIA_TYPES as h, inheritPacks as i, isPackId as l, PACK_LIMITS as m, anyTab as n, syncWorldPacks as o, PACK_ACTIONS as p, copyWorldPacks as r, worldPackStates as s, activePack as t, packFile as u };
842
838
 
843
- //# sourceMappingURL=packs-Cv8hanXJ.js.map
839
+ //# sourceMappingURL=packs-DIj5BEfq.js.map
@@ -1,15 +1,15 @@
1
- import { t as promptFor } from "./access-DtOxFKBK.js";
2
- import { c as runChild } from "./child-D6mpkkCE.js";
3
- import { c as nextSceneSerial, u as referenceImagePath } from "./library-zI-2tG7h.js";
4
- import { n as generateTransientImage, t as generateReferenceImage } from "./generator-r1Czm7oi.js";
5
- import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-D9nG3C78.js";
1
+ import { t as promptFor } from "./access-CfQWbNZP.js";
2
+ import { c as runChild } from "./child-lYYeOwl2.js";
3
+ import { n as generateTransientImage, t as generateReferenceImage } from "./generator-CLPosooC.js";
4
+ import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-D1V4h8vh.js";
5
+ import { c as nextSceneSerial, u as referenceImagePath } from "./library-Dfu0dgRj.js";
6
6
  import { dirname, join, relative } from "node:path";
7
7
  import { existsSync } from "node:fs";
8
8
  import { createHash, randomUUID } from "node:crypto";
9
9
  import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
10
10
  import { defineTool } from "@deepseek-ai/dsh-tools";
11
11
  import { characterKey, itemKey, locationKey } from "@dsh-agentic-roleplay/state";
12
- //#region src/host/images/presented.ts
12
+ // src/host/images/presented.ts
13
13
  const PRESENTED_FOLDER = "presented";
14
14
  const fileOf = (folder, node) => join(folder, "images", PRESENTED_FOLDER, `${node}.json`);
15
15
  /** The images shown for a timeline node that were not made for it. */
@@ -34,8 +34,7 @@ async function present(sessionFolder, node, image) {
34
34
  }] }, null, 2));
35
35
  await rename(temporary, file);
36
36
  }
37
- //#endregion
38
- //#region src/host/images/image-search.ts
37
+ // src/host/images/image-search.ts
39
38
  const WORD = /[\p{L}\p{N}]+/gu;
40
39
  const CJK = /[㐀-鿿぀-ヿ가-힯]/u;
41
40
  /** Function words that say nothing about a picture, so that "a boat at anchor" does not find a wood because both have an "a". */
@@ -118,8 +117,7 @@ function searchImages(images, query) {
118
117
  };
119
118
  }).filter((match) => match.score > 0).sort((a, b) => b.score - a.score || b.image.createdAt.localeCompare(a.image.createdAt)).slice(0, query.limit ?? 5);
120
119
  }
121
- //#endregion
122
- //#region src/host/images/image-vectors.ts
120
+ // src/host/images/image-vectors.ts
123
121
  const VECTORS_FILE = ".vectors.json";
124
122
  /** Images closer than this to the query by meaning are candidates even when they share no word with it. */
125
123
  const MIN_SIMILARITY = .35;
@@ -251,8 +249,7 @@ async function findImages(sessionFolder, images, query, embedder, signal) {
251
249
  };
252
250
  }
253
251
  }
254
- //#endregion
255
- //#region src/host/images/tools.ts
252
+ // src/host/images/tools.ts
256
253
  const kindSchema = {
257
254
  type: "string",
258
255
  enum: [
@@ -664,8 +661,7 @@ function imageTools(deps) {
664
661
  transient
665
662
  ];
666
663
  }
667
- //#endregion
668
- //#region src/host/images/interpreter.ts
664
+ // src/host/images/interpreter.ts
669
665
  const RESULT$1 = {
670
666
  type: "object",
671
667
  properties: {
@@ -796,8 +792,7 @@ async function interpretImage(job) {
796
792
  subjects: answer.subjects
797
793
  });
798
794
  }
799
- //#endregion
800
- //#region src/host/images/presenter-agent.ts
795
+ // src/host/images/presenter-agent.ts
801
796
  const RESULT = {
802
797
  type: "object",
803
798
  properties: { summary: {
@@ -849,7 +844,6 @@ async function runImagePresenter(job) {
849
844
  images: [...generated]
850
845
  };
851
846
  }
852
- //#endregion
853
847
  export { tokensOf as a, searchImages as i, interpretImage as n, present as o, imageTools as r, presentedFor as s, runImagePresenter as t };
854
848
 
855
- //# sourceMappingURL=presenter-agent-BSaMSd3G.js.map
849
+ //# sourceMappingURL=presenter-agent-DR0KvLE0.js.map
@@ -1,7 +1,7 @@
1
- import { Nt as ImportCardError, r as MAX_PREVIEW_TEXT } from "./authoring-tools-DNnx0Nts.js";
2
- import { H as cleanText } from "./presets-MwOSMMyu.js";
3
- import { l as SAMPLING_RANGES } from "./child-D6mpkkCE.js";
4
- //#region src/host/import/preset.ts
1
+ import { Pt as ImportCardError, r as MAX_PREVIEW_TEXT } from "./authoring-tools-BgmC2oqU.js";
2
+ import { l as SAMPLING_RANGES } from "./child-lYYeOwl2.js";
3
+ import { J as cleanText } from "./presets-HB8kJTaE.js";
4
+ // src/host/import/preset.ts
5
5
  /** The older preset layout keeps its texts under fixed keys. */
6
6
  const LEGACY_KEYS = [
7
7
  "main_prompt",
@@ -237,7 +237,6 @@ function selectPrompts(file, enabled, keepSampling) {
237
237
  }];
238
238
  return Buffer.from(JSON.stringify(kept));
239
239
  }
240
- //#endregion
241
240
  export { readPreset as n, selectPrompts as r, previewPreset as t };
242
241
 
243
- //# sourceMappingURL=preset-CWI3-0r1.js.map
242
+ //# sourceMappingURL=preset-CscHj1-Y.js.map
@@ -1,14 +1,14 @@
1
- import "./access-DtOxFKBK.js";
2
- import { i as contextOf } from "./authoring-tools-DNnx0Nts.js";
3
- import { B as readWorldPrompt, G as withPlayer, K as IMPORT_FOLDER, L as PROSE_PROMPTS, R as deleteWorldPrompt, V as writeWorldPrompt, c as presetDirectory, l as readPreset, p as updatePresetInfo, t as PRESET_FILE, v as extractStyleFrom, z as listWorldPrompts } from "./presets-MwOSMMyu.js";
4
- import { at as shippedPromptsDirectory, it as shippedLanguages, tt as languageOf } from "./hooks-BQCzgggH.js";
5
- import { i as translator, r as languageOf$1 } from "./text-BzudpQLS.js";
6
- import { n as readPreset$1 } from "./preset-CWI3-0r1.js";
1
+ import "./access-CfQWbNZP.js";
2
+ import { G as listWorldPrompts, K as readWorldPrompt, Q as IMPORT_FOLDER, U as PROSE_PROMPTS, W as deleteWorldPrompt, Z as withPlayer, c as presetDirectory, l as readPreset, p as updatePresetInfo, q as writeWorldPrompt, t as PRESET_FILE, x as extractStyleFrom } from "./presets-HB8kJTaE.js";
3
+ import { n as readPreset$1 } from "./preset-CscHj1-Y.js";
4
+ import { i as contextOf } from "./authoring-tools-BgmC2oqU.js";
5
+ import { i as translator, r as languageOf } from "./text-DyRN4nDP.js";
6
+ import { at as shippedPromptsDirectory, it as shippedLanguages, tt as languageOf$1 } from "./hooks-rQTTeOC4.js";
7
7
  import { join } from "node:path";
8
8
  import { existsSync } from "node:fs";
9
9
  import { readFile, rm } from "node:fs/promises";
10
10
  import { defineTool } from "@deepseek-ai/dsh-tools";
11
- //#region src/shared/preset-chat.ts
11
+ // src/shared/preset-chat.ts
12
12
  const PREFIX = "preset-author-";
13
13
  /** Stable DSH chat identity for the authoring conversation of one library preset. */
14
14
  function presetChatSessionId(name) {
@@ -25,8 +25,7 @@ function presetOfChat(chatSessionId) {
25
25
  return;
26
26
  }
27
27
  }
28
- //#endregion
29
- //#region src/host/authoring/preset-author-tools.ts
28
+ // src/host/authoring/preset-author-tools.ts
30
29
  const PRESET_MUTATION_TOOLS = [
31
30
  "write_preset_prompt",
32
31
  "delete_preset_prompt",
@@ -37,7 +36,7 @@ const NARRATION_IMPORT_TOOL = "import_narration_preset";
37
36
  const UPLOAD_PATH = `${IMPORT_FOLDER}/${PRESET_FILE}`;
38
37
  /** The command that has a preset's authoring chat turn an uploaded SillyTavern preset into prompts. */
39
38
  function narrationImportMessage(language) {
40
- return translator(languageOf$1(language))("Turn the SillyTavern preset I uploaded into this preset's prompts: call {tool} with file {file}.", {
39
+ return translator(languageOf(language))("Turn the SillyTavern preset I uploaded into this preset's prompts: call {tool} with file {file}.", {
41
40
  tool: NARRATION_IMPORT_TOOL,
42
41
  file: UPLOAD_PATH
43
42
  });
@@ -143,7 +142,7 @@ function presetAuthorTools(reader, settings, prompting, shipped = shippedPrompts
143
142
  return json({
144
143
  action: "written",
145
144
  id: args.id,
146
- language: languageOf(args.language)
145
+ language: languageOf$1(args.language)
147
146
  });
148
147
  }
149
148
  }),
@@ -161,7 +160,7 @@ function presetAuthorTools(reader, settings, prompting, shipped = shippedPrompts
161
160
  return json({
162
161
  action: "deleted",
163
162
  id: args.id,
164
- language: languageOf(args.language),
163
+ language: languageOf$1(args.language),
165
164
  trashPath
166
165
  });
167
166
  }
@@ -277,7 +276,6 @@ async function presetApproval(exec, next, carries) {
277
276
  }
278
277
  };
279
278
  }
280
- //#endregion
281
279
  export { presetChatSessionId as a, presetAuthorTools as i, narrationImportMessage as n, presetOfChat as o, presetApproval as r, PresetReader as t };
282
280
 
283
- //# sourceMappingURL=preset-author-tools-BrJYa2cr.js.map
281
+ //# sourceMappingURL=preset-author-tools-CxluF8qc.js.map
@@ -1,11 +1,11 @@
1
- import { n as limitAuthoringAgents } from "./authoring-tools-DNnx0Nts.js";
2
- import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-BrJYa2cr.js";
3
- import { c as presetDirectory } from "./presets-MwOSMMyu.js";
4
- import "./hooks-BQCzgggH.js";
5
- import { t as guardAuthoringTurns } from "./turn-guard-Cv8pfHEA.js";
1
+ import { n as limitAuthoringAgents } from "./authoring-tools-BgmC2oqU.js";
2
+ import { t as guardAuthoringTurns } from "./turn-guard-g_hDn0jR.js";
3
+ import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-CxluF8qc.js";
4
+ import "./hooks-rQTTeOC4.js";
5
+ import { c as presetDirectory } from "./presets-HB8kJTaE.js";
6
6
  import { join } from "node:path";
7
7
  import { existsSync } from "node:fs";
8
- //#region src/preset-authoring.ts
8
+ // src/preset-authoring.ts
9
9
  const name = "@dsh-agentic-roleplay/core/preset-authoring";
10
10
  const inject = [
11
11
  "roleplayRoot",
@@ -55,7 +55,6 @@ function apply(ctx) {
55
55
  text: (context) => ctx.roleplayPrompts.text(id, languageOf(context))
56
56
  });
57
57
  }
58
- //#endregion
59
58
  export { apply, inject, name };
60
59
 
61
60
  //# sourceMappingURL=preset-authoring.js.map