@dsh-agentic-roleplay/core 0.11.0 → 0.12.0

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 (62) hide show
  1. package/lib/{access-CXtaZNbx.js → access-DAw54-NI.js} +6 -15
  2. package/lib/{authoring-tools--6V1pIIL.js → authoring-tools-4NgDhIJV.js} +116 -13
  3. package/lib/authoring.js +38 -8
  4. package/lib/{child-C9nPIy9j.js → child-D3QUNb3m.js} +121 -2
  5. package/lib/client.js +1389 -475
  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-CtG-bDzz.js → gallery-Ct6nm4UQ.js} +3 -3
  10. package/lib/{generator-nLoPM5MF.js → generator-CI8fOnXy.js} +9 -3
  11. package/lib/helper.js +22 -1
  12. package/lib/{hooks-DORky4KT.js → hooks-BNeoGMHZ.js} +1342 -293
  13. package/lib/images.js +4 -4
  14. package/lib/index.js +444 -24
  15. package/lib/jail-BIF79PJO.js +107 -0
  16. package/lib/{library-CH-ahlm0.js → library-BF9ZMSFz.js} +3 -3
  17. package/lib/{lorebook-author-tools-BrVde1N-.js → lorebook-author-tools-DBk-V0hp.js} +7 -7
  18. package/lib/lorebook-authoring.js +4 -4
  19. package/lib/{narration-B0hConSw.js → narration-xvErE2yp.js} +34 -3
  20. package/lib/orchestration.js +915 -59
  21. package/lib/{pack-jail-Bk82pX9t.js → pack-jail-C8EyX9Ix.js} +18 -14
  22. package/lib/{packs-ELfh8yh1.js → packs-S0SzrVv-.js} +2 -2
  23. package/lib/{presenter-agent-UKbKYXMO.js → presenter-agent-Bc478nTA.js} +11 -8
  24. package/lib/{preset-D9Sfc8sf.js → preset-SJZyw0kt.js} +4 -4
  25. package/lib/{preset-author-tools-B3pFL1-e.js → preset-author-tools-CzogjK42.js} +7 -7
  26. package/lib/preset-authoring.js +5 -5
  27. package/lib/{presets-BRt4Xsy4.js → presets-DQ5rioMh.js} +251 -49
  28. package/lib/{reflection-CHiHsY4Y.js → reflection-buQiSdvq.js} +17 -609
  29. package/lib/service-mRKwpWjX.js +140 -0
  30. package/lib/{text-CzqhC8sT.js → text-Dfv8S8eq.js} +36 -2
  31. package/lib/{turn-guard-B53qOWEU.js → turn-guard-BSAba8sp.js} +3 -3
  32. package/package.json +3 -3
  33. package/prompts/en/import/finish-ok.md +1 -1
  34. package/prompts/en/import/generator.md +1 -1
  35. package/prompts/en/import/style.md +1 -1
  36. package/prompts/en/import/variables.md +3 -1
  37. package/prompts/en/roleplay/character-decide.md +1 -1
  38. package/prompts/en/roleplay/character-lookup.md +1 -1
  39. package/prompts/en/roleplay/decide-errand.md +1 -0
  40. package/prompts/en/roleplay/decide-message.md +1 -0
  41. package/prompts/en/roleplay/decide-reuse.md +3 -0
  42. package/prompts/en/roleplay/decide-variable.md +1 -0
  43. package/prompts/en/roleplay/dream.md +1 -0
  44. package/prompts/en/roleplay/gate-repeat.md +1 -0
  45. package/prompts/en/roleplay/image-presenter.md +1 -0
  46. package/prompts/en/roleplay/track-values.md +1 -0
  47. package/prompts/en/roleplay/track-variables.md +1 -0
  48. package/prompts/zh/import/finish-ok.md +1 -1
  49. package/prompts/zh/import/generator.md +1 -1
  50. package/prompts/zh/import/style.md +1 -1
  51. package/prompts/zh/import/variables.md +3 -1
  52. package/prompts/zh/roleplay/character-decide.md +1 -1
  53. package/prompts/zh/roleplay/character-lookup.md +1 -1
  54. package/prompts/zh/roleplay/decide-errand.md +1 -0
  55. package/prompts/zh/roleplay/decide-message.md +1 -0
  56. package/prompts/zh/roleplay/decide-reuse.md +3 -0
  57. package/prompts/zh/roleplay/decide-variable.md +1 -0
  58. package/prompts/zh/roleplay/dream.md +1 -0
  59. package/prompts/zh/roleplay/gate-repeat.md +1 -0
  60. package/prompts/zh/roleplay/image-presenter.md +1 -0
  61. package/prompts/zh/roleplay/track-values.md +1 -0
  62. package/prompts/zh/roleplay/track-variables.md +1 -0
package/lib/compaction.js CHANGED
@@ -1,6 +1,6 @@
1
- import { a as liveSettings, t as decodeOutput } from "./narration-B0hConSw.js";
2
- import { l as roleplaySessionOf, t as promptFor } from "./access-CXtaZNbx.js";
3
- import { E as tokensOf, l as runChild, n as childModel, r as childSampling } from "./child-C9nPIy9j.js";
1
+ import { a as liveSettings, t as decodeOutput } from "./narration-xvErE2yp.js";
2
+ import { j as roleplaySessionOf, k as tokensOf, l as runChild, n as childModel, r as childSampling } from "./child-D3QUNb3m.js";
3
+ import { t as promptFor } from "./access-DAw54-NI.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,7 +1,7 @@
1
- import { c as chatSessionId } from "./access-CXtaZNbx.js";
1
+ import { A as chatSessionId } from "./child-D3QUNb3m.js";
2
2
  import { n as doctorSessionOf } from "./doctor-chat-hL1a61hp.js";
