@dsh-agentic-roleplay/core 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +1 -1
  2. package/lib/{authoring-tools-B4mEdKp_.js → authoring-tools-C6Hzy8jU.js} +1425 -1241
  3. package/lib/authoring.js +18 -7
  4. package/lib/{child-Dtv76jNx.js → child-C8r8AFpm.js} +36 -5
  5. package/lib/client.js +1780 -829
  6. package/lib/client.js.map +1 -1
  7. package/lib/compaction.js +2 -2
  8. package/lib/doctor.js +2 -2
  9. package/lib/{gallery-BZJleAeH.js → gallery-CtG-bDzz.js} +2 -2
  10. package/lib/{generator-Cg6CQc5S.js → generator-nLoPM5MF.js} +2 -2
  11. package/lib/helper.js +1 -1
  12. package/lib/{hooks-DTjHWTfx.js → hooks-BuQ61nvQ.js} +105 -61
  13. package/lib/images.js +4 -4
  14. package/lib/index.js +964 -106
  15. package/lib/{library-GIlrkOim.js → library-CH-ahlm0.js} +2 -2
  16. package/lib/{lorebook-author-tools-BCFFJSle.js → lorebook-author-tools-B6_Jj8oe.js} +6 -6
  17. package/lib/lorebook-authoring.js +4 -4
  18. package/lib/{narration-BVzew4-K.js → narration-B0hConSw.js} +5 -2
  19. package/lib/orchestration.js +50 -13
  20. package/lib/{pack-jail-hsNQNTOf.js → pack-jail-OZSgU85i.js} +10 -10
  21. package/lib/{packs-UpK_cvI4.js → packs-B88bxt8E.js} +2 -2
  22. package/lib/{presenter-agent-DZOgBOR9.js → presenter-agent-D-WNs626.js} +5 -5
  23. package/lib/{preset-Cyoj1ZWa.js → preset-DNuqvMan.js} +4 -4
  24. package/lib/{preset-author-tools-RSta6pHK.js → preset-author-tools-CDwavcTb.js} +6 -6
  25. package/lib/preset-authoring.js +5 -5
  26. package/lib/{presets-CvpsW_10.js → presets-9_MNxwaw.js} +103 -7
  27. package/lib/{reflection-0qTvw2It.js → reflection-BvM0w1R4.js} +132 -92
  28. package/lib/{text-CbGQhK1-.js → text-CzqhC8sT.js} +11 -1
  29. package/lib/{turn-guard-BzNeGNnc.js → turn-guard-Ygdww1Wt.js} +3 -3
  30. package/package.json +2 -2
  31. package/prompts/en/checks/decide-stated.md +1 -0
  32. package/prompts/zh/checks/decide-stated.md +1 -0
@@ -1,5 +1,5 @@
1
1
  import { n as atomicWrite } from "./access-CXtaZNbx.js";
2
- import { i as translator, n as withoutExtension, r as languageOf, t as trimCharacters } from "./text-CbGQhK1-.js";
2
+ import { i as translator, n as withoutExtension, r as languageOf, t as trimCharacters } from "./text-CzqhC8sT.js";
3
3
  import { dirname, extname, join } from "node:path";
4
4
  import { existsSync } from "node:fs";
5
5
  import { createHash } from "node:crypto";
@@ -374,4 +374,4 @@ async function addToLibrary(sessionFolder, bytes, originalName) {
374
374
  }
375
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 };
376
376
 
377
- //# sourceMappingURL=library-GIlrkOim.js.map
377
+ //# sourceMappingURL=library-CH-ahlm0.js.map
@@ -1,9 +1,9 @@
1
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
- import { i as translator, r as languageOf } from "./text-CbGQhK1-.js";
6
- import { ot as shippedPromptsDirectory } from "./hooks-DTjHWTfx.js";
2
+ import { $t as ImportCardError, dt as lorebookDirectory, ft as readLorebook$1, ht as writeLorebookEntry, i as contextOf, mt as updateLorebookInfo, ot as deleteLorebookEntry, r as MAX_PREVIEW_TEXT, st as entriesOf, ut as loadLorebook } from "./authoring-tools-C6Hzy8jU.js";
3
+ import { $ as IMPORT_FOLDER, Lt as LORE_KINDS, Q as withPlayer, Rt as LORE_SCOPES, Y as cleanText, Z as partsOf, n as createPresetFromGuidance } from "./presets-9_MNxwaw.js";
4
+ import { C as slug, T as uniqueKey, w as trOf, x as mapLimit } from "./library-CH-ahlm0.js";
5
+ import { i as translator, r as languageOf } from "./text-CzqhC8sT.js";
6
+ import { ot as shippedPromptsDirectory } from "./hooks-BuQ61nvQ.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-BCFFJSle.js.map
699
+ //# sourceMappingURL=lorebook-author-tools-B6_Jj8oe.js.map
@@ -1,7 +1,7 @@
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";
1
+ import { dt as lorebookDirectory, n as limitAuthoringAgents } from "./authoring-tools-C6Hzy8jU.js";
2
+ import { t as guardAuthoringTurns } from "./turn-guard-Ygdww1Wt.js";
3
+ import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-B6_Jj8oe.js";
4
+ import "./hooks-BuQ61nvQ.js";
5
5
  import { join } from "node:path";
