@dsh-agentic-roleplay/core 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/lib/access-DtOxFKBK.js +150 -0
  3. package/lib/{authoring-tools-BWjEr_lF.js → authoring-tools-q34iq3hW.js} +160 -74
  4. package/lib/authoring.js +494 -31
  5. package/lib/{child-D5SVNk4O.js → child-CyCViUKa.js} +48 -7
  6. package/lib/client.js +1094 -604
  7. package/lib/client.js.map +1 -1
  8. package/lib/compaction.js +3 -3
  9. package/lib/doctor.js +3 -3
  10. package/lib/{gallery-C7VOJ3xH.js → gallery-BxZGOgMb.js} +2 -2
  11. package/lib/{generator-CO8usAjE.js → generator-BFmSYvR8.js} +2 -2
  12. package/lib/helper.js +1 -1
  13. package/lib/{hooks-DufjUf1p.js → hooks-HnqXO8mM.js} +6 -245
  14. package/lib/images.js +4 -4
  15. package/lib/index.js +168 -104
  16. package/lib/{library-DsDc6fQa.js → library-BGxPKs9a.js} +6 -3
  17. package/lib/{lorebook-author-tools-v-PM8Kbs.js → lorebook-author-tools-D9RrMK5g.js} +31 -28
  18. package/lib/lorebook-authoring.js +8 -3
  19. package/lib/{narration-_dA9oIt2.js → narration-DvFBqmqe.js} +9 -132
  20. package/lib/orchestration.js +11 -10
  21. package/lib/{pack-jail--Ij90LeY.js → pack-jail-MPekqSuQ.js} +14 -12
  22. package/lib/{packs-DWKnL4YX.js → packs-jowC-MN_.js} +2 -2
  23. package/lib/{presenter-agent-BHSbyWwZ.js → presenter-agent-DvZtnf0Q.js} +6 -6
  24. package/lib/{preset-CDNyJhfU.js → preset-VatN-845.js} +3 -3
  25. package/lib/{preset-author-tools-D7Azdlaq.js → preset-author-tools-8kv1Glxe.js} +11 -10
  26. package/lib/preset-authoring.js +9 -4
  27. package/lib/{reflection-CRCWK2E1.js → reflection-CvOZGjmn.js} +9 -170
  28. package/lib/{presets-D11bxWX0.js → route-DRTJ_vcA.js} +165 -4
  29. package/lib/text-JbWfTHbr.js +295 -0
  30. package/lib/turn-guard-BvCs1VxB.js +53 -0
  31. package/package.json +2 -2
  32. package/prompts/en/import/cut-off.md +1 -0
  33. package/prompts/en/import/finish-failed.md +1 -1
  34. package/prompts/en/import/finish-ok.md +1 -1
  35. package/prompts/en/roleplay/decide-instruction.md +1 -0
  36. package/prompts/en/roleplay/decide-irrelevant.md +1 -0
  37. package/prompts/en/world/procedure.md +1 -1
  38. package/prompts/zh/import/cut-off.md +1 -0
  39. package/prompts/zh/import/finish-failed.md +1 -1
  40. package/prompts/zh/import/finish-ok.md +1 -1
  41. package/prompts/zh/roleplay/decide-instruction.md +1 -0
  42. package/prompts/zh/roleplay/decide-irrelevant.md +1 -0
  43. package/prompts/zh/world/procedure.md +1 -1
  44. package/lib/access-EbNdZFbk.js +0 -25
  45. package/lib/text-CT1re6XT.js +0 -18
