@dsh-agentic-roleplay/core 0.12.0 → 0.12.2
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/cordis.patch.yml +108 -0
- package/lib/{access-DAw54-NI.js → access-Csp80TFX.js} +2 -2
- package/lib/{authoring-tools-4NgDhIJV.js → authoring-tools-BZr4bgBy.js} +25 -771
- package/lib/authoring.js +136 -12
- package/lib/{child-D3QUNb3m.js → child-DTdY14S9.js} +54 -6
- package/lib/client.js +16457 -1938
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +3 -3
- package/lib/dev-context-Cgv_wZbG.js +50 -0
- package/lib/doctor.js +6 -3
- package/lib/{gallery-Ct6nm4UQ.js → gallery-BNg0rPTp.js} +3 -3
- package/lib/{generator-CI8fOnXy.js → generator-9-5at9cZ.js} +2 -2
- package/lib/helper.js +5 -9
- package/lib/{hooks-BNeoGMHZ.js → hooks-Dtq5KZQX.js} +47 -16
- package/lib/images.js +4 -4
- package/lib/index.js +152 -476
- package/lib/{jail-BIF79PJO.js → jail-DVbPSC0R.js} +2 -2
- package/lib/{library-BF9ZMSFz.js → library-DTxakw0z.js} +2 -2
- package/lib/{lorebook-author-tools-DBk-V0hp.js → lorebook-author-tools-BjcEUo22.js} +19 -6
- package/lib/lorebook-authoring.js +13 -5
- package/lib/{narration-xvErE2yp.js → narration--K2XVIHI.js} +2 -2
- package/lib/orchestration.js +33 -12
- package/lib/{pack-jail-C8EyX9Ix.js → pack-jail-Dt0VTsu0.js} +558 -23
- package/lib/{packs-S0SzrVv-.js → packs-DWfR2Ted.js} +2 -2
- package/lib/{presenter-agent-Bc478nTA.js → presenter-agent-vFOxIuWv.js} +9 -9
- package/lib/{preset-SJZyw0kt.js → preset-Dv5YF2qj.js} +4 -4
- package/lib/{preset-author-tools-CzogjK42.js → preset-author-tools-BUzO9mTW.js} +8 -7
- package/lib/preset-authoring.js +12 -6
- package/lib/{reflection-buQiSdvq.js → reflection-Dd3pEiZB.js} +14 -15
- package/lib/{presets-DQ5rioMh.js → serial-BUaJGwVy.js} +1241 -390
- package/lib/{turn-guard-BSAba8sp.js → turn-guard-87NE-Cnp.js} +3 -3
- package/locale/de.json +6 -0
- package/locale/en.json +6 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +34 -34
- package/prompts/en/import/style.md +2 -1
- package/prompts/en/world/procedure.md +1 -1
- package/prompts/zh/import/style.md +2 -1
- package/prompts/zh/world/procedure.md +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as roleplaySessionOf } from "./child-
|
|
1
|
+
import { j as roleplaySessionOf } from "./child-DTdY14S9.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-
|
|
107
|
+
//# sourceMappingURL=jail-DVbPSC0R.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as atomicWrite } from "./access-
|
|
1
|
+
import { n as atomicWrite } from "./access-Csp80TFX.js";
|
|
2
2
|
import { i as translator, n as withoutExtension, r as languageOf, t as trimCharacters } from "./text-Dfv8S8eq.js";
|
|
3
3
|
import { dirname, extname, join } from "node:path";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
@@ -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-
|
|
377
|
+
//# sourceMappingURL=library-DTxakw0z.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./access-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import "./access-Csp80TFX.js";
|
|
2
|
+
import { Rt as ImportCardError, i as contextOf, r as MAX_PREVIEW_TEXT } from "./authoring-tools-BZr4bgBy.js";
|
|
3
|
+
import { B as createPresetFromGuidance, bt as IMPORT_FOLDER, cn as LORE_KINDS, dt as lorebookDirectory, ft as readLorebook$1, gt as cleanText, ht as writeLorebookEntry, ln as LORE_SCOPES, mt as updateLorebookInfo, ot as deleteLorebookEntry, st as entriesOf, ut as loadLorebook, vt as partsOf, yt as withPlayer } from "./serial-BUaJGwVy.js";
|
|
4
|
+
import { F as textLanguage, I as wrongLanguage, at as shippedPromptsDirectory } from "./hooks-Dtq5KZQX.js";
|
|
5
5
|
import { i as translator, r as languageOf } from "./text-Dfv8S8eq.js";
|
|
6
|
-
import {
|
|
6
|
+
import { C as slug, T as uniqueKey, w as trOf, x as mapLimit } from "./library-DTxakw0z.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";
|
|
@@ -151,6 +151,14 @@ const isSteeringTarget = (value) => Object.hasOwn(STEERING_TARGETS, value);
|
|
|
151
151
|
const RULES_TARGETS = ["game-master", "character-rules"];
|
|
152
152
|
/** Whether writing to the prompt changes how the models are told to run the game, not only how the story reads. */
|
|
153
153
|
const isRulesTarget = (target) => RULES_TARGETS.includes(target);
|
|
154
|
+
/** Words of the answer's own vocabulary that a constrained reply wrote into the guidance field instead of the instruction. */
|
|
155
|
+
const LABELS = /* @__PURE__ */ new Set([
|
|
156
|
+
"knowledge",
|
|
157
|
+
"steering",
|
|
158
|
+
"skip",
|
|
159
|
+
...Object.keys(STEERING_TARGETS)
|
|
160
|
+
]);
|
|
161
|
+
const isLabel = (guidance) => LABELS.has(guidance.toLowerCase()) || /^[a-z][a-z0-9_-]*$/i.test(guidance);
|
|
154
162
|
const DECISIONS_SCHEMA = {
|
|
155
163
|
type: "object",
|
|
156
164
|
properties: { entries: {
|
|
@@ -247,6 +255,7 @@ function problemOf(answer, batch) {
|
|
|
247
255
|
const given = answer.entries ?? [];
|
|
248
256
|
const wanted = new Set(batch.map((entry) => entry.ref));
|
|
249
257
|
const seen = /* @__PURE__ */ new Set();
|
|
258
|
+
const language = textLanguage(batch.map((entry) => entry.text).join(" "));
|
|
250
259
|
for (const decision of given) {
|
|
251
260
|
if (!wanted.has(decision.ref)) return `entry ${decision.ref} was not given; the entries are ${[...wanted].join(", ")}`;
|
|
252
261
|
if (seen.has(decision.ref)) return `entry ${decision.ref} is decided twice`;
|
|
@@ -255,6 +264,9 @@ function problemOf(answer, batch) {
|
|
|
255
264
|
if (decision.role === "knowledge" && decision.scope === "listed" && decision.has_secrets !== true && strings(decision.known_by).length === 0) return `entry ${decision.ref} is listed but names nobody who knows it: use everyone, or name them`;
|
|
256
265
|
if (decision.role === "steering" && (!isSteeringTarget(text(decision.target)) || text(decision.guidance) === "")) return `entry ${decision.ref} is steering: say where it belongs (${Object.keys(STEERING_TARGETS).join(", ")}) and give the guidance`;
|
|
257
266
|
const source = batch.find((entry) => entry.ref === decision.ref);
|
|
267
|
+
if (decision.role === "steering" && isLabel(text(decision.guidance))) return `the guidance for entry ${decision.ref} is a label ("${text(decision.guidance)}"), not an instruction: write what the entry asks for`;
|
|
268
|
+
const wrong = decision.role === "steering" && language !== void 0 ? wrongLanguage(language, { [`the guidance for entry ${decision.ref}`]: text(decision.guidance) }) : void 0;
|
|
269
|
+
if (wrong !== void 0) return wrong;
|
|
258
270
|
if (decision.role === "steering" && source !== void 0 && source.text.length > MAX_STEERING_SOURCE_CHARS) return `entry ${decision.ref} is ${source.text.length} characters long, too long to be an instruction: an entry that describes a person, a place or history is knowledge, and what is thrown away as steering is lost. Make it knowledge, or skip it if it is neither`;
|
|
259
271
|
if (decision.role === "steering" && source !== void 0 && text(decision.guidance).length < source.text.length * MIN_STEERING_SHARE) return `the guidance for entry ${decision.ref} is much shorter than the entry (${text(decision.guidance).length} of ${source.text.length} characters): keep everything the entry asks for, or, if it is not an instruction, make it knowledge`;
|
|
260
272
|
}
|
|
@@ -644,6 +656,7 @@ async function lorebookApproval(exec, next, state) {
|
|
|
644
656
|
if (!LOREBOOK_MUTATION_TOOLS.includes(exec.name) || exec.agent === void 0 || lorebookOfChat(exec.agent.session.id) === void 0) return await next();
|
|
645
657
|
const args = exec.arguments;
|
|
646
658
|
const chat = exec.agent.session.id;
|
|
659
|
+
if (state.auto?.() === true && !(exec.name === "apply_steering" && state.waiting(chat).rules)) return await next();
|
|
647
660
|
if (exec.name === "import_lorebook") {
|
|
648
661
|
if (!state.carries(chat)) return await next();
|
|
649
662
|
return {
|
|
@@ -696,4 +709,4 @@ async function lorebookApproval(exec, next, state) {
|
|
|
696
709
|
}
|
|
697
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 };
|
|
698
711
|
|
|
699
|
-
//# sourceMappingURL=lorebook-author-tools-
|
|
712
|
+
//# sourceMappingURL=lorebook-author-tools-BjcEUo22.js.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { n as limitAuthoringAgents
|
|
2
|
-
import { t as guardAuthoringTurns } from "./turn-guard-
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
1
|
+
import { n as limitAuthoringAgents } from "./authoring-tools-BZr4bgBy.js";
|
|
2
|
+
import { t as guardAuthoringTurns } from "./turn-guard-87NE-Cnp.js";
|
|
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-BjcEUo22.js";
|
|
5
|
+
import "./hooks-Dtq5KZQX.js";
|
|
6
|
+
import { dt as lorebookDirectory } from "./serial-BUaJGwVy.js";
|
|
5
7
|
import { join } from "node:path";
|
|
6
8
|
import { existsSync, readdirSync } from "node:fs";
|
|
7
9
|
// src/lorebook-authoring.ts
|
|
@@ -17,6 +19,8 @@ const inject = [
|
|
|
17
19
|
];
|
|
18
20
|
/** The lorebook authoring chat: reads and writes the entries of one library lorebook, each write approved by the person. */
|
|
19
21
|
function apply(ctx) {
|
|
22
|
+
silenceHarnessDevContext(ctx);
|
|
23
|
+
silenceRuntimeContext(ctx);
|
|
20
24
|
const library = () => ctx.roleplayRoot.path;
|
|
21
25
|
const reader = new LorebookReader(library);
|
|
22
26
|
const prompting = {
|
|
@@ -44,9 +48,13 @@ function apply(ctx) {
|
|
|
44
48
|
const book = lorebookOfChat(chat);
|
|
45
49
|
return book === void 0 ? void 0 : ctx.roleplayAuthoringLanguages.get(`lorebook:${book}`);
|
|
46
50
|
}, () => ctx.roleplayImport.settings.reasoning);
|
|
51
|
+
ctx.on("session/event", (session, event) => {
|
|
52
|
+
if (event.type === "turn/end" && session.header.origin !== "subagent" && lorebookOfChat(session.id) !== void 0) ctx.roleplayImport.turnEnded(session.id);
|
|
53
|
+
});
|
|
47
54
|
ctx.on("tools/pre-execute", (exec, next) => lorebookApproval(exec, next, {
|
|
48
55
|
carries,
|
|
49
|
-
waiting
|
|
56
|
+
waiting,
|
|
57
|
+
auto: () => ctx.roleplayImport.settings.approval === "auto"
|
|
50
58
|
}));
|
|
51
59
|
const languageOf = (context) => {
|
|
52
60
|
const chat = context.agent?.session.id;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as atomicWriteSync } from "./access-
|
|
1
|
+
import { i as atomicWriteSync } from "./access-Csp80TFX.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
|
|
488
|
+
//# sourceMappingURL=narration--K2XVIHI.js.map
|
package/lib/orchestration.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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 AUTHORING_NEEDS, a as externalGiven, c as PREVIEW_TOOL, d as toolEnabled, f as MAX_OOC_ANSWER, gt as zoneOf, ht as describeWhen, i as characterRunner, l as createTools$1, mt as ClockError, n as installHooks, ot as shippedText, p as storesOf, tt as languageOf, u as record, ut as ReflectionRefusedError, v as readVerdicts, y as writeVerdicts } from "./hooks-Dtq5KZQX.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-Dd3pEiZB.js";
|
|
6
|
+
import { A as routeVerdicts, E as askYesNo, Mt as splitPanels, O as modeFor, T as announceProblem, fn as INTENT_STATUSES, j as yesAt, k as noAt, n as STANDING_PROMPT, sn as guarded } from "./serial-BUaJGwVy.js";
|
|
7
7
|
import { i as translator, r as languageOf$1 } from "./text-Dfv8S8eq.js";
|
|
8
|
-
import {
|
|
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";
|
|
9
10
|
import { a as workspaceOf, n as storyRoots } from "./service-mRKwpWjX.js";
|
|
10
|
-
import { C as slug, T as uniqueKey, t as addToLibrary } from "./library-
|
|
11
|
-
import { _ as API_PREFIX } from "./packs-
|
|
12
|
-
import { i as updateImage, r as listGallery, t as describeGalleryImage } from "./gallery-
|
|
13
|
-
import { c as presentedFor, i as findImages, n as interpretImage, s as present, t as runImagePresenter } from "./presenter-agent-
|
|
11
|
+
import { C as slug, T as uniqueKey, t as addToLibrary } from "./library-DTxakw0z.js";
|
|
12
|
+
import { _ as API_PREFIX } from "./packs-DWfR2Ted.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";
|
|
14
15
|
import { join } from "node:path";
|
|
15
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";
|
|
16
17
|
import { existsSync } from "node:fs";
|
|
@@ -3983,6 +3984,17 @@ var TurnEngine = class {
|
|
|
3983
3984
|
this.states.get(chat)?.cancel.abort();
|
|
3984
3985
|
this.reflectionCancels.get(chat)?.abort();
|
|
3985
3986
|
}
|
|
3987
|
+
/** The same for every chat the engine has seen; used when the plugin unloads. */
|
|
3988
|
+
stopAll() {
|
|
3989
|
+
for (const chat of /* @__PURE__ */ new Set([
|
|
3990
|
+
...this.states.keys(),
|
|
3991
|
+
...this.working.keys(),
|
|
3992
|
+
...this.reflectionCancels.keys()
|
|
3993
|
+
])) this.stop(chat);
|
|
3994
|
+
}
|
|
3995
|
+
async quiesceAll() {
|
|
3996
|
+
await Promise.all([.../* @__PURE__ */ new Set([...this.working.keys(), ...this.chains.keys()])].map((chat) => this.quiesce(chat)));
|
|
3997
|
+
}
|
|
3986
3998
|
/** Resolves when nothing of the chat writes to its story any more: the records, what was made up being fitted in, the characters away, the suggestions. */
|
|
3987
3999
|
async quiesce(chat, options = {}) {
|
|
3988
4000
|
for (;;) {
|
|
@@ -4000,6 +4012,7 @@ var TurnEngine = class {
|
|
|
4000
4012
|
this.chains.delete(chat);
|
|
4001
4013
|
this.delivered.delete(chat);
|
|
4002
4014
|
this.runs.delete(chat);
|
|
4015
|
+
this.failedRuns.delete(chat);
|
|
4003
4016
|
this.working.delete(chat);
|
|
4004
4017
|
for (const key of this.objections.keys()) if (key.startsWith(`${chat}#`)) this.objections.delete(key);
|
|
4005
4018
|
}
|
|
@@ -4295,6 +4308,10 @@ var ImageJobs = class {
|
|
|
4295
4308
|
this.active.get(id)?.controller.abort();
|
|
4296
4309
|
this.active.delete(id);
|
|
4297
4310
|
}
|
|
4311
|
+
cancelAll() {
|
|
4312
|
+
for (const job of this.active.values()) job.controller.abort();
|
|
4313
|
+
this.active.clear();
|
|
4314
|
+
}
|
|
4298
4315
|
/**
|
|
4299
4316
|
* @param priority - `foreground` when the player asked for the picture, `background` when it is made on its own after a turn and may wait behind the next one.
|
|
4300
4317
|
* @param automatic - the picture was not asked for: the library is looked at first, and the pictures the person brought are described before that.
|
|
@@ -4536,6 +4553,7 @@ const inject = [
|
|
|
4536
4553
|
"agents"
|
|
4537
4554
|
];
|
|
4538
4555
|
function apply(ctx) {
|
|
4556
|
+
silenceHarnessDevContext(ctx);
|
|
4539
4557
|
const boundaries = () => ctx.roleplayOrchestration.boundaries;
|
|
4540
4558
|
const problem = (message) => {
|
|
4541
4559
|
ctx.logger.warn(`roleplay: ${message}`);
|
|
@@ -4799,9 +4817,12 @@ function apply(ctx) {
|
|
|
4799
4817
|
engine.forget(chat);
|
|
4800
4818
|
};
|
|
4801
4819
|
ctx.roleplayOrchestration.quiesce = (chat) => engine.quiesce(chat);
|
|
4802
|
-
return () => {
|
|
4820
|
+
return async () => {
|
|
4803
4821
|
ctx.roleplayOrchestration.halt = () => Promise.resolve();
|
|
4804
4822
|
ctx.roleplayOrchestration.quiesce = () => Promise.resolve();
|
|
4823
|
+
images.cancelAll();
|
|
4824
|
+
engine.stopAll();
|
|
4825
|
+
await engine.quiesceAll();
|
|
4805
4826
|
};
|
|
4806
4827
|
}, "roleplay: halt");
|
|
4807
4828
|
ctx.effect(() => {
|