6
6
  import { existsSync, readdirSync } from "node:fs";
7
7
  // src/lorebook-authoring.ts
@@ -192,7 +192,10 @@ const SETTINGS_SPEC = {
192
192
  confidence: ratio(0, 1, .7)
193
193
  },
194
194
  interface: { pack: text(60, "") },
195
- rewind: { keepSnapshots: integer(0, 500, 30) },
195
+ rewind: {
196
+ keepSnapshots: integer(0, 500, 30),
197
+ rolls: choice(["reroll", "keep"], "reroll")
198
+ },
196
199
  rules: { own: text(MAX_OWN_RULES, "") },
197
200
  preview: { enabled: flag(true) },
198
201
  suggestions: { count: integer(0, 5, 3) },
@@ -451,4 +454,4 @@ function decodeOutput(text) {
451
454
  }
452
455
  export { emptyStats as _, liveSettings as a, writeSettings as c, parseSettings as d, parseSwitchboard as f, GATE_SITES as g, DECISION_SITES as h, InvalidSettingsError as i, DEFAULT_SETTINGS as l, rulesOf as m, encodeOutput as n, readSettings as o, WORLD_RULES_KEY as p, encodePreview as r, useChildReasoning as s, decodeOutput as t, SETTINGS_SPEC as u };
453
456
 
454
- //# sourceMappingURL=narration-BVzew4-K.js.map
457
+ //# sourceMappingURL=narration-B0hConSw.js.map
@@ -1,20 +1,21 @@
1
1
  import { c as chatSessionId, l as roleplaySessionOf, t as promptFor } from "./access-CXtaZNbx.js";
2
- import { A as RESULTS, E as ClockError, G as commandFlagKey, K as commandsOf, O as describeWhen, W as COMMANDS_KEY, b as writeVerdicts, c as record, dt as ReflectionRefusedError, f as MAX_OOC_ANSWER, ht as AUTHORING_NEEDS, k as zoneOf, l as characterRunner, n as installHooks, o as PREVIEW_TOOL, p as storesOf, r as externalGiven, s as createTools$1, st as shippedText, u as toolEnabled, y as readVerdicts, z as wrongLanguage } from "./hooks-DTjHWTfx.js";
3
- import { S as tokensOf, a as childTrace, c as runChild, n as childModel, r as childSampling, v as currentTurn, x as estimateAnswer } from "./child-Dtv76jNx.js";
4
- import { _ as referent, a as whereabouts, g as sameWords, n as memoryReflector, r as recordFailure, s as Timelines, t as dueReflection } from "./reflection-0qTvw2It.js";
5
- import { B as noAt, H as yesAt, I as announceProblem, L as askYesNo, Rt as INTENT_STATUSES, V as routeVerdicts, m as STANDING_PROMPT, z as modeFor } from "./presets-CvpsW_10.js";
6
- import { i as translator, r as languageOf } from "./text-CbGQhK1-.js";
7
- import { a as liveSettings, g as GATE_SITES, n as encodeOutput } from "./narration-BVzew4-K.js";
8
- import { C as slug, T as uniqueKey, t as addToLibrary } from "./library-GIlrkOim.js";
9
- import { _ as API_PREFIX } from "./packs-UpK_cvI4.js";
10
- import { i as updateImage, r as listGallery, t as describeGalleryImage } from "./gallery-BZJleAeH.js";
11
- import { n as interpretImage, s as presentedFor, t as runImagePresenter } from "./presenter-agent-DZOgBOR9.js";
2
+ import { D as describeWhen, G as commandFlagKey, K as commandsOf, O as zoneOf, R as wrongLanguage, T as ClockError, W as COMMANDS_KEY, c as record, dt as ReflectionRefusedError, f as MAX_OOC_ANSWER, ht as AUTHORING_NEEDS, k as RESULTS, l as characterRunner, n as installHooks, o as PREVIEW_TOOL, p as storesOf, r as externalGiven, s as createTools$1, st as shippedText, u as toolEnabled, v as readVerdicts, y as writeVerdicts } from "./hooks-BuQ61nvQ.js";
3
+ import { C as tokensOf, S as estimateAnswer, a as childTrace, c as runChild, n as childModel, r as childSampling, y as currentTurn } from "./child-C8r8AFpm.js";
4
+ import { a as whereabouts, m as referent, n as memoryReflector, p as sameWords, r as recordFailure, s as Timelines, t as dueReflection } from "./reflection-BvM0w1R4.js";
5
+ import { B as modeFor, H as routeVerdicts, L as announceProblem, R as askYesNo, U as yesAt, V as noAt, Vt as INTENT_STATUSES, m as STANDING_PROMPT } from "./presets-9_MNxwaw.js";
6
+ import { i as translator, r as languageOf } from "./text-CzqhC8sT.js";
7
+ import { a as liveSettings, g as GATE_SITES, n as encodeOutput } from "./narration-B0hConSw.js";
8
+ import { C as slug, T as uniqueKey, t as addToLibrary } from "./library-CH-ahlm0.js";
9
+ import { _ as API_PREFIX } from "./packs-B88bxt8E.js";
10
+ import { i as updateImage, r as listGallery, t as describeGalleryImage } from "./gallery-CtG-bDzz.js";
11
+ import { n as interpretImage, s as presentedFor, t as runImagePresenter } from "./presenter-agent-D-WNs626.js";
12
12
  import { join } from "node:path";
