@dsh-agentic-roleplay/core 0.9.0 → 0.10.0

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 (47) hide show
  1. package/lib/{access-CfQWbNZP.js → access-CXtaZNbx.js} +50 -2
  2. package/lib/{authoring-tools-CdHlvx32.js → authoring-tools-B4mEdKp_.js} +1349 -604
  3. package/lib/authoring.js +23 -19
  4. package/lib/{child-lYYeOwl2.js → child-Dtv76jNx.js} +116 -11
  5. package/lib/client.js +2810 -795
  6. package/lib/client.js.map +1 -1
  7. package/lib/compaction.js +3 -3
  8. package/lib/doctor.js +3 -3
  9. package/lib/{gallery-BKh7eu80.js → gallery-BZJleAeH.js} +5 -9
  10. package/lib/{generator-DdZ1-sgv.js → generator-Cg6CQc5S.js} +2 -2
  11. package/lib/helper.js +1 -1
  12. package/lib/{hooks-CcQj_dJo.js → hooks-DTjHWTfx.js} +168 -28
  13. package/lib/images.js +4 -4
  14. package/lib/index.js +362 -33
  15. package/lib/{library-QFL6Z_Nr.js → library-GIlrkOim.js} +9 -14
  16. package/lib/{lorebook-author-tools-DWBnYo1E.js → lorebook-author-tools-BCFFJSle.js} +6 -6
  17. package/lib/lorebook-authoring.js +4 -4
  18. package/lib/{narration-CjB_KwwY.js → narration-BVzew4-K.js} +7 -52
  19. package/lib/orchestration.js +155 -10
  20. package/lib/{pack-jail-BMy6NcCY.js → pack-jail-hsNQNTOf.js} +25 -15
  21. package/lib/{packs-BREPSfHy.js → packs-UpK_cvI4.js} +2 -2
  22. package/lib/{presenter-agent-B49-_iUm.js → presenter-agent-DZOgBOR9.js} +12 -17
  23. package/lib/{preset-BqgY1Tz4.js → preset-Cyoj1ZWa.js} +4 -4
  24. package/lib/{preset-author-tools-BB_Dcv2o.js → preset-author-tools-RSta6pHK.js} +6 -6
  25. package/lib/preset-authoring.js +5 -5
  26. package/lib/{presets-Bwnrx7p0.js → presets-CvpsW_10.js} +17 -9
  27. package/lib/{reflection-CUWG-6Qg.js → reflection-0qTvw2It.js} +53 -26
  28. package/lib/{turn-guard-Bb8Ew-1z.js → turn-guard-BzNeGNnc.js} +3 -3
  29. package/package.json +2 -2
  30. package/prompts/en/checks/conflict.md +1 -0
  31. package/prompts/en/checks/decide-conflict.md +1 -0
  32. package/prompts/en/checks/decide-covered.md +1 -0
  33. package/prompts/en/checks/decide-opening.md +1 -0
  34. package/prompts/en/checks/decide-same-thing.md +1 -0
  35. package/prompts/en/checks/decide-same-value.md +1 -0
  36. package/prompts/en/checks/decide-sheet.md +1 -1
  37. package/prompts/en/checks/fidelity.md +1 -0
  38. package/prompts/en/checks/notice.md +2 -2
  39. package/prompts/zh/checks/conflict.md +1 -0
  40. package/prompts/zh/checks/decide-conflict.md +1 -0
  41. package/prompts/zh/checks/decide-covered.md +1 -0
  42. package/prompts/zh/checks/decide-opening.md +1 -0
  43. package/prompts/zh/checks/decide-same-thing.md +1 -0
  44. package/prompts/zh/checks/decide-same-value.md +1 -0
  45. package/prompts/zh/checks/decide-sheet.md +1 -1
  46. package/prompts/zh/checks/fidelity.md +1 -0
  47. package/prompts/zh/checks/notice.md +2 -2
