@dsh-agentic-roleplay/core 0.7.3 → 0.8.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/{authoring-tools-CIsWbq0B.js → authoring-tools-DNnx0Nts.js} +1774 -4517
- package/lib/authoring.js +51 -9
- package/lib/{child-CyCViUKa.js → child-D6mpkkCE.js} +130 -6
- package/lib/client.js +661 -427
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +2 -2
- package/lib/doctor.js +2 -2
- package/lib/{gallery-DmBZ2L5l.js → gallery-D9nG3C78.js} +2 -2
- package/lib/{generator-BmdoTIL2.js → generator-r1Czm7oi.js} +2 -2
- package/lib/helper.js +1 -1
- package/lib/{hooks-C8eELrni.js → hooks-BQCzgggH.js} +92 -8
- package/lib/images.js +4 -4
- package/lib/index.js +920 -739
- package/lib/{library-lVNf9qG_.js → library-zI-2tG7h.js} +25 -8
- package/lib/{lorebook-author-tools-BDOs4i5C.js → lorebook-author-tools-ywaYicwd.js} +7 -7
- package/lib/lorebook-authoring.js +4 -4
- package/lib/{narration-DvFBqmqe.js → narration-CnBlVure.js} +52 -8
- package/lib/orchestration.js +95 -18
- package/lib/{pack-jail-DeTscGT2.js → pack-jail-5EJ-WYyW.js} +30 -68
- package/lib/{packs-CY8ms8v_.js → packs-Cv8hanXJ.js} +2 -2
- package/lib/{presenter-agent-cFR4sos3.js → presenter-agent-BSaMSd3G.js} +6 -6
- package/lib/{preset-n4-j6k4S.js → preset-CWI3-0r1.js} +4 -3
- package/lib/{preset-author-tools-2m4BLtws.js → preset-author-tools-BrJYa2cr.js} +7 -7
- package/lib/preset-authoring.js +5 -5
- package/lib/presets-MwOSMMyu.js +3998 -0
- package/lib/{reflection-CJB5s0ip.js → reflection-zSaMsjKj.js} +127 -127
- package/lib/{text-Cwl5s0j0.js → text-BzudpQLS.js} +9 -1
- package/lib/{turn-guard-BvCs1VxB.js → turn-guard-Cv8pfHEA.js} +6 -2
- package/package.json +2 -2
- package/prompts/en/import/casting.md +14 -0
- package/prompts/en/import/classifier.md +9 -0
- package/prompts/en/import/finish-draft.md +1 -0
- package/prompts/en/import/generator.md +8 -0
- package/prompts/en/import/notice-repair.md +4 -0
- package/prompts/en/import/repair-again.md +3 -0
- package/prompts/en/import/roster.md +1 -0
- package/prompts/en/import/variables.md +1 -0
- package/prompts/en/roleplay/game-master.md +3 -0
- package/prompts/en/roleplay/standing.md +1 -0
- package/prompts/en/world/author.md +1 -1
- package/prompts/zh/import/casting.md +14 -0
- package/prompts/zh/import/classifier.md +9 -0
- package/prompts/zh/import/finish-draft.md +1 -0
- package/prompts/zh/import/generator.md +8 -0
- package/prompts/zh/import/notice-repair.md +4 -0
- package/prompts/zh/import/repair-again.md +3 -0
- package/prompts/zh/import/roster.md +1 -0
- package/prompts/zh/import/variables.md +1 -0
- package/prompts/zh/roleplay/game-master.md +3 -0
- package/prompts/zh/roleplay/standing.md +1 -0
- package/prompts/zh/world/author.md +1 -1
- package/lib/route-C6SHz9j2.js +0 -518
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./access-DtOxFKBK.js";
|
|
2
|
-
import { i as translator, n as withoutExtension, r as languageOf, t as trimCharacters } from "./text-
|
|
2
|
+
import { i as translator, n as withoutExtension, r as languageOf, t as trimCharacters } from "./text-BzudpQLS.js";
|
|
3
3
|
import { dirname, extname, join } from "node:path";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -338,14 +338,22 @@ function libraryName(original, extension, taken) {
|
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
/**
|
|
341
|
-
* Puts
|
|
342
|
-
* shows is not known yet
|
|
341
|
+
* Puts a picture into the library unless the library already holds that picture (the same image, whatever metadata the file carries), whatever it came from: an upload, an address, a generation.
|
|
342
|
+
* Metadata says where it came from and that it is reusable; what it shows is not known yet, and the interpreter fills that in.
|
|
343
|
+
* @param known the hashes of the library when the caller has read them (kept up to date here), to avoid reading the library again for each picture.
|
|
343
344
|
* @throws {Error} when the bytes are not a PNG, JPEG, WebP or GIF image.
|
|
344
|
-
* @returns its path under `images
|
|
345
|
+
* @returns its path under `images/`, and whether it was added or an equal picture was there.
|
|
345
346
|
*/
|
|
346
|
-
async function
|
|
347
|
+
async function addToLibraryOnce(sessionFolder, bytes, originalName, known) {
|
|
347
348
|
const extension = imageExtensionOf(bytes);
|
|
348
349
|
if (extension === void 0 || MEDIA_TYPES[extension] === void 0) throw new Error("only PNG, JPEG, WebP and GIF images can be added");
|
|
350
|
+
const hashes = known ?? await libraryHashes(sessionFolder);
|
|
351
|
+
const hash = pictureHash(bytes);
|
|
352
|
+
const present = hashes.get(hash);
|
|
353
|
+
if (present !== void 0) return {
|
|
354
|
+
path: present,
|
|
355
|
+
added: false
|
|
356
|
+
};
|
|
349
357
|
const directory = join(sessionFolder, "images", LIBRARY_FOLDER);
|
|
350
358
|
await mkdir(directory, { recursive: true });
|
|
351
359
|
const name = libraryName(originalName, extension, (candidate) => existsSync(join(directory, candidate)));
|
|
@@ -363,9 +371,18 @@ async function addToLibrary(sessionFolder, bytes, originalName) {
|
|
|
363
371
|
subjects: [],
|
|
364
372
|
tags: []
|
|
365
373
|
});
|
|
366
|
-
|
|
374
|
+
const path = `${LIBRARY_FOLDER}/${name}`;
|
|
375
|
+
hashes.set(hash, path);
|
|
376
|
+
return {
|
|
377
|
+
path,
|
|
378
|
+
added: true
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
/** {@link addToLibraryOnce} for a caller that only wants the path: a picture the library holds already is not added again. */
|
|
382
|
+
async function addToLibrary(sessionFolder, bytes, originalName) {
|
|
383
|
+
return (await addToLibraryOnce(sessionFolder, bytes, originalName)).path;
|
|
367
384
|
}
|
|
368
385
|
//#endregion
|
|
369
|
-
export { trOf as C, slug as S, writeImageFileMetadata as _, LIBRARY_FOLDER as a, mapLimit as b, nextSceneSerial as c, sceneImagePath as d, writeImage as f, sidecarOf as g, readImageFileMetadata as h,
|
|
386
|
+
export { trOf as C, slug as S, writeImageFileMetadata as _, LIBRARY_FOLDER as a, mapLimit 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, uniqueKey as w, norm as x, withPngMetadata as y };
|
|
370
387
|
|
|
371
|
-
//# sourceMappingURL=library-
|
|
388
|
+
//# sourceMappingURL=library-zI-2tG7h.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "./access-DtOxFKBK.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { i as translator, r as languageOf } from "./text-
|
|
6
|
-
import { C as trOf, S as slug, b as mapLimit, w as uniqueKey } from "./library-
|
|
2
|
+
import { G as loadLorebook, H as entriesOf, K as lorebookDirectory, Nt as ImportCardError, V as deleteLorebookEntry, X as writeLorebookEntry, Y as updateLorebookInfo, i as contextOf, q as readLorebook$1, r as MAX_PREVIEW_TEXT } from "./authoring-tools-DNnx0Nts.js";
|
|
3
|
+
import { Dt as LORE_KINDS, G as withPlayer, H as cleanText, K as IMPORT_FOLDER, Ot as LORE_SCOPES, W as partsOf, n as createPresetFromGuidance } from "./presets-MwOSMMyu.js";
|
|
4
|
+
import { at as shippedPromptsDirectory } from "./hooks-BQCzgggH.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-BzudpQLS.js";
|
|
6
|
+
import { C as trOf, S as slug, b as mapLimit, w as uniqueKey } from "./library-zI-2tG7h.js";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
-
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
10
9
|
import { readFile, rm, writeFile } from "node:fs/promises";
|
|
10
|
+
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
11
11
|
//#region src/shared/lorebook-chat.ts
|
|
12
12
|
const PREFIX = "lorebook-author-";
|
|
13
13
|
/** Stable DSH chat identity for the authoring conversation of one library lorebook. */
|
|
@@ -699,4 +699,4 @@ async function lorebookApproval(exec, next, state) {
|
|
|
699
699
|
//#endregion
|
|
700
700
|
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 };
|
|
701
701
|
|
|
702
|
-
//# sourceMappingURL=lorebook-author-tools-
|
|
702
|
+
//# sourceMappingURL=lorebook-author-tools-ywaYicwd.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-
|
|
3
|
-
import "./hooks-
|
|
4
|
-
import { t as guardAuthoringTurns } from "./turn-guard-
|
|
1
|
+
import { K as lorebookDirectory, n as limitAuthoringAgents } from "./authoring-tools-DNnx0Nts.js";
|
|
2
|
+
import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-ywaYicwd.js";
|
|
3
|
+
import "./hooks-BQCzgggH.js";
|
|
4
|
+
import { t as guardAuthoringTurns } from "./turn-guard-Cv8pfHEA.js";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { existsSync, readdirSync } from "node:fs";
|
|
7
7
|
//#region src/lorebook-authoring.ts
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import "./access-DtOxFKBK.js";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { existsSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, join } from "node:path";
|
|
3
|
+
import { chmodSync, existsSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { chmod, mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
4
6
|
//#region ../dsh-roleplay-model/src/clock.ts
|
|
5
7
|
/**
|
|
6
8
|
* How the story's time passes: `simulated` moves only when the story does (the game master says how
|
|
@@ -320,6 +322,51 @@ function parseSettings(value) {
|
|
|
320
322
|
};
|
|
321
323
|
}
|
|
322
324
|
//#endregion
|
|
325
|
+
//#region src/host/atomic-write.ts
|
|
326
|
+
/**
|
|
327
|
+
* 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,
|
|
328
|
+
* never half of either. Every writer of a file someone else may read at the same time goes through here.
|
|
329
|
+
*/
|
|
330
|
+
async function atomicWrite(file, data, options = {}) {
|
|
331
|
+
if (options.createDirectory === true) await mkdir(dirname(file), { recursive: true });
|
|
332
|
+
const temporary = join(dirname(file), `.${basename(file)}.${process.pid}.${randomUUID()}.tmp`);
|
|
333
|
+
try {
|
|
334
|
+
const mode = options.mode ?? await stat(file).then((value) => value.mode & 511, (error) => {
|
|
335
|
+
if (error.code === "ENOENT") return 420;
|
|
336
|
+
throw error;
|
|
337
|
+
});
|
|
338
|
+
await writeFile(temporary, data, { mode });
|
|
339
|
+
await chmod(temporary, mode);
|
|
340
|
+
await rename(temporary, file);
|
|
341
|
+
} catch (error) {
|
|
342
|
+
await rm(temporary, { force: true });
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/** A JSON file written the same way, with the indentation given (none by default) and a final newline when it is indented. */
|
|
347
|
+
async function atomicWriteJson(file, value, options = {}) {
|
|
348
|
+
const { indent, ...rest } = options;
|
|
349
|
+
await atomicWrite(file, indent === void 0 ? JSON.stringify(value) : `${JSON.stringify(value, null, indent)}\n`, rest);
|
|
350
|
+
}
|
|
351
|
+
/** The synchronous form, for the few writers that cannot wait (the chat settings, read at every step). */
|
|
352
|
+
function atomicWriteSync(file, data) {
|
|
353
|
+
const temporary = join(dirname(file), `.${basename(file)}.${process.pid}.${randomUUID()}.tmp`);
|
|
354
|
+
try {
|
|
355
|
+
let mode = 420;
|
|
356
|
+
try {
|
|
357
|
+
mode = statSync(file).mode & 511;
|
|
358
|
+
} catch (error) {
|
|
359
|
+
if (error.code !== "ENOENT") throw error;
|
|
360
|
+
}
|
|
361
|
+
writeFileSync(temporary, data, { mode });
|
|
362
|
+
chmodSync(temporary, mode);
|
|
363
|
+
renameSync(temporary, file);
|
|
364
|
+
} catch (error) {
|
|
365
|
+
rmSync(temporary, { force: true });
|
|
366
|
+
throw error;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
//#endregion
|
|
323
370
|
//#region src/host/sessions/settings.ts
|
|
324
371
|
const SETTINGS_FILE = "settings.json";
|
|
325
372
|
const known = /* @__PURE__ */ new Map();
|
|
@@ -363,10 +410,7 @@ function readSettings(folder) {
|
|
|
363
410
|
function writeSettings(folder, value) {
|
|
364
411
|
const parsed = parseSettings(value);
|
|
365
412
|
if (!parsed.ok) throw new InvalidSettingsError(parsed.problems);
|
|
366
|
-
|
|
367
|
-
const temporary = `${file}.${process.pid}.tmp`;
|
|
368
|
-
writeFileSync(temporary, `${JSON.stringify(parsed.value, null, 2)}\n`);
|
|
369
|
-
renameSync(temporary, file);
|
|
413
|
+
atomicWriteSync(join(folder, SETTINGS_FILE), `${JSON.stringify(parsed.value, null, 2)}\n`);
|
|
370
414
|
known.delete(folder);
|
|
371
415
|
return parsed.value;
|
|
372
416
|
}
|
|
@@ -456,6 +500,6 @@ function decodeOutput(text) {
|
|
|
456
500
|
}
|
|
457
501
|
}
|
|
458
502
|
//#endregion
|
|
459
|
-
export {
|
|
503
|
+
export { DECISION_SITES as _, liveSettings as a, writeSettings as c, DEFAULT_SETTINGS as d, SETTINGS_SPEC as f, rulesOf as g, WORLD_RULES_KEY as h, InvalidSettingsError as i, atomicWrite as l, parseSwitchboard as m, encodeOutput as n, readSettings as o, parseSettings as p, encodePreview as r, useChildReasoning as s, decodeOutput as t, atomicWriteJson as u, GATE_SITES as v, emptyStats as y };
|
|
460
504
|
|
|
461
|
-
//# sourceMappingURL=narration-
|
|
505
|
+
//# sourceMappingURL=narration-CnBlVure.js.map
|
package/lib/orchestration.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { a as chatSessionId, o as roleplaySessionOf, t as promptFor } from "./access-DtOxFKBK.js";
|
|
2
|
-
import {
|
|
3
|
-
import { _ as referent, a as whereabouts, g as sameWords, n as memoryReflector, r as recordFailure, s as Timelines, t as dueReflection } from "./reflection-
|
|
4
|
-
import { a as liveSettings,
|
|
5
|
-
import {
|
|
6
|
-
import { i as translator, r as languageOf } from "./text-
|
|
7
|
-
import { a as childTrace, c as runChild, h as currentTurn, n as childModel, r as childSampling, v as estimateAnswer, y as tokensOf } from "./child-
|
|
8
|
-
import { S as slug, t as addToLibrary, w as uniqueKey } from "./library-
|
|
9
|
-
import { _ as API_PREFIX } from "./packs-
|
|
10
|
-
import { i as updateImage, r as listGallery, t as describeGalleryImage } from "./gallery-
|
|
11
|
-
import { n as interpretImage, s as presentedFor, t as runImagePresenter } from "./presenter-agent-
|
|
2
|
+
import { F as routeVerdicts, I as yesAt, M as askYesNo, P as noAt, j as announceProblem, jt as INTENT_STATUSES, m as STANDING_PROMPT } from "./presets-MwOSMMyu.js";
|
|
3
|
+
import { _ as referent, a as whereabouts, g as sameWords, n as memoryReflector, r as recordFailure, s as Timelines, t as dueReflection } from "./reflection-zSaMsjKj.js";
|
|
4
|
+
import { a as liveSettings, n as encodeOutput, v as GATE_SITES } from "./narration-CnBlVure.js";
|
|
5
|
+
import { A as RESULTS, E as ClockError, O as describeWhen, b as writeVerdicts, c as record, d as toolEnabled, k as zoneOf, l as AUTHORING_NEEDS, m as storesOf, n as installHooks, o as PREVIEW_TOOL, ot as shippedText, p as MAX_OOC_ANSWER, r as externalGiven, s as createTools$1, u as characterRunner, ut as ReflectionRefusedError, y as readVerdicts, z as wrongLanguage } from "./hooks-BQCzgggH.js";
|
|
6
|
+
import { i as translator, r as languageOf } from "./text-BzudpQLS.js";
|
|
7
|
+
import { a as childTrace, c as runChild, h as currentTurn, n as childModel, r as childSampling, v as estimateAnswer, y as tokensOf } from "./child-D6mpkkCE.js";
|
|
8
|
+
import { S as slug, t as addToLibrary, w as uniqueKey } from "./library-zI-2tG7h.js";
|
|
9
|
+
import { _ as API_PREFIX } from "./packs-Cv8hanXJ.js";
|
|
10
|
+
import { i as updateImage, r as listGallery, t as describeGalleryImage } from "./gallery-D9nG3C78.js";
|
|
11
|
+
import { n as interpretImage, s as presentedFor, t as runImagePresenter } from "./presenter-agent-BSaMSd3G.js";
|
|
12
12
|
import { join } from "node:path";
|
|
13
13
|
import { existsSync } from "node:fs";
|
|
14
|
+
import { readdir } from "node:fs/promises";
|
|
14
15
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
15
16
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
16
|
-
import { readdir } from "node:fs/promises";
|
|
17
17
|
import { InvalidEditError, characterKey, createDiceTools, createTools, dayPart, describeDuration, describeHolder, describeInstant, describeValue, itemKey, judgedStatements, lintWorld, localTime, locationKey, mentioned, parseRecordsEdit, rollForCheck, sessionDatabase, sessionFolder } from "@dsh-agentic-roleplay/state";
|
|
18
18
|
//#region src/host/tools/resource-hint.ts
|
|
19
19
|
/** The name DSH's MCP resource plugin gives the prompt paragraph it adds for every agent; a section of the same name in an agent's scope replaces it. */
|
|
@@ -932,6 +932,20 @@ const THING_TEXT_CHARS = 300;
|
|
|
932
932
|
const FIT_TEXTS = 6;
|
|
933
933
|
const FIT_TEXT_CHARS = 200;
|
|
934
934
|
const editEstimate = (things, texts, chars, language) => estimateAnswer(Array.from({ length: Math.max(1, things) * texts }, () => chars), language);
|
|
935
|
+
/** A person made up without a place joins the scene: the place of the player's character, which is where the author is told to put them. */
|
|
936
|
+
function placedWhereThePlayerIs(args, store) {
|
|
937
|
+
if (!Array.isArray(args["characters"])) return args;
|
|
938
|
+
const here = store.cast().find((member) => member.character.control === "player")?.place?.location;
|
|
939
|
+
if (here === void 0) return args;
|
|
940
|
+
const characters = args["characters"].map((entry) => typeof entry === "object" && entry !== null && entry["place"] === void 0 ? {
|
|
941
|
+
...entry,
|
|
942
|
+
place: { location: locationKey(here) }
|
|
943
|
+
} : entry);
|
|
944
|
+
return {
|
|
945
|
+
...args,
|
|
946
|
+
characters
|
|
947
|
+
};
|
|
948
|
+
}
|
|
935
949
|
function authorTools(job, work, mode, limits) {
|
|
936
950
|
const link = {
|
|
937
951
|
session: job.store.story,
|
|
@@ -971,9 +985,26 @@ function authorTools(job, work, mode, limits) {
|
|
|
971
985
|
const edit = parseRecordsEdit(args);
|
|
972
986
|
const makes = (edit.characters?.length ?? 0) + (edit.places?.length ?? 0) + (edit.items?.length ?? 0) + (edit.variables?.length ?? 0) + (edit.triggers?.length ?? 0);
|
|
973
987
|
if (mode === "consolidate" && makes > 0) throw new Error("fitting things in does not make up anything new: connect what exists");
|
|
974
|
-
const
|
|
975
|
-
|
|
976
|
-
|
|
988
|
+
const madeBefore = job.store.story.consolidation.createdIn(job.turn);
|
|
989
|
+
const allowed = [
|
|
990
|
+
[
|
|
991
|
+
"character",
|
|
992
|
+
edit.characters?.length ?? 0,
|
|
993
|
+
madeBefore.filter((entry) => entry.kind === "character").length
|
|
994
|
+
],
|
|
995
|
+
[
|
|
996
|
+
"place",
|
|
997
|
+
edit.places?.length ?? 0,
|
|
998
|
+
madeBefore.filter((entry) => entry.kind === "location").length
|
|
999
|
+
],
|
|
1000
|
+
[
|
|
1001
|
+
"other thing",
|
|
1002
|
+
(edit.items?.length ?? 0) + (edit.variables?.length ?? 0) + (edit.triggers?.length ?? 0),
|
|
1003
|
+
0
|
|
1004
|
+
]
|
|
1005
|
+
];
|
|
1006
|
+
for (const [noun, now, already] of allowed) if (now > 0 && already + now > limits.perTurn) throw new Error(`this edit makes ${now} new ${noun}${now === 1 ? "" : "s"} and ${already} ${already === 1 ? "was" : "were"} already made this turn, which would pass the ${limits.perTurn} this chat allows per turn for each kind: make fewer, or none`);
|
|
1007
|
+
const result = await tool.execute(placedWhereThePlayerIs(args, job.store), exec);
|
|
977
1008
|
for (const key of result.character_keys ?? []) work.created.push({
|
|
978
1009
|
kind: "character",
|
|
979
1010
|
key
|
|
@@ -1049,7 +1080,7 @@ function createPrompt(job, perTurn) {
|
|
|
1049
1080
|
`The game master asks for something to be made up. Reason given: ${job.need}.`,
|
|
1050
1081
|
`What it says is needed: ${job.what}`,
|
|
1051
1082
|
"",
|
|
1052
|
-
`It is turn ${job.turn}. At most ${perTurn} new
|
|
1083
|
+
`It is turn ${job.turn}. At most ${perTurn} new character${perTurn === 1 ? "" : "s"} and ${perTurn} new place${perTurn === 1 ? "" : "s"} may be made in a turn (each kind has its own allowance); already made this turn: ${store.story.consolidation.createdIn(job.turn).filter((entry) => entry.kind === "character").length} character(s), ${store.story.consolidation.createdIn(job.turn).filter((entry) => entry.kind === "location").length} place(s).`,
|
|
1053
1084
|
here === void 0 ? "The story is not in any place yet." : `The story is in ${here.name} (${locationKey(here)}). With the player's character: ${present.filter((member) => member.character.control !== "player").map((member) => `${member.character.name} (${member.key})`).join(", ") || "no one else"}.`,
|
|
1054
1085
|
"",
|
|
1055
1086
|
"## What happened lately",
|
|
@@ -1194,6 +1225,12 @@ function worldAuthor(deps) {
|
|
|
1194
1225
|
return errors.length === 0 ? void 0 : `what you made is not usable yet; fix it with edit_world:\n${describeFindings(errors).join("\n")}`;
|
|
1195
1226
|
},
|
|
1196
1227
|
maxCalls: 30 + (given(parent).length > 0 ? EXTERNAL_CALLS : 0)
|
|
1228
|
+
}).catch((error) => {
|
|
1229
|
+
if (work.created.length === 0 || signal.aborted) throw error;
|
|
1230
|
+
return {
|
|
1231
|
+
outcome: "created",
|
|
1232
|
+
summary: `the author made it but did not finish its report (${error instanceof Error ? error.message : String(error)})`
|
|
1233
|
+
};
|
|
1197
1234
|
});
|
|
1198
1235
|
const label = names(job.store);
|
|
1199
1236
|
const created = work.created.map((entry) => ({
|
|
@@ -1611,6 +1648,7 @@ var AfterTurnJobs = class {
|
|
|
1611
1648
|
strategizing = /* @__PURE__ */ new Set();
|
|
1612
1649
|
judging = /* @__PURE__ */ new Set();
|
|
1613
1650
|
reflecting = /* @__PURE__ */ new Set();
|
|
1651
|
+
casting = /* @__PURE__ */ new Set();
|
|
1614
1652
|
constructor(deps) {
|
|
1615
1653
|
this.deps = deps;
|
|
1616
1654
|
}
|
|
@@ -1618,6 +1656,7 @@ var AfterTurnJobs = class {
|
|
|
1618
1656
|
this.consolidate(owner, cancel);
|
|
1619
1657
|
this.strategize(owner, cancel);
|
|
1620
1658
|
this.judge(owner, cancel);
|
|
1659
|
+
this.cast(owner, cancel);
|
|
1621
1660
|
const reason = this.reflectionDue(owner);
|
|
1622
1661
|
if (reason !== void 0) this.reflect(owner, reason, cancel);
|
|
1623
1662
|
}
|
|
@@ -1693,6 +1732,37 @@ var AfterTurnJobs = class {
|
|
|
1693
1732
|
this.strategizing.delete(owner.chat);
|
|
1694
1733
|
}));
|
|
1695
1734
|
}
|
|
1735
|
+
/** What a trigger asked the world author to make (a beat with `dispatch: author`) is made now, one request after the other: the game master is never asked, so it cannot ignore it. */
|
|
1736
|
+
cast(owner, cancel) {
|
|
1737
|
+
const store = this.deps.stores(owner.chat);
|
|
1738
|
+
if (store === void 0 || this.casting.has(owner.chat) || store.claimAuthorBeats === void 0 || !store.settings().authoring.enabled) return;
|
|
1739
|
+
const requests = store.claimAuthorBeats();
|
|
1740
|
+
if (requests.length === 0) return;
|
|
1741
|
+
this.casting.add(owner.chat);
|
|
1742
|
+
this.deps.track(owner.chat, (async () => {
|
|
1743
|
+
for (const request of requests) {
|
|
1744
|
+
const need = AUTHORING_NEEDS.find((candidate) => candidate === request.need);
|
|
1745
|
+
if (need === void 0) {
|
|
1746
|
+
this.deps.problem(`a trigger asked the world author for "${request.need}", which is not a reason to make something up`);
|
|
1747
|
+
continue;
|
|
1748
|
+
}
|
|
1749
|
+
try {
|
|
1750
|
+
await this.deps.boundaries().author.create({
|
|
1751
|
+
chat: owner.chat,
|
|
1752
|
+
turn: owner.turn,
|
|
1753
|
+
need,
|
|
1754
|
+
what: request.text,
|
|
1755
|
+
store
|
|
1756
|
+
}, cancel);
|
|
1757
|
+
this.deps.written(owner.chat);
|
|
1758
|
+
} catch (error) {
|
|
1759
|
+
if (!cancel.aborted) this.deps.problem(`the world author could not make what a trigger asked for: ${messageOf(error)}`);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
})().finally(() => {
|
|
1763
|
+
this.casting.delete(owner.chat);
|
|
1764
|
+
}));
|
|
1765
|
+
}
|
|
1696
1766
|
/** The statements that triggers wait on are judged; a trigger fires from the verdict at the next look. */
|
|
1697
1767
|
judge(owner, cancel) {
|
|
1698
1768
|
const store = this.deps.stores(owner.chat);
|
|
@@ -2179,8 +2249,9 @@ async function expandWorld(boundaries, store, state, owner, input, signal) {
|
|
|
2179
2249
|
if (what === "") throw new Error("say what is needed, from what the story has established: who or where, and why now");
|
|
2180
2250
|
const { authoring } = store.settings();
|
|
2181
2251
|
if (!authoring.enabled) throw new Error("this world is closed: nothing can be made up in it");
|
|
2182
|
-
const
|
|
2183
|
-
|
|
2252
|
+
const kind = need === "scene_change" ? "location" : need === "arrival" || need === "introduction" ? "character" : void 0;
|
|
2253
|
+
const made = store.story.consolidation.createdIn(owner.turn).filter((entry) => kind === void 0 || entry.kind === kind).length;
|
|
2254
|
+
if (made >= authoring.perTurn) throw new Error(`${made} new ${kind === "location" ? made === 1 ? "place was" : "places were" : kind === "character" ? made === 1 ? "character was" : "characters were" : made === 1 ? "thing was" : "things were"} already made up this turn, which is the most this chat allows: work with what exists, and do not ask again this turn`);
|
|
2184
2255
|
return await boundaries.author.create({
|
|
2185
2256
|
chat: owner.chat,
|
|
2186
2257
|
turn: owner.turn,
|
|
@@ -3558,6 +3629,11 @@ function apply(ctx) {
|
|
|
3558
3629
|
checks
|
|
3559
3630
|
}, chat.session);
|
|
3560
3631
|
};
|
|
3632
|
+
/** What the world carries as standing rules (the card's always-on rules), with a line that says what they are; nothing for a world that has none. */
|
|
3633
|
+
const standingSection = (text, language) => {
|
|
3634
|
+
if (text.trim() === shippedText("roleplay/standing", language).trim()) return "";
|
|
3635
|
+
return `${translator(languageOf(language))("The standing rules of this world. Apply them on every turn:")}\n\n${text}`;
|
|
3636
|
+
};
|
|
3561
3637
|
for (const [name, order, id] of [[
|
|
3562
3638
|
PERSONA_SECTION,
|
|
3563
3639
|
ctx.systemPrompt.getSectionOrder("DEPLOYMENT_PERSONA_PREFIX"),
|
|
@@ -3576,7 +3652,8 @@ function apply(ctx) {
|
|
|
3576
3652
|
const part = (name) => ctx.roleplayPrompts.text(name, language, {}, chat?.session);
|
|
3577
3653
|
const variables = id === "roleplay/game-master" ? {
|
|
3578
3654
|
preview: chat?.settings.preview.enabled === false ? "" : part("roleplay/preview"),
|
|
3579
|
-
dice: diceSection(context, chat, language)
|
|
3655
|
+
dice: diceSection(context, chat, language),
|
|
3656
|
+
standing: standingSection(part(STANDING_PROMPT), language)
|
|
3580
3657
|
} : id === "roleplay/persona" ? { style: part("roleplay/style") } : {};
|
|
3581
3658
|
return ctx.roleplayPrompts.text(id, language, variables, chat?.session);
|
|
3582
3659
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { a as chatSessionId } from "./access-DtOxFKBK.js";
|
|
2
|
-
import { $
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { B as
|
|
6
|
-
import { i as translator, r as languageOf } from "./text-
|
|
7
|
-
import { u as parseSampling } from "./child-
|
|
8
|
-
import { b as mapLimit, h as readImageFileMetadata, u as referenceImagePath, x as norm } from "./library-
|
|
9
|
-
import { n as readPreset } from "./preset-
|
|
10
|
-
import { _ as API_PREFIX, a as packIds, d as packPath, f as readPack, h as PACK_MEDIA_TYPES, l as isPackId } from "./packs-
|
|
11
|
-
import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-
|
|
2
|
+
import { $ as knowsCharacter, A as alternateOpenings, At as loadCharacters, Bt as authoredWorldOf, C as addressKey, Dt as loadCalendar, E as fetchPictures, F as WORLD_FILE_NAME, I as parseWorldFile, M as openingMessage, N as writePortrait, O as mergeReports, P as serialized, Q as loadValidatedWorld, St as loadFactions, T as candidateUrls, Vt as authoringChatSessionId, _t as LOCATIONS_DIR, at as populateItems, bt as loadItems, c as importPhase, dt as populateVariables, gt as loadLore, h as writeSnapshot, ht as LORE_DIR, i as contextOf, j as cardCharacter, jt as subfolders, kt as CHARACTERS_DIR, m as editsSince, mt as loadTriggers, p as recordProvenance, pt as TRIGGERS_FILE_NAME, s as worldOf, st as populateLocations, tt as populateCharacters, vt as loadLocations, w as addressesToFetch, xt as FACTIONS_DIR, yt as ITEMS_DIR } from "./authoring-tools-DNnx0Nts.js";
|
|
3
|
+
import { $ as writeChoices, G as withPlayer, K as IMPORT_FOLDER, O as findEntity, Q as readImportFolder, T as sourcesFor, U as itemise, V as writeWorldPrompt, X as openingText, Y as PICTURE_FILE, _t as parseCharacterFile, bt as InvalidEditProblems, ct as LOCATION_FILE_NAME, ft as parseItemFile, gt as CHARACTER_FILE_NAME, ht as parseFactionFile, lt as parseLocationFile, mt as FACTION_FILE_NAME, ot as LORE_FILE_NAME, rt as loadVariables, st as parseLoreFile, ut as ITEM_FILE_NAME, v as extractStyleFrom } from "./presets-MwOSMMyu.js";
|
|
4
|
+
import { l as atomicWrite, m as parseSwitchboard, n as encodeOutput, u as atomicWriteJson } from "./narration-CnBlVure.js";
|
|
5
|
+
import { B as PLOTS_FILE_NAME, F as LANGUAGE_NAMES, H as parsePlotsFile, I as STORY_LANGUAGES, J as formatIssue, L as isStoryLanguage, R as textLanguage, U as plotReferenceProblems, V as loadPlots, Z as PROMPTS_FOLDER, it as shippedLanguages, lt as InvalidWorldError, pt as WorldNotFoundError, st as AgentUnavailableError } from "./hooks-BQCzgggH.js";
|
|
6
|
+
import { i as translator, r as languageOf } from "./text-BzudpQLS.js";
|
|
7
|
+
import { u as parseSampling } from "./child-D6mpkkCE.js";
|
|
8
|
+
import { b as mapLimit, h as readImageFileMetadata, u as referenceImagePath, x as norm } from "./library-zI-2tG7h.js";
|
|
9
|
+
import { n as readPreset } from "./preset-CWI3-0r1.js";
|
|
10
|
+
import { _ as API_PREFIX, a as packIds, d as packPath, f as readPack, h as PACK_MEDIA_TYPES, l as isPackId } from "./packs-Cv8hanXJ.js";
|
|
11
|
+
import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-r1Czm7oi.js";
|
|
12
12
|
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
13
13
|
import { existsSync, lstatSync, statSync } from "node:fs";
|
|
14
14
|
import { randomUUID } from "node:crypto";
|
|
15
|
+
import { cp, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
15
16
|
import { Session, SessionId } from "@deepseek-ai/dsh-session";
|
|
16
17
|
import { ToolCallId, createMessage, createSystemMessage, createToolResultMessage } from "@deepseek-ai/dsh-llm";
|
|
17
18
|
import { setApprovalPolicy } from "@deepseek-ai/dsh-user-approval";
|
|
18
19
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
19
|
-
import { chmod, cp, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
20
20
|
import { createSessionStore, readTriggerDefinition, triggerReferenceProblems, writeCalendar } from "@dsh-agentic-roleplay/state";
|
|
21
21
|
//#region src/host/agent/opening.ts
|
|
22
22
|
/** What the opening is reported to come from, where a chat shows the source of a message. */
|
|
@@ -1170,6 +1170,11 @@ async function finishUpdate(directory, options = {}) {
|
|
|
1170
1170
|
});
|
|
1171
1171
|
const pictures = await updatePictures(directory, current.card.urls ?? [], next.card.urls ?? [], options);
|
|
1172
1172
|
const portrait = newPicture === void 0 ? "none" : oldPicture !== void 0 && oldPicture.equals(newPicture) ? "kept" : await refreshPortrait(directory, newPicture, next.card.name);
|
|
1173
|
+
await recordProvenance(directory, {
|
|
1174
|
+
kind: "update",
|
|
1175
|
+
card: { name: next.card.name },
|
|
1176
|
+
language: ""
|
|
1177
|
+
}, await readFile(join(folder, "card.json"), "utf8"));
|
|
1173
1178
|
await writeSnapshot(directory);
|
|
1174
1179
|
return {
|
|
1175
1180
|
forgotten,
|
|
@@ -1862,18 +1867,6 @@ function translateTools(worlds, settings, prompting) {
|
|
|
1862
1867
|
}
|
|
1863
1868
|
//#endregion
|
|
1864
1869
|
//#region src/host/worlds/world-info.ts
|
|
1865
|
-
async function replaceFile$2(file, text) {
|
|
1866
|
-
const temporary = join(dirname(file), `.${basename(file)}.${process.pid}.${randomUUID()}.tmp`);
|
|
1867
|
-
try {
|
|
1868
|
-
const { mode } = await stat(file);
|
|
1869
|
-
await writeFile(temporary, text, { mode });
|
|
1870
|
-
await chmod(temporary, mode);
|
|
1871
|
-
await rename(temporary, file);
|
|
1872
|
-
} catch (error) {
|
|
1873
|
-
await rm(temporary, { force: true });
|
|
1874
|
-
throw error;
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
1870
|
const textOf$1 = (value) => typeof value === "string" ? value : "";
|
|
1878
1871
|
const toolsOf = (value) => {
|
|
1879
1872
|
const board = value === void 0 ? {} : parseSwitchboard(value, "tools");
|
|
@@ -1928,7 +1921,10 @@ function setOrRemove(document, key, value) {
|
|
|
1928
1921
|
* back as the world will be read before it is written.
|
|
1929
1922
|
* @throws {InvalidEditProblems} when the world would no longer be valid.
|
|
1930
1923
|
*/
|
|
1931
|
-
|
|
1924
|
+
function editWorldInfo(directory, edit) {
|
|
1925
|
+
return serialized(directory, () => changeWorldInfo(directory, edit));
|
|
1926
|
+
}
|
|
1927
|
+
async function changeWorldInfo(directory, edit) {
|
|
1932
1928
|
const { text, document } = await readDocument(directory);
|
|
1933
1929
|
const before = infoOf(document);
|
|
1934
1930
|
if (edit.opening !== void 0 && before.openingParts && edit.opening !== before.opening) throw new InvalidEditProblems(["the opening has lines spoken by characters: change it in the file, or ask the authoring assistant"]);
|
|
@@ -1982,7 +1978,7 @@ async function editWorldInfo(directory, edit) {
|
|
|
1982
1978
|
const next = JSON.stringify(document, null, /^([ \t]+)"/m.exec(text)?.[1] ?? " ") + (text.endsWith("\n") ? "\n" : "");
|
|
1983
1979
|
const parsed = parseWorldFile(next);
|
|
1984
1980
|
if (!parsed.ok) throw new InvalidEditProblems(parsed.issues.map(formatIssue));
|
|
1985
|
-
await
|
|
1981
|
+
await atomicWrite(join(directory, WORLD_FILE_NAME), next);
|
|
1986
1982
|
return infoOf(document);
|
|
1987
1983
|
}
|
|
1988
1984
|
//#endregion
|
|
@@ -2148,16 +2144,7 @@ async function readTriggerDocuments(directory) {
|
|
|
2148
2144
|
return data;
|
|
2149
2145
|
}
|
|
2150
2146
|
async function writeDocuments(directory, documents) {
|
|
2151
|
-
|
|
2152
|
-
const temporary = join(dirname(file), `.${basename(file)}.${process.pid}.${randomUUID()}.tmp`);
|
|
2153
|
-
try {
|
|
2154
|
-
const mode = await stat(file).then((value) => value.mode, () => void 0);
|
|
2155
|
-
await writeFile(temporary, `${JSON.stringify(documents, null, 2)}\n`, mode === void 0 ? {} : { mode });
|
|
2156
|
-
await rename(temporary, file);
|
|
2157
|
-
} catch (error) {
|
|
2158
|
-
await rm(temporary, { force: true });
|
|
2159
|
-
throw error;
|
|
2160
|
-
}
|
|
2147
|
+
await atomicWriteJson(join(directory, TRIGGERS_FILE_NAME), documents, { indent: 2 });
|
|
2161
2148
|
}
|
|
2162
2149
|
/** The keys of the triggers a condition waits for. */
|
|
2163
2150
|
function waitsFor(condition) {
|
|
@@ -2513,7 +2500,7 @@ async function editWorldPlots(world, edit) {
|
|
|
2513
2500
|
cooldown_days: plot.pacing.cooldownDays
|
|
2514
2501
|
}
|
|
2515
2502
|
}));
|
|
2516
|
-
await replaceFile
|
|
2503
|
+
await replaceFile(join(world.directory, PLOTS_FILE_NAME), JSON.stringify(document, null, 2) + "\n");
|
|
2517
2504
|
return await readWorldEditor(world);
|
|
2518
2505
|
}
|
|
2519
2506
|
async function editWorldLore(world, key, edit) {
|
|
@@ -2552,7 +2539,7 @@ async function editWorldNarrationVoice(world, voice) {
|
|
|
2552
2539
|
const document = JSON.parse(text);
|
|
2553
2540
|
if (voice.trim() === "") delete document["narration_voice"];
|
|
2554
2541
|
else document["narration_voice"] = voice.trim();
|
|
2555
|
-
await replaceFile
|
|
2542
|
+
await replaceFile(file, JSON.stringify(document, null, /^([ \t]+)"/m.exec(text)?.[1] ?? " ") + (text.endsWith("\n") ? "\n" : ""));
|
|
2556
2543
|
return await readWorldEditor(world);
|
|
2557
2544
|
}
|
|
2558
2545
|
const relationKey = (...parts) => parts.map((part) => encodeURIComponent(part)).join(":");
|
|
@@ -2638,21 +2625,7 @@ function apply(document, edit, problems) {
|
|
|
2638
2625
|
}
|
|
2639
2626
|
}
|
|
2640
2627
|
/** Written in one step, so an interruption cannot leave a character file half written. */
|
|
2641
|
-
|
|
2642
|
-
const temporary = join(dirname(file), `.${basename(file)}.${process.pid}.${randomUUID()}.tmp`);
|
|
2643
|
-
try {
|
|
2644
|
-
const mode = await stat(file).then((value) => value.mode, (error) => {
|
|
2645
|
-
if (error.code === "ENOENT") return 420;
|
|
2646
|
-
throw error;
|
|
2647
|
-
});
|
|
2648
|
-
await writeFile(temporary, text, { mode });
|
|
2649
|
-
await chmod(temporary, mode);
|
|
2650
|
-
await rename(temporary, file);
|
|
2651
|
-
} catch (error) {
|
|
2652
|
-
await rm(temporary, { force: true });
|
|
2653
|
-
throw error;
|
|
2654
|
-
}
|
|
2655
|
-
}
|
|
2628
|
+
const replaceFile = atomicWrite;
|
|
2656
2629
|
/**
|
|
2657
2630
|
* Change a character in a world's files: the file is read, changed and checked as a whole (it has to read as a valid character, and the place has to be a place of
|
|
2658
2631
|
* the world) before it is written, so a refused edit changes nothing. Whatever the file holds that the editor does not know stays.
|
|
@@ -2674,7 +2647,7 @@ async function editWorldCharacter(world, key, edit) {
|
|
|
2674
2647
|
const parsed = parseCharacterFile(next, folder);
|
|
2675
2648
|
if (!parsed.ok) problems.push(...parsed.issues.map(formatIssue));
|
|
2676
2649
|
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
2677
|
-
await replaceFile
|
|
2650
|
+
await replaceFile(file, next);
|
|
2678
2651
|
return await readWorldEditor(world);
|
|
2679
2652
|
}
|
|
2680
2653
|
async function entityFolder(worldDirectory, directory, fileName, key, parse) {
|
|
@@ -2704,7 +2677,7 @@ async function editEntityFile(world, directory, fileName, key, parse, mutate) {
|
|
|
2704
2677
|
const next = JSON.stringify(document, null, /^([ \t]+)"/m.exec(text)?.[1] ?? " ") + (text.endsWith("\n") ? "\n" : "");
|
|
2705
2678
|
const parsed = parse(next, folder);
|
|
2706
2679
|
if (!parsed.ok) throw new InvalidEditProblems((parsed.issues ?? []).map(formatIssue));
|
|
2707
|
-
await replaceFile
|
|
2680
|
+
await replaceFile(file, next);
|
|
2708
2681
|
return await readWorldEditor(world);
|
|
2709
2682
|
}
|
|
2710
2683
|
async function editWorldPlace(world, key, edit) {
|
|
@@ -3187,17 +3160,6 @@ function serializeDocument(kind, key, value) {
|
|
|
3187
3160
|
if (!parsed.ok) throw new InvalidEditProblems(parsed.issues.map(formatIssue));
|
|
3188
3161
|
return text;
|
|
3189
3162
|
}
|
|
3190
|
-
async function replaceFile(file, text) {
|
|
3191
|
-
const temporary = join(dirname(file), `.${basename(file)}.${process.pid}.${randomUUID()}.tmp`);
|
|
3192
|
-
try {
|
|
3193
|
-
const mode = await stat(file).then((value) => value.mode);
|
|
3194
|
-
await writeFile(temporary, text, { mode });
|
|
3195
|
-
await rename(temporary, file);
|
|
3196
|
-
} catch (error) {
|
|
3197
|
-
await rm(temporary, { force: true });
|
|
3198
|
-
throw error;
|
|
3199
|
-
}
|
|
3200
|
-
}
|
|
3201
3163
|
async function readAuthoredEntityDocument(world, kind, key) {
|
|
3202
3164
|
const found = await find(world, kind, key);
|
|
3203
3165
|
if (found === void 0) throw new InvalidEditProblems([`there is no ${kind} "${key}"`]);
|
|
@@ -3225,7 +3187,7 @@ async function createAuthoredEntity(world, kind, key, document) {
|
|
|
3225
3187
|
async function replaceAuthoredEntity(world, kind, key, document) {
|
|
3226
3188
|
const found = await find(world, kind, key);
|
|
3227
3189
|
if (found === void 0) throw new InvalidEditProblems([`there is no ${kind} "${key}"`]);
|
|
3228
|
-
await
|
|
3190
|
+
await atomicWrite(found.file, serializeDocument(kind, key, document));
|
|
3229
3191
|
}
|
|
3230
3192
|
/** Deletions remain recoverable without making the trash visible to the world loaders. */
|
|
3231
3193
|
async function deleteAuthoredEntity(world, kind, key) {
|
|
@@ -3382,6 +3344,6 @@ function registerPackJail(ctx, deps) {
|
|
|
3382
3344
|
ctx.on("tools/pre-execute", (exec, next) => packJail(exec, next, deps), { prepend: true });
|
|
3383
3345
|
}
|
|
3384
3346
|
//#endregion
|
|
3385
|
-
export { matchPieces as $, worldEntityImageFile as A, readWorldInfo as B, readWorldEditor as C, uploadWorldCharacterPortrait as D, replaceFile
|
|
3347
|
+
export { matchPieces as $, worldEntityImageFile as A, readWorldInfo as B, readWorldEditor as C, uploadWorldCharacterPortrait as D, replaceFile as E, loadWorldParts as F, findTargets as G, translateTools as H, PRESET_FILE as I, revertUpdate as J, finishUpdate as K, presetMessage as L, deleteTriggerDocument as M, readTriggerDocuments as N, uploadWorldEntityImage as O, writeTriggerDocument as P, diffText as Q, presetTools as R, generateWorldEntityImage as S, removeWorldTrigger as T, languageOfDocuments as U, translateMessage as V, readWorldDocuments as W, updateStatus as X, startUpdate as Y, cardChanges as Z, editWorldPlots as _, deleteWorldPackFile as a, authoringTitle as at, entityFolder as b, createAuthoredEntity as c, ensureAgentChat as ct, replaceAuthoredEntity as d, appendNarratedTurn as dt, worldFieldChanges as et, editWorldCharacter as f, storeAuthoringOpening as ft, editWorldPlace as g, editWorldNarrationVoice as h, checkWorldPack as i, AuthoringSessions as it, writeWorldTrigger as j, worldCharacterPortraitFile as k, deleteAuthoredEntity as l, isStored as lt, editWorldLore as m, packFileProblem as n, entitiesByPiece as nt, listWorldPacks as o, AgentSessions as ot, editWorldFaction as p, storeDoctorOpening as pt, pendingUpdate as q, registerPackJail as r, readSource as rt, AUTHORED_ENTITY_KINDS as s, agentServicesOf as st, MAX_PACK_TEXT as t, cardTools as tt, readAuthoredEntityDocument as u, appendEmptyTurn as ut, editWorldRelation as v, readWorldTrigger as w, generateWorldCharacterPortrait as x, editWorldThing as y, editWorldInfo as z };
|
|
3386
3348
|
|
|
3387
|
-
//# sourceMappingURL=pack-jail-
|
|
3349
|
+
//# sourceMappingURL=pack-jail-5EJ-WYyW.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as Reader } from "./hooks-BQCzgggH.js";
|
|
2
2
|
import { dirname, extname, join, posix, sep } from "node:path";
|
|
3
3
|
import { copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync } from "node:fs";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
@@ -840,4 +840,4 @@ function anyTab(bases) {
|
|
|
840
840
|
//#endregion
|
|
841
841
|
export { API_PREFIX as _, packIds as a, describePack as c, packPath as d, readPack as f, SURFACE_NAMES as g, PACK_MEDIA_TYPES as h, inheritPacks as i, isPackId as l, PACK_LIMITS as m, anyTab as n, syncWorldPacks as o, PACK_ACTIONS as p, copyWorldPacks as r, worldPackStates as s, activePack as t, packFile as u };
|
|
842
842
|
|
|
843
|
-
//# sourceMappingURL=packs-
|
|
843
|
+
//# sourceMappingURL=packs-Cv8hanXJ.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as promptFor } from "./access-DtOxFKBK.js";
|
|
2
|
-
import { c as runChild } from "./child-
|
|
3
|
-
import { c as nextSceneSerial, u as referenceImagePath } from "./library-
|
|
4
|
-
import { n as generateTransientImage, t as generateReferenceImage } from "./generator-
|
|
5
|
-
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-
|
|
2
|
+
import { c as runChild } from "./child-D6mpkkCE.js";
|
|
3
|
+
import { c as nextSceneSerial, u as referenceImagePath } from "./library-zI-2tG7h.js";
|
|
4
|
+
import { n as generateTransientImage, t as generateReferenceImage } from "./generator-r1Czm7oi.js";
|
|
5
|
+
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-D9nG3C78.js";
|
|
6
6
|
import { dirname, join, relative } from "node:path";
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
8
|
import { createHash, randomUUID } from "node:crypto";
|
|
9
|
-
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
10
9
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
10
|
+
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
11
11
|
import { characterKey, itemKey, locationKey } from "@dsh-agentic-roleplay/state";
|
|
12
12
|
//#region src/host/images/presented.ts
|
|
13
13
|
const PRESENTED_FOLDER = "presented";
|
|
@@ -852,4 +852,4 @@ async function runImagePresenter(job) {
|
|
|
852
852
|
//#endregion
|
|
853
853
|
export { tokensOf as a, searchImages as i, interpretImage as n, present as o, imageTools as r, presentedFor as s, runImagePresenter as t };
|
|
854
854
|
|
|
855
|
-
//# sourceMappingURL=presenter-agent-
|
|
855
|
+
//# sourceMappingURL=presenter-agent-BSaMSd3G.js.map
|