13
13
  import { existsSync } from "node:fs";
14
+ import { createHash } from "node:crypto";
14
15
  import { readdir } from "node:fs/promises";
15
16
  import { SessionId } from "@deepseek-ai/dsh-session";
16
17
  import { defineTool } from "@deepseek-ai/dsh-tools";
17
- import { InvalidEditError, characterKey, createDiceTools, createTools, dayPart, describeDuration, describeHolder, describeInstant, describeValue, itemKey, judgedStatements, lintWorld, localTime, locationKey, mentioned, parseRecordsEdit, rollForCheck, sessionDatabase, sessionFolder } from "@dsh-agentic-roleplay/state";
18
+ import { InvalidEditError, characterKey, createDiceTools, createTools, dayPart, describeDuration, describeHolder, describeInstant, describeValue, itemKey, judgedStatements, lintWorld, localTime, locationKey, mentioned, parseRecordsEdit, rollForCheck, sessionDatabase, sessionFolder, systemRoller } from "@dsh-agentic-roleplay/state";
18
19
  // src/host/tools/resource-hint.ts
19
20
  /** The name DSH's MCP resource plugin gives the prompt paragraph it adds for every agent; a section of the same name in an agent's scope replaces it. */
20
21
  const RESOURCE_HINT_SECTION = "mcp-resource-servers";
@@ -1316,6 +1317,39 @@ function describeChecks(checks, tr) {
1316
1317
  });
1317
1318
  return [tr("The checks of this story:"), ...lines].join("\n");
1318
1319
  }
1320
+ // src/host/dice/replay.ts
1321
+ /**
1322
+ * Dice that fall the same way when a turn is played again from the same place. Each turn is given a seed (the story and the turn it follows); the n-th die of the turn is
1323
+ * drawn from the seed and n, so a regenerated or swapped turn meets the same numbers in the order it asks for them. The numbers are not tied to what is rolled for: a turn
1324
+ * that rolls other things in another order gets the same sequence. Stories that reroll use the system's randomness.
1325
+ */
1326
+ var RollReplay = class {
1327
+ policy;
1328
+ turns = /* @__PURE__ */ new Map();
1329
+ constructor(policy) {
1330
+ this.policy = policy;
1331
+ }
1332
+ /** A turn begins after the turn `parent` (or the start): its dice are drawn from this place. */
1333
+ begin(chat, session, parent) {
1334
+ this.turns.set(chat, {
1335
+ seed: `${session}|${parent ?? "start"}`,
1336
+ drawn: 0
1337
+ });
1338
+ }
1339
+ forget(chat) {
1340
+ this.turns.delete(chat);
1341
+ }
1342
+ /** The roller of a chat's turn. */
1343
+ roller(chat) {
1344
+ if (this.policy(chat) !== "keep") return systemRoller;
1345
+ return (sides) => {
1346
+ const turn = this.turns.get(chat);
1347
+ if (turn === void 0) return systemRoller(sides);
1348
+ turn.drawn += 1;
1349
+ return 1 + createHash("sha256").update(`${turn.seed}|${turn.drawn}`).digest().readUIntBE(0, 6) % sides;
1350
+ };
1351
+ }
1352
+ };
1319
1353
  // src/host/orchestration/check-tool.ts
1320
1354
  const CHECK_NARRATE_TOOL = "roll_and_narrate";
1321
1355
  const BRANCHES = [
@@ -1450,7 +1484,7 @@ function createCheckNarrateTool(deps) {
1450
1484
  character: args.character,
1451
1485
  ...args.target === void 0 ? {} : { target: args.target },
1452
1486
  ...args.bonus === void 0 ? {} : { bonus: args.bonus }
1453
- });
1487
+ }, deps.roller?.(owner.chat));
1454
1488
  const branch = given[rolled.result];
1455
1489
  if (branch === void 0) throw new Error(`the roll gave ${rolled.result}, for which no branch was written`);
