@dsh-agentic-roleplay/core 0.6.1 → 0.7.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 (40) hide show
  1. package/lib/access-DtOxFKBK.js +150 -0
  2. package/lib/{authoring-tools-BGzzW6O5.js → authoring-tools-BKltdiea.js} +160 -74
  3. package/lib/authoring.js +10 -5
  4. package/lib/{child-D5SVNk4O.js → child-CyCViUKa.js} +48 -7
  5. package/lib/client.js +2157 -780
  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-C7VOJ3xH.js → gallery-BxZGOgMb.js} +2 -2
  10. package/lib/{generator-CO8usAjE.js → generator-BFmSYvR8.js} +2 -2
  11. package/lib/helper.js +1 -1
  12. package/lib/{hooks-BLperIIB.js → hooks-HnqXO8mM.js} +10 -241
  13. package/lib/images.js +4 -4
  14. package/lib/index.js +1424 -203
  15. package/lib/{library-DsDc6fQa.js → library-BGxPKs9a.js} +6 -3
  16. package/lib/{lorebook-author-tools-C-cFiE6E.js → lorebook-author-tools-BAnUyRtS.js} +37 -29
  17. package/lib/lorebook-authoring.js +8 -3
  18. package/lib/{narration-_dA9oIt2.js → narration-DvFBqmqe.js} +9 -132
  19. package/lib/orchestration.js +13 -10
  20. package/lib/{pack-jail-BKFmbYP8.js → pack-jail-DLGguGS3.js} +20 -13
  21. package/lib/{packs-ZTG7fWut.js → packs-jowC-MN_.js} +2 -2
  22. package/lib/{presenter-agent-BHSbyWwZ.js → presenter-agent-DvZtnf0Q.js} +6 -6
  23. package/lib/{preset-CJLW8Mp0.js → preset-CXbC0NeU.js} +3 -3
  24. package/lib/{preset-author-tools-1RstgEZs.js → preset-author-tools-C26kj6t5.js} +14 -7
  25. package/lib/preset-authoring.js +9 -4
  26. package/lib/{reflection-6qfOC5OT.js → reflection-CvOZGjmn.js} +9 -170
  27. package/lib/{presets-DcPCnn8O.js → route-DRTJ_vcA.js} +165 -4
  28. package/lib/text-JbWfTHbr.js +295 -0
  29. package/lib/turn-guard-BvCs1VxB.js +53 -0
  30. package/package.json +29 -29
  31. package/prompts/en/import/cut-off.md +1 -0
  32. package/prompts/en/import/finish-failed.md +1 -1
  33. package/prompts/en/roleplay/decide-instruction.md +1 -0
  34. package/prompts/en/roleplay/decide-irrelevant.md +1 -0
  35. package/prompts/zh/import/cut-off.md +1 -0
  36. package/prompts/zh/import/finish-failed.md +1 -1
  37. package/prompts/zh/roleplay/decide-instruction.md +1 -0
  38. package/prompts/zh/roleplay/decide-irrelevant.md +1 -0
  39. package/lib/access-EbNdZFbk.js +0 -25
  40. package/lib/text-CT1re6XT.js +0 -18
@@ -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-BGzzW6O5.js";
2
- import { n as createPresetFromGuidance } from "./presets-DcPCnn8O.js";
3
- import "./narration-_dA9oIt2.js";
4
- import { nt as shippedPromptsDirectory } from "./hooks-BLperIIB.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 updateLorebookInfo, G as partsOf, Ht as LORE_KINDS, K as withPlayer, Rt as ImportCardError, Ut as LORE_SCOPES, W as cleanText, at as IMPORT_FOLDER, bt as lorebookDirectory, gt as entriesOf, ht as deleteLorebookEntry, i as contextOf, r as MAX_PREVIEW_TEXT, wt as writeLorebookEntry, xt as readLorebook$1, yt as loadLorebook } from "./authoring-tools-BKltdiea.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",
@@ -333,7 +336,12 @@ const STEERING_TOOL = "apply_steering";
333
336
  const LOREBOOK_UPLOAD = `${IMPORT_FOLDER}/lorebook.json`;
334
337
  const STEERING_FILE = "steering.json";
335
338
  /** The command that has a lorebook's authoring chat turn an uploaded SillyTavern lorebook into entries. */