3
- import { i as externalTools, t as externalToolLimit } from "./hooks-DORky4KT.js";
4
- import { a as liveSettings } from "./narration-B0hConSw.js";
3
+ import { o as externalTools, t as externalToolLimit } from "./hooks-BNeoGMHZ.js";
4
+ import { a as liveSettings } from "./narration-xvErE2yp.js";
5
5
  import { join } from "node:path";
6
6
  import { createTools, isSessionId, sessionDatabase, sessionFolder } from "@dsh-agentic-roleplay/state";
7
7
  import { existsSync } from "node:fs";
@@ -1,5 +1,5 @@
1
- import { n as atomicWrite } from "./access-CXtaZNbx.js";
2
- import { _ as writeImageFileMetadata, a as LIBRARY_FOLDER, g as sidecarOf, h as readImageFileMetadata, m as mediaTypeOf, x as mapLimit } from "./library-CH-ahlm0.js";
1
+ import { n as atomicWrite } from "./access-DAw54-NI.js";
2
+ import { _ as writeImageFileMetadata, a as LIBRARY_FOLDER, g as sidecarOf, h as readImageFileMetadata, m as mediaTypeOf, x as mapLimit } from "./library-BF9ZMSFz.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-CtG-bDzz.js.map
190
+ //# sourceMappingURL=gallery-Ct6nm4UQ.js.map
@@ -1,4 +1,4 @@
1
- import { d as sceneImagePath, f as writeImage, u as referenceImagePath } from "./library-CH-ahlm0.js";
1
+ import { d as sceneImagePath, f as writeImage, u as referenceImagePath } from "./library-BF9ZMSFz.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. */
@@ -23,6 +23,12 @@ function referencePrompt(request) {
23
23
  identity.negativeTags.length === 0 ? void 0 : `Avoid: ${identity.negativeTags.join(", ")}.`
24
24
  ]);
25
25
  }
26
+ /** What one subject must not look like may well be what another in the same picture does look like, so a trait that any subject has is not avoided. */
27
+ function avoidedIn(subjects) {
28
+ const wanted = new Set(subjects.flatMap((subject) => subject.identity.tags.map((tag) => tag.trim().toLowerCase())));
29
+ const avoided = [...new Set(subjects.flatMap((subject) => subject.identity.negativeTags))].filter((tag) => !wanted.has(tag.trim().toLowerCase()));
30
+ return avoided.length === 0 ? void 0 : `Avoid: ${avoided.join(", ")}.`;
31
+ }
26
32
  function transientPrompt(request) {
27
33
  return lines([
28
34
  request.artDirection,
@@ -33,7 +39,7 @@ function transientPrompt(request) {
33
39
  subject.transient === "" ? void 0 : `Current visible state: ${subject.transient}`
34
40
  ])),
35
41
  "Preserve every canonical identity. Depict only the stated subjects, state and action; do not invent story facts.",
36
- request.subjects.flatMap((subject) => subject.identity.negativeTags).length === 0 ? void 0 : `Avoid: ${[...new Set(request.subjects.flatMap((subject) => subject.identity.negativeTags))].join(", ")}.`
42
+ avoidedIn(request.subjects)
37
43
  ]);
38
44
  }
39
45
  async function firstPng(service, prompt, options = {}) {
@@ -141,4 +147,4 @@ async function generateTransientImage(service, request) {
141
147
  }
142
148
  export { uploadReferenceImage as a, transientPrompt as i, generateTransientImage as n, referencePrompt as r, generateReferenceImage as t };
143
149
 
144
- //# sourceMappingURL=generator-nLoPM5MF.js.map
150
+ //# sourceMappingURL=generator-CI8fOnXy.js.map
package/lib/helper.js CHANGED
@@ -1,4 +1,8 @@
1
- import { o as helpers } from "./child-C9nPIy9j.js";
1
+ import { o as helpers } from "./child-D3QUNb3m.js";
2
+ import { a as workspaceOf, n as storyRoots } from "./service-mRKwpWjX.js";
3
+ import { t as registerFoldersJail } from "./jail-BIF79PJO.js";
4
+ import { join } from "node:path";
5
+ import { sessionFolder } from "@dsh-agentic-roleplay/state";
2
6
  // src/helper.ts
3
7
  const name = "@dsh-agentic-roleplay/core/helper";
4
8
  const inject = ["tools", "systemPrompt"];
@@ -23,9 +27,26 @@ function apply(ctx) {
23
27
  interpolate: false,
24
28
  text: ""
25
29
  });
30
+ const rootOf = () => ctx.get("roleplayRoot")?.path;
31
+ registerFoldersJail(ctx, {
32
+ roots: async (session) => {
33
+ const root = rootOf();
34
+ return root === void 0 ? void 0 : await storyRoots(root, sessionFolder(join(root, "sessions"), session));
35
+ },
36
+ workspace: () => workspaceOf(rootOf() ?? "")
37
+ });
26
38
  ctx.on("agent/created", ({ agent }) => {
27
39
  helpers.get(agent.session.id)?.setup(agent);
28
40
  });
41
+ ctx.on("agent/pre-step", async (payload, next) => {
42
+ const decision = await next();
43
+ const selected = payload.agent.model.current();
44
+ if (decision.kind === "enter") await ctx.get("roleplayOrchestration")?.residency?.ensure("main", selected === void 0 ? void 0 : {
45
+ provider: selected.provider,
46
+ model: selected.model
47
+ });
48
+ return decision;
49
+ });
29
50
  }
30
51
  export { apply, inject, name };
31
52