1456
1490
  const run = characterRunner({
@@ -3806,11 +3840,13 @@ function apply(ctx) {
3806
3840
  interpolate: false,
3807
3841
  text: ""
3808
3842
  });
3843
+ const rolls = new RollReplay((chat) => stores(chat)?.settings().rewind.rolls ?? "reroll");
3809
3844
  const toolDeps = {
3810
3845
  engine,
3811
3846
  boundaries,
3812
3847
  stores,
3813
3848
  turnOf: currentTurn,
3849
+ roller: (chat) => rolls.roller(chat),
3814
3850
  delivered: (chat, output) => {
3815
3851
  const node = timelines.delivered(chat, output);
3816
3852
  if (node !== void 0) images.afterDelivery(chat, node, output);
@@ -3896,8 +3932,9 @@ function apply(ctx) {
3896
3932
  boundaries,
3897
3933
  stores,
3898
3934
  timelines,
3935
+ rolls,
3899
3936
  previewTool,
3900
- optionalTools: [...createDiceTools(diceLink), createCheckNarrateTool(toolDeps)]
3937
+ optionalTools: [...createDiceTools(diceLink, { rollerFor: (chat) => rolls.roller(chat) }), createCheckNarrateTool(toolDeps)]
3901
3938
  });
3902
3939
  }
3903
3940
  export { apply, inject, name };
@@ -1,13 +1,13 @@
1
1
  import { c as chatSessionId, n as atomicWrite, r as atomicWriteJson } from "./access-CXtaZNbx.js";
2
- import { Bt as loadFactions, D as baseId, E as UPDATE_FOLDER, F as writeSnapshot, Ft as LOCATIONS_DIR, G as candidateUrls, Gt as loadCalendar, It as loadLocations, J as mergeReports, Jt as loadCharacters, K as fetchPictures, Lt as ITEMS_DIR, Mt as loadTriggers, N as recordProvenance, Nt as LORE_DIR, O as cardPieces, P as editsSince, Pt as loadLore, Rt as loadItems, S as editWorldInfo, U as addressKey, W as addressesToFetch, X as cardCharacter, Yt as subfolders, Z as writePortrait, _t as knowsCharacter, an as authoringChatSessionId, b as matchPieces, c as importPhase, gt as withScratchStory, ht as loadValidatedWorld, i as contextOf, in as authoredWorldOf, jt as TRIGGERS_FILE_NAME, qt as CHARACTERS_DIR, s as worldOf, w as loadWorldParts, x as worldFieldChanges, zt as FACTIONS_DIR } from "./authoring-tools-B4mEdKp_.js";
3
- import { Ct as CHARACTER_FILE_NAME, Dt as InvalidEditProblems, Q as IMPORT_FOLDER, St as parseFactionFile, Z as withPlayer, _t as ITEM_FILE_NAME, at as writeChoices, gt as parseLocationFile, ht as LOCATION_FILE_NAME, it as readImportFolder, mt as parseLoreFile, pt as LORE_FILE_NAME, q as writeWorldPrompt, tt as PICTURE_FILE, ut as loadVariables, wt as parseCharacterFile, x as extractStyleFrom, xt as FACTION_FILE_NAME, yt as parseItemFile } from "./presets-CvpsW_10.js";
4
- import { n as encodeOutput } from "./narration-BVzew4-K.js";
5
- import { B as PLOTS_FILE_NAME, F as LANGUAGE_NAMES, H as parsePlotsFile, I as STORY_LANGUAGES, J as Reader, L as isStoryLanguage, Q as PROMPTS_FOLDER, R as textLanguage, U as plotReferenceProblems, V as loadPlots, Y as formatIssue, at as shippedLanguages, ct as AgentUnavailableError, mt as WorldNotFoundError, ut as InvalidWorldError } from "./hooks-DTjHWTfx.js";
6
- import { i as translator, r as languageOf } from "./text-CbGQhK1-.js";
7
- import { h as readImageFileMetadata, u as referenceImagePath, x as mapLimit } from "./library-GIlrkOim.js";
8
- import { n as readPreset } from "./preset-Cyoj1ZWa.js";
9
- import { _ as API_PREFIX, a as packIds, d as packPath, f as readPack, h as PACK_MEDIA_TYPES, l as isPackId } from "./packs-UpK_cvI4.js";
10
- import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-Cg6CQc5S.js";
2
+ import { A as editsSince, B as addressesToFetch, Bt as loadItems, C as worldFieldChanges, E as loadWorldParts, Ft as LORE_DIR, H as fetchPictures, Ht as loadFactions, It as loadLore, J as UPDATE_FOLDER, K as cardCharacter, Lt as LOCATIONS_DIR, Nt as TRIGGERS_FILE_NAME, Pt as loadTriggers, Rt as loadLocations, V as candidateUrls, Vt as FACTIONS_DIR, W as mergeReports, X as cardPieces, Xt as loadCharacters, Y as baseId, Yt as CHARACTERS_DIR, Zt as subfolders, _t as loadValidatedWorld, c as importPhase, i as contextOf, j as writeSnapshot, k as recordProvenance, on as authoredWorldOf, q as writePortrait, qt as loadCalendar, s as worldOf, sn as authoringChatSessionId, vt as withScratchStory, w as editWorldInfo, x as matchPieces, yt as knowsCharacter, z as addressKey, zt as ITEMS_DIR } from "./authoring-tools-C6Hzy8jU.js";
3
+ import { $ as IMPORT_FOLDER, At as InvalidEditProblems, Dt as parseCharacterFile, Et as CHARACTER_FILE_NAME, J as writeWorldPrompt, Q as withPlayer, St as parseItemFile, Tt as parseFactionFile, _t as parseLoreFile, at as readImportFolder, bt as ITEM_FILE_NAME, gt as LORE_FILE_NAME, nt as PICTURE_FILE, ot as writeChoices, pt as loadVariables, vt as LOCATION_FILE_NAME, wt as FACTION_FILE_NAME, x as extractStyleFrom, yt as parseLocationFile } from "./presets-9_MNxwaw.js";
4
+ import { n as encodeOutput } from "./narration-B0hConSw.js";
5
+ import { B as PLOTS_FILE_NAME, F as STORY_LANGUAGES, H as parsePlotsFile, I as isStoryLanguage, J as Reader, L as textLanguage, P as LANGUAGE_NAMES, Q as PROMPTS_FOLDER, U as plotReferenceProblems, V as loadPlots, Y as formatIssue, at as shippedLanguages, ct as AgentUnavailableError, mt as WorldNotFoundError, ut as InvalidWorldError } from "./hooks-BuQ61nvQ.js";
6
+ import { i as translator, r as languageOf } from "./text-CzqhC8sT.js";
7
+ import { h as readImageFileMetadata, u as referenceImagePath, x as mapLimit } from "./library-CH-ahlm0.js";
8
+ import { n as readPreset } from "./preset-DNuqvMan.js";
9
+ import { _ as API_PREFIX, a as packIds, d as packPath, f as readPack, h as PACK_MEDIA_TYPES, l as isPackId } from "./packs-B88bxt8E.js";
10
+ import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-nLoPM5MF.js";
11
11
  import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
12
12
  import { existsSync, lstatSync, statSync } from "node:fs";
13
13
  import { randomUUID } from "node:crypto";
@@ -2649,4 +2649,4 @@ function registerPackJail(ctx, deps) {
2649
2649
  }
2650
2650
  export { DOCTOR_OPENING_SOURCE as $, worldEntityImageFile as A, languageOfDocuments as B, readWorldEditor as C, uploadWorldCharacterPortrait as D, replaceFile as E, PRESET_FILE as F, revertUpdate as G, findTargets as H, presetMessage as I, AuthoringSessions as J, startUpdate as K, presetTools as L, deleteTriggerDocument as M, readTriggerDocuments as N, uploadWorldEntityImage as O, writeTriggerDocument as P, agentServicesOf as Q, translateMessage as R, generateWorldEntityImage as S, removeWorldTrigger as T, finishUpdate as U, readWorldDocuments as V, pendingUpdate as W, ensureAuthoringChat as X, authoringTitle as Y, AgentSessions as Z, editWorldPlots as _, deleteWorldPackFile as a, entityFolder as b, createAuthoredEntity as c, replaceAuthoredEntity as d, appendEmptyTurn as et, editWorldCharacter as f, editWorldPlace as g, editWorldNarrationVoice as h, checkWorldPack as i, writeWorldTrigger as j, worldCharacterPortraitFile as k, deleteAuthoredEntity as l, editWorldLore as m, packFileProblem as n, listWorldPacks as o, editWorldFaction as p, updateStatus as q, registerPackJail as r, AUTHORED_ENTITY_KINDS as s, MAX_PACK_TEXT as t, appendNarratedTurn as tt, readAuthoredEntityDocument as u, editWorldRelation as v, readWorldTrigger as w, generateWorldCharacterPortrait as x, editWorldThing as y, translateTools as z };
2651
2651
 
2652
- //# sourceMappingURL=pack-jail-hsNQNTOf.js.map
2652
+ //# sourceMappingURL=pack-jail-OZSgU85i.js.map
@@ -1,4 +1,4 @@
1
- import { J as Reader } from "./hooks-DTjHWTfx.js";
1
+ import { J as Reader } from "./hooks-BuQ61nvQ.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";
@@ -836,4 +836,4 @@ function anyTab(bases) {
836
836
  }
837
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 };
838
838
 