@@ -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-D11bxWX0.js";
3
- import { S as referent, a as whereabouts, 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 sameWords } from "./reflection-CRCWK2E1.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-DufjUf1p.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-DWKnL4YX.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";
@@ -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-BWjEr_lF.js";
2
- import { v as writeWorldPrompt } from "./presets-D11bxWX0.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, dt as translator, tt as shippedLanguages, ut as languageOf, z as PLOTS_FILE_NAME } from "./hooks-DufjUf1p.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-CDNyJhfU.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-DWKnL4YX.js";
9
- import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-CO8usAjE.js";
1
+ import "./access-DtOxFKBK.js";
2
+ import { At as loadLore, B as loadFactions, D as TRIGGERS_FILE_NAME, F as LOCATIONS_DIR, H as loadCharacters, I as loadLocations, L as ITEMS_DIR, Mt as parseLoreFile, N as loadCalendar, Nt as subfolders, O as loadTriggers, Pt as InvalidEditProblems, R as loadItems, T as populateVariables, U as extractStyleFrom, V as CHARACTERS_DIR, Y as withPlayer, Z as loadVariables, Zt as authoredWorldOf, at as parseFactionFile, ct as IMPORT_FOLDER, et as LOCATION_FILE_NAME, f as loadValidatedWorld, h as populateCharacters, i as contextOf, it as FACTION_FILE_NAME, jt as LORE_FILE_NAME, kt as LORE_DIR, mt as parseWorldFile, nt as ITEM_FILE_NAME, ot as CHARACTER_FILE_NAME, p as knowsCharacter, pt as WORLD_FILE_NAME, rt as parseItemFile, s as worldOf, st as parseCharacterFile, tt as parseLocationFile, x as populateLocations, y as populateItems, z as FACTIONS_DIR } from "./authoring-tools-q34iq3hW.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-VatN-845.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
  })];
@@ -779,7 +781,7 @@ function presetTools(worlds, settings, prompting) {
779
781
  }), "preset");
780
782
  const language = prompting.languages().get(world.id);
781
783
  const text = (id, variables) => prompting.prompts().text(id, language, variables);
782
- 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);
783
785
  for (const { id, text: body } of made.prompts) for (const tag of shippedLanguages()) await writeWorldPrompt(world.directory, tag, id, withPlayer(body));
784
786
  const carriesSampling = Object.keys(preset.sampling).length > 0;
785
787
  if (carriesSampling) {
@@ -2139,4 +2141,4 @@ function registerPackJail(ctx, deps) {
2139
2141
  //#endregion
2140
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 };
2141
2143
 
2142
- //# sourceMappingURL=pack-jail--Ij90LeY.js.map
2144
+ //# sourceMappingURL=pack-jail-MPekqSuQ.js.map
@@ -1,4 +1,4 @@
1
- import { W as Reader } from "./hooks-DufjUf1p.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-DWKnL4YX.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-BWjEr_lF.js";
2
- import { s as SAMPLING_RANGES } from "./child-D5SVNk4O.js";
1
+ import { Ht as ImportCardError, K as cleanText, r as MAX_PREVIEW_TEXT } from "./authoring-tools-q34iq3hW.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-CDNyJhfU.js.map
242
+ //# sourceMappingURL=preset-VatN-845.js.map
@@ -1,8 +1,9 @@
1
- import { G as extractStyleFrom, J as withPlayer, i as contextOf, st as IMPORT_FOLDER } from "./authoring-tools-BWjEr_lF.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-D11bxWX0.js";
3
- import "./narration-_dA9oIt2.js";
4
- import { Q as languageOf$1, dt as translator, nt as shippedPromptsDirectory, tt as shippedLanguages, ut as languageOf } from "./hooks-DufjUf1p.js";
5
- import { n as readPreset$1 } from "./preset-CDNyJhfU.js";
1
+ import "./access-DtOxFKBK.js";
2
+ import { U as extractStyleFrom, Y as withPlayer, ct as IMPORT_FOLDER, i as contextOf } from "./authoring-tools-q34iq3hW.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-VatN-845.js";
6
7
  import { join } from "node:path";
7
8
  import { existsSync } from "node:fs";
8
9
  import { defineTool } from "@deepseek-ai/dsh-tools";
@@ -36,7 +37,7 @@ const NARRATION_IMPORT_TOOL = "import_narration_preset";
36
37
  const UPLOAD_PATH = `${IMPORT_FOLDER}/${PRESET_FILE}`;
37
38
  /** The command that has a preset's authoring chat turn an uploaded SillyTavern preset into prompts. */
38
39
  function narrationImportMessage(language) {
39
- return translator(languageOf(language))("Turn the SillyTavern preset I uploaded into this preset's prompts: call {tool} with file {file}.", {
40
+ return translator(languageOf$1(language))("Turn the SillyTavern preset I uploaded into this preset's prompts: call {tool} with file {file}.", {
40
41
  tool: NARRATION_IMPORT_TOOL,
41
42
  file: UPLOAD_PATH
42
43
  });
@@ -142,7 +143,7 @@ function presetAuthorTools(reader, settings, prompting, shipped = shippedPrompts
142
143
  return json({
143
144
  action: "written",
144
145
  id: args.id,
145
- language: languageOf$1(args.language)
146
+ language: languageOf(args.language)
146
147
  });
147
148
  }
148
149
  }),
@@ -160,7 +161,7 @@ function presetAuthorTools(reader, settings, prompting, shipped = shippedPrompts
160
161
  return json({
161
162
  action: "deleted",
162
163
  id: args.id,
163
- language: languageOf$1(args.language),
164
+ language: languageOf(args.language),
164
165
  trashPath
165
166
  });
166
167
  }
@@ -217,7 +218,7 @@ function presetAuthorTools(reader, settings, prompting, shipped = shippedPrompts
217
218
  }), name);
