@dsh-agentic-roleplay/core 0.12.3 → 0.12.5

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 (37) hide show
  1. package/lib/{access-Csp80TFX.js → access-DjA0kvPM.js} +2 -2
  2. package/lib/{authoring-tools-hacA5fG-.js → authoring-tools-DqAttdUN.js} +260 -36
  3. package/lib/authoring.js +176 -10
  4. package/lib/{child-DTdY14S9.js → child-SMvjNsb8.js} +63 -9
  5. package/lib/client.js +2043 -1236
  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-BNg0rPTp.js → gallery-Dahi5TkO.js} +3 -3
  10. package/lib/{generator-9-5at9cZ.js → generator-BvSZGpzy.js} +2 -2
  11. package/lib/helper.js +2 -2
  12. package/lib/{hooks-DlrFO4aQ.js → hooks-OLl-1AOS.js} +67 -28
  13. package/lib/images.js +4 -4
  14. package/lib/index.js +45 -30
  15. package/lib/{jail-DVbPSC0R.js → jail-CDW5iymd.js} +2 -2
  16. package/lib/{library-DTxakw0z.js → library-D6AcyxGZ.js} +3 -3
  17. package/lib/{lorebook-author-tools-dupq-kb_.js → lorebook-author-tools-CXV1KD4Q.js} +7 -7
  18. package/lib/lorebook-authoring.js +5 -5
  19. package/lib/{narration--K2XVIHI.js → narration-Bnrvl0UQ.js} +2 -2
  20. package/lib/orchestration.js +37 -38
  21. package/lib/{pack-jail-Bq0fzKi4.js → pack-jail-CZAmlgE1.js} +16 -15
  22. package/lib/{packs-D-7EU3yU.js → packs-DUVCSHqi.js} +2 -2
  23. package/lib/{presenter-agent-vFOxIuWv.js → presenter-agent-CGCJrg7V.js} +7 -6
  24. package/lib/{preset-RHcOG55T.js → preset-BYfXYvp0.js} +4 -4
  25. package/lib/{preset-author-tools-Dwxnpv6V.js → preset-author-tools-DYxTLm9U.js} +7 -7
  26. package/lib/preset-authoring.js +5 -5
  27. package/lib/{reflection-DibpEUQK.js → reflection-C3zdufN9.js} +8 -8
  28. package/lib/{serial-CDGoXYh-.js → serial-Bh6gqb3f.js} +239 -51
  29. package/lib/{text-Dfv8S8eq.js → text-B-HsLdb-.js} +4 -1
  30. package/lib/{turn-guard-DDxikrq7.js → turn-guard-CNFvmz_F.js} +3 -3
  31. package/package.json +2 -2
  32. package/prompts/en/import/opening.md +17 -0
  33. package/prompts/en/roleplay/decide-opening.md +1 -0
  34. package/prompts/en/world/procedure.md +1 -1
  35. package/prompts/zh/import/opening.md +17 -0
  36. package/prompts/zh/roleplay/decide-opening.md +1 -0
  37. package/prompts/zh/world/procedure.md +1 -1
package/lib/compaction.js CHANGED
@@ -1,6 +1,6 @@
1
- import { a as liveSettings, t as decodeOutput } from "./narration--K2XVIHI.js";
2
- import { j as roleplaySessionOf, k as tokensOf, l as runChild, n as childModel, r as childSampling } from "./child-DTdY14S9.js";
3
- import { t as promptFor } from "./access-Csp80TFX.js";
1
+ import { a as liveSettings, t as decodeOutput } from "./narration-Bnrvl0UQ.js";
2
+ import { j as roleplaySessionOf, k as tokensOf, l as runChild, n as childModel, r as childSampling } from "./child-SMvjNsb8.js";
3
+ import { t as promptFor } from "./access-DjA0kvPM.js";
4
4
  import { join } from "node:path";
5
5
  import { sessionFolder } from "@dsh-agentic-roleplay/state";
6
6
  import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
package/lib/doctor.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { n as silenceRuntimeContext, t as silenceHarnessDevContext } from "./dev-context-Cgv_wZbG.js";
2
- import { A as chatSessionId } from "./child-DTdY14S9.js";
2
+ import { A as chatSessionId } from "./child-SMvjNsb8.js";
3
3
  import { n as doctorSessionOf } from "./doctor-chat-hL1a61hp.js";
4
- import { s as externalTools, t as externalToolLimit } from "./hooks-DlrFO4aQ.js";
5
- import { a as liveSettings } from "./narration--K2XVIHI.js";
4
+ import { s as externalTools, t as externalToolLimit } from "./hooks-OLl-1AOS.js";
5
+ import { a as liveSettings } from "./narration-Bnrvl0UQ.js";
6
6
  import { join } from "node:path";
7
7
  import { createTools, isSessionId, sessionDatabase, sessionFolder } from "@dsh-agentic-roleplay/state";
8
8
  import { existsSync } from "node:fs";
@@ -1,5 +1,5 @@
1
- import { n as atomicWrite } from "./access-Csp80TFX.js";
2
- import { _ as writeImageFileMetadata, a as LIBRARY_FOLDER, g as sidecarOf, h as readImageFileMetadata, m as mediaTypeOf, x as mapLimit } from "./library-DTxakw0z.js";
1
+ import { n as atomicWrite } from "./access-DjA0kvPM.js";
2
+ import { _ as writeImageFileMetadata, a as LIBRARY_FOLDER, g as sidecarOf, h as readImageFileMetadata, m as mediaTypeOf, x as mapLimit } from "./library-D6AcyxGZ.js";
3
3
  import { join, sep } from "node:path";
4
4
  import { lstat, readFile, readdir, realpath, stat } from "node:fs/promises";
5
5
  // src/host/images/gallery.ts
@@ -187,4 +187,4 @@ async function updateImage(sessionFolder, path, update) {
187
187
  }
188
188
  export { updateImage as i, galleryFile as n, listGallery as r, describeGalleryImage as t };
189
189
 
190
- //# sourceMappingURL=gallery-BNg0rPTp.js.map
190
+ //# sourceMappingURL=gallery-Dahi5TkO.js.map
@@ -1,4 +1,4 @@
1
- import { d as sceneImagePath, f as writeImage, u as referenceImagePath } from "./library-DTxakw0z.js";
1
+ import { d as sceneImagePath, f as writeImage, u as referenceImagePath } from "./library-D6AcyxGZ.js";
2
2
  // src/host/images/generator.ts
3
3
  const unique = (values) => [...new Set(values.map((value) => value.trim()).filter((value) => value !== ""))];
4
4
  /** What a reference image shows: the subject and its stable look. */
@@ -147,4 +147,4 @@ async function generateTransientImage(service, request) {
147
147
  }
148
148
  export { uploadReferenceImage as a, transientPrompt as i, generateTransientImage as n, referencePrompt as r, generateReferenceImage as t };
149
149
 
150
- //# sourceMappingURL=generator-9-5at9cZ.js.map
150
+ //# sourceMappingURL=generator-BvSZGpzy.js.map
package/lib/helper.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { n as silenceRuntimeContext, t as silenceHarnessDevContext } from "./dev-context-Cgv_wZbG.js";
2
- import { o as helpers } from "./child-DTdY14S9.js";
2
+ import { o as helpers } from "./child-SMvjNsb8.js";
3
3
  import { a as workspaceOf, n as storyRoots } from "./service-mRKwpWjX.js";
4
- import { t as registerFoldersJail } from "./jail-DVbPSC0R.js";
4
+ import { t as registerFoldersJail } from "./jail-CDW5iymd.js";
5
5
  import { join } from "node:path";