839
- //# sourceMappingURL=packs-UpK_cvI4.js.map
839
+ //# sourceMappingURL=packs-B88bxt8E.js.map
@@ -1,8 +1,8 @@
1
1
  import { n as atomicWrite, t as promptFor } from "./access-CXtaZNbx.js";
2
- import { c as runChild } from "./child-Dtv76jNx.js";
3
- import { n as generateTransientImage, t as generateReferenceImage } from "./generator-Cg6CQc5S.js";
4
- import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-BZJleAeH.js";
5
- import { c as nextSceneSerial, u as referenceImagePath } from "./library-GIlrkOim.js";
2
+ import { c as runChild } from "./child-C8r8AFpm.js";
3
+ import { n as generateTransientImage, t as generateReferenceImage } from "./generator-nLoPM5MF.js";
4
+ import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-CtG-bDzz.js";
5
+ import { c as nextSceneSerial, u as referenceImagePath } from "./library-CH-ahlm0.js";
6
6
  import { join, relative } from "node:path";
7
7
  import { existsSync } from "node:fs";
8
8
  import { createHash } from "node:crypto";
@@ -841,4 +841,4 @@ async function runImagePresenter(job) {
841
841
  }
842
842
  export { tokensOf as a, searchImages as i, interpretImage as n, present as o, imageTools as r, presentedFor as s, runImagePresenter as t };
843
843
 
844
- //# sourceMappingURL=presenter-agent-DZOgBOR9.js.map
844
+ //# sourceMappingURL=presenter-agent-D-WNs626.js.map
@@ -1,6 +1,6 @@
1
- import { Zt as ImportCardError, r as MAX_PREVIEW_TEXT } from "./authoring-tools-B4mEdKp_.js";
2
- import { l as SAMPLING_RANGES } from "./child-Dtv76jNx.js";
3
- import { J as cleanText } from "./presets-CvpsW_10.js";
1
+ import { $t as ImportCardError, r as MAX_PREVIEW_TEXT } from "./authoring-tools-C6Hzy8jU.js";
2
+ import { l as SAMPLING_RANGES } from "./child-C8r8AFpm.js";
3
+ import { Y as cleanText } from "./presets-9_MNxwaw.js";
4
4
  // src/host/import/preset.ts
