@dsh-agentic-roleplay/core 0.12.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/lib/{access-DAw54-NI.js → access-DifaiHrI.js} +2 -2
  2. package/lib/{authoring-tools-4NgDhIJV.js → authoring-tools-VOaXzr_R.js} +23 -771
  3. package/lib/authoring.js +135 -12
  4. package/lib/{child-D3QUNb3m.js → child-DzZ-aI6k.js} +10 -1
  5. package/lib/client.js +16162 -1902
  6. package/lib/client.js.map +1 -1
  7. package/lib/compaction.js +3 -3
  8. package/lib/dev-context-Bdm-eVer.js +40 -0
  9. package/lib/doctor.js +5 -3
  10. package/lib/{gallery-Ct6nm4UQ.js → gallery-Ctz-UoFk.js} +3 -3
  11. package/lib/{generator-CI8fOnXy.js → generator-Cv6WWmZT.js} +2 -2
  12. package/lib/helper.js +4 -2
  13. package/lib/{hooks-BNeoGMHZ.js → hooks-BdR3mBeM.js} +33 -14
  14. package/lib/images.js +4 -4
  15. package/lib/index.js +128 -463
  16. package/lib/{jail-BIF79PJO.js → jail-Cp4zEfip.js} +2 -2
  17. package/lib/{library-BF9ZMSFz.js → library-BU2A_Dx8.js} +2 -2
  18. package/lib/{lorebook-author-tools-DBk-V0hp.js → lorebook-author-tools-DUKcQu8P.js} +19 -6
  19. package/lib/lorebook-authoring.js +12 -5
  20. package/lib/{narration-xvErE2yp.js → narration-CDsJ5wxH.js} +2 -2
  21. package/lib/orchestration.js +33 -12
  22. package/lib/{pack-jail-C8EyX9Ix.js → pack-jail-CzHQu0n3.js} +558 -23
  23. package/lib/{packs-S0SzrVv-.js → packs-BZ-45J4-.js} +2 -2
  24. package/lib/{presenter-agent-Bc478nTA.js → presenter-agent-C2ZkoxZu.js} +9 -9
  25. package/lib/{preset-SJZyw0kt.js → preset-BPnRPW-1.js} +4 -4
  26. package/lib/{preset-author-tools-CzogjK42.js → preset-author-tools-DBqPwn-o.js} +8 -7
  27. package/lib/preset-authoring.js +11 -6
  28. package/lib/{reflection-buQiSdvq.js → reflection-Cuy0YLv0.js} +14 -15
  29. package/lib/{presets-DQ5rioMh.js → serial-BZNeK57v.js} +1180 -389
  30. package/lib/{turn-guard-BSAba8sp.js → turn-guard-xaFxYc1T.js} +3 -3
  31. package/locale/de.json +6 -0
  32. package/locale/en.json +6 -0
  33. package/locale/es.json +6 -0
  34. package/locale/fr.json +6 -0
  35. package/locale/ja.json +6 -0
  36. package/locale/pt.json +6 -0
  37. package/locale/ru.json +6 -0
  38. package/locale/zh.json +6 -0
  39. package/package.json +33 -33
  40. package/prompts/en/import/style.md +2 -1
  41. package/prompts/en/world/procedure.md +1 -1
  42. package/prompts/zh/import/style.md +2 -1
  43. package/prompts/zh/world/procedure.md +1 -1
@@ -1,9 +1,9 @@
1
- import { n as atomicWrite, t as promptFor } from "./access-DAw54-NI.js";
2
- import { l as runChild } from "./child-D3QUNb3m.js";
3
- import { n as generateTransientImage, t as generateReferenceImage } from "./generator-CI8fOnXy.js";
4
- import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-Ct6nm4UQ.js";
5
- import { c as nextSceneSerial, u as referenceImagePath } from "./library-BF9ZMSFz.js";
6
- import { join, relative } from "node:path";
1
+ import { n as atomicWrite, t as promptFor } from "./access-DifaiHrI.js";
2
+ import { l as runChild } from "./child-DzZ-aI6k.js";
3
+ import { n as generateTransientImage, t as generateReferenceImage } from "./generator-Cv6WWmZT.js";
4
+ import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-Ctz-UoFk.js";
5
+ import { c as nextSceneSerial, u as referenceImagePath } from "./library-BU2A_Dx8.js";
6
+ import { join, relative, sep } from "node:path";
7
7
  import { characterKey, itemKey, locationKey } from "@dsh-agentic-roleplay/state";
