@dsh-agentic-roleplay/core 0.10.0 → 0.10.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.
- package/README.md +1 -1
- package/icon.svg +13 -0
- package/lib/{authoring-tools-B4mEdKp_.js → authoring-tools-C9cmcUbD.js} +1820 -1243
- package/lib/authoring.js +18 -7
- package/lib/{child-Dtv76jNx.js → child-C9nPIy9j.js} +40 -5
- package/lib/client.js +4668 -2249
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +2 -2
- package/lib/doctor.js +3 -3
- package/lib/{gallery-BZJleAeH.js → gallery-CtG-bDzz.js} +2 -2
- package/lib/{generator-Cg6CQc5S.js → generator-nLoPM5MF.js} +2 -2
- package/lib/helper.js +8 -1
- package/lib/{hooks-DTjHWTfx.js → hooks-BpLN_hhT.js} +282 -211
- package/lib/images.js +4 -4
- package/lib/index.js +1399 -146
- package/lib/{library-GIlrkOim.js → library-CH-ahlm0.js} +2 -2
- package/lib/{lorebook-author-tools-BCFFJSle.js → lorebook-author-tools-Cg7QQemi.js} +6 -6
- package/lib/lorebook-authoring.js +4 -4
- package/lib/{narration-BVzew4-K.js → narration-B0hConSw.js} +5 -2
- package/lib/orchestration.js +108 -21
- package/lib/{pack-jail-hsNQNTOf.js → pack-jail-D5j5mIq6.js} +16 -12
- package/lib/{packs-UpK_cvI4.js → packs-Cc05FrId.js} +2 -2
- package/lib/{presenter-agent-DZOgBOR9.js → presenter-agent-UKbKYXMO.js} +6 -6
- package/lib/{preset-Cyoj1ZWa.js → preset-Be4lz6vB.js} +4 -4
- package/lib/{preset-author-tools-RSta6pHK.js → preset-author-tools-C3s0iSfv.js} +6 -6
- package/lib/preset-authoring.js +5 -5
- package/lib/{presets-CvpsW_10.js → presets-Cl9sU3Qs.js} +152 -14
- package/lib/{reflection-0qTvw2It.js → reflection-I9z-PvFK.js} +135 -93
- package/lib/{text-CbGQhK1-.js → text-CzqhC8sT.js} +11 -1
- package/lib/{turn-guard-BzNeGNnc.js → turn-guard-B9pGCeir.js} +3 -3
- package/package.json +4 -2
- package/prompts/en/checks/decide-opening.md +7 -1
- package/prompts/en/checks/decide-stated.md +1 -0
- package/prompts/en/roleplay/record-keeper.md +2 -1
- package/prompts/zh/checks/decide-opening.md +7 -1
- package/prompts/zh/checks/decide-stated.md +1 -0
- package/prompts/zh/roleplay/record-keeper.md +2 -1
|
@@ -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-
|
|
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-
|
|
377
|
+
//# sourceMappingURL=library-CH-ahlm0.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./access-CXtaZNbx.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { C as slug, T as uniqueKey, w as trOf, x as mapLimit } from "./library-
|
|
5
|
-
import { i as translator, r as languageOf } from "./text-
|
|
6
|
-
import {
|
|
2
|
+
import { _t as writeLorebookEntry, ct as deleteLorebookEntry, ft as loadLorebook, gt as updateLorebookInfo, i as contextOf, lt as entriesOf, mt as readLorebook$1, pt as lorebookDirectory, r as MAX_PREVIEW_TEXT, tn as ImportCardError } from "./authoring-tools-C9cmcUbD.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-Cl9sU3Qs.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 { nt as shippedPromptsDirectory } from "./hooks-BpLN_hhT.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-
|
|
699
|
+
//# sourceMappingURL=lorebook-author-tools-Cg7QQemi.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as guardAuthoringTurns } from "./turn-guard-
|
|
3
|
-
import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-
|
|
4
|
-
import "./hooks-
|
|
1
|
+
import { n as limitAuthoringAgents, pt as lorebookDirectory } from "./authoring-tools-C9cmcUbD.js";
|
|
2
|
+
import { t as guardAuthoringTurns } from "./turn-guard-B9pGCeir.js";
|
|
3
|
+
import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-Cg7QQemi.js";
|
|
4
|
+
import "./hooks-BpLN_hhT.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: {
|
|
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-
|
|
457
|
+
//# sourceMappingURL=narration-B0hConSw.js.map
|
package/lib/orchestration.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { c as chatSessionId, l as roleplaySessionOf, t as promptFor } from "./access-CXtaZNbx.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { B as
|
|
6
|
-
import { i as translator, r as languageOf } from "./text-
|
|
7
|
-
import { a as liveSettings, g as GATE_SITES, n as encodeOutput } from "./narration-
|
|
8
|
-
import { C as slug, T as uniqueKey, t as addToLibrary } from "./library-
|
|
9
|
-
import { _ as API_PREFIX } from "./packs-
|
|
10
|
-
import { i as updateImage, r as listGallery, t as describeGalleryImage } from "./gallery-
|
|
11
|
-
import { n as interpretImage, s as presentedFor, t as runImagePresenter } from "./presenter-agent-
|
|
2
|
+
import { B as COMMANDS_KEY, H as commandsOf, P as wrongLanguage, T as RESULTS, V as commandFlagKey, c as record, dt as ClockError, f as MAX_OOC_ANSWER, ht as AUTHORING_NEEDS, l as characterRunner, mt as zoneOf, n as installHooks, o as PREVIEW_TOOL, p as storesOf, pt as describeWhen, r as externalGiven, rt as shippedText, s as createTools$1, st as ReflectionRefusedError, u as toolEnabled, v as readVerdicts, y as writeVerdicts } from "./hooks-BpLN_hhT.js";
|
|
3
|
+
import { E as tokensOf, S as currentTurn, T as estimateAnswer, a as childTrace, l as runChild, n as childModel, r as childSampling } from "./child-C9nPIy9j.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-I9z-PvFK.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-Cl9sU3Qs.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-Cc05FrId.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-UKbKYXMO.js";
|
|
12
12
|
import { join } from "node:path";
|
|
13
|
+
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";
|
|
13
14
|
import { existsSync } from "node:fs";
|
|
15
|
+
import { createHash } from "node:crypto";
|
|
14
16
|
import { readdir } from "node:fs/promises";
|
|
15
17
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
16
18
|
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
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";
|
|
@@ -80,9 +81,34 @@ function canonicalTags(known, tags) {
|
|
|
80
81
|
});
|
|
81
82
|
return [...new Set(canonical)];
|
|
82
83
|
}
|
|
84
|
+
const phrase = (label) => label.normalize("NFKC").trim().toLowerCase().replace(/\s+/g, " ");
|
|
85
|
+
/** How often each relationship label is used by the story (spellings that differ only in case or spacing count together, under the most used one), most used first: the vocabulary a new label is chosen from. */
|
|
86
|
+
function labelUsage(labels) {
|
|
87
|
+
const groups = /* @__PURE__ */ new Map();
|
|
88
|
+
for (const label of labels) {
|
|
89
|
+
const key = phrase(label);
|
|
90
|
+
if (key === "") continue;
|
|
91
|
+
const spellings = groups.get(key) ?? /* @__PURE__ */ new Map();
|
|
92
|
+
spellings.set(label.trim(), (spellings.get(label.trim()) ?? 0) + 1);
|
|
93
|
+
groups.set(key, spellings);
|
|
94
|
+
}
|
|
95
|
+
const counts = [...groups.values()].map((spellings) => [[...spellings].sort((a, b) => b[1] - a[1])[0][0], [...spellings.values()].reduce((sum, n) => sum + n, 0)]);
|
|
96
|
+
return new Map(counts.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A relationship label spelled differently from one in use (case, spacing, a plural, one letter off in a long word)
|
|
100
|
+
* becomes the existing spelling, so the story keeps one word for one kind of bond. A label that matches nothing stays: a new bond is allowed.
|
|
101
|
+
*/
|
|
102
|
+
function canonicalLabel(known, label) {
|
|
103
|
+
const wanted = phrase(label);
|
|
104
|
+
if (wanted === "") return label;
|
|
105
|
+
const vocabulary = [...known.keys()];
|
|
106
|
+
return vocabulary.find((existing) => phrase(existing) === wanted) ?? vocabulary.find((existing) => stem(existing) === stem(wanted)) ?? (/^[a-z]{5,}$/.test(wanted) ? vocabulary.find((existing) => /^[a-z]{5,}$/.test(phrase(existing)) && nearby(phrase(existing), wanted)) : void 0) ?? label;
|
|
107
|
+
}
|
|
83
108
|
// src/host/orchestration/committer.ts
|
|
84
109
|
/** How many of the tags in use a brief lists. */
|
|
85
110
|
const TAGS_LISTED = 60;
|
|
111
|
+
const LABELS_LISTED = 30;
|
|
86
112
|
/** What the keeper reads back by default: the parts of the records its edits write. */
|
|
87
113
|
const VERIFY_SECTIONS = [
|
|
88
114
|
"characters",
|
|
@@ -128,6 +154,7 @@ function describePrompt(job, memory) {
|
|
|
128
154
|
const own = job.store.story.records({ rounds }).events;
|
|
129
155
|
const known = new Map(job.store.cast().map((member) => [member.key, referent(member.character)]));
|
|
130
156
|
const tags = [...tagUsage(job.store.story.events.list())].slice(0, TAGS_LISTED);
|
|
157
|
+
const labels = [...labelUsage(job.store.story.relationships.list().map((bond) => bond.label))].slice(0, LABELS_LISTED);
|
|
131
158
|
const before = records.events.filter((event) => event.turn < first.turn || event.turn === first.turn && event.round < first.round).slice(-6);
|
|
132
159
|
return [
|
|
133
160
|
memory.flaky ? "Perception in this chat: characters do not perceive perfectly. Mark a perception partial only when the character could take in just part of it (overheard, glimpsed), and mistaken only when the material shows it taking in something false; in both cases put the character's own version in content. Otherwise it is accurate and content is left out." : "Perception in this chat: every character perceives exactly what happened. Leave accuracy and content out.",
|
|
@@ -149,6 +176,9 @@ function describePrompt(job, memory) {
|
|
|
149
176
|
"## Tags already in use (choose from these; a new tag only when none fits)",
|
|
150
177
|
...tags.length === 0 ? ["- none yet"] : [tags.map(([tag, count]) => `${tag} (${count})`).join(", ")],
|
|
151
178
|
"",
|
|
179
|
+
"## Relationship labels already in use (use the same word for the same kind of bond; a new label only when none fits)",
|
|
180
|
+
...labels.length === 0 ? ["- none yet"] : [labels.map(([label, count]) => `${label} (${count})`).join(", ")],
|
|
181
|
+
"",
|
|
152
182
|
"## Goals of the characters (ids for intent_edits)",
|
|
153
183
|
...records.characters.flatMap((entry) => entry.goals.map((goal) => `- id ${goal.id}, ${entry.character}: ${goal.name} (${goal.type}, ${goal.status}${goal.deadline === null ? "" : `, deadline ${goal.deadline}`})${goal.plan.length === 0 ? "" : ` plan: ${goal.plan.join("; ")}`}`)).concat(records.characters.every((entry) => entry.goals.length === 0) ? ["- none"] : []),
|
|
154
184
|
"",
|
|
@@ -224,7 +254,7 @@ function keeperTools(job, memory, progress) {
|
|
|
224
254
|
].join(" ")
|
|
225
255
|
});
|
|
226
256
|
if (wording !== void 0) throw new InvalidEditError([wording]);
|
|
227
|
-
const result = await tool.execute(withKnownTags(args, tagUsage(job.store.story.events.list())), exec);
|
|
257
|
+
const result = await tool.execute(withKnownLabels(withKnownTags(args, tagUsage(job.store.story.events.list())), labelUsage(job.store.story.relationships.list().map((bond) => bond.label))), exec);
|
|
228
258
|
progress.edits += 1;
|
|
229
259
|
progress.unchecked = true;
|
|
230
260
|
return result;
|
|
@@ -248,6 +278,18 @@ function keeperTools(job, memory, progress) {
|
|
|
248
278
|
return tool;
|
|
249
279
|
});
|
|
250
280
|
}
|
|
281
|
+
/** The edit with the labels of its relationships brought onto the labels already in use. */
|
|
282
|
+
function withKnownLabels(args, known) {
|
|
283
|
+
const edit = args;
|
|
284
|
+
if (edit.relationships === void 0) return args;
|
|
285
|
+
return {
|
|
286
|
+
...edit,
|
|
287
|
+
relationships: edit.relationships.map((entry) => typeof entry.label === "string" ? {
|
|
288
|
+
...entry,
|
|
289
|
+
label: canonicalLabel(known, entry.label)
|
|
290
|
+
} : entry)
|
|
291
|
+
};
|
|
292
|
+
}
|
|
251
293
|
/** The edit with the tags of its new and edited events brought onto the tags already in use. */
|
|
252
294
|
function withKnownTags(args, known) {
|
|
253
295
|
const edit = args;
|
|
@@ -364,6 +406,7 @@ function suggestionWriter(deps) {
|
|
|
364
406
|
reasoningEffort: job.store.settings().reasoning.children,
|
|
365
407
|
sampling: childSampling(job.store.settings(), "suggestions", estimateAnswer(Array.from({ length: job.count }, () => 200), job.store.settings().prompts.language)),
|
|
366
408
|
...childModel(job.store.settings(), "suggestions"),
|
|
409
|
+
turn: job.turn,
|
|
367
410
|
trace: childTrace(job.store, "suggestions", "suggestions"),
|
|
368
411
|
persona: promptFor(parent, "roleplay/suggester", job.store.settings().prompts.language, { max: 200 }),
|
|
369
412
|
prompt: promptOf(job),
|
|
@@ -453,6 +496,7 @@ function triggerJudge(deps) {
|
|
|
453
496
|
const answer = await runChild({
|
|
454
497
|
parent,
|
|
455
498
|
signal,
|
|
499
|
+
turn: job.turn,
|
|
456
500
|
reasoningEffort: settings.reasoning.children,
|
|
457
501
|
sampling: childSampling(settings, "records", estimateAnswer(subset.flatMap(() => [
|
|
458
502
|
REASON_CHARS$1,
|
|
@@ -897,6 +941,7 @@ function factionStrategist(deps) {
|
|
|
897
941
|
const strategy = await runChild({
|
|
898
942
|
parent,
|
|
899
943
|
signal,
|
|
944
|
+
turn: job.turn,
|
|
900
945
|
reasoningEffort: store.settings().reasoning.children,
|
|
901
946
|
sampling: childSampling(store.settings(), "authoring", estimateAnswer(DECISION_LIMITS, store.settings().prompts.language)),
|
|
902
947
|
...childModel(store.settings(), "authoring"),
|
|
@@ -1214,6 +1259,7 @@ function worldAuthor(deps) {
|
|
|
1214
1259
|
reasoningEffort: job.store.settings().reasoning.children,
|
|
1215
1260
|
sampling: childSampling(job.store.settings(), "authoring", editEstimate(authoring.perTurn, THING_TEXTS, THING_TEXT_CHARS, job.store.settings().prompts.language)),
|
|
1216
1261
|
...childModel(job.store.settings(), "authoring"),
|
|
1262
|
+
turn: job.turn,
|
|
1217
1263
|
trace: childTrace(job.store, "authoring", "world author"),
|
|
1218
1264
|
parent,
|
|
1219
1265
|
signal,
|
|
@@ -1264,6 +1310,7 @@ function worldAuthor(deps) {
|
|
|
1264
1310
|
reasoningEffort: job.store.settings().reasoning.children,
|
|
1265
1311
|
sampling: childSampling(job.store.settings(), "authoring", editEstimate(pending.length, FIT_TEXTS, FIT_TEXT_CHARS, job.store.settings().prompts.language)),
|
|
1266
1312
|
...childModel(job.store.settings(), "authoring"),
|
|
1313
|
+
turn: job.turn,
|
|
1267
1314
|
trace: childTrace(job.store, "authoring", "world consolidation"),
|
|
1268
1315
|
parent,
|
|
1269
1316
|
signal,
|
|
@@ -1316,6 +1363,39 @@ function describeChecks(checks, tr) {
|
|
|
1316
1363
|
});
|
|
1317
1364
|
return [tr("The checks of this story:"), ...lines].join("\n");
|
|
1318
1365
|
}
|
|
1366
|
+
// src/host/dice/replay.ts
|
|
1367
|
+
/**
|
|
1368
|
+
* 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
|
|
1369
|
+
* 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
|
|
1370
|
+
* that rolls other things in another order gets the same sequence. Stories that reroll use the system's randomness.
|
|
1371
|
+
*/
|
|
1372
|
+
var RollReplay = class {
|
|
1373
|
+
policy;
|
|
1374
|
+
turns = /* @__PURE__ */ new Map();
|
|
1375
|
+
constructor(policy) {
|
|
1376
|
+
this.policy = policy;
|
|
1377
|
+
}
|
|
1378
|
+
/** A turn begins after the turn `parent` (or the start): its dice are drawn from this place. */
|
|
1379
|
+
begin(chat, session, parent) {
|
|
1380
|
+
this.turns.set(chat, {
|
|
1381
|
+
seed: `${session}|${parent ?? "start"}`,
|
|
1382
|
+
drawn: 0
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
forget(chat) {
|
|
1386
|
+
this.turns.delete(chat);
|
|
1387
|
+
}
|
|
1388
|
+
/** The roller of a chat's turn. */
|
|
1389
|
+
roller(chat) {
|
|
1390
|
+
if (this.policy(chat) !== "keep") return systemRoller;
|
|
1391
|
+
return (sides) => {
|
|
1392
|
+
const turn = this.turns.get(chat);
|
|
1393
|
+
if (turn === void 0) return systemRoller(sides);
|
|
1394
|
+
turn.drawn += 1;
|
|
1395
|
+
return 1 + createHash("sha256").update(`${turn.seed}|${turn.drawn}`).digest().readUIntBE(0, 6) % sides;
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
};
|
|
1319
1399
|
// src/host/orchestration/check-tool.ts
|
|
1320
1400
|
const CHECK_NARRATE_TOOL = "roll_and_narrate";
|
|
1321
1401
|
const BRANCHES = [
|
|
@@ -1450,7 +1530,7 @@ function createCheckNarrateTool(deps) {
|
|
|
1450
1530
|
character: args.character,
|
|
1451
1531
|
...args.target === void 0 ? {} : { target: args.target },
|
|
1452
1532
|
...args.bonus === void 0 ? {} : { bonus: args.bonus }
|
|
1453
|
-
});
|
|
1533
|
+
}, deps.roller?.(owner.chat));
|
|
1454
1534
|
const branch = given[rolled.result];
|
|
1455
1535
|
if (branch === void 0) throw new Error(`the roll gave ${rolled.result}, for which no branch was written`);
|
|
1456
1536
|
const run = characterRunner({
|
|
@@ -1690,7 +1770,7 @@ var AfterTurnJobs = class {
|
|
|
1690
1770
|
this.deps.problem(`what the characters believe was not sorted: ${messageOf(error)}`);
|
|
1691
1771
|
}).finally(() => {
|
|
1692
1772
|
this.reflecting.delete(owner.chat);
|
|
1693
|
-
}));
|
|
1773
|
+
}), true);
|
|
1694
1774
|
}
|
|
1695
1775
|
/** Fit what was made up into the rest of the world, when enough of it is waiting or some has waited long. */
|
|
1696
1776
|
consolidate(owner, cancel) {
|
|
@@ -2596,6 +2676,7 @@ var TurnEngine = class {
|
|
|
2596
2676
|
objections = /* @__PURE__ */ new Map();
|
|
2597
2677
|
/** What runs in the background of each chat and writes to its story, other than the records: fitting in what was made up, and the characters away. */
|
|
2598
2678
|
working = /* @__PURE__ */ new Map();
|
|
2679
|
+
optionalJobs = /* @__PURE__ */ new WeakSet();
|
|
2599
2680
|
afterTurn;
|
|
2600
2681
|
/** What a reflection the player asked for is cancelled with, as `stop` does for the turn. */
|
|
2601
2682
|
reflectionCancels = /* @__PURE__ */ new Map();
|
|
@@ -2609,8 +2690,8 @@ var TurnEngine = class {
|
|
|
2609
2690
|
this.afterTurn = new AfterTurnJobs({
|
|
2610
2691
|
boundaries: () => this.boundaries(),
|
|
2611
2692
|
stores: (chat) => this.stores(chat),
|
|
2612
|
-
track: (chat, job) => {
|
|
2613
|
-
this.track(chat, job);
|
|
2693
|
+
track: (chat, job, optional) => {
|
|
2694
|
+
this.track(chat, job, optional);
|
|
2614
2695
|
},
|
|
2615
2696
|
problem: (message) => {
|
|
2616
2697
|
this.problem(message);
|
|
@@ -3204,10 +3285,12 @@ var TurnEngine = class {
|
|
|
3204
3285
|
});
|
|
3205
3286
|
return count <= MAX_OBJECTIONS;
|
|
3206
3287
|
}
|
|
3207
|
-
|
|
3288
|
+
/** `optional` work (reflection) is waited for by anything that moves or ends the story, but not by the next turn: it only adds beliefs, and a pass can take minutes. */
|
|
3289
|
+
track(chat, job, optional = false) {
|
|
3208
3290
|
const set = this.working.get(chat) ?? /* @__PURE__ */ new Set();
|
|
3209
3291
|
this.working.set(chat, set);
|
|
3210
3292
|
set.add(job);
|
|
3293
|
+
if (optional) this.optionalJobs.add(job);
|
|
3211
3294
|
job.finally(() => {
|
|
3212
3295
|
set.delete(job);
|
|
3213
3296
|
});
|
|
@@ -3218,10 +3301,11 @@ var TurnEngine = class {
|
|
|
3218
3301
|
this.reflectionCancels.get(chat)?.abort();
|
|
3219
3302
|
}
|
|
3220
3303
|
/** Resolves when nothing of the chat writes to its story any more: the records, what was made up being fitted in, the characters away, the suggestions. */
|
|
3221
|
-
async quiesce(chat) {
|
|
3304
|
+
async quiesce(chat, options = {}) {
|
|
3222
3305
|
for (;;) {
|
|
3223
|
-
const
|
|
3224
|
-
|
|
3306
|
+
const working = [...this.working.get(chat) ?? []].filter((job) => options.skipOptional !== true || !this.optionalJobs.has(job));
|
|
3307
|
+
const jobs = [...working, ...this.chains.has(chat) ? [this.chains.get(chat)] : []];
|
|
3308
|
+
if (jobs.length === 0 || (this.runs.get(chat) ?? 0) === 0 && working.length === 0) return;
|
|
3225
3309
|
await Promise.allSettled(jobs);
|
|
3226
3310
|
}
|
|
3227
3311
|
}
|
|
@@ -3806,11 +3890,13 @@ function apply(ctx) {
|
|
|
3806
3890
|
interpolate: false,
|
|
3807
3891
|
text: ""
|
|
3808
3892
|
});
|
|
3893
|
+
const rolls = new RollReplay((chat) => stores(chat)?.settings().rewind.rolls ?? "reroll");
|
|
3809
3894
|
const toolDeps = {
|
|
3810
3895
|
engine,
|
|
3811
3896
|
boundaries,
|
|
3812
3897
|
stores,
|
|
3813
3898
|
turnOf: currentTurn,
|
|
3899
|
+
roller: (chat) => rolls.roller(chat),
|
|
3814
3900
|
delivered: (chat, output) => {
|
|
3815
3901
|
const node = timelines.delivered(chat, output);
|
|
3816
3902
|
if (node !== void 0) images.afterDelivery(chat, node, output);
|
|
@@ -3896,8 +3982,9 @@ function apply(ctx) {
|
|
|
3896
3982
|
boundaries,
|
|
3897
3983
|
stores,
|
|
3898
3984
|
timelines,
|
|
3985
|
+
rolls,
|
|
3899
3986
|
previewTool,
|
|
3900
|
-
optionalTools: [...createDiceTools(diceLink), createCheckNarrateTool(toolDeps)]
|
|
3987
|
+
optionalTools: [...createDiceTools(diceLink, { rollerFor: (chat) => rolls.roller(chat) }), createCheckNarrateTool(toolDeps)]
|
|
3901
3988
|
});
|
|
3902
3989
|
}
|
|
3903
3990
|
export { apply, inject, name };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { c as chatSessionId, n as atomicWrite, r as atomicWriteJson } from "./access-CXtaZNbx.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as encodeOutput } from "./narration-
|
|
5
|
-
import {
|
|
6
|
-
import { i as translator, r as languageOf } from "./text-
|
|
7
|
-
import { h as readImageFileMetadata, u as referenceImagePath, x as mapLimit } from "./library-
|
|
8
|
-
import { n as readPreset } from "./preset-
|
|
9
|
-
import { _ as API_PREFIX, a as packIds, d as packPath, f as readPack, h as PACK_MEDIA_TYPES, l as isPackId } from "./packs-
|
|
10
|
-
import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-
|
|
2
|
+
import { $t as subfolders, A as editsSince, B as addressesToFetch, Bt as loadLocations, C as worldFieldChanges, E as loadWorldParts, Ft as TRIGGERS_FILE_NAME, H as fetchPictures, Ht as loadItems, It as loadTriggers, J as UPDATE_FOLDER, K as cardCharacter, Lt as LORE_DIR, Qt as loadCharacters, Rt as loadLore, Ut as FACTIONS_DIR, V as candidateUrls, Vt as ITEMS_DIR, W as mergeReports, Wt as loadFactions, X as cardPieces, Y as baseId, Yt as loadCalendar, Zt as CHARACTERS_DIR, bt as withScratchStory, c as importPhase, i as contextOf, j as writeSnapshot, k as recordProvenance, ln as authoredWorldOf, q as writePortrait, s as worldOf, un as authoringChatSessionId, w as editWorldInfo, x as matchPieces, xt as knowsCharacter, yt as loadValidatedWorld, z as addressKey, zt as LOCATIONS_DIR } from "./authoring-tools-C9cmcUbD.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-Cl9sU3Qs.js";
|
|
4
|
+
import { n as encodeOutput } from "./narration-B0hConSw.js";
|
|
5
|
+
import { A as LANGUAGE_NAMES, G as formatIssue, I as PLOTS_FILE_NAME, J as PROMPTS_FOLDER, L as loadPlots, M as isStoryLanguage, N as textLanguage, R as parsePlotsFile, W as Reader, it as AgentUnavailableError, j as STORY_LANGUAGES, ot as InvalidWorldError, tt as shippedLanguages, ut as WorldNotFoundError, z as plotReferenceProblems } from "./hooks-BpLN_hhT.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-Be4lz6vB.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-Cc05FrId.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
|
+
import { readTriggerDefinition, triggerReferenceProblems } from "@dsh-agentic-roleplay/state";
|
|
12
13
|
import { existsSync, lstatSync, statSync } from "node:fs";
|
|
13
14
|
import { randomUUID } from "node:crypto";
|
|
14
15
|
import { cp, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
@@ -16,7 +17,6 @@ import { Session, SessionId } from "@deepseek-ai/dsh-session";
|
|
|
16
17
|
import { ToolCallId, createMessage, createSystemMessage, createToolResultMessage } from "@deepseek-ai/dsh-llm";
|
|
17
18
|
import { setApprovalPolicy } from "@deepseek-ai/dsh-user-approval";
|
|
18
19
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
19
|
-
import { readTriggerDefinition, triggerReferenceProblems } from "@dsh-agentic-roleplay/state";
|
|
20
20
|
// src/host/agent/opening.ts
|
|
21
21
|
/** What the opening is reported to come from, where a chat shows the source of a message. */
|
|
22
22
|
const OPENING_SOURCE = {
|
|
@@ -836,7 +836,11 @@ const FIELDS$1 = {
|
|
|
836
836
|
"opening_message",
|
|
837
837
|
"opening_message[].text",
|
|
838
838
|
"alternate_openings[].title",
|
|
839
|
-
"alternate_openings[].text"
|
|
839
|
+
"alternate_openings[].text",
|
|
840
|
+
"start_questions[].text",
|
|
841
|
+
"start_questions[].options[].label",
|
|
842
|
+
"start_questions[].options[].description",
|
|
843
|
+
"start_questions[].options[].effect.rules[]"
|
|
840
844
|
]
|
|
841
845
|
},
|
|
842
846
|
calendar: {
|
|
@@ -2649,4 +2653,4 @@ function registerPackJail(ctx, deps) {
|
|
|
2649
2653
|
}
|
|
2650
2654
|
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
2655
|
|
|
2652
|
-
//# sourceMappingURL=pack-jail-
|
|
2656
|
+
//# sourceMappingURL=pack-jail-D5j5mIq6.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { W as Reader } from "./hooks-BpLN_hhT.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-
|
|
839
|
+
//# sourceMappingURL=packs-Cc05FrId.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { n as atomicWrite, t as promptFor } from "./access-CXtaZNbx.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as generateTransientImage, t as generateReferenceImage } from "./generator-
|
|
4
|
-
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-
|
|
5
|
-
import { c as nextSceneSerial, u as referenceImagePath } from "./library-
|
|
2
|
+
import { l as runChild } from "./child-C9nPIy9j.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
|
+
import { characterKey, itemKey, locationKey } from "@dsh-agentic-roleplay/state";
|
|
7
8
|
import { existsSync } from "node:fs";
|
|
8
9
|
import { createHash } from "node:crypto";
|
|
9
10
|
import { readFile } from "node:fs/promises";
|
|
10
11
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
11
|
-
import { characterKey, itemKey, locationKey } from "@dsh-agentic-roleplay/state";
|
|
12
12
|
// src/host/images/presented.ts
|
|
13
13
|
const PRESENTED_FOLDER = "presented";
|
|
14
14
|
const fileOf = (folder, node) => join(folder, "images", PRESENTED_FOLDER, `${node}.json`);
|
|
@@ -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-
|
|
844
|
+
//# sourceMappingURL=presenter-agent-UKbKYXMO.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { r as MAX_PREVIEW_TEXT, tn as ImportCardError } from "./authoring-tools-C9cmcUbD.js";
|
|
2
|
+
import { u as SAMPLING_RANGES } from "./child-C9nPIy9j.js";
|
|
3
|
+
import { Y as cleanText } from "./presets-Cl9sU3Qs.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-
|
|
242
|
+
//# sourceMappingURL=preset-Be4lz6vB.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./access-CXtaZNbx.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as readPreset$1 } from "./preset-
|
|
4
|
-
import { i as contextOf } from "./authoring-tools-
|
|
5
|
-
import { i as translator, r as languageOf } from "./text-
|
|
6
|
-
import {
|
|
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-Cl9sU3Qs.js";
|
|
3
|
+
import { n as readPreset$1 } from "./preset-Be4lz6vB.js";
|
|
4
|
+
import { i as contextOf } from "./authoring-tools-C9cmcUbD.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-CzqhC8sT.js";
|
|
6
|
+
import { Q as languageOf$1, nt as shippedPromptsDirectory, tt as shippedLanguages } from "./hooks-BpLN_hhT.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-
|
|
281
|
+
//# sourceMappingURL=preset-author-tools-C3s0iSfv.js.map
|
package/lib/preset-authoring.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as limitAuthoringAgents } from "./authoring-tools-
|
|
2
|
-
import { t as guardAuthoringTurns } from "./turn-guard-
|
|
3
|
-
import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-
|
|
4
|
-
import "./hooks-
|
|
5
|
-
import { c as presetDirectory } from "./presets-
|
|
1
|
+
import { n as limitAuthoringAgents } from "./authoring-tools-C9cmcUbD.js";
|
|
2
|
+
import { t as guardAuthoringTurns } from "./turn-guard-B9pGCeir.js";
|
|
3
|
+
import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-C3s0iSfv.js";
|
|
4
|
+
import "./hooks-BpLN_hhT.js";
|
|
5
|
+
import { c as presetDirectory } from "./presets-Cl9sU3Qs.js";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
8
|
// src/preset-authoring.ts
|