5
5
  /** The older preset layout keeps its texts under fixed keys. */
6
6
  const LEGACY_KEYS = [
@@ -239,4 +239,4 @@ function selectPrompts(file, enabled, keepSampling) {
239
239
  }
240
240
  export { readPreset as n, selectPrompts as r, previewPreset as t };
241
241
 
242
- //# sourceMappingURL=preset-Cyoj1ZWa.js.map
242
+ //# sourceMappingURL=preset-DNuqvMan.js.map
@@ -1,9 +1,9 @@
1
1
  import "./access-CXtaZNbx.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-CvpsW_10.js";
3
- import { n as readPreset$1 } from "./preset-Cyoj1ZWa.js";
4
- import { i as contextOf } from "./authoring-tools-B4mEdKp_.js";
5
- import { i as translator, r as languageOf } from "./text-CbGQhK1-.js";
6
- import { at as shippedLanguages, nt as languageOf$1, ot as shippedPromptsDirectory } from "./hooks-DTjHWTfx.js";
2
+ import { $ as IMPORT_FOLDER, G as deleteWorldPrompt, J as writeWorldPrompt, K as listWorldPrompts, Q as withPlayer, W as PROSE_PROMPTS, c as presetDirectory, l as readPreset, p as updatePresetInfo, q as readWorldPrompt, t as PRESET_FILE, x as extractStyleFrom } from "./presets-9_MNxwaw.js";
3
+ import { n as readPreset$1 } from "./preset-DNuqvMan.js";
4
+ import { i as contextOf } from "./authoring-tools-C6Hzy8jU.js";
5
+ import { i as translator, r as languageOf } from "./text-CzqhC8sT.js";
6
+ import { at as shippedLanguages, nt as languageOf$1, ot as shippedPromptsDirectory } from "./hooks-BuQ61nvQ.js";
7
7
  import { join } from "node:path";
8
8
  import { existsSync } from "node:fs";
9
9
  import { readFile, rm } from "node:fs/promises";
@@ -278,4 +278,4 @@ async function presetApproval(exec, next, carries) {
278
278
  }
279
279
  export { presetChatSessionId as a, presetAuthorTools as i, narrationImportMessage as n, presetOfChat as o, presetApproval as r, PresetReader as t };
280
280
 
281
- //# sourceMappingURL=preset-author-tools-RSta6pHK.js.map
281
+ //# sourceMappingURL=preset-author-tools-CDwavcTb.js.map
@@ -1,8 +1,8 @@
1
- import { n as limitAuthoringAgents } from "./authoring-tools-B4mEdKp_.js";
2
- import { t as guardAuthoringTurns } from "./turn-guard-BzNeGNnc.js";
3
- import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-RSta6pHK.js";
4
- import "./hooks-DTjHWTfx.js";
5
- import { c as presetDirectory } from "./presets-CvpsW_10.js";
1
+ import { n as limitAuthoringAgents } from "./authoring-tools-C6Hzy8jU.js";
2
+ import { t as guardAuthoringTurns } from "./turn-guard-Ygdww1Wt.js";
3
+ import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-CDwavcTb.js";
4
+ import "./hooks-BuQ61nvQ.js";
5
+ import { c as presetDirectory } from "./presets-9_MNxwaw.js";
6
6
  import { join } from "node:path";
7
7
  import { existsSync } from "node:fs";
8
8
  // src/preset-authoring.ts
@@ -1,8 +1,9 @@
1
1
  import { a as VARIABLE_KINDS, n as atomicWrite, o as VARIABLE_SUBJECTS, s as VARIABLE_VISIBILITIES } from "./access-CXtaZNbx.js";
2
- import "./narration-BVzew4-K.js";
3
- import { J as Reader, Q as PROMPTS_FOLDER, X as errorMessage, Y as formatIssue, Z as LANGUAGE_FOLDER, at as shippedLanguages, it as promptProblem, nt as languageOf, ot as shippedPromptsDirectory, q as readDocument, rt as listFiles } from "./hooks-DTjHWTfx.js";
4
- import { u as parseSampling } from "./child-Dtv76jNx.js";
5
- import { C as slug, S as norm, T as uniqueKey, w as trOf, x as mapLimit } from "./library-GIlrkOim.js";
2
+ import "./narration-B0hConSw.js";
3
+ import { J as Reader, Q as PROMPTS_FOLDER, X as errorMessage, Y as formatIssue, Z as LANGUAGE_FOLDER, at as shippedLanguages, it as promptProblem, nt as languageOf, ot as shippedPromptsDirectory, q as readDocument, rt as listFiles } from "./hooks-BuQ61nvQ.js";
4
+ import { i as translator, r as languageOf$1 } from "./text-CzqhC8sT.js";
5
+ import { u as parseSampling } from "./child-C8r8AFpm.js";
6
+ import { C as slug, S as norm, T as uniqueKey, w as trOf, x as mapLimit } from "./library-CH-ahlm0.js";
6
7
  import { dirname, join } from "node:path";
7
8
  import { existsSync, readFileSync, readdirSync } from "node:fs";
8
9
  import { createHash, randomUUID } from "node:crypto";
@@ -1541,6 +1542,100 @@ function parseImportCommand(text) {
1541
1542
  request: command.rest.slice(boundary).trim()
1542
1543
  };
1543
1544
  }