218
219
  const language = prompting.languages().get(`preset:${name}`);
219
220
  const text = (id, variables) => prompting.prompts().text(id, language, variables);
220
- 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);
221
222
  for (const { id, text: body } of made.prompts) for (const tag of shippedLanguages(shipped)) await writeWorldPrompt(directory, tag, id, withPlayer(body), shipped);
222
223
  await rm(join(directory, IMPORT_FOLDER), {
223
224
  recursive: true,
@@ -279,4 +280,4 @@ async function presetApproval(exec, next, carries) {
279
280
  //#endregion
280
281
  export { presetChatSessionId as a, presetAuthorTools as i, narrationImportMessage as n, presetOfChat as o, presetApproval as r, PresetReader as t };
281
282
 
282
- //# sourceMappingURL=preset-author-tools-D7Azdlaq.js.map
283
+ //# sourceMappingURL=preset-author-tools-8kv1Glxe.js.map
@@ -1,7 +1,8 @@
1
- import { n as limitAuthoringAgents } from "./authoring-tools-BWjEr_lF.js";
2
- import { c as presetDirectory } from "./presets-D11bxWX0.js";
3
- import "./hooks-DufjUf1p.js";
4
- import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-D7Azdlaq.js";
1
+ import { n as limitAuthoringAgents } from "./authoring-tools-q34iq3hW.js";
2
+ import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-8kv1Glxe.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;
@@ -1,11 +1,10 @@
1
- import { r as roleplaySessionOf, t as promptFor } from "./access-EbNdZFbk.js";
2
- import { f as sha, o as listPresets, s as loadPreset } from "./presets-D11bxWX0.js";
3
- import "./narration-_dA9oIt2.js";
4
- import { A as answerLimits, D as describeWhen, E as describeTime, J as PROMPTS_FOLDER, R as wrongLanguage, Z as inheritPrompts, dt as translator, ut as languageOf } from "./hooks-DufjUf1p.js";
5
- import { t as trimCharacters } from "./text-CT1re6XT.js";
6
- import { i as childTrace, m as estimateAnswer, n as childSampling, o as runChild, t as childModel } from "./child-D5SVNk4O.js";
7
- import { a as inheritImages } from "./library-DsDc6fQa.js";
8
- import { i as inheritPacks } from "./packs-DWKnL4YX.js";
1
+ import { o as roleplaySessionOf, t as promptFor } from "./access-DtOxFKBK.js";
2
+ import { a as routeVerdicts, f as listPresets, i as noAt, n as askYesNo, o as yesAt, p as loadPreset, r as mergeReports, t as announceProblem, v as sha } from "./route-DRTJ_vcA.js";
3
+ import { A as answerLimits, D as describeWhen, E as describeTime, J as PROMPTS_FOLDER, R as wrongLanguage, Z as inheritPrompts } from "./hooks-HnqXO8mM.js";
4
+ import { i as translator, r as languageOf, t as trimCharacters } from "./text-JbWfTHbr.js";
5
+ import { a as childTrace, c as runChild, n as childModel, r as childSampling, v as estimateAnswer } from "./child-CyCViUKa.js";
6
+ import { a as inheritImages } from "./library-BGxPKs9a.js";
7
+ import { i as inheritPacks } from "./packs-jowC-MN_.js";
9
8
  import { dirname, join } from "node:path";
10
9
  import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
11
10
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
@@ -1129,166 +1128,6 @@ var Timelines = class {
1129
1128
  }
1130
1129
  };
1131
1130
  //#endregion
1132
- //#region src/host/decisions/route.ts
1133
- /** The probability from which a yes is taken as a yes, for the confidence a chat asks. */
1134
- const yesAt = (confidence) => (1 + confidence) / 2;
1135
- /** The probability up to which a no is taken as a no. */
1136
- const noAt = (confidence) => (1 - confidence) / 2;
1137
- const clip = (text) => text.length > 120 ? `${text.slice(0, 119)}…` : text;
1138
- const reportOf = (mode, items) => ({
1139
- mode,
1140
- items,
1141
- decided: 0,
1142
- escalated: 0,
1143
- fallbacks: 0,
1144
- agreed: 0,
1145
- disagreed: 0,
1146
- decisionMs: 0,
1147
- llmMs: 0,
1148
- samples: []
1149
- });
1150
- async function timed(run) {
1151
- const started = performance.now();
1152
- return {
1153
- value: await run(),
1154
- ms: Math.round(performance.now() - started)
1155
- };
1156
- }
1157
- /**
1158
- * Gives each key a verdict the way its site is set to: from the language model, from the decision model, from the decision model where it
1159
- * is confident and the language model elsewhere, or from the language model while comparing it with the decision model. A decision model
1160
- * that cannot be used never stops a story: its keys go to the language model and the report says why.
1161
- */
1162
- async function routeVerdicts(route, signal) {
1163
- const { mode, keys } = route;
1164
- const report = reportOf(mode, keys.length);
1165
- const verdicts = /* @__PURE__ */ new Map();
1166
- if (keys.length === 0) return {
1167
- verdicts,
1168
- report
1169
- };
1170
- const viaLlm = async (subset) => {
1171
- const { value, ms } = await timed(() => route.llm(subset));
1172
- report.llmMs += ms;
1173
- for (const [key, verdict] of value) verdicts.set(key, verdict);
1174
- };
1175
- const viaDecision = async () => {
1176
- try {
1177
- const { value, ms } = await timed(() => route.probabilities(keys));
1178
- report.decisionMs += ms;
1179
- return value;
1180
- } catch (error) {
1181
- if (signal.aborted) throw error;
1182
- report.problem = error instanceof Error ? error.message : String(error);
1183
- return;
1184
- }
1185
- };
1186
- if (mode === "llm") {
1187
- await viaLlm(keys);
1188
- return {
1189
- verdicts,
1190
- report
1191
- };
1192
- }
1193
- if (mode === "shadow") {
1194
- const [decided] = await Promise.all([viaDecision(), viaLlm(keys)]);
1195
- if (decided === void 0) return {
1196
- verdicts,
1197
- report
1198
- };
1199
- for (const key of keys) {
1200
- const probability = decided.get(key);
1201
- const llm = verdicts.get(key);
1202
- if (probability === void 0 || llm === void 0) continue;
1203
- const decision = probability >= route.yesAt;
1204
- if (decision === llm) report.agreed += 1;
1205
- else {
1206
- report.disagreed += 1;
1207
- if (report.samples.length < 20) report.samples.push({
1208
- turn: route.turn,
1209
- what: clip(route.what(key)),
1210
- probability: Math.round(probability * 1e3) / 1e3,
1211
- decision,
1212
- llm
1213
- });
1214
- }
1215
- }
1216
- return {
1217
- verdicts,
1218
- report
1219
- };
1220
- }
1221
- const decided = await viaDecision();
1222
- if (decided === void 0) {
1223
- report.fallbacks = keys.length;
1224
- await viaLlm(keys);
1225
- return {
1226
- verdicts,
1227
- report
1228
- };
1229
- }
1230
- const unsure = [];
1231
- for (const key of keys) {
1232
- const probability = decided.get(key);
1233
- if (probability === void 0) {
1234
- unsure.push(key);
1235
- continue;
1236
- }
1237
- if (mode === "hybrid" && probability > route.noAt && probability < route.yesAt) unsure.push(key);
1238
- else verdicts.set(key, probability >= route.yesAt);
1239
- }
1240
- report.decided = keys.length - unsure.length;
1241
- report.escalated = unsure.length;
1242
- if (unsure.length > 0) await viaLlm(unsure);
1243
- return {
1244
- verdicts,
1245
- report
1246
- };
1247
- }
1248
- /** Asks the decision model one yes-or-no question for each key about one state, in a single request; the answers are probabilities of yes. */
1249
- async function askYesNo(service, state, asks, signal) {
1250
- const questions = Object.fromEntries(asks.map(({ key, instructions }) => [key, {
1251
- type: "noul",
1252
- instructions
1253
- }]));
1254
- const { answers } = await service.decide(state, questions, {
1255
- priority: "background",
1256
- signal
1257
- });
1258
- return new Map(asks.map(({ key }) => [key, answers[key].probability]));
1259
- }
1260
- /**
1261
- * Says once, through `say`, why a site's decision model could not be used, and again only when the reason changes, so that a story
1262
- * played on without the service does not fill the log.
1263
- */
1264
- function announceProblem(seen, key, report, say) {
1265
- if (report.problem === void 0) {
1266
- seen.delete(key);
1267
- return;
1268
- }
1269
- if (seen.get(key) === report.problem) return;
1270
- seen.set(key, report.problem);
1271
- say?.(`the decision model could not be used for ${key}, the language model judged instead: ${report.problem}`);
1272
- }
1273
- /** The reports of several routed runs of one site as one: counts and times added, the disagreements kept up to the limit, the latest problem. */
1274
- function mergeReports(mode, reports) {
1275
- const merged = reportOf(mode, 0);
1276
- for (const report of reports) {
1277
- merged.items += report.items;
1278
- merged.decided += report.decided;
1279
- merged.escalated += report.escalated;
1280
- merged.fallbacks += report.fallbacks;
1281
- merged.agreed += report.agreed;
1282
- merged.disagreed += report.disagreed;
1283
- merged.decisionMs += report.decisionMs;
1284
- merged.llmMs += report.llmMs;
1285
- merged.samples.push(...report.samples);
1286
- if (report.problem !== void 0) merged.problem = report.problem;
1287
- }
1288
- merged.samples = merged.samples.slice(-20);
1289
- return merged;
1290
- }
1291
- //#endregion
1292
1131
  //#region src/host/orchestration/whereabouts.ts
1293
1132
  const within = (inner, outer, places) => {
1294
1133
  const byId = new Map(places.map((place) => [place.id, place]));
@@ -2198,6 +2037,6 @@ function memoryReflector(deps) {
2198
2037
  } };
2199
2038
  }
2200
2039
  //#endregion
2201
- export { referent as S, readTimeline as _, whereabouts as a, defaultBoundaries as b, noAt as c, TimelineError as d, Timelines as f, switchPreset as g, recordPreset as h, reflectionStatus as i, routeVerdicts as l, presetStatus as m, memoryReflector as n, announceProblem as o, copyPreset as p, recordFailure as r, askYesNo as s, dueReflection as t, yesAt as u, writeTimeline as v, sameWords as x, pathTo as y };
2040
+ export { referent as _, whereabouts as a, copyPreset as c, switchPreset as d, readTimeline as f, sameWords as g, defaultBoundaries as h, reflectionStatus as i, presetStatus as l, pathTo as m, memoryReflector as n, TimelineError as o, writeTimeline as p, recordFailure as r, Timelines as s, dueReflection as t, recordPreset as u };
2202
2041
 
2203
- //# sourceMappingURL=reflection-CRCWK2E1.js.map
2042
+ //# sourceMappingURL=reflection-CvOZGjmn.js.map