8
8
  import { existsSync } from "node:fs";
9
9
  import { createHash } from "node:crypto";
@@ -450,7 +450,7 @@ function imageTools(deps) {
450
450
  ...args.art_direction === void 0 ? {} : { artDirection: args.art_direction },
451
451
  ...deps.signal === void 0 ? {} : { signal: deps.signal }
452
452
  });
453
- const local = relative(deps.root, path);
453
+ const local = relative(deps.root, path).split(sep).join("/");
454
454
  recorded.push(local);
455
455
  return { path: local };
456
456
  }
@@ -543,7 +543,7 @@ function imageTools(deps) {
543
543
  ...references.length === 0 ? {} : { references },
544
544
  ...deps.signal === void 0 ? {} : { signal: deps.signal }
545
545
  });
546
- const local = relative(deps.root, path);
546
+ const local = relative(deps.root, path).split(sep).join("/");
547
547
  recorded.push(local);
548
548
  return {
549
549
  path: local,
@@ -844,4 +844,4 @@ async function runImagePresenter(job) {
844
844
  }
845
845
  export { searchImages as a, presentedFor as c, findImages as i, interpretImage as n, tokensOf as o, imageTools as r, present as s, runImagePresenter as t };
846
846
 
847
- //# sourceMappingURL=presenter-agent-Bc478nTA.js.map
847
+ //# sourceMappingURL=presenter-agent-C2ZkoxZu.js.map
@@ -1,6 +1,6 @@
1
- import { r as MAX_PREVIEW_TEXT, tn as ImportCardError } from "./authoring-tools-4NgDhIJV.js";
2
- import { p as SAMPLING_RANGES } from "./child-D3QUNb3m.js";
3
- import { Y as cleanText } from "./presets-DQ5rioMh.js";
1
+ import { Rt as ImportCardError, r as MAX_PREVIEW_TEXT } from "./authoring-tools-VOaXzr_R.js";
2
+ import { p as SAMPLING_RANGES } from "./child-DzZ-aI6k.js";
3
+ import { gt as cleanText } from "./serial-BZNeK57v.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-SJZyw0kt.js.map
242
+ //# sourceMappingURL=preset-BPnRPW-1.js.map
@@ -1,9 +1,9 @@
1
- import "./access-DAw54-NI.js";
2
- import { $ as IMPORT_FOLDER, G as deleteWorldPrompt, J as writeWorldPrompt, K as listWorldPrompts, Q as withPlayer, W as PROSE_PROMPTS, c as presetDirectory, l as readPreset, p as updatePresetInfo, q as readWorldPrompt, t as PRESET_FILE, x as extractStyleFrom } from "./presets-DQ5rioMh.js";
3
- import { n as readPreset$1 } from "./preset-SJZyw0kt.js";
4
- import { i as contextOf } from "./authoring-tools-4NgDhIJV.js";
1
+ import "./access-DifaiHrI.js";
2
+ import { $ as deleteWorldPrompt, K as presetDirectory, Q as PROSE_PROMPTS, Z as updatePresetInfo, bt as IMPORT_FOLDER, et as listWorldPrompts, l as extractStyleFrom, nt as writeWorldPrompt, q as readPreset, tt as readWorldPrompt, yt as withPlayer, z as PRESET_FILE } from "./serial-BZNeK57v.js";
3
+ import { n as readPreset$1 } from "./preset-BPnRPW-1.js";
4
+ import { i as contextOf } from "./authoring-tools-VOaXzr_R.js";
5
5
  import { i as translator, r as languageOf } from "./text-Dfv8S8eq.js";
6
- import { et as languageOf$1, it as shippedPromptsDirectory, rt as shippedLanguages } from "./hooks-BNeoGMHZ.js";
6
+ import { et as languageOf$1, it as shippedPromptsDirectory, rt as shippedLanguages } from "./hooks-BdR3mBeM.js";
7
7
  import { join } from "node:path";
8
8
  import { existsSync } from "node:fs";
9
9
  import { readFile, rm } from "node:fs/promises";
@@ -234,10 +234,11 @@ function presetAuthorTools(reader, settings, prompting, shipped = shippedPrompts
234
234
  ];
235
235
  }
236
236
  /** Every change to a preset is put to the person; the first import into an empty preset only fills it, so it is not. */