1545
+ // src/host/import/dialect.ts
1546
+ const MAX_NAMES = 8;
1547
+ const PLAIN_MACROS = /* @__PURE__ */ new Set([
1548
+ "user",
1549
+ "char",
1550
+ "bot"
1551
+ ]);
1552
+ const MARKUP = /* @__PURE__ */ new Set([
1553
+ "a",
1554
+ "b",
1555
+ "i",
1556
+ "u",
1557
+ "s",
1558
+ "p",
1559
+ "br",
1560
+ "hr",
1561
+ "em",
1562
+ "strong",
1563
+ "span",
1564
+ "div",
1565
+ "code",
1566
+ "pre",
1567
+ "center",
1568
+ "small",
1569
+ "img",
1570
+ "ul",
1571
+ "ol",
1572
+ "li",
1573
+ "blockquote",
1574
+ "details",
1575
+ "summary",
1576
+ "font",
1577
+ "sub",
1578
+ "sup",
1579
+ "h1",
1580
+ "h2",
1581
+ "h3",
1582
+ "table",
1583
+ "tr",
1584
+ "td",
1585
+ "th"
1586
+ ]);
1587
+ const MACRO = /\{\{\s*([\p{L}_][\p{L}\p{N}_]*)/gu;
1588
+ const BLOCK = /<([\p{L}][\p{L}\p{N}_-]{1,30})(?:\s[^>]*)?>[\s\S]*?<\/\1\s*>/gu;
1589
+ function textsOf(card) {
1590
+ return [
1591
+ card.description,
1592
+ card.personality,
1593
+ card.scenario,
1594
+ card.firstMessage,
1595
+ ...card.alternateGreetings,
1596
+ card.messageExample,
1597
+ card.systemPrompt,
1598
+ card.postHistoryInstructions,
1599
+ ...(card.book?.entries ?? []).map((entry) => entry.content)
1600
+ ];
1601
+ }
1602
+ /** The distinct values of a pattern's first group over some texts, in the order met, lowercased and cut to a few. */
1603
+ function namesIn(texts, pattern, skip) {
1604
+ const found = /* @__PURE__ */ new Set();
1605
+ for (const text of texts) for (const match of text.matchAll(pattern)) {
1606
+ const name = match[1].toLowerCase();
1607
+ if (!skip(name)) found.add(name);
1608
+ }
1609
+ return [...found].slice(0, MAX_NAMES);
1610
+ }
1611
+ /** Reads the machinery of the source tool out of a card: macros, tag blocks and the scripts the reader counted. */
1612
+ function dialectOf(card) {
1613
+ const texts = textsOf(card);
1614
+ return {
1615
+ macros: namesIn(texts, MACRO, (name) => PLAIN_MACROS.has(name)),
1616
+ tags: namesIn(texts, BLOCK, (name) => MARKUP.has(name)),
1617
+ regexScripts: card.ignored.regexScripts ?? 0,
1618
+ helperScripts: card.ignored.helperScripts ?? card.ignored.scripts - (card.ignored.regexScripts ?? 0)
1619
+ };
1620
+ }
1621
+ /** What the person is told about a card before the import starts: what it is, and which of its machinery is left out. */
1622
+ function sourceSummary(card, language) {
1623
+ const tr = translator(languageOf$1(language));
1624
+ const dialect = dialectOf(card);
1625
+ const lines = [tr("The source is a {format} card with {entries} lorebook entries and {greetings} alternate openings.", {
1626
+ format: card.sourceSpec === "chara_card_v2" ? "V2" : "V3",
1627
+ entries: String(card.book?.entries.length ?? 0),
1628
+ greetings: String(card.alternateGreetings.length)
1629
+ })];
1630
+ const left = [
1631
+ ...dialect.regexScripts > 0 ? [tr("{count} regular expressions", { count: String(dialect.regexScripts) })] : [],
1632
+ ...dialect.helperScripts > 0 ? [tr("{count} helper scripts", { count: String(dialect.helperScripts) })] : [],
1633
+ ...dialect.macros.length > 0 ? [tr("macros ({names})", { names: dialect.macros.join(", ") })] : [],
1634
+ ...dialect.tags.length > 0 ? [tr("tag blocks ({names})", { names: dialect.tags.join(", ") })] : []
1635
+ ];
1636
+ if (left.length > 0) lines.push(tr("Nothing runs them, so they are not carried: {parts}. Their effect is kept only where the card also says it in words.", { parts: left.join("; ") }));
1637
+ return lines.join(" ");
1638
+ }
1544
1639
  // src/host/import/store.ts
1545
1640
  const IMPORT_FOLDER = ".import";
1546
1641
  const CARD_FILE = "card.json";
@@ -1655,7 +1750,8 @@ var ImportStore = class {
1655
1750
  id,
1656
1751
  card,
1657
1752
  choices,
1658
- hasAvatar: hasPicture
1753
+ hasAvatar: hasPicture,
1754
+ dialect: dialectOf(card)
1659
1755
  };
1660
1756
  } catch (error) {
1661
1757
  if (error.code === "ENOENT") throw new ImportNotFoundError(`there is no import "${id}"`);
@@ -4007,6 +4103,6 @@ async function createPresetFromGuidance(root, request, guidance, shipped = shipp
4007
4103
  });
4008
4104
  }