336
- const lorebookImportMessage = () => `Turn the SillyTavern lorebook I uploaded into this lorebook: call ${LOREBOOK_IMPORT_TOOL} with file ${LOREBOOK_UPLOAD}.`;
339
+ function lorebookImportMessage(language) {
340
+ return translator(languageOf(language))("Turn the SillyTavern lorebook I uploaded into this lorebook: call {tool} with file {file}.", {
341
+ tool: LOREBOOK_IMPORT_TOOL,
342
+ file: LOREBOOK_UPLOAD
343
+ });
344
+ }
337
345
  const output = (value) => [{
338
346
  type: "text",
339
347
  text: JSON.stringify(value, null, 2)
@@ -563,7 +571,7 @@ function lorebookAuthorTools(reader, settings, prompting, shipped = shippedPromp
563
571
  }), name);
564
572
  const language = prompting.languages().get(`lorebook:${name}`);
565
573
  const text = (id, variables) => prompting.prompts().text(id, language, variables);
566
- const made = await classifyEntries(contextOf(exec, settings(), text), uploaded);
574
+ const made = await classifyEntries(contextOf(exec, settings(), text, language), uploaded);
567
575
  const taken = new Set((await loadLorebook(reader.library, name)).entries.map((entry) => entry.id));
568
576
  for (const entry of made.entries) {
569
577
  let id = entry.id;
@@ -689,6 +697,6 @@ async function lorebookApproval(exec, next, state) {
689
697
  };
690
698
  }
691
699
  //#endregion
692
- 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 };
693
701
 