6
6
  import { sessionFolder } from "@dsh-agentic-roleplay/state";
7
7
  // src/helper.ts
@@ -1,12 +1,13 @@
1
- import { C as addTokens, D as finishOf, E as cutOff, O as estimateAnswer, S as NO_TOKENS, a as childTrace, b as estimateTokens, f as tracerOf, j as roleplaySessionOf, l as runChild, n as childModel, r as childSampling, u as TurnTraces, v as requestsOf, x as tokensOf, y as blockText } from "./child-DTdY14S9.js";
2
- import { _ as emptyStats, a as liveSettings, h as DECISION_SITES, m as rulesOf, n as encodeOutput, p as WORLD_RULES_KEY, r as encodePreview } from "./narration--K2XVIHI.js";
3
- import { t as promptFor } from "./access-Csp80TFX.js";
4
- import { i as translator, r as languageOf$1, t as trimCharacters } from "./text-Dfv8S8eq.js";
1
+ import { C as addTokens, D as finishOf, E as cutOff, O as estimateAnswer, S as NO_TOKENS, a as childTrace, b as estimateTokens, f as tracerOf, j as roleplaySessionOf, l as runChild, n as childModel, r as childSampling, u as TurnTraces, v as requestsOf, x as tokensOf, y as blockText } from "./child-SMvjNsb8.js";
2
+ import { _ as emptyStats, a as liveSettings, h as DECISION_SITES, m as rulesOf, n as encodeOutput, p as WORLD_RULES_KEY, r as encodePreview } from "./narration-Bnrvl0UQ.js";
3
+ import { t as promptFor } from "./access-DjA0kvPM.js";
4
+ import { i as translator, r as languageOf$1, t as trimCharacters } from "./text-B-HsLdb-.js";
5
5
  import { n as storyRoots } from "./service-mRKwpWjX.js";
6
6
  import { dirname, join } from "node:path";
7
7
  import { DAY, ENGAGEMENT_GRACE, ITEM_ACTIONS, MINUTE, SECOND, addLocalDays, agendaAt, announcements, applyItemPlan, changeItem, changeVariable, clockTime, createCharacterTools, createDiceTools, createTools, dayPart, describeDuration, describeInstant, describeValue, holidaysOn, inAudience, isSessionId, itemKey, localTime, locationKey, mentioned, nextOccurrence, nextTimeOfDay, occurrenceAt, overlap, parseInstant, planItemChange, planVariableChange, readCalendar, rollPlain, seasonOf, sessionDatabase, sessionFolder, shownVariables, tokens } from "@dsh-agentic-roleplay/state";