4009
4105
  }
4010
- export { ImportNotFoundError as $, sourcesFor as A, parseLoreEdit as At, noAt as B, inert as C, CHARACTER_FILE_NAME as Ct, pruneLoreSubjects as D, InvalidEditProblems as Dt, pruneLinks as E, readIdentifier as Et, isLeftOut as F, LORE_SCOPES as Ft, listWorldPrompts as G, yesAt as H, announceProblem as I, WEEKDAY_NAMES as It, cleanText as J, readWorldPrompt as K, askYesNo as L, DEFAULT_SLOTS as Lt, classifyItems as M, parseRelationEdit as Mt, findEntity as N, parseThingEdit as Nt, pruneMembers as O, parseCharacterEdit as Ot, ROLES as P, LORE_KINDS as Pt, IMPORT_FOLDER as Q, mergeReports as R, INTENT_STATUSES as Rt, extractVariables as S, parseFactionFile as St, pruneKnowledge as T, readVariableValues as Tt, PROSE_PROMPTS as U, routeVerdicts as V, deleteWorldPrompt as W, partsOf as X, itemise as Y, withPlayer as Z, characterDocument as _, ITEM_FILE_NAME as _t, isPresetName as a, writeChoices as at, extractStyle as b, parseSlotsFile as bt, presetDirectory as c, parseAuthoringCommand as ct, savePresetFromWorld as d, parseVariablesFile as dt, ImportStore as et, sha as f, variableProblems as ft, asWritten as g, parseLocationFile as gt, addLore as h, LOCATION_FILE_NAME as ht, deletePreset as i, readImportFolder as it, buildRoster as j, parsePlaceEdit as jt, pruneRelationships as k, parseFactionEdit as kt, readPreset as l, VARIABLES_FILE_NAME as lt, STANDING_PROMPT as m, parseLoreFile as mt, createPresetFromGuidance as n, openingText as nt, listPresets as o, IMPORT_COMMAND as ot, updatePresetInfo as p, LORE_FILE_NAME as pt, writeWorldPrompt as q, createPresetFromShipped as r, parseChoices as rt, loadPreset as s, parseImportCommand as st, PRESET_FILE as t, PICTURE_FILE as tt, reservePreset as u, loadVariables as ut, emptyExtracted as v, SLOTS_FILE_NAME as vt, loreDocuments as w, parseCharacterFile as wt, extractStyleFrom as x, FACTION_FILE_NAME as xt, extractEntities as y, parseItemFile as yt, modeFor as z };
4106
+ export { IMPORT_FOLDER as $, sourcesFor as A, InvalidEditProblems as At, modeFor as B, DEFAULT_SLOTS as Bt, inert as C, parseSlotsFile as Ct, pruneLoreSubjects as D, parseCharacterFile as Dt, pruneLinks as E, CHARACTER_FILE_NAME as Et, ROLE_TABLE as F, parseRelationEdit as Ft, deleteWorldPrompt as G, routeVerdicts as H, isLeftOut as I, parseThingEdit as It, writeWorldPrompt as J, listWorldPrompts as K, announceProblem as L, LORE_KINDS as Lt, classifyItems as M, parseFactionEdit as Mt, findEntity as N, parseLoreEdit as Nt, pruneMembers as O, readVariableValues as Ot, ROLES as P, parsePlaceEdit as Pt, withPlayer as Q, askYesNo as R, LORE_SCOPES as Rt, extractVariables as S, parseItemFile as St, pruneKnowledge as T, parseFactionFile as Tt, yesAt as U, noAt as V, INTENT_STATUSES as Vt, PROSE_PROMPTS as W, itemise as X, cleanText as Y, partsOf as Z, characterDocument as _, parseLoreFile as _t, isPresetName as a, readImportFolder as at, extractStyle as b, ITEM_FILE_NAME as bt, presetDirectory as c, sourceSummary as ct, savePresetFromWorld as d, parseAuthoringCommand as dt, ImportNotFoundError as et, sha as f, VARIABLES_FILE_NAME as ft, asWritten as g, LORE_FILE_NAME as gt, addLore as h, variableProblems as ht, deletePreset as i, parseChoices as it, buildRoster as j, parseCharacterEdit as jt, pruneRelationships as k, readIdentifier as kt, readPreset as l, IMPORT_COMMAND as lt, STANDING_PROMPT as m, parseVariablesFile as mt, createPresetFromGuidance as n, PICTURE_FILE as nt, listPresets as o, writeChoices as ot, updatePresetInfo as p, loadVariables as pt, readWorldPrompt as q, createPresetFromShipped as r, openingText as rt, loadPreset as s, dialectOf as st, PRESET_FILE as t, ImportStore as tt, reservePreset as u, parseImportCommand as ut, emptyExtracted as v, LOCATION_FILE_NAME as vt, loreDocuments as w, FACTION_FILE_NAME as wt, extractStyleFrom as x, SLOTS_FILE_NAME as xt, extractEntities as y, parseLocationFile as yt, mergeReports as z, WEEKDAY_NAMES as zt };
4011
4107
 
4012
- //# sourceMappingURL=presets-CvpsW_10.js.map
4108
+ //# sourceMappingURL=presets-9_MNxwaw.js.map