@dsh-agentic-roleplay/core 0.3.4 → 0.3.6
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/lib/authoring.js +5 -3
- package/lib/client.js +3260 -493
- package/lib/client.js.map +1 -1
- package/lib/{deliver-CpZOxBX5.js → deliver-BBgciEEK.js} +3 -2
- package/lib/doctor.js +3 -3
- package/lib/{gallery-CtFDL22W.js → gallery-DIEgETzU.js} +2 -2
- package/lib/generator-DJ48HxPI.js +145 -0
- package/lib/{hooks-KTCR3fNJ.js → hooks-DkwFGtNH.js} +3 -3
- package/lib/images.js +4 -3
- package/lib/index.js +889 -52
- package/lib/language-BgyxtB2h.js +38 -0
- package/lib/{generator-B6FxlKOV.js → library-9JB9zw5a.js} +2 -143
- package/lib/{language-DWVwi1R7.js → load-CVwJjIJ5.js} +11 -45
- package/lib/lorebook-author-tools-Bj31z1cu.js +619 -0
- package/lib/lorebook-authoring.js +67 -0
- package/lib/orchestration.js +22 -14
- package/lib/pack-jail-2XztyYAX.js +1980 -0
- package/lib/{packs-BYjrAen6.js → packs-xHRCcGdb.js} +3 -29
- package/lib/{presenter-agent-CiEVKcjJ.js → presenter-agent-DnNEG_Mn.js} +4 -3
- package/lib/preset-D0FMSeZ9.js +59 -0
- package/lib/preset-author-tools-BxycmoAr.js +276 -0
- package/lib/preset-authoring.js +53 -0
- package/lib/presets-gkBWAiVb.js +374 -0
- package/lib/{reflection-waxFg1x-.js → reflection-q0UpwXlx.js} +130 -8
- package/lib/{pack-jail-CybSNzxr.js → tools-Dy1fgP6B.js} +454 -2303
- package/package.json +4 -2
- package/prompts/en/import/lorebook.md +7 -0
- package/prompts/en/lorebook/persona.md +1 -0
- package/prompts/en/lorebook/procedure.md +1 -0
- package/prompts/en/lorebook/welcome.md +1 -0
- package/prompts/en/preset/persona.md +1 -0
- package/prompts/en/preset/procedure.md +1 -0
- package/prompts/en/preset/welcome.md +1 -0
- package/prompts/zh/import/lorebook.md +7 -0
- package/prompts/zh/lorebook/persona.md +1 -0
- package/prompts/zh/lorebook/procedure.md +1 -0
- package/prompts/zh/lorebook/welcome.md +1 -0
- package/prompts/zh/preset/persona.md +1 -0
- package/prompts/zh/preset/procedure.md +1 -0
- package/prompts/zh/preset/welcome.md +1 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { t as promptFor } from "./access-EbNdZFbk.js";
|
|
2
2
|
import "./settings-CA6icLL_.js";
|
|
3
|
-
import {
|
|
3
|
+
import { T as SessionNotFoundError, r as parsePlotsFile } from "./load-CVwJjIJ5.js";
|
|
4
4
|
import { n as encodeOutput, r as encodePreview } from "./narration-DK2kiIjE.js";
|
|
5
5
|
import { a as runChild, c as addTokens, i as childTrace, n as childSampling, s as NO_TOKENS, t as childModel, u as estimateAnswer } from "./child-CFjnaTZt.js";
|
|
6
|
+
import { a as wrongLanguage } from "./language-BgyxtB2h.js";
|
|
6
7
|
import { join } from "node:path";
|
|
7
8
|
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
8
9
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
@@ -1963,4 +1964,4 @@ function deliverNow(session, notes, clock) {
|
|
|
1963
1964
|
//#endregion
|
|
1964
1965
|
export { observeAsPlayer as A, RESULTS as B, parseOoc as C, notesOfSession as D, clearNotes as E, describeWhen as F, languageOf as H, endRound as I, readTime as L, ClockError as M, beginTurn as N, putNote as O, describeTime as P, skipTime as R, MAX_OOC_ANSWER as S, addToNote as T, translator as U, answerLimits as V, pacingAdvice as _, forgetRunDetails as a, populatePlots as b, readRunDetail as c, externalTools as d, externalWithheld as f, describePacingAdvice as g, PLOTS_METADATA_KEY as h, readUsage as i, observeSurroundings as j, readNotes as k, recordActivity as l, createTools$1 as m, readWithdrawn as n, keepRunDetail as o, PREVIEW_TOOL as p, addUsage as r, readActivity as s, deliverNow as t, externalGiven as u, plotAuthorNeeded as v, toolEnabled as w, AUTHORING_NEEDS as x, plotProgressOf as y, zoneOf as z };
|
|
1965
1966
|
|
|
1966
|
-
//# sourceMappingURL=deliver-
|
|
1967
|
+
//# sourceMappingURL=deliver-BBgciEEK.js.map
|
package/lib/doctor.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as chatSessionId } from "./access-EbNdZFbk.js";
|
|
2
|
-
import "./
|
|
3
|
-
import { d as externalTools } from "./deliver-
|
|
2
|
+
import "./load-CVwJjIJ5.js";
|
|
3
|
+
import { d as externalTools } from "./deliver-BBgciEEK.js";
|
|
4
4
|
import { a as liveSettings } from "./narration-DK2kiIjE.js";
|
|
5
5
|
import { n as doctorSessionOf } from "./doctor-chat-ByDfCMeo.js";
|
|
6
|
-
import { t as externalToolLimit } from "./hooks-
|
|
6
|
+
import { t as externalToolLimit } from "./hooks-DkwFGtNH.js";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as mediaTypeOf, h as writeImageFileMetadata, m as sidecarOf, p as readImageFileMetadata, r as LIBRARY_FOLDER, v as mapLimit } from "./library-9JB9zw5a.js";
|
|
2
2
|
import { join, sep } from "node:path";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { lstat, mkdir, readFile, readdir, realpath, rename, stat, writeFile } from "node:fs/promises";
|
|
@@ -192,4 +192,4 @@ async function updateImage(sessionFolder, path, update) {
|
|
|
192
192
|
//#endregion
|
|
193
193
|
export { updateImage as i, galleryFile as n, listGallery as r, describeGalleryImage as t };
|
|
194
194
|
|
|
195
|
-
//# sourceMappingURL=gallery-
|
|
195
|
+
//# sourceMappingURL=gallery-DIEgETzU.js.map
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { c as referenceImagePath, l as sceneImagePath, u as writeImage } from "./library-9JB9zw5a.js";
|
|
2
|
+
//#region src/host/images/generator.ts
|
|
3
|
+
const unique = (values) => [...new Set(values.map((value) => value.trim()).filter((value) => value !== ""))];
|
|
4
|
+
/** What a reference image shows: the subject and its stable look. */
|
|
5
|
+
function referenceDescription(request) {
|
|
6
|
+
return `${request.subject.name} (${request.subject.kind}): ${request.identity.description}`.trim();
|
|
7
|
+
}
|
|
8
|
+
/** What a scene image shows: the established moment, then how each subject looks in it. */
|
|
9
|
+
function transientDescription(request) {
|
|
10
|
+
return [request.scene.trim(), ...request.subjects.map((subject) => subject.transient.trim() === "" ? void 0 : `${subject.name}: ${subject.transient.trim()}`)].filter((part) => part !== void 0 && part !== "").join("\n");
|
|
11
|
+
}
|
|
12
|
+
function lines(parts) {
|
|
13
|
+
return parts.filter((part) => part !== void 0 && part.trim() !== "").join("\n");
|
|
14
|
+
}
|
|
15
|
+
function referencePrompt(request) {
|
|
16
|
+
const { subject, identity } = request;
|
|
17
|
+
return lines([
|
|
18
|
+
request.artDirection,
|
|
19
|
+
`Create a canonical reference image of the ${subject.kind} ${subject.name}.`,
|
|
20
|
+
identity.description,
|
|
21
|
+
identity.tags.length === 0 ? void 0 : `Stable visual traits: ${identity.tags.join(", ")}.`,
|
|
22
|
+
"Show the subject clearly and neutrally. Do not add story events or temporary changes.",
|
|
23
|
+
identity.negativeTags.length === 0 ? void 0 : `Avoid: ${identity.negativeTags.join(", ")}.`
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
function transientPrompt(request) {
|
|
27
|
+
return lines([
|
|
28
|
+
request.artDirection,
|
|
29
|
+
`Illustrate this established story moment: ${request.scene}`,
|
|
30
|
+
...request.subjects.map((subject) => lines([
|
|
31
|
+
`${subject.kind} ${subject.name}: ${subject.identity.description}`,
|
|
32
|
+
subject.identity.tags.length === 0 ? void 0 : `Stable visual traits: ${subject.identity.tags.join(", ")}.`,
|
|
33
|
+
subject.transient === "" ? void 0 : `Current visible state: ${subject.transient}`
|
|
34
|
+
])),
|
|
35
|
+
"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(", ")}.`
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
async function firstPng(service, prompt, options = {}) {
|
|
40
|
+
const result = await service.generate(prompt, {
|
|
41
|
+
count: 1,
|
|
42
|
+
...options
|
|
43
|
+
});
|
|
44
|
+
const image = result.images[0];
|
|
45
|
+
if (image === void 0) throw new Error(`${service.provider} returned no image`);
|
|
46
|
+
if (image.mediaType !== "image/png") throw new Error(`${service.provider} returned ${image.mediaType}; roleplay image storage currently requires PNG`);
|
|
47
|
+
return {
|
|
48
|
+
data: new Uint8Array(await image.data.arrayBuffer()),
|
|
49
|
+
model: result.model,
|
|
50
|
+
...image.revisedPrompt === void 0 ? {} : { revisedPrompt: image.revisedPrompt }
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Generates the stable reference.png of one entity. It is intentionally not registered in the live roleplay loop yet. */
|
|
54
|
+
async function generateReferenceImage(service, request) {
|
|
55
|
+
const prompt = referencePrompt(request);
|
|
56
|
+
const image = await firstPng(service, prompt, request.signal === void 0 ? {} : { signal: request.signal });
|
|
57
|
+
request.signal?.throwIfAborted();
|
|
58
|
+
const path = referenceImagePath(request.root, request.subject);
|
|
59
|
+
const metadata = {
|
|
60
|
+
schema: "dsh-roleplay-image/v3",
|
|
61
|
+
purpose: "reference",
|
|
62
|
+
origin: "generated",
|
|
63
|
+
reusable: true,
|
|
64
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
65
|
+
prompt,
|
|
66
|
+
description: referenceDescription(request),
|
|
67
|
+
tags: unique([request.subject.name, ...request.identity.tags]),
|
|
68
|
+
...image.revisedPrompt === void 0 ? {} : { revisedPrompt: image.revisedPrompt },
|
|
69
|
+
provider: service.provider,
|
|
70
|
+
model: image.model,
|
|
71
|
+
subjects: [{
|
|
72
|
+
...request.subject,
|
|
73
|
+
identityVersion: request.identity.version
|
|
74
|
+
}]
|
|
75
|
+
};
|
|
76
|
+
await writeImage(path, image.data, metadata, { replace: true });
|
|
77
|
+
return path;
|
|
78
|
+
}
|
|
79
|
+
const PNG_SIGNATURE = [
|
|
80
|
+
137,
|
|
81
|
+
80,
|
|
82
|
+
78,
|
|
83
|
+
71,
|
|
84
|
+
13,
|
|
85
|
+
10,
|
|
86
|
+
26,
|
|
87
|
+
10
|
|
88
|
+
];
|
|
89
|
+
/** Takes a picture the person brought as the stable reference.png of one entity, replacing the one there. Only PNG is stored, so any other format is refused. */
|
|
90
|
+
async function uploadReferenceImage(request) {
|
|
91
|
+
if (request.png.length < PNG_SIGNATURE.length || PNG_SIGNATURE.some((byte, index) => request.png[index] !== byte)) throw new Error("the portrait must be a PNG picture: convert it first");
|
|
92
|
+
const path = referenceImagePath(request.root, request.subject);
|
|
93
|
+
const metadata = {
|
|
94
|
+
schema: "dsh-roleplay-image/v3",
|
|
95
|
+
purpose: "reference",
|
|
96
|
+
origin: "uploaded",
|
|
97
|
+
reusable: true,
|
|
98
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
99
|
+
description: `${request.subject.name}, a picture brought by the author.`,
|
|
100
|
+
tags: [request.subject.name],
|
|
101
|
+
...request.originalName === void 0 ? {} : { originalName: request.originalName },
|
|
102
|
+
subjects: [request.subject]
|
|
103
|
+
};
|
|
104
|
+
await writeImage(path, request.png, metadata, { replace: true });
|
|
105
|
+
return path;
|
|
106
|
+
}
|
|
107
|
+
/** Generates one immutable scene image for a timeline node. It is intentionally not registered in the live roleplay loop yet. */
|
|
108
|
+
async function generateTransientImage(service, request) {
|
|
109
|
+
if (request.subjects.length === 0) throw new Error("a transient image needs at least one subject");
|
|
110
|
+
const prompt = transientPrompt(request);
|
|
111
|
+
const image = await firstPng(service, prompt, {
|
|
112
|
+
...request.references === void 0 ? {} : { references: request.references },
|
|
113
|
+
...request.signal === void 0 ? {} : { signal: request.signal }
|
|
114
|
+
});
|
|
115
|
+
request.signal?.throwIfAborted();
|
|
116
|
+
const path = sceneImagePath(request.root, request.timelineNode, request.serial);
|
|
117
|
+
const metadata = {
|
|
118
|
+
schema: "dsh-roleplay-image/v3",
|
|
119
|
+
purpose: "transient",
|
|
120
|
+
origin: "generated",
|
|
121
|
+
reusable: request.reusable === true,
|
|
122
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
123
|
+
prompt,
|
|
124
|
+
description: transientDescription(request),
|
|
125
|
+
tags: unique(request.subjects.flatMap((subject) => [subject.name, ...subject.identity.tags])),
|
|
126
|
+
...image.revisedPrompt === void 0 ? {} : { revisedPrompt: image.revisedPrompt },
|
|
127
|
+
provider: service.provider,
|
|
128
|
+
model: image.model,
|
|
129
|
+
subjects: request.subjects.map(({ identity, transient: _transient, ...subject }) => ({
|
|
130
|
+
...subject,
|
|
131
|
+
identityVersion: identity.version
|
|
132
|
+
})),
|
|
133
|
+
source: {
|
|
134
|
+
turn: request.turn,
|
|
135
|
+
timelineNode: request.timelineNode,
|
|
136
|
+
...request.segment === void 0 ? {} : { segment: request.segment }
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
await writeImage(path, image.data, metadata);
|
|
140
|
+
return path;
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { uploadReferenceImage as a, transientPrompt as i, generateTransientImage as n, referencePrompt as r, generateReferenceImage as t };
|
|
144
|
+
|
|
145
|
+
//# sourceMappingURL=generator-DJ48HxPI.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as roleplaySessionOf } from "./access-EbNdZFbk.js";
|
|
2
2
|
import { a as WORLD_RULES_KEY, o as rulesOf } from "./settings-CA6icLL_.js";
|
|
3
|
-
import {
|
|
4
|
-
import { A as observeAsPlayer, C as parseOoc, E as clearNotes, F as describeWhen, H as languageOf, I as endRound, L as readTime, N as beginTurn, O as putNote, R as skipTime, T as addToNote, U as translator, _ as pacingAdvice, a as forgetRunDetails, f as externalWithheld, g as describePacingAdvice, j as observeSurroundings, k as readNotes, l as recordActivity, o as keepRunDetail, r as addUsage, t as deliverNow, v as plotAuthorNeeded, w as toolEnabled, z as zoneOf } from "./deliver-
|
|
3
|
+
import { y as shippedText } from "./load-CVwJjIJ5.js";
|
|
4
|
+
import { A as observeAsPlayer, C as parseOoc, E as clearNotes, F as describeWhen, H as languageOf, I as endRound, L as readTime, N as beginTurn, O as putNote, R as skipTime, T as addToNote, U as translator, _ as pacingAdvice, a as forgetRunDetails, f as externalWithheld, g as describePacingAdvice, j as observeSurroundings, k as readNotes, l as recordActivity, o as keepRunDetail, r as addUsage, t as deliverNow, v as plotAuthorNeeded, w as toolEnabled, z as zoneOf } from "./deliver-BBgciEEK.js";
|
|
5
5
|
import { a as liveSettings } from "./narration-DK2kiIjE.js";
|
|
6
6
|
import { o as tokensOf } from "./child-CFjnaTZt.js";
|
|
7
7
|
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
@@ -1057,4 +1057,4 @@ function installHooks(ctx, deps) {
|
|
|
1057
1057
|
//#endregion
|
|
1058
1058
|
export { writeVerdicts as a, readVerdicts as i, installHooks as n, storesOf as r, externalToolLimit as t };
|
|
1059
1059
|
|
|
1060
|
-
//# sourceMappingURL=hooks-
|
|
1060
|
+
//# sourceMappingURL=hooks-DkwFGtNH.js.map
|
package/lib/images.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
3
|
-
import {
|
|
1
|
+
import { _ as withPngMetadata, a as inheritImages, c as referenceImagePath, g as readPngMetadata, i as entityImageDirectory, l as sceneImagePath, o as nextSceneSerial, s as readImageMetadata, t as addToLibrary } from "./library-9JB9zw5a.js";
|
|
2
|
+
import { i as transientPrompt, n as generateTransientImage, r as referencePrompt, t as generateReferenceImage } from "./generator-DJ48HxPI.js";
|
|
3
|
+
import { i as updateImage, r as listGallery } from "./gallery-DIEgETzU.js";
|
|
4
|
+
import { a as tokensOf, i as searchImages, n as interpretImage, o as present, r as imageTools, s as presentedFor, t as runImagePresenter } from "./presenter-agent-DnNEG_Mn.js";
|
|
4
5
|
export { addToLibrary, entityImageDirectory, generateReferenceImage, generateTransientImage, imageTools, inheritImages, interpretImage, listGallery, nextSceneSerial, present, presentedFor, readImageMetadata, readPngMetadata, referenceImagePath, referencePrompt, runImagePresenter, sceneImagePath, searchImages, tokensOf, transientPrompt, updateImage, withPngMetadata };
|