694
- //# sourceMappingURL=lorebook-author-tools-C-cFiE6E.js.map
702
+ //# sourceMappingURL=lorebook-author-tools-BAnUyRtS.js.map
@@ -1,6 +1,7 @@
1
- import { St as lorebookDirectory, n as limitAuthoringAgents } from "./authoring-tools-BGzzW6O5.js";
2
- import "./hooks-BLperIIB.js";
3
- import { c as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-C-cFiE6E.js";
1
+ import { bt as lorebookDirectory, n as limitAuthoringAgents } from "./authoring-tools-BKltdiea.js";
2
+ import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-BAnUyRtS.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
@@ -1,3 +1,4 @@
1
+ import "./access-DtOxFKBK.js";
1
2
  import { join } from "node:path";
2
3
  import { existsSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
3
4
  //#region ../dsh-roleplay-model/src/clock.ts
@@ -7,131 +8,6 @@ import { existsSync, readFileSync, renameSync, statSync, writeFileSync } from "n
7
8
  */
8
9
  const CLOCK_MODES = ["simulated", "real"];
9
10
  //#endregion
10
- //#region ../dsh-roleplay-model/src/variable.ts
11
- /** What a variable holds: a number within bounds, a yes or no, or one of a list of words. */
12
- const VARIABLE_KINDS = [
13
- "number",
14
- "flag",
15
- "choice"
16
- ];
17
- /** What a variable is about: each character, item or place has its own value; `world` has one value for the whole story. */
18
- const VARIABLE_SUBJECTS = [
19
- "character",
20
- "item",
21
- "location",
22
- "world"
23
- ];
24
- /**
25
- * Who can tell what the value is. `public`: anyone present (what shows). `private`: the character it belongs to, and the
26
- * game master (what it feels or knows of itself). `hidden`: only the game master and the record keeper.
27
- */
28
- const VARIABLE_VISIBILITIES = [
29
- "public",
30
- "private",
31
- "hidden"
32
- ];
33
- [
34
- {
35
- key: "valence",
36
- name: "Valence",
37
- description: "How pleasant its mood is: -1 very unpleasant, 0 neutral, 1 very pleasant.",
38
- labels: [
39
- {
40
- upTo: -.6,
41
- label: "miserable"
42
- },
43
- {
44
- upTo: -.25,
45
- label: "unhappy"
46
- },
47
- {
48
- upTo: .25,
49
- label: "even"
50
- },
51
- {
52
- upTo: .6,
53
- label: "pleased"
54
- },
55
- {
56
- upTo: 1,
57
- label: "delighted"
58
- }
59
- ]
60
- },
61
- {
62
- key: "arousal",
63
- name: "Arousal",
64
- description: "How worked up it is: -1 drowsy, 0 ordinary, 1 frantic.",
65
- labels: [
66
- {
67
- upTo: -.6,
68
- label: "drowsy"
69
- },
70
- {
71
- upTo: -.25,
72
- label: "calm"
73
- },
74
- {
75
- upTo: .25,
76
- label: "alert"
77
- },
78
- {
79
- upTo: .6,
80
- label: "keyed up"
81
- },
82
- {
83
- upTo: 1,
84
- label: "frantic"
85
- }
86
- ]
87
- },
88
- {
89
- key: "dominance",
90
- name: "Dominance",
91
- description: "How much in control it feels: -1 helpless, 0 even, 1 commanding.",
92
- labels: [
93
- {
94
- upTo: -.6,
95
- label: "helpless"
96
- },
97
- {
98
- upTo: -.25,
99
- label: "uneasy"
100
- },
101
- {
102
- upTo: .25,
103
- label: "steady"
104
- },
105
- {
106
- upTo: .6,
107
- label: "confident"
108
- },
109
- {
110
- upTo: 1,
111
- label: "commanding"
112
- }
113
- ]
114
- }
115
- ].map(({ labels, ...rest }) => ({
116
- ...rest,
117
- kind: "number",
118
- subject: "character",
119
- only: [],
120
- min: -1,
121
- max: 1,
122
- integer: false,
123
- options: [],
124
- default: 0,
125
- baseline: true,
126
- visibility: "private",
127
- bands: labels.map((band) => ({
128
- upTo: band.upTo,
129
- label: band.label
130
- })),
131
- always: false,
132
- builtin: true
133
- }));
134
- //#endregion
135
11
  //#region src/shared/decisions.ts
136
12
  /** The places where a language model's closed-choice judgement can be given to a decision model instead, or, for the gates, a check can be made at all. */
137
13
  const DECISION_SITES = [
@@ -447,12 +323,12 @@ function parseSettings(value) {
447
323
  //#region src/host/sessions/settings.ts
448
324
  const SETTINGS_FILE = "settings.json";
449
325
  const known = /* @__PURE__ */ new Map();
450
- let childReasoning = "";
451
- /** The thinking level helpers get when a chat's own setting is empty (the profile's choice); returns the function that takes it back. */
326
+ let childReasoning = () => "";
327
+ /** The thinking level helpers get when a chat's own setting is empty (the profile's choice, read at each use); returns the function that takes it back. */
452
328
  function useChildReasoning(level) {
453
329
  childReasoning = level;
454
330
  return () => {
455
- childReasoning = "";
331
+ childReasoning = () => "";
456
332
  };
457
333
  }
458
334
  /** The settings are not acceptable; `problems` say what to fix. */
@@ -502,11 +378,12 @@ function writeSettings(folder, value) {
502
378
  */
503
379
  function liveSettings(folder, problem = () => void 0) {
504
380
  const value = loadedSettings(folder, problem);
505
- return value.reasoning.children === "" && childReasoning !== "" ? {
381
+ const fallback = childReasoning();
382
+ return value.reasoning.children === "" && fallback !== "" ? {
506
383
  ...value,
507
384
  reasoning: {
508
385
  ...value.reasoning,
509
- children: childReasoning
386
+ children: fallback
510
387
  }
511
388
  } : value;
512
389
  }
@@ -579,6 +456,6 @@ function decodeOutput(text) {
579
456
  }
580
457
  }
581
458
  //#endregion
582
- export { emptyStats as _, liveSettings as a, VARIABLE_VISIBILITIES as b, 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, VARIABLE_KINDS as v, VARIABLE_SUBJECTS as y };
459
+ 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 };
583
460
 
584
- //# sourceMappingURL=narration-_dA9oIt2.js.map
461
+ //# sourceMappingURL=narration-DvFBqmqe.js.map
@@ -1,13 +1,14 @@
1
- import { n as chatSessionId, r as roleplaySessionOf, t as promptFor } from "./access-EbNdZFbk.js";
2
- import { b as INTENT_STATUSES } from "./presets-DcPCnn8O.js";
3
- import { a as whereabouts, b as sameWords, c as noAt, f as Timelines, l as routeVerdicts, n as memoryReflector, o as announceProblem, r as recordFailure, s as askYesNo, t as dueReflection, u as yesAt, x as referent } from "./reflection-6qfOC5OT.js";
4
- import { a as liveSettings, g as GATE_SITES, n as encodeOutput } from "./narration-_dA9oIt2.js";
5
- import { D as describeWhen, O as zoneOf, R as wrongLanguage, T as ClockError, c as record, d as toolEnabled, dt as translator, f as MAX_OOC_ANSWER, k as RESULTS, l as AUTHORING_NEEDS, n as installHooks, o as PREVIEW_TOOL, ot as ReflectionRefusedError, p as storesOf, r as externalGiven, s as createTools$1, u as characterRunner, ut as languageOf, v as readVerdicts, y as writeVerdicts } from "./hooks-BLperIIB.js";
6
- import { h as tokensOf, i as childTrace, m as estimateAnswer, n as childSampling, o as runChild, p as currentTurn, t as childModel } from "./child-D5SVNk4O.js";
7
- import { b as slug, t as addToLibrary, x as uniqueKey } from "./library-DsDc6fQa.js";
8
- import { _ as API_PREFIX } from "./packs-ZTG7fWut.js";
9
- import { i as updateImage, r as listGallery, t as describeGalleryImage } from "./gallery-C7VOJ3xH.js";
10
- import { n as interpretImage, s as presentedFor, t as runImagePresenter } from "./presenter-agent-BHSbyWwZ.js";
1
+ import { a as chatSessionId, o as roleplaySessionOf, t as promptFor } from "./access-DtOxFKBK.js";
2
+ import { E as INTENT_STATUSES, a as routeVerdicts, i as noAt, n as askYesNo, o as yesAt, t as announceProblem } from "./route-DRTJ_vcA.js";
3
+ import { _ as referent, a as whereabouts, g as sameWords, n as memoryReflector, r as recordFailure, s as Timelines, t as dueReflection } from "./reflection-CvOZGjmn.js";
4
+ import { a as liveSettings, g as GATE_SITES, n as encodeOutput } from "./narration-DvFBqmqe.js";
5
+ import { D as describeWhen, O as zoneOf, R as wrongLanguage, T as ClockError, c as record, d as toolEnabled, f as MAX_OOC_ANSWER, k as RESULTS, l as AUTHORING_NEEDS, n as installHooks, o as PREVIEW_TOOL, ot as ReflectionRefusedError, p as storesOf, r as externalGiven, s as createTools$1, u as characterRunner, v as readVerdicts, y as writeVerdicts } from "./hooks-HnqXO8mM.js";
6
+ import { i as translator, r as languageOf } from "./text-JbWfTHbr.js";
7
+ import { a as childTrace, c as runChild, h as currentTurn, n as childModel, r as childSampling, v as estimateAnswer, y as tokensOf } from "./child-CyCViUKa.js";
8
+ import { S as uniqueKey, b as slug, t as addToLibrary } from "./library-BGxPKs9a.js";
9
+ import { _ as API_PREFIX } from "./packs-jowC-MN_.js";
10
+ import { i as updateImage, r as listGallery, t as describeGalleryImage } from "./gallery-BxZGOgMb.js";
11
+ import { n as interpretImage, s as presentedFor, t as runImagePresenter } from "./presenter-agent-DvZtnf0Q.js";
11
12
  import { join } from "node:path";
12
13
  import { existsSync } from "node:fs";
13
14
  import { SessionId } from "@deepseek-ai/dsh-session";
@@ -3652,8 +3653,10 @@ function apply(ctx) {
3652
3653
  await engine.quiesce(chat);
3653
3654
  engine.forget(chat);
3654
3655
  };
3656
+ ctx.roleplayOrchestration.quiesce = (chat) => engine.quiesce(chat);
3655
3657
  return () => {
3656
3658
  ctx.roleplayOrchestration.halt = () => Promise.resolve();
3659
+ ctx.roleplayOrchestration.quiesce = () => Promise.resolve();
3657
3660
  };
3658
3661
  }, "roleplay: halt");
3659
3662
  ctx.effect(() => {
@@ -1,12 +1,14 @@
1
- import { $ as LOCATION_FILE_NAME, A as loadTriggers, At as parseLoreFile, B as loadItems, C as populateLocations, D as populateVariables, Dt as LORE_DIR, F as loadCalendar, G as extractStyleFrom, H as loadFactions, J as withPlayer, L as LOCATIONS_DIR, Mt as InvalidEditProblems, Ot as loadLore, R as loadLocations, U as CHARACTERS_DIR, V as FACTIONS_DIR, W as loadCharacters, X as loadVariables, _ as populateCharacters, at as CHARACTER_FILE_NAME, c as authoredWorldOf, dt as WORLD_FILE_NAME, et as parseLocationFile, ft as parseWorldFile, h as knowsCharacter, i as contextOf, it as parseFactionFile, jt as subfolders, k as TRIGGERS_FILE_NAME, kt as LORE_FILE_NAME, m as loadValidatedWorld, nt as parseItemFile, ot as parseCharacterFile, rt as FACTION_FILE_NAME, s as worldOf, st as IMPORT_FOLDER, tt as ITEM_FILE_NAME, x as populateItems, z as ITEMS_DIR } from "./authoring-tools-BGzzW6O5.js";
2
- import { v as writeWorldPrompt } from "./presets-DcPCnn8O.js";
3
- import { f as parseSwitchboard } from "./narration-_dA9oIt2.js";
4
- import { B as loadPlots, F as STORY_LANGUAGES, G as formatIssue, H as plotReferenceProblems, I as isStoryLanguage, J as PROMPTS_FOLDER, L as textLanguage, P as LANGUAGE_NAMES, V as parsePlotsFile, at as InvalidWorldError, tt as shippedLanguages, z as PLOTS_FILE_NAME } from "./hooks-BLperIIB.js";
5
- import { c as parseSampling } from "./child-D5SVNk4O.js";
6
- import { c as referenceImagePath, v as mapLimit } from "./library-DsDc6fQa.js";
7
- import { n as readPreset } from "./preset-CJLW8Mp0.js";
8
- import { _ as API_PREFIX, a as packIds, d as packPath, f as readPack, h as PACK_MEDIA_TYPES, l as isPackId } from "./packs-ZTG7fWut.js";
9
- import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-CO8usAjE.js";
1
+ import "./access-DtOxFKBK.js";
2
+ import { $ as ITEM_FILE_NAME, At as InvalidEditProblems, B as loadFactions, D as TRIGGERS_FILE_NAME, Dt as LORE_FILE_NAME, Et as loadLore, F as LOCATIONS_DIR, H as loadCharacters, I as loadLocations, J as loadVariables, K as withPlayer, L as ITEMS_DIR, N as loadCalendar, O as loadTriggers, Ot as parseLoreFile, Q as parseLocationFile, R as loadItems, T as populateVariables, Tt as LORE_DIR, U as extractStyleFrom, V as CHARACTERS_DIR, Z as LOCATION_FILE_NAME, at as IMPORT_FOLDER, et as parseItemFile, f as loadValidatedWorld, h as populateCharacters, i as contextOf, it as parseCharacterFile, kt as subfolders, lt as WORLD_FILE_NAME, nt as parseFactionFile, p as knowsCharacter, qt as authoredWorldOf, rt as CHARACTER_FILE_NAME, s as worldOf, tt as FACTION_FILE_NAME, ut as parseWorldFile, x as populateLocations, y as populateItems, z as FACTIONS_DIR } from "./authoring-tools-BKltdiea.js";
3
+ import { w as writeWorldPrompt } from "./route-DRTJ_vcA.js";
4
+ import { f as parseSwitchboard } from "./narration-DvFBqmqe.js";
5
+ import { B as loadPlots, F as STORY_LANGUAGES, G as formatIssue, H as plotReferenceProblems, I as isStoryLanguage, J as PROMPTS_FOLDER, L as textLanguage, P as LANGUAGE_NAMES, V as parsePlotsFile, at as InvalidWorldError, tt as shippedLanguages, z as PLOTS_FILE_NAME } from "./hooks-HnqXO8mM.js";
6
+ import { i as translator, r as languageOf } from "./text-JbWfTHbr.js";
7
+ import { u as parseSampling } from "./child-CyCViUKa.js";
8
+ import { c as referenceImagePath, v as mapLimit } from "./library-BGxPKs9a.js";
9
+ import { n as readPreset } from "./preset-CXbC0NeU.js";
10
+ import { _ as API_PREFIX, a as packIds, d as packPath, f as readPack, h as PACK_MEDIA_TYPES, l as isPackId } from "./packs-jowC-MN_.js";
11
+ import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-BFmSYvR8.js";
10
12
  import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
11
13
  import { existsSync, lstatSync, statSync } from "node:fs";
12
14
  import { randomUUID } from "node:crypto";
@@ -610,7 +612,7 @@ function translateTools(worlds, settings, prompting) {
610
612
  const world = await worldOf(worlds, exec);
611
613
  const told = prompting.languages().get(world.id);
612
614
  const text = (id, variables) => prompting.prompts().text(id, told, variables);
613
- const report = await translateWorld(contextOf(exec, settings(), text), worlds, world, args.language, told.startsWith("zh") ? "zh" : "en");
615
+ const report = await translateWorld(contextOf(exec, settings(), text, told), worlds, world, args.language, told.startsWith("zh") ? "zh" : "en");
614
616
  return JSON.parse(JSON.stringify(report));
615
617
  }
616
618
  })];
@@ -746,7 +748,12 @@ const PRESET_TOOL = "import_preset";
746
748
  const PRESET_FILE = "preset.json";
747
749
  const PRESET_PATH = `${IMPORT_FOLDER}/${PRESET_FILE}`;
748
750
  /** The command that has the authoring chat apply a preset that was uploaded to the world. */
749
- const presetMessage = () => `Apply the narration preset I uploaded to this world: call ${PRESET_TOOL} with file ${PRESET_PATH}.`;
751
+ function presetMessage(language) {
752
+ return translator(languageOf(language))("Apply the narration preset I uploaded to this world: call {tool} with file {file}.", {
753
+ tool: PRESET_TOOL,
754
+ file: PRESET_PATH
755
+ });
756
+ }
750
757
  /** The tool that turns an uploaded narration preset into the world's prose prompts; every call asks the person first. */
751
758
  function presetTools(worlds, settings, prompting) {
752
759
  return [defineTool({
@@ -774,7 +781,7 @@ function presetTools(worlds, settings, prompting) {
774
781
  }), "preset");
775
782
  const language = prompting.languages().get(world.id);
776
783
  const text = (id, variables) => prompting.prompts().text(id, language, variables);
777
- const made = await extractStyleFrom(contextOf(exec, settings(), text), preset.name, preset.pieces);
784
+ const made = await extractStyleFrom(contextOf(exec, settings(), text, language), preset.name, preset.pieces);
778
785
  for (const { id, text: body } of made.prompts) for (const tag of shippedLanguages()) await writeWorldPrompt(world.directory, tag, id, withPlayer(body));
779
786
  const carriesSampling = Object.keys(preset.sampling).length > 0;
780
787
  if (carriesSampling) {
@@ -2134,4 +2141,4 @@ function registerPackJail(ctx, deps) {
2134
2141
  //#endregion
2135
2142
  export { worldEntityImageFile as A, readWorldInfo as B, readWorldEditor as C, uploadWorldCharacterPortrait as D, replaceFile$1 as E, loadWorldParts as F, translateTools as H, PRESET_FILE as I, presetMessage as L, deleteTriggerDocument as M, readTriggerDocuments as N, uploadWorldEntityImage as O, writeTriggerDocument as P, presetTools as R, generateWorldEntityImage as S, removeWorldTrigger as T, languageOfDocuments as U, translateMessage as V, readWorldDocuments as W, editWorldPlots as _, deleteWorldPackFile as a, entityFolder as b, createAuthoredEntity as c, replaceAuthoredEntity as d, 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, registerPackJail as r, AUTHORED_ENTITY_KINDS as s, MAX_PACK_TEXT as t, readAuthoredEntityDocument as u, editWorldRelation as v, readWorldTrigger as w, generateWorldCharacterPortrait as x, editWorldThing as y, editWorldInfo as z };
2136
2143
 
2137
- //# sourceMappingURL=pack-jail-BKFmbYP8.js.map
2144
+ //# sourceMappingURL=pack-jail-DLGguGS3.js.map
@@ -1,4 +1,4 @@
1
- import { W as Reader } from "./hooks-BLperIIB.js";
1
+ import { W as Reader } from "./hooks-HnqXO8mM.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";
@@ -840,4 +840,4 @@ function anyTab(bases) {
840
840
  //#endregion
841
841
  export { API_PREFIX as _, packIds as a, describePack as c, packPath as d, readPack as f, SURFACE_NAMES as g, PACK_MEDIA_TYPES as h, inheritPacks as i, isPackId as l, PACK_LIMITS as m, anyTab as n, syncWorldPacks as o, PACK_ACTIONS as p, copyWorldPacks as r, worldPackStates as s, activePack as t, packFile as u };
842
842
 
843
- //# sourceMappingURL=packs-ZTG7fWut.js.map
843
+ //# sourceMappingURL=packs-jowC-MN_.js.map
@@ -1,8 +1,8 @@
1
- import { t as promptFor } from "./access-EbNdZFbk.js";
2
- import { o as runChild } from "./child-D5SVNk4O.js";
3
- import { c as referenceImagePath, o as nextSceneSerial } from "./library-DsDc6fQa.js";
4
- import { n as generateTransientImage, t as generateReferenceImage } from "./generator-CO8usAjE.js";
5
- import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-C7VOJ3xH.js";
1
+ import { t as promptFor } from "./access-DtOxFKBK.js";
2
+ import { c as runChild } from "./child-CyCViUKa.js";
3
+ import { c as referenceImagePath, o as nextSceneSerial } from "./library-BGxPKs9a.js";
4
+ import { n as generateTransientImage, t as generateReferenceImage } from "./generator-BFmSYvR8.js";
5
+ import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-BxZGOgMb.js";
6
6
  import { dirname, join, relative } from "node:path";
7
7
  import { existsSync } from "node:fs";
8
8
  import { createHash, randomUUID } from "node:crypto";
@@ -852,4 +852,4 @@ async function runImagePresenter(job) {
852
852
  //#endregion
853
853
  export { tokensOf as a, searchImages as i, interpretImage as n, present as o, imageTools as r, presentedFor as s, runImagePresenter as t };
854
854
 
855
- //# sourceMappingURL=presenter-agent-BHSbyWwZ.js.map
855
+ //# sourceMappingURL=presenter-agent-DvZtnf0Q.js.map
@@ -1,5 +1,5 @@
1
- import { Bt as ImportCardError, K as cleanText, r as MAX_PREVIEW_TEXT } from "./authoring-tools-BGzzW6O5.js";
2
- import { s as SAMPLING_RANGES } from "./child-D5SVNk4O.js";
1
+ import { Rt as ImportCardError, W as cleanText, r as MAX_PREVIEW_TEXT } from "./authoring-tools-BKltdiea.js";
2
+ import { l as SAMPLING_RANGES } from "./child-CyCViUKa.js";
3
3
  //#region src/host/import/preset.ts
4
4
  /** The older preset layout keeps its texts under fixed keys. */
5
5
  const LEGACY_KEYS = [
@@ -239,4 +239,4 @@ function selectPrompts(file, enabled, keepSampling) {
239
239
  //#endregion
240
240
  export { readPreset as n, selectPrompts as r, previewPreset as t };
241
241
 
242
- //# sourceMappingURL=preset-CJLW8Mp0.js.map
242
+ //# sourceMappingURL=preset-CXbC0NeU.js.map
@@ -1,7 +1,9 @@
1
- import { G as extractStyleFrom, J as withPlayer, i as contextOf, st as IMPORT_FOLDER } from "./authoring-tools-BGzzW6O5.js";
2
- import { _ as readWorldPrompt, c as presetDirectory, g as listWorldPrompts, h as deleteWorldPrompt, l as readPreset, m as PROSE_PROMPTS, p as updatePresetInfo, t as PRESET_FILE, v as writeWorldPrompt } from "./presets-DcPCnn8O.js";
3
- import { Q as languageOf, nt as shippedPromptsDirectory, tt as shippedLanguages } from "./hooks-BLperIIB.js";
4
- import { n as readPreset$1 } from "./preset-CJLW8Mp0.js";
1
+ import "./access-DtOxFKBK.js";
2
+ import { K as withPlayer, U as extractStyleFrom, at as IMPORT_FOLDER, i as contextOf } from "./authoring-tools-BKltdiea.js";
3
+ import { C as readWorldPrompt, S as listWorldPrompts, b as PROSE_PROMPTS, h as readPreset, m as presetDirectory, s as PRESET_FILE, w as writeWorldPrompt, x as deleteWorldPrompt, y as updatePresetInfo } from "./route-DRTJ_vcA.js";
4
+ import { Q as languageOf, nt as shippedPromptsDirectory, tt as shippedLanguages } from "./hooks-HnqXO8mM.js";
5
+ import { i as translator, r as languageOf$1 } from "./text-JbWfTHbr.js";
6
+ import { n as readPreset$1 } from "./preset-CXbC0NeU.js";
5
7
  import { join } from "node:path";
6
8
  import { existsSync } from "node:fs";
7
9
  import { defineTool } from "@deepseek-ai/dsh-tools";
@@ -34,7 +36,12 @@ const PRESET_MUTATION_TOOLS = [
34
36
  const NARRATION_IMPORT_TOOL = "import_narration_preset";
35
37
  const UPLOAD_PATH = `${IMPORT_FOLDER}/${PRESET_FILE}`;
36
38
  /** The command that has a preset's authoring chat turn an uploaded SillyTavern preset into prompts. */
37
- const narrationImportMessage = () => `Turn the SillyTavern preset I uploaded into this preset's prompts: call ${NARRATION_IMPORT_TOOL} with file ${UPLOAD_PATH}.`;
39
+ function narrationImportMessage(language) {
40
+ return translator(languageOf$1(language))("Turn the SillyTavern preset I uploaded into this preset's prompts: call {tool} with file {file}.", {
41
+ tool: NARRATION_IMPORT_TOOL,
42
+ file: UPLOAD_PATH
43
+ });
44
+ }
38
45
  const output = (value) => [{
39
46
  type: "text",
40
47
  text: JSON.stringify(value, null, 2)
@@ -211,7 +218,7 @@ function presetAuthorTools(reader, settings, prompting, shipped = shippedPrompts
211
218
  }), name);
212
219
  const language = prompting.languages().get(`preset:${name}`);
213
220
  const text = (id, variables) => prompting.prompts().text(id, language, variables);
214
- const made = await extractStyleFrom(contextOf(exec, settings(), text), uploaded.name, uploaded.pieces);
221
+ const made = await extractStyleFrom(contextOf(exec, settings(), text, language), uploaded.name, uploaded.pieces);
215
222
  for (const { id, text: body } of made.prompts) for (const tag of shippedLanguages(shipped)) await writeWorldPrompt(directory, tag, id, withPlayer(body), shipped);
216
223
  await rm(join(directory, IMPORT_FOLDER), {
217
224
  recursive: true,
@@ -273,4 +280,4 @@ async function presetApproval(exec, next, carries) {
273
280
  //#endregion
274
281
  export { presetChatSessionId as a, presetAuthorTools as i, narrationImportMessage as n, presetOfChat as o, presetApproval as r, PresetReader as t };
275
282
 
276
- //# sourceMappingURL=preset-author-tools-1RstgEZs.js.map
283
+ //# sourceMappingURL=preset-author-tools-C26kj6t5.js.map
@@ -1,7 +1,8 @@
1
- import { n as limitAuthoringAgents } from "./authoring-tools-BGzzW6O5.js";
2
- import { c as presetDirectory } from "./presets-DcPCnn8O.js";
3
- import "./hooks-BLperIIB.js";
4
- import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-1RstgEZs.js";
1
+ import { n as limitAuthoringAgents } from "./authoring-tools-BKltdiea.js";
2
+ import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-C26kj6t5.js";
3
+ import { m as presetDirectory } from "./route-DRTJ_vcA.js";
4
+ import "./hooks-HnqXO8mM.js";
5
+ import { t as guardAuthoringTurns } from "./turn-guard-BvCs1VxB.js";
5
6
  import { join } from "node:path";
6
7
  import { existsSync } from "node:fs";
7
8
  //#region src/preset-authoring.ts
@@ -29,6 +30,10 @@ function apply(ctx) {
29
30
  return preset !== void 0 && existsSync(join(presetDirectory(library(), preset), "prompts"));
30
31
  };
31
32
  limitAuthoringAgents(ctx, (chat) => presetOfChat(chat) === void 0 ? void 0 : "presetAuthoring");
33
+ guardAuthoringTurns(ctx, () => ctx.roleplayPrompts, (chat) => {
34
+ const preset = presetOfChat(chat);
35
+ return preset === void 0 ? void 0 : ctx.roleplayAuthoringLanguages.get(`preset:${preset}`);
36
+ }, () => ctx.roleplayImport.settings.reasoning);
32
37
  ctx.on("tools/pre-execute", (exec, next) => presetApproval(exec, next, carries));
33
38
  const languageOf = (context) => {
34
39
  const chat = context.agent?.session.id;