package/lib/index.js CHANGED
@@ -1,20 +1,20 @@
1
- import { a as chatSessionId, i as VARIABLE_VISIBILITIES, n as VARIABLE_KINDS, o as roleplaySessionOf, r as VARIABLE_SUBJECTS } from "./access-CfQWbNZP.js";
2
- import { $ as WORLD_FILE_NAME, $t as pictureOf, At as routineProblems, B as localChanges, Ct as populateItems, Dt as populateRoutines, Et as populateLore, Gt as loadCalendar, H as writeOrigin, Ht as loadDice, It as loadLocations, J as guardedLookup, Jt as loadCharacters, Kt as parseCalendarFile, L as describeChanges, Ot as populateTriggers, Qt as isPng, R as hashWorld, Rt as loadItems, St as populateFactions, T as loadWorldParts, Tt as populateLocations, U as CatalogueError, Ut as parseDiceFile, V as readOrigin, Vt as DICE_FILE_NAME, Wt as CALENDAR_FILE_NAME, X as vetUrl, Xt as knownOutputCeiling, Yt as subfolders, Zt as ImportCardError, _t as knowsCharacter, at as deleteLorebookEntry, bt as populateClock, c as importPhase, ct as listLorebooks, d as markReady, en as readCard, et as parseWorldFile, f as settleDraft, ft as reserveLorebook, gt as loadValidatedWorld, ht as checkWorld, in as authoredWorldOf, it as deleteLorebook, jt as TRIGGERS_FILE_NAME, kt as populateVariables, lt as loadLorebook, mt as writeLorebookEntry, nn as DICE_READINGS, nt as addLorebookEntries, ot as entriesOf, p as structureImport, pt as updateLorebookInfo, qt as CHARACTERS_DIR, rn as DICE_RESULTS, rt as createLorebook, st as isLorebookName, t as AuthoringTools, tn as DICE_COMPARISONS, tt as parseWorldInfoEdit, u as keepDraft, ut as lorebookDirectory, v as editWorldInfo, vt as populateCalendar, wt as populateKnowledge, xt as populateDice, y as readWorldInfo, yt as populateCharacters, z as isUnchanged } from "./authoring-tools-CdHlvx32.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-DWBnYo1E.js";
4
- import { a as presetChatSessionId, n as narrationImportMessage, o as presetOfChat } from "./preset-author-tools-BB_Dcv2o.js";
5
- import { a as liveSettings, c as writeSettings, d as DEFAULT_SETTINGS, f as SETTINGS_SPEC, h as WORLD_RULES_KEY, i as InvalidSettingsError, l as atomicWrite, o as readSettings, p as parseSettings, s as useChildReasoning } from "./narration-CjB_KwwY.js";
6
- import { $ as DOCTOR_OPENING_SOURCE, A as worldEntityImageFile, B as languageOfDocuments, C as readWorldEditor, D as uploadWorldCharacterPortrait, E as replaceFile, F as PRESET_FILE, G as revertUpdate, H as findTargets, I as presetMessage, J as AuthoringSessions, K as startUpdate, O as uploadWorldEntityImage, Q as agentServicesOf, R as translateMessage, S as generateWorldEntityImage, T as removeWorldTrigger, V as readWorldDocuments, X as ensureAuthoringChat, Y as authoringTitle, Z as AgentSessions, _ as editWorldPlots$1, a as deleteWorldPackFile, b as entityFolder, c as createAuthoredEntity, et as appendEmptyTurn, 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, q as updateStatus, t as MAX_PACK_TEXT, tt as appendNarratedTurn, u as readAuthoredEntityDocument, v as editWorldRelation$1, w as readWorldTrigger, x as generateWorldCharacterPortrait, y as editWorldThing$1 } from "./pack-jail-BMy6NcCY.js";
7
- import { d as sharedSamplingOf, i as childSamplingOf, u as parseSampling } from "./child-lYYeOwl2.js";
8
- import { $ as copyWorldPrompts, C as readNotes, H as plotReferenceProblems, J as formatIssue, K as readDocument, M as plotProgressOf, N as populatePlots, O as zoneOf, Q as PromptLibrary, S as notesOfSession, U as COMMANDS_KEY, V as parsePlotsFile, Y as errorMessage, _ as readRunDetail, b as readWithdrawn, ct as InvalidStartError, dt as SessionArchivedError, ft as SessionNotFoundError, g as readActivity, h as readDecisionStats, i as externalTools, it as shippedLanguages, j as PLOTS_METADATA_KEY, lt as InvalidWorldError, m as readUsage, pt as WorldNotFoundError, st as AgentUnavailableError, tt as languageOf, ut as ReflectionRefusedError, w as observeAsPlayer, x as addToNote } from "./hooks-CcQj_dJo.js";
9
- import { $ as ImportNotFoundError, At as parseLoreEdit, Ct as CHARACTER_FILE_NAME, Dt as InvalidEditProblems, Ft as LORE_SCOPES, G as listWorldPrompts, K as readWorldPrompt, Mt as parseRelationEdit, Nt as parseThingEdit, Ot as parseCharacterEdit, Pt as LORE_KINDS, Q as IMPORT_FOLDER, W as deleteWorldPrompt, X as partsOf, Z as withPlayer, a as isPresetName, c as presetDirectory, d as savePresetFromWorld, dt as parseVariablesFile, et as ImportStore, ft as variableProblems, i as deletePreset, jt as parsePlaceEdit, kt as parseFactionEdit, lt as VARIABLES_FILE_NAME, o as listPresets, ot as IMPORT_COMMAND, p as updatePresetInfo, q as writeWorldPrompt, r as createPresetFromShipped, rt as parseChoices, s as loadPreset, t as PRESET_FILE$1, u as reservePreset, ut as loadVariables, wt as parseCharacterFile } from "./presets-Bwnrx7p0.js";
1
+ import { a as VARIABLE_KINDS, c as chatSessionId, i as atomicWriteSync, l as roleplaySessionOf, n as atomicWrite, o as VARIABLE_SUBJECTS, r as atomicWriteJson, s as VARIABLE_VISIBILITIES } from "./access-CXtaZNbx.js";
2
+ import { $ as parseWorldFile, $t as pictureOf, At as routineProblems, B as readOrigin, C as readWorldInfo, Ct as populateItems, Dt as populateRoutines, Et as populateLore, Gt as loadCalendar, H as CatalogueError, Ht as loadDice, I as describeChanges, It as loadLocations, Jt as loadCharacters, Kt as parseCalendarFile, L as hashWorld, Ot as populateTriggers, Q as WORLD_FILE_NAME, Qt as isPng, R as isUnchanged, Rt as loadItems, S as editWorldInfo, St as populateFactions, Tt as populateLocations, Ut as parseDiceFile, V as writeOrigin, Vt as DICE_FILE_NAME, Wt as CALENDAR_FILE_NAME, Xt as knownOutputCeiling, Y as vetUrl, Yt as subfolders, Zt as ImportCardError, _t as knowsCharacter, at as entriesOf, bt as populateClock, c as importPhase, ct as loadLorebook, d as markReady, dt as reserveLorebook, en as readCard, et as parseWorldInfoEdit, f as settleDraft, ft as updateLorebookInfo, ht as loadValidatedWorld, in as authoredWorldOf, it as deleteLorebookEntry, jt as TRIGGERS_FILE_NAME, kt as populateVariables, lt as lorebookDirectory, mt as checkWorld, nn as DICE_READINGS, nt as createLorebook, ot as isLorebookName, p as structureImport, pt as writeLorebookEntry, q as guardedLookup, qt as CHARACTERS_DIR, rn as DICE_RESULTS, rt as deleteLorebook, st as listLorebooks, t as AuthoringTools, tn as DICE_COMPARISONS, tt as addLorebookEntries, u as keepDraft, vt as populateCalendar, w as loadWorldParts, wt as populateKnowledge, xt as populateDice, yt as populateCharacters, z as localChanges } from "./authoring-tools-B4mEdKp_.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-BCFFJSle.js";
4
+ import { a as presetChatSessionId, n as narrationImportMessage, o as presetOfChat } from "./preset-author-tools-RSta6pHK.js";
5
+ import { a as liveSettings, c as writeSettings, d as parseSettings, i as InvalidSettingsError, l as DEFAULT_SETTINGS, o as readSettings, p as WORLD_RULES_KEY, s as useChildReasoning, u as SETTINGS_SPEC } from "./narration-BVzew4-K.js";
6
+ import { $ as DOCTOR_OPENING_SOURCE, A as worldEntityImageFile, B as languageOfDocuments, C as readWorldEditor, D as uploadWorldCharacterPortrait, E as replaceFile, F as PRESET_FILE, G as revertUpdate, H as findTargets, I as presetMessage, J as AuthoringSessions, K as startUpdate, O as uploadWorldEntityImage, Q as agentServicesOf, R as translateMessage, S as generateWorldEntityImage, T as removeWorldTrigger, V as readWorldDocuments, X as ensureAuthoringChat, Y as authoringTitle, Z as AgentSessions, _ as editWorldPlots$1, a as deleteWorldPackFile, b as entityFolder, c as createAuthoredEntity, et as appendEmptyTurn, 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, q as updateStatus, t as MAX_PACK_TEXT, tt as appendNarratedTurn, u as readAuthoredEntityDocument, v as editWorldRelation$1, w as readWorldTrigger, x as generateWorldCharacterPortrait, y as editWorldThing$1 } from "./pack-jail-hsNQNTOf.js";
7
+ import { d as sharedSamplingOf, i as childSamplingOf, u as parseSampling } from "./child-Dtv76jNx.js";
8
+ import { $ as PromptLibrary, C as notesOfSession, H as parsePlotsFile, M as PLOTS_METADATA_KEY, N as plotProgressOf, P as populatePlots, S as addToNote, T as observeAsPlayer, U as plotReferenceProblems, W as COMMANDS_KEY, X as errorMessage, Y as formatIssue, _ as readRunDetail, at as shippedLanguages, ct as AgentUnavailableError, dt as ReflectionRefusedError, et as copyWorldPrompts, ft as SessionArchivedError, g as readActivity, h as readDecisionStats, i as externalTools, k as zoneOf, lt as InvalidStartError, m as readUsage, mt as WorldNotFoundError, nt as languageOf, pt as SessionNotFoundError, q as readDocument, ut as InvalidWorldError, v as readTraces, w as readNotes, x as readWithdrawn } from "./hooks-DTjHWTfx.js";
9
+ import { $ as ImportNotFoundError, At as parseLoreEdit, Ct as CHARACTER_FILE_NAME, Dt as InvalidEditProblems, Ft as LORE_SCOPES, G as listWorldPrompts, K as readWorldPrompt, Mt as parseRelationEdit, Nt as parseThingEdit, Ot as parseCharacterEdit, Pt as LORE_KINDS, Q as IMPORT_FOLDER, W as deleteWorldPrompt, X as partsOf, Z as withPlayer, a as isPresetName, c as presetDirectory, d as savePresetFromWorld, dt as parseVariablesFile, et as ImportStore, ft as variableProblems, i as deletePreset, jt as parsePlaceEdit, kt as parseFactionEdit, lt as VARIABLES_FILE_NAME, o as listPresets, ot as IMPORT_COMMAND, p as updatePresetInfo, q as writeWorldPrompt, r as createPresetFromShipped, rt as parseChoices, s as loadPreset, t as PRESET_FILE$1, u as reservePreset, ut as loadVariables, wt as parseCharacterFile } from "./presets-CvpsW_10.js";
10
10
  import { i as translator, r as languageOf$1, t as trimCharacters } from "./text-CbGQhK1-.js";
