@dsh-agentic-roleplay/core 0.9.1 → 0.10.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.
- package/README.md +1 -1
- package/lib/{access-CfQWbNZP.js → access-CXtaZNbx.js} +50 -2
- package/lib/{authoring-tools-C_l07RYn.js → authoring-tools-C6Hzy8jU.js} +1571 -1301
- package/lib/authoring.js +19 -8
- package/lib/{child-lYYeOwl2.js → child-C8r8AFpm.js} +150 -14
- package/lib/client.js +6295 -3329
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +3 -3
- package/lib/doctor.js +3 -3
- package/lib/{gallery-q7niLtWn.js → gallery-CtG-bDzz.js} +5 -9
- package/lib/{generator-BpjPrvHe.js → generator-nLoPM5MF.js} +2 -2
- package/lib/helper.js +1 -1
- package/lib/{hooks-DNaDzMjW.js → hooks-BuQ61nvQ.js} +207 -56
- package/lib/images.js +4 -4
- package/lib/index.js +1312 -125
- package/lib/{library-CIkxhf_R.js → library-CH-ahlm0.js} +7 -14
- package/lib/{lorebook-author-tools-BiMDmdFi.js → lorebook-author-tools-B6_Jj8oe.js} +7 -7
- package/lib/lorebook-authoring.js +4 -4
- package/lib/{narration-CjB_KwwY.js → narration-B0hConSw.js} +11 -53
- package/lib/orchestration.js +196 -14
- package/lib/{pack-jail-B35Vx3hT.js → pack-jail-OZSgU85i.js} +11 -11
- package/lib/{packs-BajKw7S9.js → packs-B88bxt8E.js} +2 -2
- package/lib/{presenter-agent-jgtuTwZr.js → presenter-agent-D-WNs626.js} +12 -17
- package/lib/{preset-DWgkcPau.js → preset-DNuqvMan.js} +4 -4
- package/lib/{preset-author-tools-BhuYIKms.js → preset-author-tools-CDwavcTb.js} +7 -7
- package/lib/preset-authoring.js +5 -5
- package/lib/{presets-9GzaSELc.js → presets-9_MNxwaw.js} +105 -10
- package/lib/{reflection-4L0Plvct.js → reflection-BvM0w1R4.js} +179 -112
- package/lib/{text-CbGQhK1-.js → text-CzqhC8sT.js} +11 -1
- package/lib/{turn-guard-sCUXmp-5.js → turn-guard-Ygdww1Wt.js} +3 -3
- package/package.json +2 -2
- package/prompts/en/checks/conflict.md +1 -1
- package/prompts/en/checks/decide-conflict.md +1 -1
- package/prompts/en/checks/decide-opening.md +1 -1
- package/prompts/en/checks/decide-same-value.md +1 -1
- package/prompts/en/checks/decide-sheet.md +1 -1
- package/prompts/en/checks/decide-stated.md +1 -0
- package/prompts/en/checks/fidelity.md +1 -0
- package/prompts/zh/checks/conflict.md +1 -1
- package/prompts/zh/checks/decide-conflict.md +1 -1
- package/prompts/zh/checks/decide-opening.md +1 -1
- package/prompts/zh/checks/decide-same-value.md +1 -1
- package/prompts/zh/checks/decide-sheet.md +1 -1
- package/prompts/zh/checks/decide-stated.md +1 -0
- package/prompts/zh/checks/fidelity.md +1 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The UI, orchestration, world authoring, media, and filesystem integration plugin behind DSH Agentic Roleplay.
|
|
4
4
|
|
|
5
|
-
It provides the bounded game-master loop, point-of-view character agents, world and session interfaces, authoring agents and tools that ask before changing files by default, resumable character-card import with draft repair, assisted card-version updates, world-defined commands, story compaction, speech integration, and image-generation workflows. It turns the structured state supplied by [`@dsh-agentic-roleplay/state`](https://www.npmjs.com/package/@dsh-agentic-roleplay/state) into a playable and editable experience.
|
|
5
|
+
It provides the bounded game-master loop, point-of-view character agents, world and session interfaces, isolated world playtests, authoring agents and tools that ask before changing files by default, resumable character-card import with draft repair, assisted card-version updates, story transcripts and archives, world-defined commands, story compaction, speech integration, and image-generation workflows. It turns the structured state supplied by [`@dsh-agentic-roleplay/state`](https://www.npmjs.com/package/@dsh-agentic-roleplay/state) into a playable and editable experience.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { basename, dirname, join } from "node:path";
|
|
2
|
+
import { chmodSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { chmod, mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
1
5
|
// src/shared/chat.ts
|
|
2
6
|
const CHAT_PREFIX = "session-";
|
|
3
7
|
const UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
@@ -135,6 +139,50 @@ const VARIABLE_VISIBILITIES = [
|
|
|
135
139
|
always: false,
|
|
136
140
|
builtin: true
|
|
137
141
|
}));
|
|
142
|
+
// src/host/atomic-write.ts
|
|
143
|
+
/**
|
|
144
|
+
* Replaces a file in one step: the data goes to a temporary file in the same folder and is renamed over the file, so an interruption leaves the old file or the new one,
|
|
145
|
+
* never half of either. Every writer of a file someone else may read at the same time goes through here.
|
|
146
|
+
*/
|
|
147
|
+
async function atomicWrite(file, data, options = {}) {
|
|
148
|
+
if (options.createDirectory === true) await mkdir(dirname(file), { recursive: true });
|
|
149
|
+
const temporary = join(dirname(file), `.${basename(file)}.${process.pid}.${randomUUID()}.tmp`);
|
|
150
|
+
try {
|
|
151
|
+
const mode = options.mode ?? await stat(file).then((value) => value.mode & 511, (error) => {
|
|
152
|
+
if (error.code === "ENOENT") return 420;
|
|
153
|
+
throw error;
|
|
154
|
+
});
|
|
155
|
+
await writeFile(temporary, data, { mode });
|
|
156
|
+
await chmod(temporary, mode);
|
|
157
|
+
await rename(temporary, file);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
await rm(temporary, { force: true });
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/** A JSON file written the same way, with the indentation given (none by default) and a final newline when it is indented. */
|
|
164
|
+
async function atomicWriteJson(file, value, options = {}) {
|
|
165
|
+
const { indent, ...rest } = options;
|
|
166
|
+
await atomicWrite(file, indent === void 0 ? JSON.stringify(value) : `${JSON.stringify(value, null, indent)}\n`, rest);
|
|
167
|
+
}
|
|
168
|
+
/** The synchronous form, for the few writers that cannot wait (the chat settings, read at every step). */
|
|
169
|
+
function atomicWriteSync(file, data) {
|
|
170
|
+
const temporary = join(dirname(file), `.${basename(file)}.${process.pid}.${randomUUID()}.tmp`);
|
|
171
|
+
try {
|
|
172
|
+
let mode = 420;
|
|
173
|
+
try {
|
|
174
|
+
mode = statSync(file).mode & 511;
|
|
175
|
+
} catch (error) {
|
|
176
|
+
if (error.code !== "ENOENT") throw error;
|
|
177
|
+
}
|
|
178
|
+
writeFileSync(temporary, data, { mode });
|
|
179
|
+
chmodSync(temporary, mode);
|
|
180
|
+
renameSync(temporary, file);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
rmSync(temporary, { force: true });
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
138
186
|
// src/host/prompts/access.ts
|
|
139
187
|
/** The prompt `id` in `language`, from the library of the agent's own context. */
|
|
140
188
|
function promptFor(agent, id, language, variables) {
|
|
@@ -142,6 +190,6 @@ function promptFor(agent, id, language, variables) {
|
|
|
142
190
|
if (library === void 0) throw new Error("the prompt library is not running");
|
|
143
191
|
return library.text(id, language, variables, roleplaySessionOf(agent.session.id));
|
|
144
192
|
}
|
|
145
|
-
export {
|
|
193
|
+
export { VARIABLE_KINDS as a, chatSessionId as c, atomicWriteSync as i, roleplaySessionOf as l, atomicWrite as n, VARIABLE_SUBJECTS as o, atomicWriteJson as r, VARIABLE_VISIBILITIES as s, promptFor as t };
|
|
146
194
|
|
|
147
|
-
//# sourceMappingURL=access-
|
|
195
|
+
//# sourceMappingURL=access-CXtaZNbx.js.map
|