@dsh-agentic-roleplay/core 0.7.0 → 0.7.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 (45) hide show
  1. package/README.md +1 -1
  2. package/lib/access-DtOxFKBK.js +150 -0
  3. package/lib/{authoring-tools-BWjEr_lF.js → authoring-tools-q34iq3hW.js} +160 -74
  4. package/lib/authoring.js +494 -31
  5. package/lib/{child-D5SVNk4O.js → child-CyCViUKa.js} +48 -7
  6. package/lib/client.js +1094 -604
  7. package/lib/client.js.map +1 -1
  8. package/lib/compaction.js +3 -3
  9. package/lib/doctor.js +3 -3
  10. package/lib/{gallery-C7VOJ3xH.js → gallery-BxZGOgMb.js} +2 -2
  11. package/lib/{generator-CO8usAjE.js → generator-BFmSYvR8.js} +2 -2
  12. package/lib/helper.js +1 -1
  13. package/lib/{hooks-DufjUf1p.js → hooks-HnqXO8mM.js} +6 -245
  14. package/lib/images.js +4 -4
  15. package/lib/index.js +168 -104
  16. package/lib/{library-DsDc6fQa.js → library-BGxPKs9a.js} +6 -3
  17. package/lib/{lorebook-author-tools-v-PM8Kbs.js → lorebook-author-tools-D9RrMK5g.js} +31 -28
  18. package/lib/lorebook-authoring.js +8 -3
  19. package/lib/{narration-_dA9oIt2.js → narration-DvFBqmqe.js} +9 -132
  20. package/lib/orchestration.js +11 -10
  21. package/lib/{pack-jail--Ij90LeY.js → pack-jail-MPekqSuQ.js} +14 -12
  22. package/lib/{packs-DWKnL4YX.js → packs-jowC-MN_.js} +2 -2
  23. package/lib/{presenter-agent-BHSbyWwZ.js → presenter-agent-DvZtnf0Q.js} +6 -6
  24. package/lib/{preset-CDNyJhfU.js → preset-VatN-845.js} +3 -3
  25. package/lib/{preset-author-tools-D7Azdlaq.js → preset-author-tools-8kv1Glxe.js} +11 -10
  26. package/lib/preset-authoring.js +9 -4
  27. package/lib/{reflection-CRCWK2E1.js → reflection-CvOZGjmn.js} +9 -170
  28. package/lib/{presets-D11bxWX0.js → route-DRTJ_vcA.js} +165 -4
  29. package/lib/text-JbWfTHbr.js +295 -0
  30. package/lib/turn-guard-BvCs1VxB.js +53 -0
  31. package/package.json +2 -2
  32. package/prompts/en/import/cut-off.md +1 -0
  33. package/prompts/en/import/finish-failed.md +1 -1
  34. package/prompts/en/import/finish-ok.md +1 -1
  35. package/prompts/en/roleplay/decide-instruction.md +1 -0
  36. package/prompts/en/roleplay/decide-irrelevant.md +1 -0
  37. package/prompts/en/world/procedure.md +1 -1
  38. package/prompts/zh/import/cut-off.md +1 -0
  39. package/prompts/zh/import/finish-failed.md +1 -1
  40. package/prompts/zh/import/finish-ok.md +1 -1
  41. package/prompts/zh/roleplay/decide-instruction.md +1 -0
  42. package/prompts/zh/roleplay/decide-irrelevant.md +1 -0
  43. package/prompts/zh/world/procedure.md +1 -1
  44. package/lib/access-EbNdZFbk.js +0 -25
  45. package/lib/text-CT1re6XT.js +0 -18