11
- import { n as readPreset, r as selectPrompts, t as previewPreset } from "./preset-BqgY1Tz4.js";
12
- import { S as slug, d as sceneImagePath, s as inheritImages, t as addToLibrary, u as referenceImagePath, w as uniqueKey } from "./library-QFL6Z_Nr.js";
11
+ import { n as readPreset, r as selectPrompts, t as previewPreset } from "./preset-Cyoj1ZWa.js";
12
+ import { C as slug, T as uniqueKey, d as sceneImagePath, s as inheritImages, t as addToLibrary, u as referenceImagePath } from "./library-GIlrkOim.js";
13
13
  import { t as doctorChatSessionId } from "./doctor-chat-hL1a61hp.js";
14
- import { c as readTimeline, d as copyPreset, f as presetStatus, h as defaultBoundaries, i as reflectionStatus, l as writeTimeline, m as switchPreset, o as TimelineError, p as recordPreset, u as pathTo } from "./reflection-CUWG-6Qg.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-BREPSfHy.js";
16
- import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-DdZ1-sgv.js";
17
- import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-BKh7eu80.js";
14
+ import { c as readTimeline, d as copyPreset, f as presetStatus, h as defaultBoundaries, i as reflectionStatus, l as writeTimeline, m as switchPreset, o as TimelineError, p as recordPreset, u as pathTo } from "./reflection-0qTvw2It.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-UpK_cvI4.js";
16
+ import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-Cg6CQc5S.js";
17
+ import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-BZJleAeH.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";
@@ -570,7 +570,7 @@ async function lorebookLore(root, names, chosen, knows, taken) {
570
570
  function lorebooksOf(session) {
571
571
  return session.metadata.getValue("roleplay.lorebooks") ?? [];
572
572
  }
573
- const keyOf$3 = (entry) => entry.sourceId ?? String(entry.id);
573
+ const keyOf$4 = (entry) => entry.sourceId ?? String(entry.id);
574
574
  /**
575
575
  * Copies a library lorebook into a story that is already being played. The characters that know an entry learn it at the story's current turn.
576
576
  * @throws {Error} when the story already has the book or the book cannot be used.
@@ -603,12 +603,12 @@ function removeLorebook(session, name) {
603
603
  const ids = new Set(leaving.map((entry) => entry.id));
604
604
  const citing = all.filter((entry) => !ids.has(entry.id) && (entry.related.some((id) => ids.has(id)) || entry.subjects.some((subject) => subject.kind === "lore" && ids.has(subject.id)))).map((entry) => entry.title);
605
605
  if (citing.length > 0) throw new Error(`other lore refers to entries of this lorebook: ${citing.join(", ")}`);
606
- const remaining = all.filter((entry) => !ids.has(entry.id)).map(keyOf$3);
606
+ const remaining = all.filter((entry) => !ids.has(entry.id)).map(keyOf$4);
607
607
  const plots = plotReferenceProblems(plotProgressOf(session.metadata).map((progress) => progress.plot), [
608
- ...session.characters.list().map(keyOf$3),
609
- ...session.factions.list().map(keyOf$3),
610
- ...session.locations.list().map(keyOf$3),
611
- ...session.items.list().map(keyOf$3),
608
+ ...session.characters.list().map(keyOf$4),
609
+ ...session.factions.list().map(keyOf$4),
610
+ ...session.locations.list().map(keyOf$4),
611
+ ...session.items.list().map(keyOf$4),
612
612
  ...remaining
613
613
  ]);
614
614
  if (plots.length > 0) throw new Error(`a plot refers to entries of this lorebook: ${plots.join("; ")}`);
@@ -840,6 +840,8 @@ var RoleplayOrchestration = class extends Service {
840
840
  halt = () => Promise.resolve();
841
841
  /** Starts a reflection of a chat's characters on what they have taken in, in the background; there while the orchestration is. */
842
842
  reflect = () => Promise.reject(/* @__PURE__ */ new Error("the orchestration is not running"));
843
+ /** What a moment would bring back for the chat's characters, without playing it or changing the story; there while the orchestration is. */
844
+ recallPreview = () => Promise.reject(/* @__PURE__ */ new Error("the orchestration is not running"));
843
845
  /** Whether a turn of the chat is being played; there while the orchestration is. */
844
846
  playing = () => false;
845
847
  /** Whether a reflection of the chat is running; there while the orchestration is. */
@@ -1650,7 +1652,7 @@ function withBridge(html) {
1650
1652
  return `${script}${html}`;
1651
1653
  }
1652
1654
  // src/host/interface/player-view.ts
1653
- const keyOf$2 = (character) => character.sourceId ?? String(character.id);
1655
+ const keyOf$3 = (character) => character.sourceId ?? String(character.id);
1654
1656
  /** What a variable shows, in one line of data. */
1655
1657
  function shown(subject, entries) {
1656
1658
  return entries.map(({ variable, value }) => ({
@@ -1697,12 +1699,12 @@ function playerViewOf(session, options) {
1697
1699
  if (player === void 0) return finish(view, session);
1698
1700
  const playerState = session.characterStates.get(player.id);
1699
1701
  view.player = {
1700
- key: keyOf$2(player),
1702
+ key: keyOf$3(player),
1701
1703
  name: player.name,
1702
1704
  summary: player.summary,
1703
1705
  publicState: playerState?.publicState ?? ""
1704
1706
  };
1705
- view.variables.push(...shown(player.name, shownVariables(session, "character", player.id, keyOf$2(player), "others")));
1707
+ view.variables.push(...shown(player.name, shownVariables(session, "character", player.id, keyOf$3(player), "others")));
1706
1708
  const placement = session.placements.get("character", player.id);
1707
1709
  const here = placement === void 0 ? void 0 : session.locations.get(placement.locationId);
1708
1710
  const known = new Set(session.knowledge.list(player.id, "location").map((entry) => entry.subjectId));
@@ -1733,7 +1735,7 @@ function playerViewOf(session, options) {
1733
1735
  here: session.placements.at(here.id, "character").flatMap((other) => {
1734
1736
  const character = other.entityId === player.id ? void 0 : session.characters.get(other.entityId);
1735
1737
  return character === void 0 ? [] : [{
1736
- key: keyOf$2(character),
1738
+ key: keyOf$3(character),
1737
1739
  name: character.name,
1738
1740
  publicState: session.characterStates.get(character.id)?.publicState ?? ""
1739
1741
  }];
@@ -1741,7 +1743,7 @@ function playerViewOf(session, options) {
1741
1743
  };
1742
1744
  view.variables.push(...shown(here.name, shownVariables(session, "location", here.id, locationKey(here), "others")));
1743
1745
  for (const other of view.place.here) {
1744
- const character = session.characters.list().find((candidate) => keyOf$2(candidate) === other.key);
1746
+ const character = session.characters.list().find((candidate) => keyOf$3(candidate) === other.key);
1745
1747
  if (character !== void 0) view.variables.push(...shown(character.name, shownVariables(session, "character", character.id, other.key, "others")));
1746
1748
  }
1747
1749
  for (const entry of session.items.contents({
@@ -1847,13 +1849,13 @@ async function previewViewOf(world, wall) {
1847
1849
  }
1848
1850
  }
1849
1851
  // src/host/interface/storage.ts
1850
- const keyOf$1 = (pack) => `roleplay.interface.${pack}`;
1852
+ const keyOf$2 = (pack) => `roleplay.interface.${pack}`;
1851
1853
  function checkedKey(key) {
1852
1854
  if (key === "" || key.length > 100) throw new RangeError("a key is 1 to 100 characters");
1853
1855
  return key;
1854
1856
  }
1855
1857
  function read(session, pack) {
1856
- const stored = session.metadata.getValue(keyOf$1(pack));
1858
+ const stored = session.metadata.getValue(keyOf$2(pack));
1857
1859
  return typeof stored === "object" && stored !== null && !Array.isArray(stored) ? stored : {};
1858
1860
  }
1859
1861
  /** What a pack keeps in a session: small JSON values by name. */
@@ -1880,12 +1882,12 @@ var PackStorage = class {
1880
1882
  throw new RangeError("a stored value must be JSON");
1881
1883
  }
1882
1884
  if (Buffer.byteLength(json) > PACK_LIMITS.storageBytes) throw new RangeError(`a pack keeps at most ${PACK_LIMITS.storageBytes / 1024} KB in a story`);
1883
- this.session.metadata.setValue(keyOf$1(this.pack), next);
1885
+ this.session.metadata.setValue(keyOf$2(this.pack), next);
1884
1886
  }
1885
1887
  remove(key) {
1886
1888
  checkedKey(key);
1887
1889
  const { [key]: _removed, ...rest } = read(this.session, this.pack);
1888
- this.session.metadata.setValue(keyOf$1(this.pack), rest);
1890
+ this.session.metadata.setValue(keyOf$2(this.pack), rest);
1889
1891
  }
1890
1892
  };
1891
1893
  // src/host/interface/service.ts
@@ -3690,6 +3692,268 @@ function worldFilesRoutes({ worldFiles, worldEditor, sessions }) {
3690
3692
  ]))
3691
3693
  };
3692
3694
  }
3695
+ // src/shared/journal.ts
3696
+ /** The most a journal may hold. */
3697
+ const MAX_JOURNAL = 2e4;
3698
+ // src/host/reference/journal.ts
3699
+ const JOURNAL_FILE = "journal.json";
3700
+ var InvalidJournalError = class extends Error {};
3701
+ function folderOf$2(sessionsDir, id) {
3702
+ if (!isSessionId(id) || !existsSync(sessionDatabase(sessionsDir, id))) throw new SessionNotFoundError(`no session "${id}"`);
3703
+ return sessionFolder(sessionsDir, id);
3704
+ }
3705
+ /**
3706
+ * The player's notes. They sit beside the database, so taking the story back does not touch them and a branch starts with a copy.
3707
+ * @throws {SessionNotFoundError} when the id names no session.
3708
+ */
3709
+ async function readJournal(sessionsDir, id) {
3710
+ const file = join(folderOf$2(sessionsDir, id), JOURNAL_FILE);
3711
+ let value;
3712
+ try {
3713
+ value = JSON.parse(await readFile(file, "utf8"));
3714
+ } catch (error) {
3715
+ if (error.code === "ENOENT") return { text: "" };
3716
+ throw error;
3717
+ }
3718
+ const { text, updatedAt } = value ?? {};
3719
+ return {
3720
+ text: typeof text === "string" ? text : "",
3721
+ ...typeof updatedAt === "string" ? { updatedAt } : {}
3722
+ };
3723
+ }
3724
+ /** @throws {InvalidJournalError} for text that is not a string or is over `MAX_JOURNAL`. */
3725
+ async function writeJournal(sessionsDir, id, body, now = () => /* @__PURE__ */ new Date()) {
3726
+ const folder = folderOf$2(sessionsDir, id);
3727
+ const text = body?.text;
3728
+ if (typeof text !== "string") throw new InvalidJournalError("the journal needs a text");
3729
+ if (text.length > 2e4) throw new InvalidJournalError(`the journal may hold at most ${MAX_JOURNAL} characters`);
3730
+ const journal = {
3731
+ text,
3732
+ updatedAt: now().toISOString()
3733
+ };
3734
+ await atomicWriteJson(join(folder, JOURNAL_FILE), journal);
3735
+ return journal;
3736
+ }
3737
+ // src/shared/reference.ts
3738
+ /** The pages of the reference: what the player may look up about the story, never what only the story knows. */
3739
+ const REFERENCE_SECTIONS = [
3740
+ "profile",
3741
+ "people",
3742
+ "places",
3743
+ "things"
3744
+ ];
3745
+ const isReferenceSection = (value) => REFERENCE_SECTIONS.includes(value);
3746
+ // src/host/reference/profile.ts
3747
+ const keyOf$1 = (character) => character.sourceId ?? String(character.id);
3748
+ const BLOCKS = [
3749
+ {
3750
+ audiences: ["self", "observer"],
3751
+ build: (session, character, audience) => {
3752
+ const state = session.characterStates.get(character.id);
3753
+ return {
3754
+ aliases: character.aliases,
3755
+ ...character.age === void 0 || character.age === null ? {} : { age: character.age },
3756
+ ...character.gender === void 0 || character.gender === null ? {} : { gender: character.gender },
3757
+ ...character.pronouns === void 0 || character.pronouns === null ? {} : { pronouns: character.pronouns },
3758
+ appearance: character.appearance,
3759
+ publicState: state?.publicState ?? "",
3760
+ values: shownVariables(session, "character", character.id, keyOf$1(character), audience === "self" ? "self" : "others").map(({ variable, value }) => ({
3761
+ name: variable.name,
3762
+ value: describeValue(variable, value)
3763
+ }))
3764
+ };
3765
+ }
3766
+ },
3767
+ {
3768
+ audiences: ["self"],
3769
+ build: (session, character) => {
3770
+ const state = session.characterStates.get(character.id);
3771
+ const groups = session.factionMemberships.ofCharacter(character.id, "active").flatMap((membership) => {
3772
+ const faction = session.factions.get(membership.factionId);
3773
+ return faction === void 0 ? [] : [{
3774
+ name: faction.name,
3775
+ role: membership.role
3776
+ }];
3777
+ });
3778
+ return {
3779
+ summary: character.summary,
3780
+ personality: character.personality,
3781
+ background: character.background,
3782
+ speech: character.speech,
3783
+ innerState: state?.innerState ?? "",
3784
+ activity: state?.activity ?? "",
3785
+ groups,
3786
+ goals: session.intents.list(character.id, { status: "active" }).map((intent) => ({
3787
+ name: intent.name,
3788
+ description: intent.description,
3789
+ status: intent.status,
3790
+ plan: intent.plan,
3791
+ ...intent.deadline === void 0 ? {} : { deadline: intent.deadline }
3792
+ }))
3793
+ };
3794
+ }
3795
+ },
3796
+ {
3797
+ audiences: ["self"],
3798
+ build: (session, character) => {
3799
+ const recollections = session.events.perceivedBy(character.id).sort((a, b) => b.event.turn - a.event.turn || b.event.round - a.event.round);
3800
+ const beliefs = session.memories.list(character.id).sort((a, b) => b.turn - a.turn);
3801
+ return {
3802
+ recollections: recollections.slice(0, 100).map(({ perception, event }) => ({
3803
+ text: perception.content,
3804
+ gist: perception.gist,
3805
+ mode: perception.mode,
3806
+ turn: event.turn
3807
+ })),
3808
+ beliefs: beliefs.slice(0, 100).map((memory) => ({
3809
+ text: memory.text,
3810
+ kind: memory.kind,
3811
+ confidence: memory.confidence,
3812
+ turn: memory.turn
3813
+ })),
3814
+ totals: {
3815
+ recollections: recollections.length,
3816
+ beliefs: beliefs.length
3817
+ }
3818
+ };
3819
+ }
3820
+ }
3821
+ ];
3822
+ /** A character as the audience may see them: only the blocks that audience is allowed. */
3823
+ function profileOf(session, character, audience) {
3824
+ const profile = {
3825
+ key: keyOf$1(character),
3826
+ name: character.name,
3827
+ audience,
3828
+ aliases: [],
3829
+ appearance: "",
3830
+ publicState: "",
3831
+ values: []
3832
+ };
3833
+ for (const block of BLOCKS) if (block.audiences.includes(audience)) Object.assign(profile, block.build(session, character, audience));
3834
+ return profile;
3835
+ }
3836
+ // src/host/reference/reference.ts
3837
+ var UnknownSectionError = class extends Error {};
3838
+ /** Where the player's character is and what it has met or learned of: the only ground a page may read from. */
3839
+ function standpoint(session) {
3840
+ const player = session.characters.list().find((character) => character.control === "player");
3841
+ if (player === void 0) return void 0;
3842
+ const placement = session.placements.get("character", player.id);
3843
+ return {
3844
+ player,
3845
+ here: placement === void 0 ? void 0 : session.locations.get(placement.locationId)
3846
+ };
3847
+ }
3848
+ /**
3849
+ * The player's character in full, or another character the player has met or is with, as an observer sees them.
3850
+ * Anyone the player's character has not met is not shown.
3851
+ */
3852
+ function profile(session, options) {
3853
+ const stand = standpoint(session);
3854
+ if (stand === void 0) return [];
3855
+ if (options.character === void 0 || options.character === keyOf$1(stand.player)) return [profileOf(session, stand.player, "self")];
3856
+ const other = people(session).some((person) => person.key === options.character) ? session.characters.list().find((character) => keyOf$1(character) === options.character) : void 0;
3857
+ return other === void 0 ? [] : [profileOf(session, other, "observer")];
3858
+ }
3859
+ function people(session) {
3860
+ const stand = standpoint(session);
3861
+ if (stand === void 0) return [];
3862
+ const present = new Set(stand.here === void 0 ? [] : session.placements.at(stand.here.id, "character").map((entry) => entry.entityId));
3863
+ const met = new Map(session.relationships.from(stand.player.id).map((relation) => [relation.toId, relation]));
3864
+ return session.characters.list().flatMap((character) => {
3865
+ if (character.id === stand.player.id || !present.has(character.id) && !met.has(character.id)) return [];
3866
+ const relation = met.get(character.id);
3867
+ return [{
3868
+ key: keyOf$1(character),
3869
+ name: character.name,
3870
+ publicState: session.characterStates.get(character.id)?.publicState ?? "",
3871
+ here: present.has(character.id),
3872
+ ...relation === void 0 ? {} : {
3873
+ label: relation.label,
3874
+ summary: relation.summary
3875
+ }
3876
+ }];
3877
+ }).sort((a, b) => Number(b.here) - Number(a.here) || a.name.localeCompare(b.name));
3878
+ }
3879
+ function places(session) {
3880
+ const stand = standpoint(session);
3881
+ if (stand === void 0) return [];
3882
+ const known = new Set(session.knowledge.list(stand.player.id, "location").map((entry) => entry.subjectId));
3883
+ if (stand.here !== void 0) known.add(stand.here.id);
3884
+ const knownExits = new Set(session.knowledge.list(stand.player.id, "exit").map((entry) => entry.subjectId));
3885
+ const exits = session.locations.allExits();
3886
+ const placeOf = (id) => known.has(id) ? session.locations.get(id) : void 0;
3887
+ const nameOf = (id) => placeOf(id)?.name;
3888
+ return [...known].flatMap((id) => {
3889
+ const place = session.locations.get(id);
3890
+ if (place === void 0) return [];
3891
+ const here = place.id === stand.here?.id;
3892
+ const parent = place.parentId === void 0 ? void 0 : nameOf(place.parentId);
3893
+ return [{
3894
+ key: locationKey(place),
3895
+ name: place.name,
3896
+ here,
3897
+ ...parent === void 0 ? {} : { parent },
3898
+ ...here ? { description: place.description } : {},
3899
+ features: here ? place.features.map((feature) => feature.name) : [],
3900
+ ways: exits.filter((exit) => exit.fromId === place.id && (here || knownExits.has(exit.id))).flatMap((exit) => {
3901
+ const to = placeOf(exit.toId);
3902
+ return to === void 0 ? [] : [{
3903
+ to: to.name,
3904
+ toKey: locationKey(to),
3905
+ open: exit.state === "open"
3906
+ }];
3907
+ })
3908
+ }];
3909
+ }).sort((a, b) => Number(b.here) - Number(a.here) || a.name.localeCompare(b.name));
3910
+ }
3911
+ function things(session) {
3912
+ const stand = standpoint(session);
3913
+ if (stand === void 0) return [];
3914
+ const carried = session.items.contents({
3915
+ kind: "character",
3916
+ id: stand.player.id
3917
+ }).filter((entry) => !entry.item.hidden).map((entry) => {
3918
+ const holder = entry.holding.holder;
3919
+ return {
3920
+ name: entry.item.name,
3921
+ quantity: entry.item.quantity,
3922
+ where: holder.kind === "character" && holder.mode === "worn" ? "worn" : "carried"
3923
+ };
3924
+ });
3925
+ const around = stand.here === void 0 ? [] : session.items.contents({
3926
+ kind: "location",
3927
+ id: stand.here.id
3928
+ }).filter((entry) => !entry.item.hidden).map((entry) => ({
3929
+ name: entry.item.name,
3930
+ quantity: entry.item.quantity,
3931
+ where: "here"
3932
+ }));
3933
+ return [...carried, ...around];
3934
+ }
3935
+ /** One page per section; a new page is a new entry here and in `REFERENCE_SECTIONS`. */
3936
+ const PAGES = {
3937
+ profile,
3938
+ people,
3939
+ places,
3940
+ things
3941
+ };
3942
+ function referencePage(session, section, options = {}) {
3943
+ if (!isReferenceSection(section)) throw new UnknownSectionError(`no reference section "${section}"`);
3944
+ return {
3945
+ section,
3946
+ entries: PAGES[section](session, options)
3947
+ };
3948
+ }
3949
+ /** @throws {SessionNotFoundError} when the id names no session. */
3950
+ function referenceOfSession(deps, id, section, options = {}) {
3951
+ if (!isSessionId(id) || !existsSync(sessionDatabase(deps.sessionsDir(), id))) throw new SessionNotFoundError(`no session "${id}"`);
3952
+ return referencePage(deps.open(id), section, options);
3953
+ }
3954
+ // src/shared/recall-preview.ts
3955
+ /** The longest situation accepted. */
3956
+ const MAX_SITUATION = 4e3;
3693
3957
  // src/host/http/routes/sessions.ts
3694
3958
  /** The routes of the API for sessions. */
3695
3959
  function sessionsRoutes({ sessions, externalTools, redundantLayers }) {
@@ -3794,6 +4058,35 @@ function sessionsRoutes({ sessions, externalTools, redundantLayers }) {
3794
4058
  throw error;
3795
4059
  }
3796
4060
  } },
4061
+ "/sessions/reference": { GET: async (_req, res, url) => {
4062
+ try {
4063
+ sendJson(res, 200, sessions.reference(url.searchParams.get("id") ?? "", url.searchParams.get("section") ?? "", url.searchParams.get("character") ?? void 0));
4064
+ } catch (error) {
4065
+ if (error instanceof SessionNotFoundError) return sendError(res, 404, error.message);
4066
+ if (error instanceof UnknownSectionError) return sendError(res, 400, error.message);
4067
+ throw error;
4068
+ }
4069
+ } },
4070
+ "/sessions/journal": {
4071
+ GET: async (_req, res, url) => {
4072
+ try {
4073
+ sendJson(res, 200, await sessions.readJournal(url.searchParams.get("id") ?? ""));
4074
+ } catch (error) {
4075
+ if (error instanceof SessionNotFoundError) return sendError(res, 404, error.message);
4076
+ throw error;
4077
+ }
4078
+ },
4079
+ PUT: async (req, res, url) => {
4080
+ const body = await readJsonBody(req);
4081
+ try {
4082
+ sendJson(res, 200, await sessions.writeJournal(url.searchParams.get("id") ?? "", body));
4083
+ } catch (error) {
4084
+ if (error instanceof SessionNotFoundError) return sendError(res, 404, error.message);
4085
+ if (error instanceof InvalidJournalError) return sendError(res, 422, error.message);
4086
+ throw error;
4087
+ }
4088
+ }
4089
+ },
3797
4090
  "/sessions/images": {
3798
4091
  GET: async (_req, res, url) => {
3799
4092
  try {
@@ -3943,6 +4236,30 @@ function sessionsRoutes({ sessions, externalTools, redundantLayers }) {
3943
4236
  res.statusCode = 202;
3944
4237
  res.end();
3945
4238
  } },
4239
+ "/sessions/recall": { POST: async (req, res, url) => {
4240
+ const body = await readJsonBody(req);
4241
+ if (typeof body.situation !== "string" || body.situation.trim() === "") return sendError(res, 400, "a situation is needed");
4242
+ if (body.situation.length > 4e3) return sendError(res, 413, `the situation is longer than ${MAX_SITUATION} characters`);
4243
+ if (body.character !== void 0 && typeof body.character !== "string") return sendError(res, 400, "character must be a key");
4244
+ const abort = new AbortController();
4245
+ req.on("aborted", () => {
4246
+ abort.abort();
4247
+ });
4248
+ res.on("close", () => {
4249
+ if (!res.writableEnded) abort.abort();
4250
+ });
4251
+ try {
4252
+ sendJson(res, 200, await sessions.recallPreview(url.searchParams.get("id") ?? "", {
4253
+ situation: body.situation,
4254
+ ...body.character === void 0 ? {} : { character: body.character }
4255
+ }, abort.signal));
4256
+ } catch (error) {
4257
+ if (error instanceof SessionNotFoundError) return sendError(res, 404, error.message);
4258
+ if (error instanceof AgentUnavailableError) return sendError(res, 503, error.message);
4259
+ if (error instanceof Error && /^no character /.test(error.message)) return sendError(res, 422, error.message);
4260
+ throw error;
4261
+ }
4262
+ } },
3946
4263
  "/sessions/vectors/reset": { POST: async (_req, res, url) => {
3947
4264
  try {
3948
4265
  sessions.resetVectors(url.searchParams.get("id") ?? "");
@@ -5794,6 +6111,7 @@ function payloadOf(deps, id, settings) {
5794
6111
  pendingConsolidation: deps.pendingConsolidation(id),
5795
6112
  activity: deps.activity(id),
5796
6113
  usage: deps.usage(id),
6114
+ trace: deps.trace(id),
5797
6115
  interventions: deps.interventions(id),
5798
6116
  vectors: deps.vectors(id),
5799
6117
  reflection: deps.reflection(id),
@@ -7349,9 +7667,7 @@ function readStore(root) {
7349
7667
  function writeStore(root, store) {
7350
7668
  const folder = syncFolder(root);
7351
7669
  mkdirSync(folder, { recursive: true });
7352
- const temporary = join(folder, `state.json.${process.pid}.tmp`);
7353
- writeFileSync(temporary, `${JSON.stringify(store, null, 2)}\n`);
7354
- renameSync(temporary, join(folder, "state.json"));
7670
+ atomicWriteSync(join(folder, "state.json"), `${JSON.stringify(store, null, 2)}\n`);
7355
7671
  }
7356
7672
  // src/host/sync/units.ts
7357
7673
  /** Folders of the root that are one unit each, whatever they hold. */
@@ -8313,6 +8629,7 @@ function apply(ctx, config) {
8313
8629
  reflection: (id) => reflectionStatus(ctx.roleplayState.openSession(join(root.path, "sessions"), id), orchestration.reflecting(chatSessionId(id))),
8314
8630
  activity: (id) => readActivity(ctx.roleplayState.openSession(join(root.path, "sessions"), id)),
8315
8631
  usage: (id) => readUsage(ctx.roleplayState.openSession(join(root.path, "sessions"), id)),
8632
+ trace: (id) => readTraces(ctx.roleplayState.openSession(join(root.path, "sessions"), id)),
8316
8633
  interventions: (id) => readInterventions(ctx.roleplayState.openSession(join(root.path, "sessions"), id))
8317
8634
  };
8318
8635
  const staging = new ImportStaging();
@@ -8703,6 +9020,12 @@ function apply(ctx, config) {
8703
9020
  await agent.ensure(id, ctx.roleplayState.openSession(sessions, id).metadata.get().name);
8704
9021
  await ctx.roleplayOrchestration.reflect(chatSessionId(id));
8705
9022
  },
9023
+ recallPreview: async (id, request, signal) => {
9024
+ const sessions = join(root.path, "sessions");
9025
+ if (!isSessionId(id) || !existsSync(sessionDatabase(sessions, id))) throw new SessionNotFoundError(`no session "${id}"`);
9026
+ await agent.ensure(id, ctx.roleplayState.openSession(sessions, id).metadata.get().name);
9027
+ return ctx.roleplayOrchestration.recallPreview(chatSessionId(id), request, signal);
9028
+ },
8706
9029
  resetVectors: (id) => {
8707
9030
  const sessions = join(root.path, "sessions");
8708
9031
  if (!isSessionId(id) || !existsSync(sessionDatabase(sessions, id))) throw new SessionNotFoundError(`no session "${id}"`);
@@ -8716,6 +9039,12 @@ function apply(ctx, config) {
8716
9039
  sessionsDir: deps.sessionsDir,
8717
9040
  open: (sessionId) => ctx.roleplayState.openSession(deps.sessionsDir(), sessionId)
8718
9041
  }, id),
9042
+ reference: (id, section, character) => referenceOfSession({
9043
+ sessionsDir: deps.sessionsDir,
9044
+ open: (sessionId) => ctx.roleplayState.openSession(deps.sessionsDir(), sessionId)
9045
+ }, id, section, character === void 0 ? {} : { character }),
9046
+ readJournal: (id) => readJournal(deps.sessionsDir(), id),
9047
+ writeJournal: (id, body) => writeJournal(deps.sessionsDir(), id, body),
8719
9048
  imageStatus: (id, node) => imagesOf(ctx, deps.sessionsDir, id).status(id, node),
8720
9049
  generateImage: (id, node) => imagesOf(ctx, deps.sessionsDir, id).generate(id, node),
8721
9050
  imageFile: async (id, node, serial) => {
@@ -1,10 +1,12 @@
1
- import "./access-CfQWbNZP.js";
1
+ import { n as atomicWrite } from "./access-CXtaZNbx.js";
2
2
  import { i as translator, n as withoutExtension, r as languageOf, t as trimCharacters } from "./text-CbGQhK1-.js";
3
3
  import { dirname, extname, join } from "node:path";
4
4
  import { existsSync } from "node:fs";
5
- import { createHash, randomUUID } from "node:crypto";
5
+ import { createHash } from "node:crypto";
6
6
  import { copyFile, link, mkdir, readFile, readdir, rename, unlink, writeFile } from "node:fs/promises";
7
7
  // src/host/import/run.ts
8
+ /** What `ImportContext.embed` rejects with when no embedding provider is selected or loaded: the checks that would use it go without. */
9
+ var NoEmbeddingService = class extends Error {};
8
10
  /** The labels of a job's prompt, in the language of the import. */
9
11
  const trOf = (ctx) => translator(languageOf(ctx.language));
10
12
  /** Runs `work` on every item, at most `limit` at a time, and returns the results in the order of the items. */
@@ -168,15 +170,10 @@ async function readImageFileMetadata(file) {
168
170
  return;
169
171
  }
170
172
  }
171
- async function replaceAtomically(file, data) {
172
- const temporary = `${file}.${process.pid}.${randomUUID()}.writing`;
173
- await writeFile(temporary, data);
174
- await rename(temporary, file);
175
- }
176
173
  /** Writes the metadata where the format keeps it, replacing what was there. */
177
174
  async function writeImageFileMetadata(file, metadata) {
178
- if (extname(file).toLowerCase() === ".png") await replaceAtomically(file, withPngMetadata(await readFile(file), metadata));
179
- else await replaceAtomically(sidecarOf(file), `${JSON.stringify(metadata, null, 2)}\n`);
175
+ if (extname(file).toLowerCase() === ".png") await atomicWrite(file, withPngMetadata(await readFile(file), metadata));
176
+ else await atomicWrite(sidecarOf(file), `${JSON.stringify(metadata, null, 2)}\n`);
180
177
  }
181
178
  // src/host/images/storage.ts
182
179
  const PLURAL = {
@@ -353,9 +350,7 @@ async function addToLibraryOnce(sessionFolder, bytes, originalName, known) {
353
350
  await mkdir(directory, { recursive: true });
354
351
  const name = libraryName(originalName, extension, (candidate) => existsSync(join(directory, candidate)));
355
352
  const file = join(directory, name);
356
- const temporary = `${file}.${process.pid}.${randomUUID()}.writing`;
357
- await writeFile(temporary, bytes);
358
- await rename(temporary, file);
353
+ await atomicWrite(file, bytes);
359
354
  await writeImageFileMetadata(file, {
360
355
  schema: "dsh-roleplay-image/v3",
361
356
  purpose: "uploaded",
@@ -377,6 +372,6 @@ async function addToLibraryOnce(sessionFolder, bytes, originalName, known) {
377
372
  async function addToLibrary(sessionFolder, bytes, originalName) {
378
373
  return (await addToLibraryOnce(sessionFolder, bytes, originalName)).path;
379
374
  }
380
- export { trOf as C, slug as S, writeImageFileMetadata as _, LIBRARY_FOLDER as a, mapLimit as b, nextSceneSerial as c, sceneImagePath as d, writeImage as f, sidecarOf as g, readImageFileMetadata as h, libraryHashes as i, readImageMetadata as l, mediaTypeOf as m, addToLibraryOnce as n, entityImageDirectory as o, MEDIA_TYPES as p, imageExtensionOf as r, inheritImages as s, addToLibrary as t, referenceImagePath as u, readPngMetadata as v, uniqueKey as w, norm as x, withPngMetadata as y };
375
+ export { slug as C, norm as S, uniqueKey as T, writeImageFileMetadata as _, LIBRARY_FOLDER as a, NoEmbeddingService as b, nextSceneSerial as c, sceneImagePath as d, writeImage as f, sidecarOf as g, readImageFileMetadata as h, libraryHashes as i, readImageMetadata as l, mediaTypeOf as m, addToLibraryOnce as n, entityImageDirectory as o, MEDIA_TYPES as p, imageExtensionOf as r, inheritImages as s, addToLibrary as t, referenceImagePath as u, readPngMetadata as v, trOf as w, mapLimit as x, withPngMetadata as y };
381
376
 
382
- //# sourceMappingURL=library-QFL6Z_Nr.js.map
377
+ //# sourceMappingURL=library-GIlrkOim.js.map
@@ -1,9 +1,9 @@
1
- import "./access-CfQWbNZP.js";
2
- import { Zt as ImportCardError, at as deleteLorebookEntry, dt as readLorebook$1, i as contextOf, lt as loadLorebook, mt as writeLorebookEntry, ot as entriesOf, pt as updateLorebookInfo, r as MAX_PREVIEW_TEXT, ut as lorebookDirectory } from "./authoring-tools-CdHlvx32.js";
3
- import { Ft as LORE_SCOPES, J as cleanText, Pt as LORE_KINDS, Q as IMPORT_FOLDER, X as partsOf, Z as withPlayer, n as createPresetFromGuidance } from "./presets-Bwnrx7p0.js";
4
- import { C as trOf, S as slug, b as mapLimit, w as uniqueKey } from "./library-QFL6Z_Nr.js";
1
+ import "./access-CXtaZNbx.js";
2
+ import { Zt as ImportCardError, at as entriesOf, ct as loadLorebook, ft as updateLorebookInfo, i as contextOf, it as deleteLorebookEntry, lt as lorebookDirectory, pt as writeLorebookEntry, r as MAX_PREVIEW_TEXT, ut as readLorebook$1 } from "./authoring-tools-B4mEdKp_.js";
3
+ import { Ft as LORE_SCOPES, J as cleanText, Pt as LORE_KINDS, Q as IMPORT_FOLDER, X as partsOf, Z as withPlayer, n as createPresetFromGuidance } from "./presets-CvpsW_10.js";
4
+ import { C as slug, T as uniqueKey, w as trOf, x as mapLimit } from "./library-GIlrkOim.js";
5
5
  import { i as translator, r as languageOf } from "./text-CbGQhK1-.js";
6
- import { at as shippedPromptsDirectory } from "./hooks-CcQj_dJo.js";
6
+ import { ot as shippedPromptsDirectory } from "./hooks-DTjHWTfx.js";
7
7
  import { join } from "node:path";
8
8
  import { existsSync, readFileSync } from "node:fs";
9
9
  import { readFile, rm, writeFile } from "node:fs/promises";
@@ -696,4 +696,4 @@ async function lorebookApproval(exec, next, state) {
696
696
  }
697
697
  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
698
 
699
- //# sourceMappingURL=lorebook-author-tools-DWBnYo1E.js.map
699
+ //# sourceMappingURL=lorebook-author-tools-BCFFJSle.js.map
@@ -1,7 +1,7 @@
1
- import { n as limitAuthoringAgents, ut as lorebookDirectory } from "./authoring-tools-CdHlvx32.js";
2
- import { t as guardAuthoringTurns } from "./turn-guard-Bb8Ew-1z.js";
3
- import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-DWBnYo1E.js";
4
- import "./hooks-CcQj_dJo.js";
1
+ import { lt as lorebookDirectory, n as limitAuthoringAgents } from "./authoring-tools-B4mEdKp_.js";
2
+ import { t as guardAuthoringTurns } from "./turn-guard-BzNeGNnc.js";
3
+ import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-BCFFJSle.js";
4
+ import "./hooks-DTjHWTfx.js";
5
5
  import { join } from "node:path";
6
6
  import { existsSync, readdirSync } from "node:fs";
7
7
  // src/lorebook-authoring.ts