8
8
  import { copyFileSync, cpSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
9
9
  import { readFile, stat } from "node:fs/promises";
10
+ import { parseCommand } from "@deepseek-ai/dsh-commands";
10
11
  import { ReasoningEffortId, createUserMessage } from "@deepseek-ai/dsh-llm";
11
12
  import { defineTool } from "@deepseek-ai/dsh-tools";
12
13
  import { fileURLToPath } from "node:url";
@@ -195,29 +196,44 @@ function skipTime(session, config, turn, round, wall, request) {
195
196
  }
196
197
  // src/host/commands/registry.ts
197
198
  /**
199
+ * The handlers this plugin registered. A caller outside the input box runs a line only when the command it names is one of ours: a slash line of the profile's own (DSH's `/compact`,
200
+ * `/goal`) stays a message there, so an API call or a benchmark script cannot compact a story by saying something that looks like a command.
201
+ */
202
+ const ownHandlers = /* @__PURE__ */ new WeakSet();
203
+ /** The registration of one spec, with the handler marked as the plugin's own. */
204
+ function definitionOf(spec) {
205
+ const handler = (call) => spec.handler(call);
206
+ ownHandlers.add(handler);
207
+ return {
208
+ name: spec.name,
209
+ description: spec.description,
210
+ input: { hint: spec.hint },
211
+ ...spec.recordInput === void 0 ? {} : { recordInput: spec.recordInput },
212
+ handler
213
+ };
214
+ }
215
+ /**
198
216
  * Registers the commands of the plugin's scope with DSH while the registry exists: they are listed, completed and run by the interface, and a command is not sent to the model.
199
217
  * A plugin mounted by an agent preset registers them for that preset's agents only.
200
218
  */
201
219
  function registerCommands(ctx, specs) {
202
220
  ctx.inject(["commands"], (scope) => {
203
- for (const spec of specs) scope.effect(() => scope.commands.register({
204
- name: spec.name,
205
- description: spec.description,
206
- input: { hint: spec.hint },
207
- ...spec.recordInput === void 0 ? {} : { recordInput: spec.recordInput },
208
- handler: (call) => spec.handler(call)
209
- }), `roleplay: /${spec.name}`);
221
+ for (const spec of specs) scope.effect(() => scope.commands.register(definitionOf(spec)), `roleplay: /${spec.name}`);
210
222
  });
211
223
  }
212
224
  /** The registry of the running profile, or nothing when it has none. */
213
225
  const registryOf = (ctx) => ctx.get("commands");
214
226
  /**
215
227
  * Runs a line the way the input box does when the agent knows the command it starts, for callers that are not the input box (the plugin's own starts, the HTTP API, the benchmark).
216
- * Nothing when the line is no command of this agent; the caller then sends it on as a message.
228
+ * Nothing when the line is not a command of this plugin for this agent; the caller then sends it on as a message.
217
229
  */
218
230
  async function runCommandLine(ctx, agent, line, signal) {
219
231
  const registry = registryOf(ctx);
220
232
  if (registry === void 0) return void 0;
233
+ const parsed = parseCommand(line);
234
+ if (parsed === void 0) return void 0;
235
+ const found = registry.find(agent, parsed.name);
236
+ if (found === void 0 || !ownHandlers.has(found.handler)) return void 0;
221
237
  return (await registry.execute(agent, line, [], signal))?.result;
222
238
  }
223
239
  /** A command that was run from outside the input box and refused: what it says is for the person. */
@@ -225,18 +241,16 @@ var CommandRefusedError = class extends Error {};
225
241
  /**
226
242
  * Registers commands for one agent only, through the agent's own context: they are listed and run for that chat and for no other, and go with the agent. For commands that depend on
227
243
  * what the chat holds (the commands a world defines).
244
+ *
245
+ * The registration has two owners on purpose: the agent's context ends it with the chat, and the plugin's own effect ends it when the plugin unloads while the chat is still open. Without
246
+ * the second, a reloaded plugin would leave a command of the previous copy answering in that chat.
228
247
  */
229
- function registerAgentCommands(agent, specs) {
248
+ function registerAgentCommands(ctx, agent, specs) {
230
249
  if (specs.length === 0) return;
231
- agent.ctx.inject(["commands"], (scope) => {
232
- for (const spec of specs) scope.effect(() => scope.commands.register({
233
- name: spec.name,
234
- description: spec.description,
235
- input: { hint: spec.hint },
236
- ...spec.recordInput === void 0 ? {} : { recordInput: spec.recordInput },
237
- handler: (call) => spec.handler(call)
238
- }), `roleplay: /${spec.name}`);
250
+ const registration = agent.ctx.inject(["commands"], (scope) => {
251
+ for (const spec of specs) scope.effect(() => scope.commands.register(definitionOf(spec)), `roleplay: /${spec.name}`);
239
252
  });
253
+ ctx.effect(() => () => registration.dispose().catch(() => void 0), "roleplay: agent commands");
240
254
  }
241
255
  // src/host/sessions/errors.ts
242
256
  var WorldNotFoundError = class extends Error {};
@@ -4369,22 +4383,47 @@ const UNITS = [
4369
4383
  /**
4370
4384
  * The wait in what a player typed after `/wait` (`2 hours`, `30m until the ferry`, `3天`). The time may be missing or unreadable, and is then `undefined` in `minutes`.
4371
4385
  */
4386
+ const isDigit = (char) => char >= "0" && char <= "9";
4387
+ const isSpace = (char) => char.trim() === "";
4388
+ const LETTER = /^\p{L}$/u;
4389
+ const isLetter = (char) => LETTER.test(char);
4390
+ /**
4391
+ * The wait in what a player typed after `/wait` (`2 hours`, `30m until the ferry`, `3天`). The time may be missing or unreadable, and is then `undefined` in `minutes`.
4392
+ * Read by scanning rather than by one regular expression, so that a long line of digits cannot make the matcher backtrack over itself.
4393
+ */
4372
4394
  function waitArguments(rawInput) {
4373
4395
  const body = rawInput.trim();
4374
- const match = /^(\d+(?:\.\d+)?)\s*([\p{L}]+)\s*(.*)$/su.exec(body);
4375
- if (match === null) return {
4396
+ let at = 0;
4397
+ while (at < body.length && isDigit(body[at])) at += 1;
4398
+ if (at === 0) return {
4399
+ minutes: void 0,
4400
+ reason: body
4401
+ };
4402
+ let whole = body.slice(0, at);
4403
+ if (body[at] === ".") {
4404
+ let fraction = at + 1;
4405
+ while (fraction < body.length && isDigit(body[fraction])) fraction += 1;
4406
+ if (fraction > at + 1) {
4407
+ whole = body.slice(0, fraction);
4408
+ at = fraction;
4409
+ }
4410
+ }
4411
+ while (at < body.length && isSpace(body[at])) at += 1;
4412
+ const unitStart = at;
4413
+ while (at < body.length && isLetter(body[at])) at += 1;
4414
+ if (at === unitStart) return {
4376
4415
  minutes: void 0,
4377
4416
  reason: body
4378
4417
  };
4379
- const unit = UNITS.find(([pattern]) => pattern.test(match[2]));
4418
+ const unit = UNITS.find(([pattern]) => pattern.test(body.slice(unitStart, at)));
4380
4419
  if (unit === void 0) return {
4381
4420
  minutes: void 0,
4382
4421
  reason: body
4383
4422
  };
4384
- const minutes = Math.round(Number(match[1]) * unit[1]);
4423
+ const minutes = Math.round(Number(whole) * unit[1]);
4385
4424
  return {
4386
4425
  minutes: minutes >= 1 && minutes <= 525600 ? minutes : void 0,
4387
- reason: match[3].trim()
4426
+ reason: body.slice(at).trim()
4388
4427
  };
4389
4428
  }
4390
4429
  // src/host/orchestration/player-commands.ts
@@ -4720,7 +4759,7 @@ function installHooks(ctx, deps) {
4720
4759
  if (store === void 0) return;
4721
4760
  registerConditionalTools(agent, conditionsOf(agent.session.id));
4722
4761
  applyLimit(agent, store);
4723
- registerAgentCommands(agent, worldCommands(intents, store.commands?.() ?? []));
4762
+ registerAgentCommands(ctx, agent, worldCommands(intents, store.commands?.() ?? []));
4724
4763
  });
4725
4764
  /** Where the open turn of each chat began, so its own events can be read back without walking the whole log. */
4726
4765
  const openTurns = /* @__PURE__ */ new Map();
@@ -5010,4 +5049,4 @@ function installHooks(ctx, deps) {
5010
5049
  }
5011
5050
  export { copyWorldPrompts as $, plotProgressOf as A, parsePlotsFile as B, readNotes as C, referent as D, sameWords as E, textLanguage as F, readDocument as G, COMMANDS_KEY as H, wrongLanguage as I, errorMessage as J, Reader as K, readUsage as L, LANGUAGE_NAMES as M, STORY_LANGUAGES as N, RESULTS as O, isStoryLanguage as P, PromptLibrary as Q, PLOTS_FILE_NAME as R, notesOfSession as S, defaultBoundaries as T, commandFlagKey as U, plotReferenceProblems as V, commandsOf as W, LANGUAGE_TAG as X, LANGUAGE_FOLDER as Y, PROMPTS_FOLDER as Z, readTraces as _, ClockError as _t, MAX_OOC_ANSWER as a, shippedPromptsDirectory as at, readWithdrawn as b, AUTHORING_NEEDS as bt, externalWithheld as c, InvalidStartError as ct, record as d, SessionArchivedError as dt, inheritPrompts as et, toolEnabled as f, SessionNotFoundError as ft, readRunDetail as g, runCommandLine as gt, readActivity as h, registerCommands as ht, characterRunner as i, shippedLanguages as it, populatePlots as j, PLOTS_METADATA_KEY as k, PREVIEW_TOOL as l, InvalidWorldError as lt, readDecisionStats as m, CommandRefusedError as mt, installHooks as n, listFiles as nt, externalGiven as o, shippedText as ot, storesOf as p, WorldNotFoundError as pt, formatIssue as q, guardRepeatedCalls as r, promptProblem as rt, externalTools as s, AgentUnavailableError as st, externalToolLimit as t, languageOf as tt, createTools$1 as u, ReflectionRefusedError as ut, readVerdicts as v, describeWhen as vt, observeAsPlayer as w, addToNote as x, COMPARISONS as xt, writeVerdicts as y, zoneOf as yt, loadPlots as z };
5012
5051
 
5013
- //# sourceMappingURL=hooks-DlrFO4aQ.js.map
5052
+ //# sourceMappingURL=hooks-OLl-1AOS.js.map
package/lib/images.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as searchImages, c as presentedFor, n as interpretImage, o as tokensOf, r as imageTools, s as present, t as runImagePresenter } from "./presenter-agent-vFOxIuWv.js";
2
- import { i as updateImage, r as listGallery } from "./gallery-BNg0rPTp.js";
3
- import { c as nextSceneSerial, d as sceneImagePath, l as readImageMetadata, o as entityImageDirectory, s as inheritImages, t as addToLibrary, u as referenceImagePath, v as readPngMetadata, y as withPngMetadata } from "./library-DTxakw0z.js";
4
- import { i as transientPrompt, n as generateTransientImage, r as referencePrompt, t as generateReferenceImage } from "./generator-9-5at9cZ.js";
1
+ import { a as searchImages, c as presentedFor, n as interpretImage, o as tokensOf, r as imageTools, s as present, t as runImagePresenter } from "./presenter-agent-CGCJrg7V.js";
2
+ import { i as updateImage, r as listGallery } from "./gallery-Dahi5TkO.js";
3
+ import { c as nextSceneSerial, d as sceneImagePath, l as readImageMetadata, o as entityImageDirectory, s as inheritImages, t as addToLibrary, u as referenceImagePath, v as readPngMetadata, y as withPngMetadata } from "./library-D6AcyxGZ.js";
4
+ import { i as transientPrompt, n as generateTransientImage, r as referencePrompt, t as generateReferenceImage } from "./generator-BvSZGpzy.js";
5
5
  export { addToLibrary, entityImageDirectory, generateReferenceImage, generateTransientImage, imageTools, inheritImages, interpretImage, listGallery, nextSceneSerial, present, presentedFor, readImageMetadata, readPngMetadata, referenceImagePath, referencePrompt, runImagePresenter, sceneImagePath, searchImages, tokensOf, transientPrompt, updateImage, withPngMetadata };
package/lib/index.js CHANGED
@@ -1,21 +1,21 @@
1
- import { A as chatSessionId, _ as RECOVERY_SHRINK, g as RECOVERY_FLOOR, h as sharedSamplingOf, i as childSamplingOf, j as roleplaySessionOf, m as parseSampling, s as isUnfinishedCall, w as totalTokens } from "./child-DTdY14S9.js";
2
- import { $ as checkWorld, A as loadWorldParts, B as localChanges, Gt as pictureOf, H as writeOrigin, Ht as ImportCardError, J as guardedLookup, Kt as readCard, L as describeChanges, O as editWorldInfo, Ot as CHARACTERS_DIR, R as hashWorld, U as CatalogueError, Ut as cardFormat, V as readOrigin, Wt as isPng, X as vetUrl, Xt as authoredWorldOf, Zt as authoringChatSessionId, _ as structureImport, _t as loadLocations, a as beginImport, at as populateClock, c as importTextFor, ct as populateItems, d as knownOutputCeiling, dt as populateLore, et as loadValidatedWorld, f as importPhase, ft as populateRoutines, g as settleDraft, h as markReady, i as ImportState, it as populateCharacters, k as readWorldInfo, kt as loadCharacters, lt as populateKnowledge, m as keepDraft, mt as populateVariables, nt as knowsCharacter, ot as populateDice, pt as populateTriggers, rt as populateCalendar, st as populateFactions, t as AuthoringTools, ut as populateLocations, x as runChecks, z as isUnchanged } from "./authoring-tools-hacA5fG-.js";
3
- import { a as lorebookImportMessage, c as readLorebook, d as lorebookOfChat, l as selectEntries, s as previewLorebook, t as LOREBOOK_UPLOAD, u as lorebookChatSessionId } from "./lorebook-author-tools-dupq-kb_.js";
4
- import { a as presetChatSessionId, n as narrationImportMessage, o as presetOfChat } from "./preset-author-tools-Dwxnpv6V.js";
5
- import { $ as copyWorldPrompts, A as plotProgressOf, B as parsePlotsFile, C as readNotes, G as readDocument, H as COMMANDS_KEY, J as errorMessage, L as readUsage, Q as PromptLibrary, S as notesOfSession, T as defaultBoundaries, V as plotReferenceProblems, Y as LANGUAGE_FOLDER, Z as PROMPTS_FOLDER, _ as readTraces, b as readWithdrawn, ct as InvalidStartError, dt as SessionArchivedError, ft as SessionNotFoundError, g as readRunDetail, h as readActivity, it as shippedLanguages, j as populatePlots, k as PLOTS_METADATA_KEY, lt as InvalidWorldError, m as readDecisionStats, mt as CommandRefusedError, nt as listFiles, pt as WorldNotFoundError, q as formatIssue, rt as promptProblem, s as externalTools, st as AgentUnavailableError, tt as languageOf, ut as ReflectionRefusedError, w as observeAsPlayer, x as addToNote, yt as zoneOf } from "./hooks-DlrFO4aQ.js";
6
- import { a as liveSettings, c as writeSettings, d as parseSettings, i as InvalidSettingsError, l as DEFAULT_SETTINGS, o as readSettings, p as WORLD_RULES_KEY, s as useChildReasoning, u as SETTINGS_SPEC } from "./narration--K2XVIHI.js";
7
- import { $ as deleteWorldPrompt, Ct as IMPORT_FOLDER, F as parseWorldInfoEdit, Ft as parsePlaceEdit, G as loadPreset, H as deletePreset, I as combineAnswers, It as parseRelationEdit, J as reservePreset, K as presetDirectory, L as questionView, Lt as parseThingEdit, M as WORLD_FILE_NAME, Mt as parseCharacterEdit, N as parseWorldFile, Nt as parseFactionEdit, Ot as parseChoices, Pt as parseLoreEdit, St as withPlayer, Tt as ImportStore, U as isPresetName, Ut as sourceSummary, V as createPresetFromShipped, W as listPresets, Y as savePresetFromWorld, Z as updatePresetInfo, an as parseCharacterFile, at as deleteLorebook, cn as LORE_SCOPES, ct as isLorebookName, dt as lorebookDirectory, et as listWorldPrompts, ht as writeLorebookEntry, it as createLorebook, jt as InvalidEditProblems, kt as readImportFolder, lt as listLorebooks, mt as updateLorebookInfo, nt as writeWorldPrompt, on as guarded, ot as deleteLorebookEntry, pt as reserveLorebook, rt as addLorebookEntries, sn as LORE_KINDS, st as entriesOf, tt as readWorldPrompt, ut as loadLorebook, vt as subfolders, wt as ImportNotFoundError, xt as partsOf, z as PRESET_FILE } from "./serial-CDGoXYh-.js";
8
- import { $ as languageOfDocuments, A as generateWorldCharacterPortrait, C as editWorldFaction$1, D as editWorldPlots$1, E as editWorldPlace$1, F as uploadWorldCharacterPortrait, G as parseVariablesEdit, I as uploadWorldEntityImage, J as PRESET_FILE$1, K as parseDiceEdit, L as worldCharacterPortraitFile, M as readWorldEditor, N as readWorldTrigger, O as editWorldRelation$1, P as removeWorldTrigger, R as worldEntityImageFile, S as editWorldCharacter$1, T as editWorldNarrationVoice, U as parseCalendarEdit, W as parseRoutineEdit, Y as presetMessage, Z as translateMessage, _ as readCalendarDocument, a as deleteWorldPackFile, at as startUpdate, b as readRoutines, c as createAuthoredEntity, ct as authoringTitle, dt as agentServicesOf, et as readWorldDocuments, f as editCalendar, ft as DOCTOR_OPENING_SOURCE, g as editVariables, h as editRoutine, it as revertUpdate, j as generateWorldEntityImage, k as editWorldThing$1, l as deleteAuthoredEntity, lt as ensureAuthoringChat, m as editDice, mt as appendNarratedTurn, n as packFileProblem, ot as updateStatus, p as editCommands, pt as appendEmptyTurn, q as parseCommandsEdit, st as AuthoringSessions, t as MAX_PACK_TEXT, tt as findTargets, u as readAuthoredEntityDocument, ut as AgentSessions, v as readCommandsDocument, w as editWorldLore$1, x as readVariables, y as readDiceDocument, z as writeWorldTrigger } from "./pack-jail-Bq0fzKi4.js";
9
- import { i as atomicWriteSync, n as atomicWrite, r as atomicWriteJson } from "./access-Csp80TFX.js";
10
- import { i as translator, r as languageOf$1, t as trimCharacters } from "./text-Dfv8S8eq.js";
11
- import { _ as snapshotOf, c as copyPreset, d as switchPreset, f as readTimeline, g as pathTo, h as childrenOf, i as reflectionStatus, l as presetStatus, m as START_SNAPSHOT, o as TimelineError, p as writeTimeline, u as recordPreset } from "./reflection-DibpEUQK.js";
12
- import { n as readPreset, r as selectPrompts, t as previewPreset } from "./preset-RHcOG55T.js";
13
- import { C as slug, T as uniqueKey, d as sceneImagePath, s as inheritImages, t as addToLibrary, u as referenceImagePath } from "./library-DTxakw0z.js";
1
+ import { A as chatSessionId, _ as RECOVERY_SHRINK, g as RECOVERY_FLOOR, h as sharedSamplingOf, i as childSamplingOf, j as roleplaySessionOf, m as parseSampling, s as isUnfinishedCall, w as totalTokens } from "./child-SMvjNsb8.js";
2
+ import { $ as checkWorld, $t as authoringChatSessionId, A as loadWorldParts, B as localChanges, Gt as cardFormat, H as writeOrigin, J as guardedLookup, Jt as readCard, Kt as isPng, L as describeChanges, O as editWorldInfo, Ot as CHARACTERS_DIR, Qt as authoredWorldOf, R as hashWorld, U as CatalogueError, V as readOrigin, Wt as ImportCardError, X as vetUrl, _ as structureImport, _t as loadLocations, a as beginImport, at as populateClock, c as importTextFor, ct as populateItems, d as knownOutputCeiling, dt as populateLore, et as loadValidatedWorld, f as importPhase, ft as populateRoutines, g as settleDraft, h as markReady, i as ImportState, it as populateCharacters, k as readWorldInfo, kt as loadCharacters, lt as populateKnowledge, m as keepDraft, mt as populateVariables, nt as knowsCharacter, ot as populateDice, pt as populateTriggers, qt as pictureOf, rt as populateCalendar, st as populateFactions, t as AuthoringTools, ut as populateLocations, x as runChecks, z as isUnchanged } from "./authoring-tools-DqAttdUN.js";
3
+ import { a as lorebookImportMessage, c as readLorebook, d as lorebookOfChat, l as selectEntries, s as previewLorebook, t as LOREBOOK_UPLOAD, u as lorebookChatSessionId } from "./lorebook-author-tools-CXV1KD4Q.js";
4
+ import { a as presetChatSessionId, n as narrationImportMessage, o as presetOfChat } from "./preset-author-tools-DYxTLm9U.js";
5
+ import { $ as copyWorldPrompts, A as plotProgressOf, B as parsePlotsFile, C as readNotes, G as readDocument, H as COMMANDS_KEY, J as errorMessage, L as readUsage, Q as PromptLibrary, S as notesOfSession, T as defaultBoundaries, V as plotReferenceProblems, Y as LANGUAGE_FOLDER, Z as PROMPTS_FOLDER, _ as readTraces, b as readWithdrawn, ct as InvalidStartError, dt as SessionArchivedError, ft as SessionNotFoundError, g as readRunDetail, h as readActivity, it as shippedLanguages, j as populatePlots, k as PLOTS_METADATA_KEY, lt as InvalidWorldError, m as readDecisionStats, mt as CommandRefusedError, nt as listFiles, pt as WorldNotFoundError, q as formatIssue, rt as promptProblem, s as externalTools, st as AgentUnavailableError, tt as languageOf, ut as ReflectionRefusedError, w as observeAsPlayer, x as addToNote, yt as zoneOf } from "./hooks-OLl-1AOS.js";
6
+ import { a as liveSettings, c as writeSettings, d as parseSettings, i as InvalidSettingsError, l as DEFAULT_SETTINGS, o as readSettings, p as WORLD_RULES_KEY, s as useChildReasoning, u as SETTINGS_SPEC } from "./narration-Bnrvl0UQ.js";
7
+ import { B as questionView, Bt as parseThingEdit, Dt as ImportNotFoundError, Et as IMPORT_FOLDER, F as parseWorldInfoEdit, Ft as parseCharacterEdit, G as deletePreset, H as PRESET_FILE, It as parseFactionEdit, J as loadPreset, K as isPresetName, Kt as sourceSummary, Lt as parseLoreEdit, M as WORLD_FILE_NAME, Mt as readImportFolder, N as parseWorldFile, Ot as ImportStore, Pt as InvalidEditProblems, Q as savePresetFromWorld, Rt as parsePlaceEdit, Tt as withPlayer, W as createPresetFromShipped, Y as presetDirectory, Z as reservePreset, _t as updateLorebookInfo, at as writeWorldPrompt, cn as parseCharacterFile, ct as deleteLorebook, dn as LORE_SCOPES, dt as isLorebookName, et as updatePresetInfo, ft as listLorebooks, gt as reserveLorebook, it as readWorldPrompt, jt as parseChoices, ln as guarded, lt as deleteLorebookEntry, mt as lorebookDirectory, nt as deleteWorldPrompt, ot as addLorebookEntries, pt as loadLorebook, q as listPresets, rt as listWorldPrompts, st as createLorebook, un as LORE_KINDS, ut as entriesOf, vt as writeLorebookEntry, wt as partsOf, xt as subfolders, z as combineAnswers, zt as parseRelationEdit } from "./serial-Bh6gqb3f.js";
8
+ import { $ as languageOfDocuments, A as generateWorldCharacterPortrait, C as editWorldFaction$1, D as editWorldPlots$1, E as editWorldPlace$1, F as uploadWorldCharacterPortrait, G as parseVariablesEdit, I as uploadWorldEntityImage, J as PRESET_FILE$1, K as parseDiceEdit, L as worldCharacterPortraitFile, M as readWorldEditor, N as readWorldTrigger, O as editWorldRelation$1, P as removeWorldTrigger, R as worldEntityImageFile, S as editWorldCharacter$1, T as editWorldNarrationVoice, U as parseCalendarEdit, W as parseRoutineEdit, Y as presetMessage, Z as translateMessage, _ as readCalendarDocument, a as deleteWorldPackFile, at as startUpdate, b as readRoutines, c as createAuthoredEntity, ct as authoringTitle, dt as agentServicesOf, et as readWorldDocuments, f as editCalendar, ft as DOCTOR_OPENING_SOURCE, g as editVariables, h as editRoutine, it as revertUpdate, j as generateWorldEntityImage, k as editWorldThing$1, l as deleteAuthoredEntity, lt as ensureAuthoringChat, m as editDice, mt as appendNarratedTurn, n as packFileProblem, ot as updateStatus, p as editCommands, pt as appendEmptyTurn, q as parseCommandsEdit, st as AuthoringSessions, t as MAX_PACK_TEXT, tt as findTargets, u as readAuthoredEntityDocument, ut as AgentSessions, v as readCommandsDocument, w as editWorldLore$1, x as readVariables, y as readDiceDocument, z as writeWorldTrigger } from "./pack-jail-CZAmlgE1.js";
9
+ import { i as atomicWriteSync, n as atomicWrite, r as atomicWriteJson } from "./access-DjA0kvPM.js";
10
+ import { i as translator, r as languageOf$1, t as trimCharacters } from "./text-B-HsLdb-.js";
11
+ import { _ as snapshotOf, c as copyPreset, d as switchPreset, f as readTimeline, g as pathTo, h as childrenOf, i as reflectionStatus, l as presetStatus, m as START_SNAPSHOT, o as TimelineError, p as writeTimeline, u as recordPreset } from "./reflection-C3zdufN9.js";
12
+ import { n as readPreset, r as selectPrompts, t as previewPreset } from "./preset-BYfXYvp0.js";
13
+ import { C as slug, T as uniqueKey, d as sceneImagePath, s as inheritImages, t as addToLibrary, u as referenceImagePath } from "./library-D6AcyxGZ.js";
14
14
  import { o as FOLDER_ACCESS, r as InvalidFoldersError, t as StoryFoldersService } from "./service-mRKwpWjX.js";
15
15
  import { t as doctorChatSessionId } from "./doctor-chat-hL1a61hp.js";
16
- import { _ as API_PREFIX, a as packIds, c as describePack, d as packPath, f as readPack, l as isPackId, m as PACK_LIMITS, n as anyTab, o as syncWorldPacks, r as copyWorldPacks, s as worldPackStates, t as activePack, u as packFile } from "./packs-D-7EU3yU.js";
17
- import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-9-5at9cZ.js";
18
- import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-BNg0rPTp.js";
16
+ import { _ as API_PREFIX, a as packIds, c as describePack, d as packPath, f as readPack, l as isPackId, m as PACK_LIMITS, n as anyTab, o as syncWorldPacks, r as copyWorldPacks, s as worldPackStates, t as activePack, u as packFile } from "./packs-DUVCSHqi.js";
17
+ import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-BvSZGpzy.js";
18
+ import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-Dahi5TkO.js";
19
19
  import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
20
20
  import { SESSION_DATABASE_FILE, addLocalDays, createSessionStore, describeInstant, describeValue, holidaysOn, isSessionId, itemKey, lintWorld, locationKey, openSessionStore, parseInstant, readCalendar, seasonOf, sessionDatabase, sessionFolder, shownVariables, systemTimeZone } from "@dsh-agentic-roleplay/state";
21
21
  import { copyFileSync, cpSync, createReadStream, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -566,7 +566,7 @@ function lengthOf(text) {
566
566
  return (text.match(CJK)?.length ?? 0) + (text.replace(CJK, " ").match(/[\p{L}\p{N}]+/gu)?.length ?? 0);
567
567
  }
568
568
  /** Voices of the delivered turns on the way the story went: who spoke how often and how much, and what the narration came to. */
569
- function speakingOf(timeline) {
569
+ function speakingOf$1(timeline) {
570
570
  const voices = /* @__PURE__ */ new Map();
571
571
  const narration = {
572
572
  passages: 0,
@@ -631,7 +631,7 @@ function statisticsOfSession(deps, id) {
631
631
  ...first === void 0 || now === void 0 ? {} : { elapsedSeconds: Math.max(0, Math.round((now - first.to) / 1e3)) }
632
632
  },
633
633
  scenes: places.filter((place, index) => index === 0 || place !== places[index - 1]).length,
634
- ...speakingOf(timeline),
634
+ ...speakingOf$1(timeline),
635
635
  threads: {
636
636
  open: threads.filter((thread) => thread.status === "open").length,
637
637
  resolved: threads.filter((thread) => thread.status !== "open").length
@@ -3119,7 +3119,11 @@ async function sendPackFile(api, path, res) {
3119
3119
  function speechRoutes({ speech }) {
3120
3120
  return {
3121
3121
  "/speech/capabilities": { GET: async (_req, res) => {
3122
- sendJson(res, 200, { streaming: speech.streaming() });
3122
+ sendJson(res, 200, {
3123
+ streaming: speech.streaming(),
3124
+ synthesis: speech.synthesis(),
3125
+ images: speech.images()
3126
+ });
3123
3127
  } },
3124
3128
  "/speech/voices": { GET: async (_req, res) => {
3125
3129
  sendJson(res, 200, await speech.voices());
@@ -6850,10 +6854,10 @@ async function startSession(deps, request) {
6850
6854
  const openingIndex = request.opening ?? answers.opening;
6851
6855
  const startingTimeAsked = request.startingTime?.trim() || answers.startingTime;
6852
6856
  if (openingIndex !== void 0 && (!Number.isInteger(openingIndex) || openingIndex < 0 || openingIndex >= (world.alternateOpenings?.length ?? 0))) throw new InvalidStartError(`the world has no alternate opening ${String(openingIndex)}`);
6853
- const opening = openingIndex === void 0 ? openingOf(world, authored) : [{
6857
+ const opening = openingIndex === void 0 ? openingOf(world, authored) : speakingOf(world, world.alternateOpenings[openingIndex].parts ?? [{
6854
6858
  type: "narration",
6855
6859
  text: world.alternateOpenings[openingIndex].text
6856
- }];
6860
+ }], authored, `alternate_openings[${openingIndex}]`);
6857
6861
  const keys = [...new Set(request.avatars ?? [])];
6858
6862
  if (keys.length > 0 && deps.avatars === void 0) throw new InvalidStartError("player avatars are not available");
6859
6863
  const avatars = keys.length === 0 ? void 0 : await deps.avatars();
@@ -6868,6 +6872,11 @@ async function startSession(deps, request) {
6868
6872
  path: `alternate_openings[${index}].character`,
6869
6873
  message: `"${entry.character}" is not a playable character of this world`
6870
6874
  }]);
6875
+ const speakerProblems = (world.alternateOpenings ?? []).flatMap((entry, index) => (entry.parts ?? []).flatMap((part) => part.type === "utterance" && !authored.some((character) => character.id === part.character) ? [{
6876
+ path: `alternate_openings[${index}].parts`,
6877
+ message: `"${part.character}" is not a character of this world`
6878
+ }] : []));
6879
+ openingProblems.push(...speakerProblems);
6871
6880
  if (openingProblems.length > 0) throw new InvalidWorldError(`the alternate openings of "${world.summary.name}" have ${openingProblems.length} problem(s)`, openingProblems);
6872
6881
  const forCharacter = openingIndex === void 0 ? void 0 : world.alternateOpenings[openingIndex].character;
6873
6882
  if (forCharacter !== void 0 && forCharacter !== player.id) throw new InvalidStartError(`this opening is for ${authored.find((character) => character.id === forCharacter)?.name ?? forCharacter}, not for ${player.name}`);
@@ -7058,19 +7067,15 @@ function presetFor(deps, asked, suggested) {
7058
7067
  return { unavailable: [`The world suggests the preset "${name}", which cannot be used here (${reason}), so the story is told in the default style.`] };
7059
7068
  }
7060
7069
  }
7061
- /** The opening of the world with each speaker's name, or the reason it cannot be used. */
7062
- function openingOf(world, characters) {
7063
- if (world.opening === void 0) return [{
7064
- type: "narration",
7065
- text: DEFAULT_OPENING
7066
- }];
7070
+ /** The parts of an opening with each speaker's name, or the reason it cannot be used: a speaker the world does not have. */
7071
+ function speakingOf(world, parts, characters, where) {
7067
7072
  const problems = [];
7068
- const segments = world.opening.map((segment) => {
7073
+ const segments = parts.map((segment) => {
7069
7074
  if (segment.type === "narration") return segment;
7070
7075
  const speaker = characters.find((character) => character.id === segment.character);
7071
7076
  if (speaker === void 0) problems.push({
7072
7077
  path: join(world.directory, WORLD_FILE_NAME),
7073
- message: `opening_message: "${segment.character}" is not a character of this world`
7078
+ message: `${where}: "${segment.character}" is not a character of this world`
7074
7079
  });
7075
7080
  return {
7076
7081
  type: "utterance",
@@ -7082,6 +7087,14 @@ function openingOf(world, characters) {
7082
7087
  if (problems.length > 0) throw new InvalidWorldError(`the opening of "${world.summary.name}" has ${problems.length} problem(s)`, problems);
7083
7088
  return segments;
7084
7089
  }
7090
+ /** The opening of the world with each speaker's name, or the reason it cannot be used. */
7091
+ function openingOf(world, characters) {
7092
+ if (world.opening === void 0) return [{
7093
+ type: "narration",
7094
+ text: DEFAULT_OPENING
7095
+ }];
7096
+ return speakingOf(world, world.opening, characters, "opening_message");
7097
+ }
7085
7098
  // src/host/sessions/rename-session.ts
7086
7099
  /**
7087
7100
  * Give a session a new name, and its chat the same one.
@@ -10043,7 +10056,9 @@ function apply(ctx, config) {
10043
10056
  speech: {
10044
10057
  voices: async () => await voicesOf(textToSpeechOf(ctx)),
10045
10058
  speak: async (parts) => await speakParts(textToSpeechOf(ctx), parts),
10046
- streaming: () => streamingSpeechToTextOf(ctx) !== void 0
10059
+ streaming: () => streamingSpeechToTextOf(ctx) !== void 0,
10060
+ synthesis: () => ctx.get("textToSpeech") !== void 0,
10061
+ images: () => ctx.get("imageGeneration") !== void 0
10047
10062
  },
10048
10063
  worlds,
10049
10064
  createWorld: (input) => createWorld(worlds, input),
@@ -1,4 +1,4 @@
1
- import { j as roleplaySessionOf } from "./child-DTdY14S9.js";
1
+ import { j as roleplaySessionOf } from "./child-SMvjNsb8.js";
2
2
  import { i as isInside } from "./service-mRKwpWjX.js";
3
3
  import { dirname, isAbsolute, resolve } from "node:path";
4
4
  import { readdirSync, realpathSync, statSync } from "node:fs";
@@ -104,4 +104,4 @@ function registerFoldersJail(ctx, deps) {
104
104
  }
105
105
  export { registerFoldersJail as t };
106
106
 
107
- //# sourceMappingURL=jail-DVbPSC0R.js.map
107
+ //# sourceMappingURL=jail-CDW5iymd.js.map
@@ -1,5 +1,5 @@
1
- import { n as atomicWrite } from "./access-Csp80TFX.js";
2
- import { i as translator, n as withoutExtension, r as languageOf, t as trimCharacters } from "./text-Dfv8S8eq.js";
1
+ import { n as atomicWrite } from "./access-DjA0kvPM.js";
2
+ import { i as translator, n as withoutExtension, r as languageOf, t as trimCharacters } from "./text-B-HsLdb-.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-DTxakw0z.js.map
377
+ //# sourceMappingURL=library-D6AcyxGZ.js.map
@@ -1,9 +1,9 @@
1
- import "./access-Csp80TFX.js";
2
- import { Ht as ImportCardError, o as contextOf, r as MAX_PREVIEW_TEXT } from "./authoring-tools-hacA5fG-.js";
3
- import { B as createPresetFromGuidance, Ct as IMPORT_FOLDER, St as withPlayer, cn as LORE_SCOPES, dt as lorebookDirectory, ft as readLorebook$1, ht as writeLorebookEntry, mt as updateLorebookInfo, ot as deleteLorebookEntry, sn as LORE_KINDS, st as entriesOf, ut as loadLorebook, xt as partsOf, yt as cleanText } from "./serial-CDGoXYh-.js";
4
- import { F as textLanguage, I as wrongLanguage, at as shippedPromptsDirectory } from "./hooks-DlrFO4aQ.js";
5
- import { i as translator, r as languageOf } from "./text-Dfv8S8eq.js";
6
- import { C as slug, T as uniqueKey, w as trOf, x as mapLimit } from "./library-DTxakw0z.js";
1
+ import "./access-DjA0kvPM.js";
2
+ import { Wt as ImportCardError, o as contextOf, r as MAX_PREVIEW_TEXT } from "./authoring-tools-DqAttdUN.js";
3
+ import { Et as IMPORT_FOLDER, St as cleanText, Tt as withPlayer, U as createPresetFromGuidance, _t as updateLorebookInfo, dn as LORE_SCOPES, ht as readLorebook$1, lt as deleteLorebookEntry, mt as lorebookDirectory, pt as loadLorebook, un as LORE_KINDS, ut as entriesOf, vt as writeLorebookEntry, wt as partsOf } from "./serial-Bh6gqb3f.js";
4
+ import { F as textLanguage, I as wrongLanguage, at as shippedPromptsDirectory } from "./hooks-OLl-1AOS.js";
5
+ import { i as translator, r as languageOf } from "./text-B-HsLdb-.js";
6
+ import { C as slug, T as uniqueKey, w as trOf, x as mapLimit } from "./library-D6AcyxGZ.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";
@@ -709,4 +709,4 @@ async function lorebookApproval(exec, next, state) {
709
709
  }
710
710
  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 };
711
711
 
712
- //# sourceMappingURL=lorebook-author-tools-dupq-kb_.js.map
712
+ //# sourceMappingURL=lorebook-author-tools-CXV1KD4Q.js.map
@@ -1,9 +1,9 @@
1
- import { n as limitAuthoringAgents } from "./authoring-tools-hacA5fG-.js";
2
- import { t as guardAuthoringTurns } from "./turn-guard-DDxikrq7.js";
1
+ import { n as limitAuthoringAgents } from "./authoring-tools-DqAttdUN.js";
2
+ import { t as guardAuthoringTurns } from "./turn-guard-CNFvmz_F.js";
3
3
  import { n as silenceRuntimeContext, t as silenceHarnessDevContext } from "./dev-context-Cgv_wZbG.js";
4
- import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-dupq-kb_.js";
5
- import "./hooks-DlrFO4aQ.js";
6
- import { dt as lorebookDirectory } from "./serial-CDGoXYh-.js";
4
+ import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-CXV1KD4Q.js";
5
+ import "./hooks-OLl-1AOS.js";
6
+ import { mt as lorebookDirectory } from "./serial-Bh6gqb3f.js";
7
7
  import { join } from "node:path";
8
8
  import { existsSync, readdirSync } from "node:fs";
9
9
  // src/lorebook-authoring.ts
@@ -1,4 +1,4 @@
1
- import { i as atomicWriteSync } from "./access-Csp80TFX.js";
1
+ import { i as atomicWriteSync } from "./access-DjA0kvPM.js";
2
2
  import { join } from "node:path";
3
3
  import { existsSync, readFileSync, statSync } from "node:fs";
4
4
  // ../dsh-roleplay-model/src/clock.ts
@@ -485,4 +485,4 @@ function decodeOutput(text) {
485
485
  }
486
486
  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 };
487
487
 
488
- //# sourceMappingURL=narration--K2XVIHI.js.map
488
+ //# sourceMappingURL=narration-Bnrvl0UQ.js.map
@@ -1,17 +1,17 @@
1
- import { t as silenceHarnessDevContext } from "./dev-context-Cgv_wZbG.js";
2
- import { t as promptFor } from "./access-Csp80TFX.js";
3
- import { D as referent, E as sameWords, H as COMMANDS_KEY, I as wrongLanguage, O as RESULTS, U as commandFlagKey, W as commandsOf, _t as ClockError, a as MAX_OOC_ANSWER, bt as AUTHORING_NEEDS, d as record, f as toolEnabled, i as characterRunner, l as PREVIEW_TOOL, n as installHooks, o as externalGiven, ot as shippedText, p as storesOf, tt as languageOf, u as createTools$1, ut as ReflectionRefusedError, v as readVerdicts, vt as describeWhen, y as writeVerdicts, yt as zoneOf } from "./hooks-DlrFO4aQ.js";
4
- import { A as chatSessionId, O as estimateAnswer, T as currentTurn, a as childTrace, d as sessionOfChat, f as tracerOf, j as roleplaySessionOf, k as tokensOf, l as runChild, n as childModel, r as childSampling, u as TurnTraces } from "./child-DTdY14S9.js";
5
- import { a as whereabouts, n as memoryReflector, r as recordFailure, s as Timelines, t as dueReflection } from "./reflection-DibpEUQK.js";
6
- import { A as routeVerdicts, E as askYesNo, O as modeFor, T as announceProblem, Vt as splitPanels, dn as INTENT_STATUSES, j as yesAt, k as noAt, n as STANDING_PROMPT, on as guarded } from "./serial-CDGoXYh-.js";
7
- import { i as translator, r as languageOf$1 } from "./text-Dfv8S8eq.js";
8
- import { a as liveSettings, g as GATE_SITES, n as encodeOutput } from "./narration--K2XVIHI.js";
9
- import { t as registerFoldersJail } from "./jail-DVbPSC0R.js";
1
+ import { n as silenceRuntimeContext, t as silenceHarnessDevContext } from "./dev-context-Cgv_wZbG.js";
2
+ import { t as promptFor } from "./access-DjA0kvPM.js";
3
+ import { D as referent, E as sameWords, H as COMMANDS_KEY, I as wrongLanguage, O as RESULTS, U as commandFlagKey, W as commandsOf, _t as ClockError, a as MAX_OOC_ANSWER, bt as AUTHORING_NEEDS, d as record, f as toolEnabled, i as characterRunner, l as PREVIEW_TOOL, n as installHooks, o as externalGiven, ot as shippedText, p as storesOf, tt as languageOf, u as createTools$1, ut as ReflectionRefusedError, v as readVerdicts, vt as describeWhen, y as writeVerdicts, yt as zoneOf } from "./hooks-OLl-1AOS.js";
4
+ import { A as chatSessionId, O as estimateAnswer, T as currentTurn, a as childTrace, d as sessionOfChat, f as tracerOf, j as roleplaySessionOf, k as tokensOf, l as runChild, n as childModel, r as childSampling, u as TurnTraces } from "./child-SMvjNsb8.js";
5
+ import { a as whereabouts, n as memoryReflector, r as recordFailure, s as Timelines, t as dueReflection } from "./reflection-C3zdufN9.js";
6
+ import { A as routeVerdicts, E as askYesNo, O as modeFor, T as announceProblem, Wt as splitPanels, j as yesAt, k as noAt, ln as guarded, mn as INTENT_STATUSES, n as STANDING_PROMPT } from "./serial-Bh6gqb3f.js";
7
+ import { i as translator, r as languageOf$1 } from "./text-B-HsLdb-.js";
8
+ import { a as liveSettings, g as GATE_SITES, n as encodeOutput } from "./narration-Bnrvl0UQ.js";
9
+ import { t as registerFoldersJail } from "./jail-CDW5iymd.js";
10
10
  import { a as workspaceOf, n as storyRoots } from "./service-mRKwpWjX.js";
11
- import { C as slug, T as uniqueKey, t as addToLibrary } from "./library-DTxakw0z.js";
12
- import { _ as API_PREFIX } from "./packs-D-7EU3yU.js";
13
- import { i as updateImage, r as listGallery, t as describeGalleryImage } from "./gallery-BNg0rPTp.js";
14
- import { c as presentedFor, i as findImages, n as interpretImage, s as present, t as runImagePresenter } from "./presenter-agent-vFOxIuWv.js";
11
+ import { C as slug, T as uniqueKey, t as addToLibrary } from "./library-D6AcyxGZ.js";
12
+ import { _ as API_PREFIX } from "./packs-DUVCSHqi.js";
13
+ import { i as updateImage, r as listGallery, t as describeGalleryImage } from "./gallery-Dahi5TkO.js";
14
+ import { c as presentedFor, i as findImages, n as interpretImage, s as present, t as runImagePresenter } from "./presenter-agent-CGCJrg7V.js";
15
15
  import { join } from "node:path";
16
16
  import { InvalidEditError, characterKey, createDiceTools, createTools, dayPart, describeDuration, describeHolder, describeInstant, describeValue, itemKey, judgedStatements, lintWorld, localTime, locationKey, mentioned, parseRecordsEdit, rollForCheck, seededRoll, sessionDatabase, sessionFolder, systemRoller } from "@dsh-agentic-roleplay/state";
17
17
  import { existsSync } from "node:fs";
@@ -4328,24 +4328,29 @@ var ImageJobs = class {
4328
4328
  this.failures.delete(this.key(id, node));
4329
4329
  const request = output.segments.map((segment) => segment.type === "utterance" ? `${segment.name}: “${segment.text}”` : segment.text).join("\n");
4330
4330
  const reuse = automatic && settings.images.reuse;
4331
- const present$1 = () => (this.deps.presenter ?? runImagePresenter)({
4332
- parent,
4333
- signal: controller.signal,
4334
- service: withPriority(service, priority, settings.images.highRes),
4335
- story: this.deps.state.openSession(this.deps.sessionsDir(), id),
4336
- root: sessionFolder(this.deps.sessionsDir(), id),
4337
- turn,
4338
- timelineNode: node,
4339
- request,
4340
- purpose: "transient",
4341
- reuse,
4342
- language: settings.prompts.language,
4343
- sampling: childSampling(settings, "records"),
4344
- referenceMode: settings.images.references,
4345
- ...reuse && this.deps.attachments?.() !== void 0 ? { attachments: this.deps.attachments() } : {},
4346
- ...reuse && this.deps.embedder?.() !== void 0 ? { embedder: this.deps.embedder() } : {},
4347
- ...settings.reasoning.children === "" ? {} : { reasoningEffort: settings.reasoning.children }
4348
- });
4331
+ const tr = translator(languageOf$1(settings.prompts.language));
4332
+ const present$1 = () => {
4333
+ const turns = store();
4334
+ return (this.deps.presenter ?? runImagePresenter)({
4335
+ parent,
4336
+ signal: controller.signal,
4337
+ service: withPriority(service, priority, settings.images.highRes),
4338
+ story: this.deps.state.openSession(this.deps.sessionsDir(), id),
4339
+ root: sessionFolder(this.deps.sessionsDir(), id),
4340
+ turn,
4341
+ timelineNode: node,
4342
+ request,
4343
+ purpose: "transient",
4344
+ reuse,
4345
+ language: settings.prompts.language,
4346
+ ...turns === void 0 ? {} : { trace: childTrace(turns, "records", tr("Scene picture")) },
4347
+ sampling: childSampling(settings, "records"),
4348
+ referenceMode: settings.images.references,
4349
+ ...reuse && this.deps.attachments?.() !== void 0 ? { attachments: this.deps.attachments() } : {},
4350
+ ...reuse && this.deps.embedder?.() !== void 0 ? { embedder: this.deps.embedder() } : {},
4351
+ ...settings.reasoning.children === "" ? {} : { reasoningEffort: settings.reasoning.children }
4352
+ });
4353
+ };
4349
4354
  const store = () => this.deps.turnStore?.(chatSessionId(id));
4350
4355
  const begin = () => {
4351
4356
  const make = () => reuse && settings.images.interpret && this.deps.attachments?.() !== void 0 ? this.describePending(id, controller.signal).then(present$1) : present$1();
@@ -4536,7 +4541,6 @@ function pictureReuse(deps) {
4536
4541
  };
4537
4542
  }
4538
4543
  // src/orchestration.ts
4539
- const WORKING_DIRECTORY_CONTEXT = "working-directory:current";
4540
4544
  const name = "@dsh-agentic-roleplay/core/orchestration";
4541
4545
  /**
4542
4546
  * Mounted by the `roleplay` agent preset, so it applies to roleplay chats only.
@@ -4697,12 +4701,7 @@ function apply(ctx) {
4697
4701
  return resourceHint(ctx.tools.schemas(context.scope).map((tool) => tool.name), ctx.tools.schemas().map((tool) => tool.name), translator(languageOf$1(chat?.settings.prompts.language ?? "en")));
4698
4702
  }
4699
4703
  });
4700
- ctx.systemPrompt.context({
4701
- name: WORKING_DIRECTORY_CONTEXT,
4702
- order: ctx.systemPrompt.getContextOrder("WORKING_DIRECTORY"),
4703
- interpolate: false,
4704
- text: ""
4705
- });
4704
+ silenceRuntimeContext(ctx);
4706
4705
  const rolls = new RollReplay((chat) => stores(chat)?.settings().rewind.rolls ?? "reroll");
4707
4706
  const turnTraces = new TurnTraces(() => tracerOf(ctx));
4708
4707
  const toolDeps = {