237
- async function presetApproval(exec, next, carries) {
237
+ async function presetApproval(exec, next, carries, auto = () => false) {
238
238
  if (!PRESET_MUTATION_TOOLS.includes(exec.name) || exec.agent === void 0 || presetOfChat(exec.agent.session.id) === void 0) return await next();
239
239
  const args = exec.arguments;
240
240
  const chat = exec.agent.session.id;
241
+ if (auto() && !isRulesPrompt(args["id"])) return await next();
241
242
  if (exec.name === "import_narration_preset") {
242
243
  if (!carries(chat)) return await next();
243
244
  return {
@@ -278,4 +279,4 @@ async function presetApproval(exec, next, carries) {
278
279
  }
279
280
  export { presetChatSessionId as a, presetAuthorTools as i, narrationImportMessage as n, presetOfChat as o, presetApproval as r, PresetReader as t };
280
281
 
281
- //# sourceMappingURL=preset-author-tools-CzogjK42.js.map
282
+ //# sourceMappingURL=preset-author-tools-DBqPwn-o.js.map
@@ -1,8 +1,9 @@
1
- import { n as limitAuthoringAgents } from "./authoring-tools-4NgDhIJV.js";
2
- import { t as guardAuthoringTurns } from "./turn-guard-BSAba8sp.js";
3
- import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-CzogjK42.js";
4
- import "./hooks-BNeoGMHZ.js";
5
- import { c as presetDirectory } from "./presets-DQ5rioMh.js";
1
+ import { n as limitAuthoringAgents } from "./authoring-tools-VOaXzr_R.js";
2
+ import { t as guardAuthoringTurns } from "./turn-guard-xaFxYc1T.js";
3
+ import { t as silenceHarnessDevContext } from "./dev-context-Bdm-eVer.js";
4
+ import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-DBqPwn-o.js";
5
+ import "./hooks-BdR3mBeM.js";
6
+ import { K as presetDirectory } from "./serial-BZNeK57v.js";
6
7
  import { join } from "node:path";
7
8
  import { existsSync } from "node:fs";
8
9
  // src/preset-authoring.ts
@@ -18,6 +19,7 @@ const inject = [
18
19
  ];
19
20
  /** The preset authoring chat: reads and writes the prose prompts of one library preset, each write approved by the person. */
20
21
  function apply(ctx) {
22
+ silenceHarnessDevContext(ctx);
21
23
  const library = () => ctx.roleplayRoot.path;
22
24
  const reader = new PresetReader(library);
23
25
  const prompting = {
@@ -34,7 +36,10 @@ function apply(ctx) {
34
36
  const preset = presetOfChat(chat);
35
37
  return preset === void 0 ? void 0 : ctx.roleplayAuthoringLanguages.get(`preset:${preset}`);
36
38
  }, () => ctx.roleplayImport.settings.reasoning);
37
- ctx.on("tools/pre-execute", (exec, next) => presetApproval(exec, next, carries));
39
+ ctx.on("session/event", (session, event) => {
40
+ if (event.type === "turn/end" && session.header.origin !== "subagent" && presetOfChat(session.id) !== void 0) ctx.roleplayImport.turnEnded(session.id);
41
+ });
42
+ ctx.on("tools/pre-execute", (exec, next) => presetApproval(exec, next, carries, () => ctx.roleplayImport.settings.approval === "auto"));
38
43
  const languageOf = (context) => {
39
44
  const chat = context.agent?.session.id;
40
45
  const preset = chat === void 0 ? void 0 : presetOfChat(chat);
@@ -1,10 +1,10 @@
1
- import { O as estimateAnswer, a as childTrace, j as roleplaySessionOf, l as runChild, n as childModel, r as childSampling } from "./child-D3QUNb3m.js";
2
- import { H as routeVerdicts, L as announceProblem, R as askYesNo, U as yesAt, V as noAt, f as sha, o as listPresets, s as loadPreset, z as mergeReports } from "./presets-DQ5rioMh.js";
3
- import { t as promptFor } from "./access-DAw54-NI.js";
4
- import { $ as inheritPrompts, D as referent, I as wrongLanguage, X as PROMPTS_FOLDER, mt as describeWhen } from "./hooks-BNeoGMHZ.js";
1
+ import { O as estimateAnswer, a as childTrace, j as roleplaySessionOf, l as runChild, n as childModel, r as childSampling } from "./child-DzZ-aI6k.js";
2
+ import { A as routeVerdicts, D as mergeReports, E as askYesNo, G as loadPreset, T as announceProblem, W as listPresets, X as sha, j as yesAt, k as noAt, t as SerialQueue } from "./serial-BZNeK57v.js";
3
+ import { t as promptFor } from "./access-DifaiHrI.js";
4
+ import { $ as inheritPrompts, D as referent, I as wrongLanguage, X as PROMPTS_FOLDER, mt as describeWhen } from "./hooks-BdR3mBeM.js";
5
5
  import { i as translator, r as languageOf } from "./text-Dfv8S8eq.js";
6
- import { s as inheritImages } from "./library-BF9ZMSFz.js";
7
- import { i as inheritPacks } from "./packs-S0SzrVv-.js";
6
+ import { s as inheritImages } from "./library-BU2A_Dx8.js";
7
+ import { i as inheritPacks } from "./packs-BZ-45J4-.js";
8
8
  import { dirname, join } from "node:path";
9
9
  import { characterKey, locationKey, sessionDatabase, sessionFolder, tokens } from "@dsh-agentic-roleplay/state";
10
10
  import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
@@ -342,14 +342,12 @@ var TimelineError = class extends Error {};
342
342
  */
343
343
  var Timelines = class {
344
344
  deps;
345
- queues = /* @__PURE__ */ new Map();
345
+ queue = new SerialQueue();
346
346
  constructor(deps) {
347
347
  this.deps = deps;
348
348
  }
349
349
  serial(chat, job) {
350
- const run = (this.queues.get(chat) ?? Promise.resolve()).then(job, job);
351
- this.queues.set(chat, run.catch(() => void 0));
352
- return run;
350
+ return this.queue.run(chat, job);
353
351
  }
354
352
  idOf(chat) {
355
353
  const id = roleplaySessionOf(chat);
@@ -416,19 +414,20 @@ var Timelines = class {
416
414
  /**
417
415
  * The turn ended in the log. Its own message is found now: it is the first message of the player after the last turn that ended
418
416
  * (it is not in the log yet when the turn begins).
417
+ * @param beganSeq - where that turn's own `turn/start` sits, so the log is not searched for it.
419
418
  */
420
- ended(chat, session, seq) {
419
+ ended(chat, session, seq, beganSeq) {
421
420
  const id = this.idOf(chat);
422
421
  const timeline = this.read(id);
423
422
  const node = timeline.nodes.find((candidate) => candidate.id === timeline.head);
424
423
  if (node === void 0 || node.endSeq !== void 0) return;
425
424
  const after = Math.max(-1, ...timeline.nodes.filter((other) => other.id !== node.id).map((other) => other.endSeq ?? other.userSeq));
426
- const human = session.snapshotEvents().find((event) => event.seq > after && event.type === "user/message" && event.data.source.kind === "user");
425
+ const human = session.snapshotEvents(after + 1).find((event) => event.seq > after && event.type === "user/message" && event.data.source.kind === "user");
427
426
  if (human === void 0) throw new TimelineError(`turn ${node.turn} has no message of the player in the log`);
428
427
  node.userSeq = human.seq;
429
428
  node.endSeq = seq;
430
- const began = session.snapshotEvents().find((event) => event.type === "turn/start" && event.data.turn === node.turn);
431
- node.startSeq = Math.min(began?.seq ?? human.seq, human.seq);
429
+ const began = beganSeq ?? session.snapshotEvents(0).find((event) => event.type === "turn/start" && event.data.turn === node.turn)?.seq;
430
+ node.startSeq = Math.min(began ?? human.seq, human.seq);
432
431
  writeTimeline(this.folder(id), timeline);
433
432
  }
434
433
  /** Keeps the state as it is under the name of the turn it follows from, when that is not done yet. */
@@ -1505,4 +1504,4 @@ function memoryReflector(deps) {
1505
1504
  }
1506
1505
  export { snapshotOf as _, whereabouts as a, copyPreset as c, switchPreset as d, readTimeline as f, pathTo as g, childrenOf as h, reflectionStatus as i, presetStatus as l, START_SNAPSHOT as m, memoryReflector as n, TimelineError as o, writeTimeline as p, recordFailure as r, Timelines as s, dueReflection as t, recordPreset as u };
1507
1506
 
1508
- //# sourceMappingURL=reflection-buQiSdvq.js.map
1507
+ //# sourceMappingURL=reflection-Cuy0YLv0.js.map