package/lib/index.js CHANGED
@@ -1,20 +1,20 @@
1
- import { n as chatSessionId, r as roleplaySessionOf } from "./access-EbNdZFbk.js";
2
- import { B as loadItems, Bt as ImportCardError, C as populateLocations, D as populateVariables, E as populateTriggers, Et as writeLorebookEntry, F as loadCalendar, Ft as parseLoreEdit, Gt as LORE_SCOPES, Ht as pictureOf, I as parseCalendarFile, It as parsePlaceEdit, J as withPlayer, Jt as DICE_RESULTS, Kt as DICE_COMPARISONS, Lt as parseRelationEdit, M as loadDice, Mt as InvalidEditProblems, N as parseDiceFile, Nt as parseCharacterEdit, O as routineProblems, P as CALENDAR_FILE_NAME, Pt as parseFactionEdit, Q as variableProblems, R as loadLocations, Rt as parseThingEdit, S as populateKnowledge, St as lorebookDirectory, T as populateRoutines, Tt as updateLorebookInfo, U as CHARACTERS_DIR, Ut as readCard, Vt as isPng, W as loadCharacters, Wt as LORE_KINDS, X as loadVariables, Y as VARIABLES_FILE_NAME, Z as parseVariablesFile, _ as populateCharacters, _t as deleteLorebookEntry, at as CHARACTER_FILE_NAME, b as populateFactions, bt as listLorebooks, ct as ImportNotFoundError, d as markReady, dt as WORLD_FILE_NAME, f as guardedLookup, ft as parseWorldFile, g as populateCalendar, gt as deleteLorebook, h as knowsCharacter, ht as createLorebook, j as DICE_FILE_NAME, jt as subfolders, k as TRIGGERS_FILE_NAME, l as authoringChatSessionId, lt as ImportStore, m as loadValidatedWorld, mt as addLorebookEntries, ot as parseCharacterFile, p as vetUrl, pt as parseWorldInfoEdit, q as partsOf, qt as DICE_READINGS, st as IMPORT_FOLDER, t as AuthoringTools, ut as parseChoices, v as populateClock, vt as entriesOf, w as populateLore, wt as reserveLorebook, x as populateItems, xt as loadLorebook, y as populateDice, yt as isLorebookName, zt as IMPORT_COMMAND } from "./authoring-tools-BWjEr_lF.js";
3
- import { _ as readWorldPrompt, a as isPresetName, c as presetDirectory, d as savePresetFromWorld, g as listWorldPrompts, h as deleteWorldPrompt, i as deletePreset, o as listPresets, p as updatePresetInfo, r as createPresetFromShipped, s as loadPreset, t as PRESET_FILE, u as reservePreset, v as writeWorldPrompt } from "./presets-D11bxWX0.js";
4
- import { _ as readTimeline, b as defaultBoundaries, d as TimelineError, g as switchPreset, h as recordPreset, i as reflectionStatus, m as presetStatus, p as copyPreset, v as writeTimeline, y as pathTo } from "./reflection-CRCWK2E1.js";
5
- import { a as liveSettings, b as VARIABLE_VISIBILITIES, c as writeSettings, d as parseSettings, i as InvalidSettingsError, l as DEFAULT_SETTINGS, n as encodeOutput, o as readSettings, p as WORLD_RULES_KEY, s as useChildReasoning, u as SETTINGS_SPEC, v as VARIABLE_KINDS, y as VARIABLE_SUBJECTS } from "./narration-_dA9oIt2.js";
6
- import { C as readNotes, G as formatIssue, H as plotReferenceProblems, K as errorMessage, M as plotProgressOf, N as populatePlots, O as zoneOf, Q as languageOf, S as notesOfSession, U as readDocument, V as parsePlotsFile, X as copyWorldPrompts, Y as PromptLibrary, _ as readRunDetail, at as InvalidWorldError, b as readWithdrawn, ct as SessionNotFoundError, dt as translator, g as readActivity, h as readDecisionStats, i as externalTools, it as InvalidStartError, j as PLOTS_METADATA_KEY, lt as WorldNotFoundError, m as readUsage, ot as ReflectionRefusedError, rt as AgentUnavailableError, st as SessionArchivedError, tt as shippedLanguages, ut as languageOf$1, w as observeAsPlayer, x as addToNote } from "./hooks-DufjUf1p.js";
7
- import { t as trimCharacters } from "./text-CT1re6XT.js";
8
- import { c as parseSampling, l as sharedSamplingOf, r as childSamplingOf } from "./child-D5SVNk4O.js";
9
- import { a as inheritImages, b as slug, c as referenceImagePath, l as sceneImagePath, t as addToLibrary, x as uniqueKey } from "./library-DsDc6fQa.js";
10
- import { A as worldEntityImageFile, B as readWorldInfo, C as readWorldEditor, D as uploadWorldCharacterPortrait, E as replaceFile, F as loadWorldParts, I as PRESET_FILE$1, L as presetMessage, O as uploadWorldEntityImage, S as generateWorldEntityImage, T as removeWorldTrigger, U as languageOfDocuments, V as translateMessage, W as readWorldDocuments, _ as editWorldPlots$1, a as deleteWorldPackFile, b as entityFolder, c as createAuthoredEntity, f as editWorldCharacter$1, g as editWorldPlace$1, h as editWorldNarrationVoice, j as writeWorldTrigger, k as worldCharacterPortraitFile, l as deleteAuthoredEntity, m as editWorldLore$1, n as packFileProblem, p as editWorldFaction$1, t as MAX_PACK_TEXT, u as readAuthoredEntityDocument, v as editWorldRelation$1, w as readWorldTrigger, x as generateWorldCharacterPortrait, y as editWorldThing$1, z as editWorldInfo } from "./pack-jail--Ij90LeY.js";
11
- import { n as readPreset, r as selectPrompts, t as previewPreset } from "./preset-CDNyJhfU.js";
12
- import { a as lorebookImportMessage, d as selectEntries, l as previewLorebook, s as lorebookChatSessionId, t as LOREBOOK_UPLOAD, u as readLorebook } from "./lorebook-author-tools-v-PM8Kbs.js";
13
- import { a as presetChatSessionId, n as narrationImportMessage } from "./preset-author-tools-D7Azdlaq.js";
1
+ import { a as chatSessionId, i as VARIABLE_VISIBILITIES, n as VARIABLE_KINDS, o as roleplaySessionOf, r as VARIABLE_SUBJECTS } from "./access-DtOxFKBK.js";
2
+ import { $ as variableProblems, A as loadDice, Bt as parseThingEdit, C as populateRoutines, Ct as loadLorebook, D as TRIGGERS_FILE_NAME, Dt as updateLorebookInfo, E as routineProblems, Et as reserveLorebook, Ft as parseCharacterEdit, Gt as readCard, H as loadCharacters, Ht as ImportCardError, I as loadLocations, It as parseFactionEdit, J as partsOf, Jt as DICE_COMPARISONS, Kt as LORE_KINDS, Lt as parseLoreEdit, M as CALENDAR_FILE_NAME, N as loadCalendar, Nt as subfolders, Ot as writeLorebookEntry, P as parseCalendarFile, Pt as InvalidEditProblems, Q as parseVariablesFile, Qt as authoringChatSessionId, R as loadItems, Rt as parsePlaceEdit, S as populateLore, St as listLorebooks, T as populateVariables, Ut as isPng, V as CHARACTERS_DIR, Vt as IMPORT_COMMAND, Wt as pictureOf, X as VARIABLES_FILE_NAME, Xt as DICE_RESULTS, Y as withPlayer, Yt as DICE_READINGS, Z as loadVariables, Zt as authoredWorldOf, _ as populateDice, _t as createLorebook, b as populateKnowledge, bt as entriesOf, ct as IMPORT_FOLDER, d as vetUrl, dt as parseChoices, f as loadValidatedWorld, g as populateClock, gt as addLorebookEntries, h as populateCharacters, ht as parseWorldInfoEdit, j as parseDiceFile, k as DICE_FILE_NAME, l as markReady, lt as ImportNotFoundError, m as populateCalendar, mt as parseWorldFile, ot as CHARACTER_FILE_NAME, p as knowsCharacter, pt as WORLD_FILE_NAME, qt as LORE_SCOPES, st as parseCharacterFile, t as AuthoringTools, u as guardedLookup, ut as ImportStore, v as populateFactions, vt as deleteLorebook, w as populateTriggers, wt as lorebookDirectory, x as populateLocations, xt as isLorebookName, y as populateItems, yt as deleteLorebookEntry, zt as parseRelationEdit } from "./authoring-tools-q34iq3hW.js";
3
+ import { a as lorebookImportMessage, c as readLorebook, d as lorebookOfChat, l as selectEntries, s as previewLorebook, t as LOREBOOK_UPLOAD, u as lorebookChatSessionId } from "./lorebook-author-tools-D9RrMK5g.js";
4
+ import { a as presetChatSessionId, n as narrationImportMessage, o as presetOfChat } from "./preset-author-tools-8kv1Glxe.js";
5
+ import { C as readWorldPrompt, S as listWorldPrompts, _ as savePresetFromWorld, d as isPresetName, f as listPresets, g as reservePreset, l as createPresetFromShipped, m as presetDirectory, p as loadPreset, s as PRESET_FILE, u as deletePreset, w as writeWorldPrompt, x as deleteWorldPrompt, y as updatePresetInfo } from "./route-DRTJ_vcA.js";
6
+ import { c as copyPreset, d as switchPreset, f as readTimeline, h as defaultBoundaries, i as reflectionStatus, l as presetStatus, m as pathTo, o as TimelineError, p as writeTimeline, u as recordPreset } from "./reflection-CvOZGjmn.js";
7
+ import { a as liveSettings, c as writeSettings, d as parseSettings, i as InvalidSettingsError, l as DEFAULT_SETTINGS, n as encodeOutput, o as readSettings, p as WORLD_RULES_KEY, s as useChildReasoning, u as SETTINGS_SPEC } from "./narration-DvFBqmqe.js";
8
+ import { C as readNotes, G as formatIssue, H as plotReferenceProblems, K as errorMessage, M as plotProgressOf, N as populatePlots, O as zoneOf, Q as languageOf, S as notesOfSession, U as readDocument, V as parsePlotsFile, X as copyWorldPrompts, Y as PromptLibrary, _ as readRunDetail, at as InvalidWorldError, b as readWithdrawn, ct as SessionNotFoundError, g as readActivity, h as readDecisionStats, i as externalTools, it as InvalidStartError, j as PLOTS_METADATA_KEY, lt as WorldNotFoundError, m as readUsage, ot as ReflectionRefusedError, rt as AgentUnavailableError, st as SessionArchivedError, tt as shippedLanguages, w as observeAsPlayer, x as addToNote } from "./hooks-HnqXO8mM.js";
9
+ import { i as translator, r as languageOf$1, t as trimCharacters } from "./text-JbWfTHbr.js";
10
+ import { d as sharedSamplingOf, i as childSamplingOf, u as parseSampling } from "./child-CyCViUKa.js";
11
+ import { S as uniqueKey, a as inheritImages, b as slug, c as referenceImagePath, l as sceneImagePath, t as addToLibrary } from "./library-BGxPKs9a.js";
12
+ import { A as worldEntityImageFile, B as readWorldInfo, C as readWorldEditor, D as uploadWorldCharacterPortrait, E as replaceFile, F as loadWorldParts, I as PRESET_FILE$1, L as presetMessage, O as uploadWorldEntityImage, S as generateWorldEntityImage, T as removeWorldTrigger, U as languageOfDocuments, V as translateMessage, W as readWorldDocuments, _ as editWorldPlots$1, a as deleteWorldPackFile, b as entityFolder, c as createAuthoredEntity, f as editWorldCharacter$1, g as editWorldPlace$1, h as editWorldNarrationVoice, j as writeWorldTrigger, k as worldCharacterPortraitFile, l as deleteAuthoredEntity, m as editWorldLore$1, n as packFileProblem, p as editWorldFaction$1, t as MAX_PACK_TEXT, u as readAuthoredEntityDocument, v as editWorldRelation$1, w as readWorldTrigger, x as generateWorldCharacterPortrait, y as editWorldThing$1, z as editWorldInfo } from "./pack-jail-MPekqSuQ.js";
13
+ import { n as readPreset, r as selectPrompts, t as previewPreset } from "./preset-VatN-845.js";
14
14
  import { t as doctorChatSessionId } from "./doctor-chat-ByDfCMeo.js";
