@dsh-agentic-roleplay/core 0.7.1 → 0.7.3
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-BKltdiea.js → authoring-tools-CIsWbq0B.js} +197 -20
- package/lib/authoring.js +410 -32
- package/lib/client.js +679 -347
- package/lib/client.js.map +1 -1
- package/lib/doctor.js +1 -1
- package/lib/{gallery-BxZGOgMb.js → gallery-DmBZ2L5l.js} +2 -2
- package/lib/{generator-BFmSYvR8.js → generator-BmdoTIL2.js} +2 -2
- package/lib/{hooks-HnqXO8mM.js → hooks-C8eELrni.js} +2 -2
- package/lib/images.js +4 -4
- package/lib/index.js +111 -566
- package/lib/{library-BGxPKs9a.js → library-lVNf9qG_.js} +37 -4
- package/lib/{lorebook-author-tools-BAnUyRtS.js → lorebook-author-tools-BDOs4i5C.js} +6 -6
- package/lib/lorebook-authoring.js +3 -3
- package/lib/orchestration.js +8 -8
- package/lib/{pack-jail-DLGguGS3.js → pack-jail-DeTscGT2.js} +1255 -12
- package/lib/{packs-jowC-MN_.js → packs-CY8ms8v_.js} +2 -2
- package/lib/{presenter-agent-DvZtnf0Q.js → presenter-agent-cFR4sos3.js} +4 -4
- package/lib/{preset-author-tools-C26kj6t5.js → preset-author-tools-2m4BLtws.js} +6 -6
- package/lib/preset-authoring.js +4 -4
- package/lib/{preset-CXbC0NeU.js → preset-n4-j6k4S.js} +2 -2
- package/lib/{reflection-CvOZGjmn.js → reflection-CJB5s0ip.js} +6 -6
- package/lib/{route-DRTJ_vcA.js → route-C6SHz9j2.js} +2 -2
- package/lib/{text-JbWfTHbr.js → text-Cwl5s0j0.js} +3 -1
- package/package.json +2 -2
- package/prompts/en/import/finish-ok.md +1 -1
- package/prompts/en/world/procedure.md +1 -1
- package/prompts/zh/import/finish-ok.md +1 -1
- package/prompts/zh/world/procedure.md +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
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-Cwl5s0j0.js";
|
|
3
3
|
import { dirname, extname, join } from "node:path";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
|
-
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
6
6
|
import { copyFile, link, mkdir, readFile, readdir, rename, unlink, writeFile } from "node:fs/promises";
|
|
7
7
|
//#region src/host/import/run.ts
|
|
8
8
|
/** The labels of a job's prompt, in the language of the import. */
|
|
@@ -94,6 +94,18 @@ function chunks(png) {
|
|
|
94
94
|
function isOurText(entry) {
|
|
95
95
|
return entry.type === "iTXt" && entry.data.subarray(0, 12).toString("latin1") === KEYWORD && entry.data[12] === 0;
|
|
96
96
|
}
|
|
97
|
+
/** Chunks that describe a picture instead of being it: text, time and EXIF. */
|
|
98
|
+
const DESCRIPTIVE_CHUNKS = /* @__PURE__ */ new Set([
|
|
99
|
+
"iTXt",
|
|
100
|
+
"tEXt",
|
|
101
|
+
"zTXt",
|
|
102
|
+
"tIME",
|
|
103
|
+
"eXIf"
|
|
104
|
+
]);
|
|
105
|
+
/** The PNG without what only describes it, so the same picture gives the same bytes before and after metadata is written into it. */
|
|
106
|
+
function pngPictureBytes(png) {
|
|
107
|
+
return Buffer.concat([SIGNATURE, ...chunks(Buffer.from(png)).filter((entry) => !DESCRIPTIVE_CHUNKS.has(entry.type)).map((entry) => entry.bytes)]);
|
|
108
|
+
}
|
|
97
109
|
/** Put self-describing UTF-8 JSON in a PNG iTXt chunk, replacing older roleplay metadata. */
|
|
98
110
|
function withPngMetadata(png, metadata) {
|
|
99
111
|
const entries = chunks(Buffer.from(png)).filter((entry) => !isOurText(entry));
|
|
@@ -296,6 +308,27 @@ const MAGIC = [
|
|
|
296
308
|
function imageExtensionOf(bytes) {
|
|
297
309
|
return MAGIC.find((format) => format.test(bytes))?.type;
|
|
298
310
|
}
|
|
311
|
+
/** A hash of the picture itself: a PNG's metadata (ours is written into it after the file is saved) is left out, so the same picture hashes the same wherever it came from. */
|
|
312
|
+
function pictureHash(bytes) {
|
|
313
|
+
let picture = bytes;
|
|
314
|
+
if (imageExtensionOf(bytes) === ".png") try {
|
|
315
|
+
picture = pngPictureBytes(bytes);
|
|
316
|
+
} catch {
|
|
317
|
+
picture = bytes;
|
|
318
|
+
}
|
|
319
|
+
return createHash("sha256").update(picture).digest("hex");
|
|
320
|
+
}
|
|
321
|
+
/** The pictures already in the library, by the hash of the picture: its path under `images/`. */
|
|
322
|
+
async function libraryHashes(sessionFolder) {
|
|
323
|
+
const directory = join(sessionFolder, "images", LIBRARY_FOLDER);
|
|
324
|
+
const found = /* @__PURE__ */ new Map();
|
|
325
|
+
for (const name of await readdir(directory).catch(() => [])) {
|
|
326
|
+
if (MEDIA_TYPES[extname(name).toLowerCase()] === void 0) continue;
|
|
327
|
+
const bytes = await readFile(join(directory, name)).catch(() => void 0);
|
|
328
|
+
if (bytes !== void 0 && imageExtensionOf(bytes) !== void 0) found.set(pictureHash(bytes), `${LIBRARY_FOLDER}/${name}`);
|
|
329
|
+
}
|
|
330
|
+
return found;
|
|
331
|
+
}
|
|
299
332
|
/** A file name made of the letters and digits of the name it came with, in any script. */
|
|
300
333
|
function libraryName(original, extension, taken) {
|
|
301
334
|
const stem = trimCharacters(withoutExtension(original).normalize("NFKC").replace(/[^\p{L}\p{N}]+/gu, "-"), "-").slice(0, 60) || "image";
|
|
@@ -333,6 +366,6 @@ async function addToLibrary(sessionFolder, bytes, originalName) {
|
|
|
333
366
|
return `${LIBRARY_FOLDER}/${name}`;
|
|
334
367
|
}
|
|
335
368
|
//#endregion
|
|
336
|
-
export {
|
|
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, pictureHash as i, readImageMetadata as l, mediaTypeOf as m, imageExtensionOf as n, entityImageDirectory as o, MEDIA_TYPES as p, libraryHashes as r, inheritImages as s, addToLibrary as t, referenceImagePath as u, readPngMetadata as v, uniqueKey as w, norm as x, withPngMetadata as y };
|
|
337
370
|
|
|
338
|
-
//# sourceMappingURL=library-
|
|
371
|
+
//# sourceMappingURL=library-lVNf9qG_.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./access-DtOxFKBK.js";
|
|
2
|
-
import {
|
|
3
|
-
import { c as createPresetFromGuidance } from "./route-
|
|
4
|
-
import { nt as shippedPromptsDirectory } from "./hooks-
|
|
5
|
-
import { i as translator, r as languageOf } from "./text-
|
|
6
|
-
import {
|
|
2
|
+
import { Dt as IMPORT_FOLDER, Gt as loadLorebook, Ht as entriesOf, Kt as lorebookDirectory, Vt as deleteLorebookEntry, Xt as writeLorebookEntry, Yt as updateLorebookInfo, dt as cleanText, hn as LORE_SCOPES, i as contextOf, mn as LORE_KINDS, mt as withPlayer, pt as partsOf, qt as readLorebook$1, r as MAX_PREVIEW_TEXT, un as ImportCardError } from "./authoring-tools-CIsWbq0B.js";
|
|
3
|
+
import { c as createPresetFromGuidance } from "./route-C6SHz9j2.js";
|
|
4
|
+
import { nt as shippedPromptsDirectory } from "./hooks-C8eELrni.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-Cwl5s0j0.js";
|
|
6
|
+
import { C as trOf, S as slug, b as mapLimit, w as uniqueKey } from "./library-lVNf9qG_.js";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { existsSync, readFileSync } from "node:fs";
|
|
9
9
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
@@ -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-BDOs4i5C.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
1
|
+
import { Kt as lorebookDirectory, n as limitAuthoringAgents } from "./authoring-tools-CIsWbq0B.js";
|
|
2
|
+
import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-BDOs4i5C.js";
|
|
3
|
+
import "./hooks-C8eELrni.js";
|
|
4
4
|
import { t as guardAuthoringTurns } from "./turn-guard-BvCs1VxB.js";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { existsSync, readdirSync } from "node:fs";
|
package/lib/orchestration.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { a as chatSessionId, o as roleplaySessionOf, t as promptFor } from "./access-DtOxFKBK.js";
|
|
2
|
-
import { E as INTENT_STATUSES, a as routeVerdicts, i as noAt, n as askYesNo, o as yesAt, t as announceProblem } from "./route-
|
|
3
|
-
import { _ as referent, a as whereabouts, g as sameWords, n as memoryReflector, r as recordFailure, s as Timelines, t as dueReflection } from "./reflection-
|
|
2
|
+
import { E as INTENT_STATUSES, a as routeVerdicts, i as noAt, n as askYesNo, o as yesAt, t as announceProblem } from "./route-C6SHz9j2.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-CJB5s0ip.js";
|
|
4
4
|
import { a as liveSettings, g as GATE_SITES, n as encodeOutput } from "./narration-DvFBqmqe.js";
|
|
5
|
-
import { D as describeWhen, O as zoneOf, R as wrongLanguage, T as ClockError, c as record, d as toolEnabled, f as MAX_OOC_ANSWER, k as RESULTS, l as AUTHORING_NEEDS, n as installHooks, o as PREVIEW_TOOL, ot as ReflectionRefusedError, p as storesOf, r as externalGiven, s as createTools$1, u as characterRunner, v as readVerdicts, y as writeVerdicts } from "./hooks-
|
|
6
|
-
import { i as translator, r as languageOf } from "./text-
|
|
5
|
+
import { D as describeWhen, O as zoneOf, R as wrongLanguage, T as ClockError, c as record, d as toolEnabled, f as MAX_OOC_ANSWER, k as RESULTS, l as AUTHORING_NEEDS, n as installHooks, o as PREVIEW_TOOL, ot as ReflectionRefusedError, p as storesOf, r as externalGiven, s as createTools$1, u as characterRunner, v as readVerdicts, y as writeVerdicts } from "./hooks-C8eELrni.js";
|
|
6
|
+
import { i as translator, r as languageOf } from "./text-Cwl5s0j0.js";
|
|
7
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-CyCViUKa.js";
|
|
8
|
-
import { S as
|
|
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-
|
|
8
|
+
import { S as slug, t as addToLibrary, w as uniqueKey } from "./library-lVNf9qG_.js";
|
|
9
|
+
import { _ as API_PREFIX } from "./packs-CY8ms8v_.js";
|
|
10
|
+
import { i as updateImage, r as listGallery, t as describeGalleryImage } from "./gallery-DmBZ2L5l.js";
|
|
11
|
+
import { n as interpretImage, s as presentedFor, t as runImagePresenter } from "./presenter-agent-cFR4sos3.js";
|
|
12
12
|
import { join } from "node:path";
|
|
13
13
|
import { existsSync } from "node:fs";
|
|
14
14
|
import { SessionId } from "@deepseek-ai/dsh-session";
|