15
- import { _ as API_PREFIX, a as packIds, c as describePack, d as packPath, f as readPack, l as isPackId, m as PACK_LIMITS, n as anyTab, o as syncWorldPacks, r as copyWorldPacks, s as worldPackStates, t as activePack, u as packFile } from "./packs-DWKnL4YX.js";
16
- import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-CO8usAjE.js";
17
- import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-C7VOJ3xH.js";
15
+ import { _ as API_PREFIX, a as packIds, c as describePack, d as packPath, f as readPack, l as isPackId, m as PACK_LIMITS, n as anyTab, o as syncWorldPacks, r as copyWorldPacks, s as worldPackStates, t as activePack, u as packFile } from "./packs-jowC-MN_.js";
16
+ import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-BFmSYvR8.js";
17
+ import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-BxZGOgMb.js";
18
18
  import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
19
19
  import { cpSync, createReadStream, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
20
20
  import { createHash, randomBytes, randomUUID } from "node:crypto";
@@ -445,10 +445,73 @@ var AuthoringLanguages = class extends Service {
445
445
  //#region src/host/import/service.ts
446
446
  /** What an import is configured to do, for the parts of the plugin that run in other scopes (the authoring chat's tools). */
447
447
  var RoleplayImport = class extends Service {
448
- settings;
449
- constructor(ctx, settings) {
448
+ read;
449
+ constructor(ctx, read) {
450
450
  super(ctx, "roleplayImport");
451
- this.settings = settings;
451
+ this.read = read;
452
+ }
453
+ /** The settings as they stand now: they are edited while the plugin runs. */
454
+ get settings() {
455
+ return this.read();
456
+ }
457
+ };
458
+ //#endregion
459
+ //#region src/host/agent/authoring-sessions.ts
460
+ const AUTHORING_PROJECT_TITLE = "World Authoring";
461
+ const AUTHORING_AGENT_PRESET = "world-authoring";
462
+ /** The title of a world's authoring chat, in the language of the person who opened it. */
463
+ function authoringTitle(worldName, language) {
464
+ return translator(languageOf$1(language))("Authoring {name}", { name: worldName });
465
+ }
466
+ /** Creates or reopens the dedicated authoring chat of an authored world, and speaks in it for the person when asked to. */
467
+ var AuthoringSessions = class {
468
+ services;
469
+ roleplayRoot;
470
+ prompts;
471
+ languages;
472
+ constructor(services, roleplayRoot, prompts, languages) {
473
+ this.services = services;
474
+ this.roleplayRoot = roleplayRoot;
475
+ this.prompts = prompts;
476
+ this.languages = languages;
477
+ }
478
+ async ensure(worldId, worldName, title, language) {
479
+ const chatTitle = title ?? authoringTitle(worldName, language);
480
+ this.languages.set(worldId, language);
481
+ const services = this.services();
482
+ const projectPath = join(this.roleplayRoot(), "worlds");
483
+ const project = await services.registry.create(projectPath, AUTHORING_PROJECT_TITLE);
484
+ const sessionId = authoringChatSessionId(worldId);
485
+ const existed = project.sessionIds.includes(sessionId);
486
+ const stored = !existed && await isStored(services.persistence, sessionId);
487
+ if (!existed && !stored) {
488
+ if (services.persistence === void 0) throw new AgentUnavailableError("this DSH profile cannot store the opening of an authoring chat");
489
+ await storeAuthoringOpening(services.persistence, {
490
+ id: sessionId,
491
+ cwd: project.path,
492
+ agentPreset: AUTHORING_AGENT_PRESET
493
+ }, this.prompts.text("world/welcome", this.languages.get(worldId), { world: worldName }));
494
+ }
495
+ return await ensureAgentChat(services, {
496
+ projectPath,
497
+ projectTitle: AUTHORING_PROJECT_TITLE,
498
+ sessionId,
499
+ agentPreset: AUTHORING_AGENT_PRESET,
500
+ title: chatTitle,
501
+ renameExisting: true
502
+ }, project);
503
+ }
504
+ /** Sends a message into a chat as if the person had written it. */
505
+ async send(sessionId, text) {
506
+ await this.services().controller.prompt({
507
+ requestId: randomUUID(),
508
+ sessionId,
509
+ mode: "queue",
510
+ content: [{
511
+ type: "text",
512
+ text
513
+ }]
514
+ }, new AbortController().signal);
452
515
  }
453
516
  };
454
517
  //#endregion
@@ -532,7 +595,7 @@ async function startImport(deps, id, choices, language) {
532
595
  if (record === void 0) throw new WorldNotFoundError(`the world "${world.name}" was made but cannot be found`);
533
596
  await deps.store.adopt(id, record.directory);
534
597
  await markReady(record.directory);
535
- const chatSessionId = await deps.authoring.ensure(world.id, world.name, deps.chatTitle(world.name), language);
598
+ const chatSessionId = await deps.authoring.ensure(world.id, world.name, authoringTitle(world.name, language), language);
536
599
  let failure;
537
600
  try {
538
601
  await deps.authoring.send(chatSessionId, importMessage(language));
@@ -608,7 +671,7 @@ async function uploadPreset(deps, worldId, file, name, language) {
608
671
  const preset = readPreset(file, name);
609
672
  await mkdir(join(world.directory, IMPORT_FOLDER), { recursive: true });
610
673
  await writeFile(join(world.directory, IMPORT_FOLDER, PRESET_FILE$1), file);
611
- const chatSessionId = await deps.authoring.ensure(world.summary.id, world.summary.name, `Authoring ${world.summary.name}`, language);
674
+ const chatSessionId = await deps.authoring.ensure(world.summary.id, world.summary.name, authoringTitle(world.summary.name, language), language);
612
675
  let failure;
613
676
  try {
614
677
  await deps.authoring.send(chatSessionId, presetMessage(language));
@@ -716,60 +779,6 @@ function parseSelectionChoice(body) {
716
779
  };
717
780
  }
718
781
  //#endregion
719
- //#region src/host/agent/authoring-sessions.ts
720
- const AUTHORING_PROJECT_TITLE = "World Authoring";
721
- const AUTHORING_AGENT_PRESET = "world-authoring";
722
- /** Creates or reopens the dedicated authoring chat of an authored world, and speaks in it for the person when asked to. */
723
- var AuthoringSessions = class {
724
- services;
725
- roleplayRoot;
726
- prompts;
727
- languages;
728
- constructor(services, roleplayRoot, prompts, languages) {
729
- this.services = services;
730
- this.roleplayRoot = roleplayRoot;
731
- this.prompts = prompts;
732
- this.languages = languages;
733
- }
734
- async ensure(worldId, worldName, title = `Authoring ${worldName}`, language) {
735
- this.languages.set(worldId, language);
736
- const services = this.services();
737
- const projectPath = join(this.roleplayRoot(), "worlds");
738
- const project = await services.registry.create(projectPath, AUTHORING_PROJECT_TITLE);
739
- const sessionId = authoringChatSessionId(worldId);
740
- const existed = project.sessionIds.includes(sessionId);
741
- const stored = !existed && await isStored(services.persistence, sessionId);
742
- if (!existed && !stored) {
743
- if (services.persistence === void 0) throw new AgentUnavailableError("this DSH profile cannot store the opening of an authoring chat");
744
- await storeAuthoringOpening(services.persistence, {
745
- id: sessionId,
746
- cwd: project.path,
747
- agentPreset: AUTHORING_AGENT_PRESET
748
- }, this.prompts.text("world/welcome", this.languages.get(worldId), { world: worldName }));
749
- }
750
- return await ensureAgentChat(services, {
751
- projectPath,
752
- projectTitle: AUTHORING_PROJECT_TITLE,
753
- sessionId,
754
- agentPreset: AUTHORING_AGENT_PRESET,
755
- title,
756
- renameExisting: true
757
- }, project);
758
- }
759
- /** Sends a message into a chat as if the person had written it. */
760
- async send(sessionId, text) {
761
- await this.services().controller.prompt({
762
- requestId: randomUUID(),
763
- sessionId,
764
- mode: "queue",
765
- content: [{
766
- type: "text",
767
- text
768
- }]
769
- }, new AbortController().signal);
770
- }
771
- };
772
- //#endregion
773
782
  //#region src/host/agent/preset-authoring-sessions.ts
774
783
  const PRESET_AUTHORING_PROJECT_TITLE = "Preset Authoring";
775
784
  const PRESET_AUTHORING_PRESET = "preset-authoring";
@@ -3081,7 +3090,7 @@ function languageField(value) {
3081
3090
  throw new InvalidEditProblems([error instanceof Error ? error.message : String(error)]);
3082
3091
  }
3083
3092
  }
3084
- function createApiHandler({ catalogue, worlds, createWorld, starter, authorWorld, translation, worldCharacters, importer, avatars, worldFiles, worldEditor, sessions, packs, presets, lorebooks, sync, locked, anyLocked, connection, speech, externalTools }) {
3093
+ function createApiHandler({ catalogue, worlds, createWorld, starter, authorWorld, translation, worldCharacters, importer, avatars, worldFiles, worldEditor, sessions, packs, presets, lorebooks, sync, locked, anyLocked, connection, speech, externalTools, redundantLayers }) {
3085
3094
  const routes = {
3086
3095
  "/speech/capabilities": { GET: async (_req, res) => {
3087
3096
  sendJson(res, 200, { streaming: speech.streaming() });
@@ -4153,6 +4162,9 @@ function createApiHandler({ catalogue, worlds, createWorld, starter, authorWorld
4153
4162
  }
4154
4163
  await sendImage(res, image);
4155
4164
  } },
4165
+ "/setup": { GET: async (_req, res) => {
4166
+ sendJson(res, 200, { redundantLayers: redundantLayers?.() ?? [] });
4167
+ } },
4156
4168
  "/tools": { GET: async (_req, res) => {
4157
4169
  sendJson(res, 200, { tools: externalTools?.() ?? [] });
4158
4170
  } },
@@ -4642,6 +4654,35 @@ function purgeDepsOf(ctx, storePath) {
4642
4654
  }
4643
4655
  const purgeOf = (ctx, storePath) => (chat) => purgeChat(purgeDepsOf(ctx, storePath), chat);
4644
4656
  //#endregion
4657
+ //#region src/host/setup/rows.ts
4658
+ const ALL = ["@dsh-agentic-roleplay/all", "dsh-agentic-roleplay"];
4659
+ const SINGLE = [
4660
+ "@dsh-agentic-roleplay/core",
4661
+ "@dsh-agentic-roleplay/state",
4662
+ "dsh-agentic-roleplay-core",
4663
+ "dsh-roleplay-state"
4664
+ ];
4665
+ /** The bundle layers the profile has selected, in order; none when the profile cannot be read. */
4666
+ function selectedBundles(profileDir) {
4667
+ if (profileDir === void 0) return [];
4668
+ try {
4669
+ const bundles = JSON.parse(readFileSync(join(profileDir, "package.json"), "utf8")).dsh?.profile?.bundles;
4670
+ return Array.isArray(bundles) ? bundles.filter((name) => typeof name === "string") : [];
4671
+ } catch {
4672
+ return [];
4673
+ }
4674
+ }
4675
+ /**
4676
+ * The layers of single packages that are selected next to the `all` layer. Each of them inserts the same plugin row as `all`, so the profile then holds the row twice
4677
+ * and DSH, which writes a plugin's settings through its row, refuses every save of Settings → Role Play.
4678
+ */
4679
+ function redundantLayers(bundles) {
4680
+ return bundles.some((name) => ALL.includes(name)) ? bundles.filter((name) => SINGLE.includes(name)) : [];
4681
+ }
4682
+ function redundantLayersMessage(layers) {
4683
+ return `the profile selects ${layers.map((name) => `"${name}"`).join(", ")} next to the all bundle, which already inserts the same plugin rows, so DSH refuses to save the Role Play settings: deselect them (keep the packages installed) and restart`;
4684
+ }
4685
+ //#endregion
4645
4686
  //#region src/host/worlds/daily-life.ts
4646
4687
  /** The day each character lives, and the places its windows may name. */
4647
4688
  async function readRoutines(world) {
@@ -8603,14 +8644,19 @@ const Config = z.object({
8603
8644
  passwordRef: z.string().default(""),
8604
8645
  intervalMinutes: z.number().min(0).default(0)
8605
8646
  }).default({ ...DEFAULT_SYNC }).volatile(),
8606
- catalogueMaxBytes: z.number().min(1024).default(268435456),
8607
- catalogueTrashDays: z.number().min(0).default(30),
8608
- importMaxUploadBytes: z.number().min(1024).default(104857600),
8609
- importConcurrency: z.number().min(1).max(16).default(4),
8610
- importReasoning: z.string().default(""),
8611
- childReasoning: z.string().default(""),
8612
- importMaxTokens: z.number().min(1e3).max(2e5).default(16e3),
8613
- importTemperature: z.number().min(0).max(2).default(.2)
8647
+ catalogueMaxBytes: z.number().min(1024).default(268435456).volatile(),
8648
+ catalogueTrashDays: z.number().min(0).default(30).volatile(),
8649
+ importMaxUploadBytes: z.number().min(1024).default(104857600).volatile(),
8650
+ importConcurrency: z.number().min(1).max(16).default(4).volatile(),
8651
+ importReasoning: z.string().default("").volatile(),
8652
+ childReasoning: z.string().default("").volatile(),
8653
+ importModel: z.string().default("").volatile(),
8654
+ importMaxTokens: z.number().min(1e3).max(2e5).default(16e3).volatile(),
8655
+ importTemperature: z.number().min(0).max(2).default(.2).volatile(),
8656
+ importTimeoutMinutes: z.number().min(0).max(240).default(15).volatile(),
8657
+ importDecisions: z.union([z.const("llm"), z.const("decision")]).default("llm").volatile(),
8658
+ importConfidence: z.number().min(0).max(1).default(.7).volatile(),
8659
+ authoringApproval: z.union([z.const("ask"), z.const("auto")]).default("ask").volatile()
8614
8660
  });
8615
8661
  //#endregion
8616
8662
  //#region src/index.ts
@@ -8618,6 +8664,9 @@ const name = "@dsh-agentic-roleplay/core";
8618
8664
  /** Sessions are kept by the state plugin, which the bundle installs with this one. */
8619
8665
  const inject = ["roleplayState"];
8620
8666
  function apply(ctx, config) {
8667
+ const layers = () => redundantLayers(selectedBundles(ctx.get("profileContext")?.dir));
8668
+ const repeated = layers();
8669
+ if (repeated.length > 0) ctx.logger.error(redundantLayersMessage(repeated));
8621
8670
  ctx.inject(["aiProviders"], (scope) => {
8622
8671
  const providers = Reflect.get(scope, "aiProviders");
8623
8672
  scope.effect(() => providers.policy(({ options }) => {
@@ -8625,6 +8674,10 @@ function apply(ctx, config) {
8625
8674
  const id = String(options.sessionId);
8626
8675
  const helper = childSamplingOf(id);
8627
8676
  if (helper !== void 0) return helper;
8677
+ if (authoredWorldOf(id) !== void 0 || presetOfChat(id) !== void 0 || lorebookOfChat(id) !== void 0) return {
8678
+ maxTokens: config.importMaxTokens.get(),
8679
+ priority: "foreground"
8680
+ };
8628
8681
  const session = roleplaySessionOf(id);
8629
8682
  if (session === void 0) return void 0;
8630
8683
  const { sampling } = liveSettings(sessionFolder(join(root.path, "sessions"), session));
@@ -8636,7 +8689,7 @@ function apply(ctx, config) {
8636
8689
  };
8637
8690
  }), "roleplay: request controls");
8638
8691
  });
8639
- ctx.effect(() => useChildReasoning(config.childReasoning), "roleplay: helper thinking level");
8692
+ ctx.effect(() => useChildReasoning(() => config.childReasoning.get()), "roleplay: helper thinking level");
8640
8693
  const root = new RoleplayRoot(ctx, config.rootPath);
8641
8694
  root.start();
8642
8695
  const orchestration = new RoleplayOrchestration(ctx);
@@ -8654,13 +8707,20 @@ function apply(ctx, config) {
8654
8707
  const lorebookAuthoring = new LorebookAuthoringSessions(agentServicesOf(ctx), () => root.path, prompts, languages);
8655
8708
  const doctors = new DoctorSessions(agentServicesOf(ctx), () => root.path, prompts);
8656
8709
  const imports = new ImportStore(() => root.path);
8657
- const roleplayImport = new RoleplayImport(ctx, {
8658
- maxUploadBytes: config.importMaxUploadBytes,
8659
- concurrency: config.importConcurrency,
8660
- reasoning: config.importReasoning,
8661
- maxTokens: config.importMaxTokens,
8662
- temperature: config.importTemperature
8663
- });
8710
+ const roleplayImport = new RoleplayImport(ctx, () => ({
8711
+ get maxUploadBytes() {
8712
+ return config.importMaxUploadBytes.get();
8713
+ },
8714
+ concurrency: config.importConcurrency.get(),
8715
+ reasoning: config.importReasoning.get() || config.childReasoning.get(),
8716
+ model: config.importModel.get(),
8717
+ maxTokens: config.importMaxTokens.get(),
8718
+ temperature: config.importTemperature.get(),
8719
+ timeoutMinutes: config.importTimeoutMinutes.get(),
8720
+ decisions: config.importDecisions.get() === "decision" ? "decision" : "llm",
8721
+ confidence: config.importConfidence.get(),
8722
+ approval: config.authoringApproval.get() === "auto" ? "auto" : "ask"
8723
+ }));
8664
8724
  const settingsDeps = {
8665
8725
  sessionsDir: () => join(root.path, "sessions"),
8666
8726
  pendingRecords: (id) => ctx.roleplayState.openSession(join(root.path, "sessions"), id).pendingCommits.list().length,
@@ -8687,7 +8747,9 @@ function apply(ctx, config) {
8687
8747
  worldDirectory: async (worldId) => (await worlds.find(worldId))?.directory,
8688
8748
  authoring: presetAuthoring,
8689
8749
  importMessage: narrationImportMessage,
8690
- maxUploadBytes: config.importMaxUploadBytes,
8750
+ get maxUploadBytes() {
8751
+ return config.importMaxUploadBytes.get();
8752
+ },
8691
8753
  staging,
8692
8754
  playing: (id) => orchestration.playing(chatSessionId(id))
8693
8755
  });
@@ -8695,7 +8757,9 @@ function apply(ctx, config) {
8695
8757
  root: () => root.path,
8696
8758
  authoring: lorebookAuthoring,
8697
8759
  importMessage: lorebookImportMessage,
8698
- maxUploadBytes: config.importMaxUploadBytes,
8760
+ get maxUploadBytes() {
8761
+ return config.importMaxUploadBytes.get();
8762
+ },
8699
8763
  staging,
8700
8764
  session: (id) => {
8701
8765
  const sessions = join(root.path, "sessions");
@@ -8707,9 +8771,9 @@ function apply(ctx, config) {
8707
8771
  const catalogue = new Catalogue({
8708
8772
  sources: new Sources(() => config.catalogues.get(), () => ctx.get("credentials")),
8709
8773
  worlds,
8710
- maxBytes: () => config.catalogueMaxBytes,
8711
- maxCardBytes: () => config.importMaxUploadBytes,
8712
- trashDays: () => config.catalogueTrashDays,
8774
+ maxBytes: () => config.catalogueMaxBytes.get(),
8775
+ maxCardBytes: () => config.importMaxUploadBytes.get(),
8776
+ trashDays: () => config.catalogueTrashDays.get(),
8713
8777
  problem: (message) => {
8714
8778
  ctx.logger.warn(message);
8715
8779
  },
@@ -8720,16 +8784,14 @@ function apply(ctx, config) {
8720
8784
  startCard: async (id, choices, language) => await startImport({
8721
8785
  store: imports,
8722
8786
  worlds,
8723
- authoring,
8724
- chatTitle: (title) => `Authoring ${title}`
8787
+ authoring
8725
8788
  }, id, choices, language),
8726
8789
  importCard: async (file, name, language) => {
8727
8790
  const preview = await imports.create(readCard(file, name), isPng(file) ? pictureOf(file) : void 0);
8728
8791
  return await startImport({
8729
8792
  store: imports,
8730
8793
  worlds,
8731
- authoring,
8732
- chatTitle: (title) => `Authoring ${title}`
8794
+ authoring
8733
8795
  }, preview.id, preview.choices, language);
8734
8796
  }
8735
8797
  });
@@ -8791,7 +8853,9 @@ function apply(ctx, config) {
8791
8853
  }, id, to, title, language)
8792
8854
  },
8793
8855
  importer: {
8794
- maxUploadBytes: config.importMaxUploadBytes,
8856
+ get maxUploadBytes() {
8857
+ return config.importMaxUploadBytes.get();
8858
+ },
8795
8859
  upload: async (file, name) => {
8796
8860
  const card = readCard(file, name);
8797
8861
  return await imports.create(card, isPng(file) ? pictureOf(file) : void 0);
@@ -8802,8 +8866,7 @@ function apply(ctx, config) {
8802
8866
  start: (id, choices, language) => startImport({
8803
8867
  store: imports,
8804
8868
  worlds,
8805
- authoring,
8806
- chatTitle: (name) => `Authoring ${name}`
8869
+ authoring
8807
8870
  }, id, choices, language),
8808
8871
  picture: (id) => imports.picture(id),
8809
8872
  uploadPreset: (worldId, file, name, language) => uploadPreset({
@@ -8842,6 +8905,7 @@ function apply(ctx, config) {
8842
8905
  return await addAvatarsToWorld(await avatarsWorld(root.path), world, keys, locations);
8843
8906
  }
8844
8907
  },
8908
+ redundantLayers: layers,
8845
8909
  externalTools: () => {
8846
8910
  const registry = ctx.get("tools");
8847
8911
  return registry === void 0 ? [] : externalTools(registry);
@@ -1,9 +1,12 @@
1
- import { n as withoutExtension, t as trimCharacters } from "./text-CT1re6XT.js";
1
+ import "./access-DtOxFKBK.js";
2
+ import { i as translator, n as withoutExtension, r as languageOf, t as trimCharacters } from "./text-JbWfTHbr.js";
2
3
  import { dirname, extname, join } from "node:path";
3
4
  import { existsSync } from "node:fs";
4
5
  import { randomUUID } from "node:crypto";
5
6
  import { copyFile, link, mkdir, readFile, readdir, rename, unlink, writeFile } from "node:fs/promises";
6
7
  //#region src/host/import/run.ts
8
+ /** The labels of a job's prompt, in the language of the import. */
9
+ const trOf = (ctx) => translator(languageOf(ctx.language));
7
10
  /** Runs `work` on every item, at most `limit` at a time, and returns the results in the order of the items. */
8
11
  async function mapLimit(items, limit, work) {
9
12
  const results = new Array(items.length);
@@ -330,6 +333,6 @@ async function addToLibrary(sessionFolder, bytes, originalName) {
330
333
  return `${LIBRARY_FOLDER}/${name}`;
331
334
  }
332
335
  //#endregion
333
- export { withPngMetadata as _, inheritImages as a, slug as b, referenceImagePath as c, MEDIA_TYPES as d, mediaTypeOf as f, readPngMetadata as g, writeImageFileMetadata as h, entityImageDirectory as i, sceneImagePath as l, sidecarOf as m, imageExtensionOf as n, nextSceneSerial as o, readImageFileMetadata as p, LIBRARY_FOLDER as r, readImageMetadata as s, addToLibrary as t, writeImage as u, mapLimit as v, uniqueKey as x, norm as y };
336
+ export { uniqueKey as S, withPngMetadata as _, inheritImages as a, slug as b, referenceImagePath as c, MEDIA_TYPES as d, mediaTypeOf as f, readPngMetadata as g, writeImageFileMetadata as h, entityImageDirectory as i, sceneImagePath as l, sidecarOf as m, imageExtensionOf as n, nextSceneSerial as o, readImageFileMetadata as p, LIBRARY_FOLDER as r, readImageMetadata as s, addToLibrary as t, writeImage as u, mapLimit as v, trOf as x, norm as y };
334
337
 
335
- //# sourceMappingURL=library-DsDc6fQa.js.map
338
+ //# sourceMappingURL=library-BGxPKs9a.js.map
@@ -1,12 +1,31 @@
1
- import { Bt as ImportCardError, Ct as readLorebook$1, Et as writeLorebookEntry, Gt as LORE_SCOPES, J as withPlayer, K as cleanText, St as lorebookDirectory, Tt as updateLorebookInfo, Wt as LORE_KINDS, _t as deleteLorebookEntry, i as contextOf, q as partsOf, r as MAX_PREVIEW_TEXT, st as IMPORT_FOLDER, vt as entriesOf, xt as loadLorebook } from "./authoring-tools-BWjEr_lF.js";
2
- import { n as createPresetFromGuidance } from "./presets-D11bxWX0.js";
3
- import "./narration-_dA9oIt2.js";
4
- import { dt as translator, nt as shippedPromptsDirectory, ut as languageOf } from "./hooks-DufjUf1p.js";
5
- import { b as slug, v as mapLimit, x as uniqueKey } from "./library-DsDc6fQa.js";
1
+ import "./access-DtOxFKBK.js";
2
+ import { Ct as loadLorebook, Dt as updateLorebookInfo, Ht as ImportCardError, J as partsOf, K as cleanText, Kt as LORE_KINDS, Ot as writeLorebookEntry, Tt as readLorebook$1, Y as withPlayer, bt as entriesOf, ct as IMPORT_FOLDER, i as contextOf, qt as LORE_SCOPES, r as MAX_PREVIEW_TEXT, wt as lorebookDirectory, yt as deleteLorebookEntry } from "./authoring-tools-q34iq3hW.js";
3
+ import { c as createPresetFromGuidance } from "./route-DRTJ_vcA.js";
4
+ import { nt as shippedPromptsDirectory } from "./hooks-HnqXO8mM.js";
5
+ import { i as translator, r as languageOf } from "./text-JbWfTHbr.js";
6
+ import { S as uniqueKey, b as slug, v as mapLimit, x as trOf } from "./library-BGxPKs9a.js";
6
7
  import { join } from "node:path";
7
8
  import { existsSync, readFileSync } from "node:fs";
8
9
  import { defineTool } from "@deepseek-ai/dsh-tools";
9
10
  import { readFile, rm, writeFile } from "node:fs/promises";
11
+ //#region src/shared/lorebook-chat.ts
12
+ const PREFIX = "lorebook-author-";
13
+ /** Stable DSH chat identity for the authoring conversation of one library lorebook. */
14
+ function lorebookChatSessionId(name) {
15
+ if (name === "") throw new TypeError("lorebook name cannot be empty");
16
+ return `${PREFIX}${encodeURIComponent(name)}`;
17
+ }
18
+ /** The library lorebook named by a dedicated lorebook authoring chat. */
19
+ function lorebookOfChat(chatSessionId) {
20
+ if (!chatSessionId.startsWith(PREFIX)) return void 0;
21
+ try {
22
+ const name = decodeURIComponent(chatSessionId.slice(16));
23
+ return name === "" ? void 0 : name;
24
+ } catch {
25
+ return;
26
+ }
27
+ }
28
+ //#endregion
10
29
  //#region src/host/import/lorebook.ts
11
30
  const MAX_ENTRIES = 500;
12
31
  const BATCH_CHARS = 6e3;
@@ -243,18 +262,20 @@ function problemOf(answer, batch) {
243
262
  const missing = batch.filter((entry) => !seen.has(entry.ref)).map((entry) => entry.ref);
244
263
  return missing.length === 0 ? void 0 : `decide every entry: ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} missing`;
245
264
  }
246
- const describe = (entry) => `Entry ${entry.ref}${entry.title === "" ? "" : ` “${entry.title}”`}${entry.keys.length === 0 ? "" : ` (triggers: ${entry.keys.join(", ")})`}:\n${entry.text}`;
265
+ const describe = (entry, tr) => `${tr("Entry {ref}", { ref: entry.ref })}${entry.title === "" ? "" : ` “${entry.title}”`}${entry.keys.length === 0 ? "" : ` ${tr("(triggers: {keys})", { keys: entry.keys.join(", ") })}`}:\n${entry.text}`;
247
266
  /**
248
267
  * Sorts the entries of a lorebook into what the world is (kept word for word as lorebook entries, common knowledge unless an entry clearly says otherwise)
249
268
  * and what is told to the AI (kept as guidance for the prompts). Throws when the model never gives a usable answer, so that nothing half-made is written.
250
269
  */
251
270
  async function classifyEntries(ctx, book) {
252
271
  const batches = batchesOf(book.entries);
272
+ const tr = trOf(ctx);
253
273
  ctx.say(`sorting ${book.entries.length} entries`);
254
274
  const answers = await mapLimit(batches, ctx.concurrency, async (batch) => {
255
275
  return await ctx.run({
256
276
  persona: ctx.text("import/lorebook"),
257
- prompt: `Lorebook: ${book.name}\n\n${batch.map(describe).join("\n\n---\n\n")}`,
277
+ maxTokens: 4e3,
278
+ prompt: `${tr("Lorebook: {name}", { name: book.name })}\n\n${batch.map((entry) => describe(entry, tr)).join("\n\n---\n\n")}`,
258
279
  result: DECISIONS_SCHEMA,
259
280
  check: (value) => problemOf(value, batch)
260
281
  });
@@ -302,24 +323,6 @@ async function classifyEntries(ctx, book) {
302
323
  return result;
303
324
  }
304
325
  //#endregion
305
- //#region src/shared/lorebook-chat.ts
306
- const PREFIX = "lorebook-author-";
307
- /** Stable DSH chat identity for the authoring conversation of one library lorebook. */
308
- function lorebookChatSessionId(name) {
309
- if (name === "") throw new TypeError("lorebook name cannot be empty");
310
- return `${PREFIX}${encodeURIComponent(name)}`;
311
- }
312
- /** The library lorebook named by a dedicated lorebook authoring chat. */
313
- function lorebookOfChat(chatSessionId) {
314
- if (!chatSessionId.startsWith(PREFIX)) return void 0;
315
- try {
316
- const name = decodeURIComponent(chatSessionId.slice(16));
317
- return name === "" ? void 0 : name;
318
- } catch {
319
- return;
320
- }
321
- }
322
- //#endregion
323
326
  //#region src/host/authoring/lorebook-author-tools.ts
324
327
  const LOREBOOK_MUTATION_TOOLS = [
325
328
  "write_lorebook_entry",
@@ -568,7 +571,7 @@ function lorebookAuthorTools(reader, settings, prompting, shipped = shippedPromp
568
571
  }), name);
569
572
  const language = prompting.languages().get(`lorebook:${name}`);
570
573
  const text = (id, variables) => prompting.prompts().text(id, language, variables);
571
- const made = await classifyEntries(contextOf(exec, settings(), text), uploaded);
574
+ const made = await classifyEntries(contextOf(exec, settings(), text, language), uploaded);
572
575
  const taken = new Set((await loadLorebook(reader.library, name)).entries.map((entry) => entry.id));
573
576
  for (const entry of made.entries) {
574
577
  let id = entry.id;
@@ -694,6 +697,6 @@ async function lorebookApproval(exec, next, state) {
694
697
  };
695
698
  }
696
699
  //#endregion
697
- export { lorebookImportMessage as a, lorebookOfChat as c, selectEntries as d, lorebookAuthorTools as i, previewLorebook as l, LorebookReader as n, pendingTargets as o, lorebookApproval as r, lorebookChatSessionId as s, LOREBOOK_UPLOAD as t, readLorebook as u };
700
+ export { lorebookImportMessage as a, readLorebook as c, lorebookOfChat as d, lorebookAuthorTools as i, selectEntries as l, LorebookReader as n, pendingTargets as o, lorebookApproval as r, previewLorebook as s, LOREBOOK_UPLOAD as t, lorebookChatSessionId as u };
698
701
 
699
- //# sourceMappingURL=lorebook-author-tools-v-PM8Kbs.js.map
702
+ //# sourceMappingURL=lorebook-author-tools-D9RrMK5g.js.map
@@ -1,6 +1,7 @@
1
- import { St as lorebookDirectory, n as limitAuthoringAgents } from "./authoring-tools-BWjEr_lF.js";
2
- import "./hooks-DufjUf1p.js";
3
- import { c as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-v-PM8Kbs.js";
1
+ import { n as limitAuthoringAgents, wt as lorebookDirectory } from "./authoring-tools-q34iq3hW.js";
2
+ import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-D9RrMK5g.js";
3
+ import "./hooks-HnqXO8mM.js";
4
+ import { t as guardAuthoringTurns } from "./turn-guard-BvCs1VxB.js";
4
5
  import { join } from "node:path";
5
6
  import { existsSync, readdirSync } from "node:fs";
6
7
  //#region src/lorebook-authoring.ts
@@ -39,6 +40,10 @@ function apply(ctx) {
39
40
  } : pendingTargets(directory);
40
41
  };
41
42
  limitAuthoringAgents(ctx, (chat) => lorebookOfChat(chat) === void 0 ? void 0 : "lorebookAuthoring");
43
+ guardAuthoringTurns(ctx, () => ctx.roleplayPrompts, (chat) => {
44
+ const book = lorebookOfChat(chat);
45
+ return book === void 0 ? void 0 : ctx.roleplayAuthoringLanguages.get(`lorebook:${book}`);
46
+ }, () => ctx.roleplayImport.settings.reasoning);
42
47
  ctx.on("tools/pre-execute", (exec, next) => lorebookApproval(exec, next, {
43
48
  carries,
44
49
  waiting