@dsh-agentic-roleplay/core 0.11.0 → 0.12.0
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/{access-CXtaZNbx.js → access-DAw54-NI.js} +6 -15
- package/lib/{authoring-tools--6V1pIIL.js → authoring-tools-4NgDhIJV.js} +116 -13
- package/lib/authoring.js +38 -8
- package/lib/{child-C9nPIy9j.js → child-D3QUNb3m.js} +121 -2
- package/lib/client.js +1389 -475
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +3 -3
- package/lib/doctor.js +3 -3
- package/lib/{gallery-CtG-bDzz.js → gallery-Ct6nm4UQ.js} +3 -3
- package/lib/{generator-nLoPM5MF.js → generator-CI8fOnXy.js} +9 -3
- package/lib/helper.js +22 -1
- package/lib/{hooks-DORky4KT.js → hooks-BNeoGMHZ.js} +1342 -293
- package/lib/images.js +4 -4
- package/lib/index.js +444 -24
- package/lib/jail-BIF79PJO.js +107 -0
- package/lib/{library-CH-ahlm0.js → library-BF9ZMSFz.js} +3 -3
- package/lib/{lorebook-author-tools-BrVde1N-.js → lorebook-author-tools-DBk-V0hp.js} +7 -7
- package/lib/lorebook-authoring.js +4 -4
- package/lib/{narration-B0hConSw.js → narration-xvErE2yp.js} +34 -3
- package/lib/orchestration.js +915 -59
- package/lib/{pack-jail-Bk82pX9t.js → pack-jail-C8EyX9Ix.js} +18 -14
- package/lib/{packs-ELfh8yh1.js → packs-S0SzrVv-.js} +2 -2
- package/lib/{presenter-agent-UKbKYXMO.js → presenter-agent-Bc478nTA.js} +11 -8
- package/lib/{preset-D9Sfc8sf.js → preset-SJZyw0kt.js} +4 -4
- package/lib/{preset-author-tools-B3pFL1-e.js → preset-author-tools-CzogjK42.js} +7 -7
- package/lib/preset-authoring.js +5 -5
- package/lib/{presets-BRt4Xsy4.js → presets-DQ5rioMh.js} +251 -49
- package/lib/{reflection-CHiHsY4Y.js → reflection-buQiSdvq.js} +17 -609
- package/lib/service-mRKwpWjX.js +140 -0
- package/lib/{text-CzqhC8sT.js → text-Dfv8S8eq.js} +36 -2
- package/lib/{turn-guard-B53qOWEU.js → turn-guard-BSAba8sp.js} +3 -3
- package/package.json +3 -3
- package/prompts/en/import/finish-ok.md +1 -1
- package/prompts/en/import/generator.md +1 -1
- package/prompts/en/import/style.md +1 -1
- package/prompts/en/import/variables.md +3 -1
- package/prompts/en/roleplay/character-decide.md +1 -1
- package/prompts/en/roleplay/character-lookup.md +1 -1
- package/prompts/en/roleplay/decide-errand.md +1 -0
- package/prompts/en/roleplay/decide-message.md +1 -0
- package/prompts/en/roleplay/decide-reuse.md +3 -0
- package/prompts/en/roleplay/decide-variable.md +1 -0
- package/prompts/en/roleplay/dream.md +1 -0
- package/prompts/en/roleplay/gate-repeat.md +1 -0
- package/prompts/en/roleplay/image-presenter.md +1 -0
- package/prompts/en/roleplay/track-values.md +1 -0
- package/prompts/en/roleplay/track-variables.md +1 -0
- package/prompts/zh/import/finish-ok.md +1 -1
- package/prompts/zh/import/generator.md +1 -1
- package/prompts/zh/import/style.md +1 -1
- package/prompts/zh/import/variables.md +3 -1
- package/prompts/zh/roleplay/character-decide.md +1 -1
- package/prompts/zh/roleplay/character-lookup.md +1 -1
- package/prompts/zh/roleplay/decide-errand.md +1 -0
- package/prompts/zh/roleplay/decide-message.md +1 -0
- package/prompts/zh/roleplay/decide-reuse.md +3 -0
- package/prompts/zh/roleplay/decide-variable.md +1 -0
- package/prompts/zh/roleplay/dream.md +1 -0
- package/prompts/zh/roleplay/gate-repeat.md +1 -0
- package/prompts/zh/roleplay/image-presenter.md +1 -0
- package/prompts/zh/roleplay/track-values.md +1 -0
- package/prompts/zh/roleplay/track-variables.md +1 -0
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $t as subfolders, A as editsSince, B as addressesToFetch, Bt as loadLocations, C as worldFieldChanges, E as loadWorldParts, Ft as TRIGGERS_FILE_NAME, H as fetchPictures, Ht as loadItems, It as loadTriggers, J as UPDATE_FOLDER, K as cardCharacter, Lt as LORE_DIR, Qt as loadCharacters, Rt as loadLore, Ut as FACTIONS_DIR, V as candidateUrls, Vt as ITEMS_DIR, W as mergeReports, Wt as loadFactions, X as cardPieces, Y as baseId, Yt as loadCalendar, Zt as CHARACTERS_DIR, bt as withScratchStory, c as importPhase, i as contextOf, j as writeSnapshot, k as recordProvenance, ln as authoredWorldOf, q as writePortrait, s as worldOf, un as authoringChatSessionId, w as editWorldInfo, x as matchPieces, xt as knowsCharacter, yt as loadValidatedWorld, z as addressKey, zt as LOCATIONS_DIR } from "./authoring-tools
|
|
3
|
-
import { $ as IMPORT_FOLDER,
|
|
4
|
-
import { n as encodeOutput } from "./narration-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { a as
|
|
1
|
+
import { A as chatSessionId } from "./child-D3QUNb3m.js";
|
|
2
|
+
import { $t as subfolders, A as editsSince, B as addressesToFetch, Bt as loadLocations, C as worldFieldChanges, E as loadWorldParts, Ft as TRIGGERS_FILE_NAME, H as fetchPictures, Ht as loadItems, It as loadTriggers, J as UPDATE_FOLDER, K as cardCharacter, Lt as LORE_DIR, Qt as loadCharacters, Rt as loadLore, Ut as FACTIONS_DIR, V as candidateUrls, Vt as ITEMS_DIR, W as mergeReports, Wt as loadFactions, X as cardPieces, Y as baseId, Yt as loadCalendar, Zt as CHARACTERS_DIR, bt as withScratchStory, c as importPhase, i as contextOf, j as writeSnapshot, k as recordProvenance, ln as authoredWorldOf, q as writePortrait, s as worldOf, un as authoringChatSessionId, w as editWorldInfo, x as matchPieces, xt as knowsCharacter, yt as loadValidatedWorld, z as addressKey, zt as LOCATIONS_DIR } from "./authoring-tools-4NgDhIJV.js";
|
|
3
|
+
import { $ as IMPORT_FOLDER, Dt as parseFactionFile, Et as FACTION_FILE_NAME, J as writeWorldPrompt, Mt as InvalidEditProblems, Ot as CHARACTER_FILE_NAME, Q as withPlayer, St as ITEM_FILE_NAME, at as readImportFolder, bt as LOCATION_FILE_NAME, ht as loadVariables, kt as parseCharacterFile, nt as PICTURE_FILE, ot as writeChoices, vt as LORE_FILE_NAME, wt as parseItemFile, x as extractStyleFrom, xt as parseLocationFile, yt as parseLoreFile } from "./presets-DQ5rioMh.js";
|
|
4
|
+
import { n as encodeOutput } from "./narration-xvErE2yp.js";
|
|
5
|
+
import { n as atomicWrite, r as atomicWriteJson } from "./access-DAw54-NI.js";
|
|
6
|
+
import { B as parsePlotsFile, F as textLanguage, K as Reader, M as LANGUAGE_NAMES, N as STORY_LANGUAGES, P as isStoryLanguage, R as PLOTS_FILE_NAME, V as plotReferenceProblems, X as PROMPTS_FOLDER, ct as InvalidWorldError, ft as WorldNotFoundError, ot as AgentUnavailableError, q as formatIssue, rt as shippedLanguages, z as loadPlots } from "./hooks-BNeoGMHZ.js";
|
|
7
|
+
import { i as translator, r as languageOf } from "./text-Dfv8S8eq.js";
|
|
8
|
+
import { h as readImageFileMetadata, u as referenceImagePath, x as mapLimit } from "./library-BF9ZMSFz.js";
|
|
9
|
+
import { n as readPreset } from "./preset-SJZyw0kt.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-S0SzrVv-.js";
|
|
11
|
+
import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-CI8fOnXy.js";
|
|
11
12
|
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
12
13
|
import { readTriggerDefinition, triggerReferenceProblems } from "@dsh-agentic-roleplay/state";
|
|
13
14
|
import { existsSync, lstatSync, statSync } from "node:fs";
|
|
@@ -1463,7 +1464,7 @@ function waitsFor(condition) {
|
|
|
1463
1464
|
* what it names that the world does not have is refused, with every problem; nothing is written then.
|
|
1464
1465
|
* @throws {InvalidEditProblems}
|
|
1465
1466
|
*/
|
|
1466
|
-
async function writeTriggerDocument(directory, parts, key, document) {
|
|
1467
|
+
async function writeTriggerDocument(directory, parts, key, document, options = {}) {
|
|
1467
1468
|
if (!isDocument(document)) throw new InvalidEditProblems(["document must be a JSON object"]);
|
|
1468
1469
|
const unknown = Object.keys(document).filter((field) => !FIELDS.has(field));
|
|
1469
1470
|
if (unknown.length > 0) throw new InvalidEditProblems(unknown.map((field) => `"${field}" is not a field of a trigger (${[...FIELDS].join(", ")})`));
|
|
@@ -1480,7 +1481,7 @@ async function writeTriggerDocument(directory, parts, key, document) {
|
|
|
1480
1481
|
return "definition" in read ? [read.definition] : [];
|
|
1481
1482
|
}), parsed.definition]).get(key) ?? [];
|
|
1482
1483
|
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
1483
|
-
await writeDocuments(directory, at < 0 ? [...documents, written] : documents.map((entry, index) => index === at ? written : entry));
|
|
1484
|
+
if (options.dryRun !== true) await writeDocuments(directory, at < 0 ? [...documents, written] : documents.map((entry, index) => index === at ? written : entry));
|
|
1484
1485
|
return at < 0 ? "created" : "replaced";
|
|
1485
1486
|
}
|
|
1486
1487
|
/**
|
|
@@ -2482,6 +2483,7 @@ async function createAuthoredEntity(world, kind, key, document, options = {}) {
|
|
|
2482
2483
|
const root = join(world.directory, format.directory);
|
|
2483
2484
|
const folder = join(root, key);
|
|
2484
2485
|
const text = serializeDocument(kind, key, document, options);
|
|
2486
|
+
if (options.dryRun === true) return;
|
|
2485
2487
|
await mkdir(root, { recursive: true });
|
|
2486
2488
|
await mkdir(folder, { recursive: false });
|
|
2487
2489
|
try {
|
|
@@ -2497,7 +2499,9 @@ async function createAuthoredEntity(world, kind, key, document, options = {}) {
|
|
|
2497
2499
|
async function replaceAuthoredEntity(world, kind, key, document, options = {}) {
|
|
2498
2500
|
const found = await find(world, kind, key);
|
|
2499
2501
|
if (found === void 0) throw new InvalidEditProblems([`there is no ${kind} "${key}"`]);
|
|
2500
|
-
|
|
2502
|
+
const text = serializeDocument(kind, key, document, options);
|
|
2503
|
+
if (options.dryRun === true) return;
|
|
2504
|
+
await atomicWrite(found.file, text);
|
|
2501
2505
|
}
|
|
2502
2506
|
/** Deletions remain recoverable without making the trash visible to the world loaders. */
|
|
2503
2507
|
async function deleteAuthoredEntity(world, kind, key) {
|
|
@@ -2660,4 +2664,4 @@ function registerPackJail(ctx, deps) {
|
|
|
2660
2664
|
}
|
|
2661
2665
|
export { DOCTOR_OPENING_SOURCE as $, worldEntityImageFile as A, languageOfDocuments as B, readWorldEditor as C, uploadWorldCharacterPortrait as D, replaceFile as E, PRESET_FILE as F, revertUpdate as G, findTargets as H, presetMessage as I, AuthoringSessions as J, startUpdate as K, presetTools as L, deleteTriggerDocument as M, readTriggerDocuments as N, uploadWorldEntityImage as O, writeTriggerDocument as P, agentServicesOf as Q, translateMessage as R, generateWorldEntityImage as S, removeWorldTrigger as T, finishUpdate as U, readWorldDocuments as V, pendingUpdate as W, ensureAuthoringChat as X, authoringTitle as Y, AgentSessions as Z, editWorldPlots as _, deleteWorldPackFile as a, entityFolder as b, createAuthoredEntity as c, replaceAuthoredEntity as d, appendEmptyTurn as et, editWorldCharacter as f, editWorldPlace as g, editWorldNarrationVoice as h, checkWorldPack as i, writeWorldTrigger as j, worldCharacterPortraitFile as k, deleteAuthoredEntity as l, editWorldLore as m, packFileProblem as n, listWorldPacks as o, editWorldFaction as p, updateStatus as q, registerPackJail as r, AUTHORED_ENTITY_KINDS as s, MAX_PACK_TEXT as t, appendNarratedTurn as tt, readAuthoredEntityDocument as u, editWorldRelation as v, readWorldTrigger as w, generateWorldCharacterPortrait as x, editWorldThing as y, translateTools as z };
|
|
2662
2666
|
|
|
2663
|
-
//# sourceMappingURL=pack-jail-
|
|
2667
|
+
//# sourceMappingURL=pack-jail-C8EyX9Ix.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { K as Reader } from "./hooks-BNeoGMHZ.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";
|
|
@@ -836,4 +836,4 @@ function anyTab(bases) {
|
|
|
836
836
|
}
|
|
837
837
|
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 };
|
|
838
838
|
|
|
839
|
-
//# sourceMappingURL=packs-
|
|
839
|
+
//# sourceMappingURL=packs-S0SzrVv-.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as atomicWrite, t as promptFor } from "./access-
|
|
2
|
-
import { l as runChild } from "./child-
|
|
3
|
-
import { n as generateTransientImage, t as generateReferenceImage } from "./generator-
|
|
4
|
-
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-
|
|
5
|
-
import { c as nextSceneSerial, u as referenceImagePath } from "./library-
|
|
1
|
+
import { n as atomicWrite, t as promptFor } from "./access-DAw54-NI.js";
|
|
2
|
+
import { l as runChild } from "./child-D3QUNb3m.js";
|
|
3
|
+
import { n as generateTransientImage, t as generateReferenceImage } from "./generator-CI8fOnXy.js";
|
|
4
|
+
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-Ct6nm4UQ.js";
|
|
5
|
+
import { c as nextSceneSerial, u as referenceImagePath } from "./library-BF9ZMSFz.js";
|
|
6
6
|
import { join, relative } from "node:path";
|
|
7
7
|
import { characterKey, itemKey, locationKey } from "@dsh-agentic-roleplay/state";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
@@ -390,7 +390,7 @@ function imageTools(deps) {
|
|
|
390
390
|
negative_tags: {
|
|
391
391
|
...stringList,
|
|
392
392
|
required: true,
|
|
393
|
-
description: "
|
|
393
|
+
description: "What the picture must not show for this entity: its opposites and the drift a model tends to make (a different build, hair colour, age, style). Never a trait it has, and never an expression, pose or action."
|
|
394
394
|
},
|
|
395
395
|
global_id: {
|
|
396
396
|
type: "string",
|
|
@@ -403,6 +403,9 @@ function imageTools(deps) {
|
|
|
403
403
|
},
|
|
404
404
|
execute(args) {
|
|
405
405
|
const subject = findSubject(deps.story, args.kind, args.key);
|
|
406
|
+
const own = new Set(args.tags.map((tag) => tag.trim().toLowerCase()));
|
|
407
|
+
const contradicting = args.negative_tags.filter((tag) => own.has(tag.trim().toLowerCase()));
|
|
408
|
+
if (contradicting.length > 0) throw new Error(`${contradicting.map((tag) => `"${tag}"`).join(", ")} ${contradicting.length === 1 ? "is" : "are"} also in tags: a trait the entity has cannot be one to avoid. Leave ${contradicting.length === 1 ? "it" : "them"} out of negative_tags, or out of tags if it is not stable.`);
|
|
406
409
|
const identity = deps.story.visualIdentities.set(subject.kind, subject.id, {
|
|
407
410
|
description: args.description,
|
|
408
411
|
tags: args.tags,
|
|
@@ -839,6 +842,6 @@ async function runImagePresenter(job) {
|
|
|
839
842
|
images: [...generated]
|
|
840
843
|
};
|
|
841
844
|
}
|
|
842
|
-
export {
|
|
845
|
+
export { searchImages as a, presentedFor as c, findImages as i, interpretImage as n, tokensOf as o, imageTools as r, present as s, runImagePresenter as t };
|
|
843
846
|
|
|
844
|
-
//# sourceMappingURL=presenter-agent-
|
|
847
|
+
//# sourceMappingURL=presenter-agent-Bc478nTA.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as MAX_PREVIEW_TEXT, tn as ImportCardError } from "./authoring-tools
|
|
2
|
-
import {
|
|
3
|
-
import { Y as cleanText } from "./presets-
|
|
1
|
+
import { r as MAX_PREVIEW_TEXT, tn as ImportCardError } from "./authoring-tools-4NgDhIJV.js";
|
|
2
|
+
import { p as SAMPLING_RANGES } from "./child-D3QUNb3m.js";
|
|
3
|
+
import { Y as cleanText } from "./presets-DQ5rioMh.js";
|
|
4
4
|
// src/host/import/preset.ts
|
|
5
5
|
/** The older preset layout keeps its texts under fixed keys. */
|
|
6
6
|
const LEGACY_KEYS = [
|
|
@@ -239,4 +239,4 @@ function selectPrompts(file, enabled, keepSampling) {
|
|
|
239
239
|
}
|
|
240
240
|
export { readPreset as n, selectPrompts as r, previewPreset as t };
|
|
241
241
|
|
|
242
|
-
//# sourceMappingURL=preset-
|
|
242
|
+
//# sourceMappingURL=preset-SJZyw0kt.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./access-
|
|
2
|
-
import { $ as IMPORT_FOLDER, G as deleteWorldPrompt, J as writeWorldPrompt, K as listWorldPrompts, Q as withPlayer, W as PROSE_PROMPTS, c as presetDirectory, l as readPreset, p as updatePresetInfo, q as readWorldPrompt, t as PRESET_FILE, x as extractStyleFrom } from "./presets-
|
|
3
|
-
import { n as readPreset$1 } from "./preset-
|
|
4
|
-
import { i as contextOf } from "./authoring-tools
|
|
5
|
-
import { i as translator, r as languageOf } from "./text-
|
|
6
|
-
import {
|
|
1
|
+
import "./access-DAw54-NI.js";
|
|
2
|
+
import { $ as IMPORT_FOLDER, G as deleteWorldPrompt, J as writeWorldPrompt, K as listWorldPrompts, Q as withPlayer, W as PROSE_PROMPTS, c as presetDirectory, l as readPreset, p as updatePresetInfo, q as readWorldPrompt, t as PRESET_FILE, x as extractStyleFrom } from "./presets-DQ5rioMh.js";
|
|
3
|
+
import { n as readPreset$1 } from "./preset-SJZyw0kt.js";
|
|
4
|
+
import { i as contextOf } from "./authoring-tools-4NgDhIJV.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-Dfv8S8eq.js";
|
|
6
|
+
import { et as languageOf$1, it as shippedPromptsDirectory, rt as shippedLanguages } from "./hooks-BNeoGMHZ.js";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { readFile, rm } from "node:fs/promises";
|
|
@@ -278,4 +278,4 @@ async function presetApproval(exec, next, carries) {
|
|
|
278
278
|
}
|
|
279
279
|
export { presetChatSessionId as a, presetAuthorTools as i, narrationImportMessage as n, presetOfChat as o, presetApproval as r, PresetReader as t };
|
|
280
280
|
|
|
281
|
-
//# sourceMappingURL=preset-author-tools-
|
|
281
|
+
//# sourceMappingURL=preset-author-tools-CzogjK42.js.map
|
package/lib/preset-authoring.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as limitAuthoringAgents } from "./authoring-tools
|
|
2
|
-
import { t as guardAuthoringTurns } from "./turn-guard-
|
|
3
|
-
import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-
|
|
4
|
-
import "./hooks-
|
|
5
|
-
import { c as presetDirectory } from "./presets-
|
|
1
|
+
import { n as limitAuthoringAgents } from "./authoring-tools-4NgDhIJV.js";
|
|
2
|
+
import { t as guardAuthoringTurns } from "./turn-guard-BSAba8sp.js";
|
|
3
|
+
import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-CzogjK42.js";
|
|
4
|
+
import "./hooks-BNeoGMHZ.js";
|
|
5
|
+
import { c as presetDirectory } from "./presets-DQ5rioMh.js";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
8
|
// src/preset-authoring.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./narration-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { C as slug, S as norm, T as uniqueKey, w as trOf, x as mapLimit } from "./library-
|
|
1
|
+
import { m as parseSampling } from "./child-D3QUNb3m.js";
|
|
2
|
+
import "./narration-xvErE2yp.js";
|
|
3
|
+
import { a as VARIABLE_KINDS, n as atomicWrite, o as VARIABLE_SUBJECTS, s as VARIABLE_VISIBILITIES } from "./access-DAw54-NI.js";
|
|
4
|
+
import { G as readDocument, J as errorMessage, K as Reader, X as PROMPTS_FOLDER, Y as LANGUAGE_FOLDER, et as languageOf, it as shippedPromptsDirectory, nt as promptProblem, q as formatIssue, rt as shippedLanguages, tt as listFiles } from "./hooks-BNeoGMHZ.js";
|
|
5
|
+
import { i as translator, r as languageOf$1 } from "./text-Dfv8S8eq.js";
|
|
6
|
+
import { C as slug, S as norm, T as uniqueKey, w as trOf, x as mapLimit } from "./library-BF9ZMSFz.js";
|
|
7
7
|
import { dirname, join } from "node:path";
|
|
8
8
|
import { MAX_ROUTINE_WINDOWS, createSessionStore, dayTokenProblems, valueIssue } from "@dsh-agentic-roleplay/state";
|
|
9
9
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
@@ -151,6 +151,18 @@ const LORE_SUBJECT_KINDS = [
|
|
|
151
151
|
"item",
|
|
152
152
|
"lore"
|
|
153
153
|
];
|
|
154
|
+
// src/host/residency/guard.ts
|
|
155
|
+
/** The same service, whose listed methods first make room for the model they use and keep it from being unloaded while they run. */
|
|
156
|
+
function guarded(residency, role, service, methods) {
|
|
157
|
+
if (residency === void 0 || service === void 0) return service;
|
|
158
|
+
return new Proxy(service, { get(target, property, receiver) {
|
|
159
|
+
const value = Reflect.get(target, property, receiver);
|
|
160
|
+
if (typeof value !== "function") return value;
|
|
161
|
+
const call = value;
|
|
162
|
+
if (typeof property === "string" && methods.includes(property)) return (...args) => residency.run(role, async () => await call.apply(target, args));
|
|
163
|
+
return call.bind(target);
|
|
164
|
+
} });
|
|
165
|
+
}
|
|
154
166
|
// src/shared/world-state.ts
|
|
155
167
|
/** The problems with an edit, for the person who made it; nothing was changed. */
|
|
156
168
|
var InvalidEditProblems = class extends Error {
|
|
@@ -674,7 +686,7 @@ function parseRelationEdit(value) {
|
|
|
674
686
|
if (typeof input["status"] !== "string" || !choices.includes(input["status"])) problems.push(`status must be one of: ${choices.join(", ")}`);
|
|
675
687
|
}
|
|
676
688
|
if (creating) {
|
|
677
|
-
for (const field of ["from", "to"]) if (typeof input[field] !== "string" || input[field].trim() === "") problems.push(`${field} is needed`);
|
|
689
|
+
for (const field of ["from", "to"]) if (typeof input[field] !== "string" || input[field].trim() === "") problems.push(`${field} is needed: the key of the entity, written as plain text and not as an object`);
|
|
678
690
|
if ((kind === "character" || kind === "social") && (typeof input["label"] !== "string" || input["label"].trim() === "")) problems.push("label is needed");
|
|
679
691
|
if (kind === "membership" && (typeof input["role"] !== "string" || input["role"].trim() === "")) problems.push("role is needed");
|
|
680
692
|
if (kind === "exit" && typeof input["description"] !== "string") problems.push("description is needed");
|
|
@@ -819,6 +831,8 @@ function readRoutine(reader) {
|
|
|
819
831
|
if (location === void 0 && feature !== void 0) window.fail("feature", "needs a location");
|
|
820
832
|
const flag = window.raw("interruptible");
|
|
821
833
|
if (flag !== void 0 && typeof flag !== "boolean") window.fail("interruptible", "must be true or false");
|
|
834
|
+
const sleep = window.raw("sleep");
|
|
835
|
+
if (sleep !== void 0 && typeof sleep !== "boolean") window.fail("sleep", "must be true or false");
|
|
822
836
|
if (from === void 0 || to === void 0 || activity === void 0) return [];
|
|
823
837
|
return [{
|
|
824
838
|
days,
|
|
@@ -829,7 +843,8 @@ function readRoutine(reader) {
|
|
|
829
843
|
...location === void 0 ? {} : { location },
|
|
830
844
|
...feature === void 0 ? {} : { feature },
|
|
831
845
|
...position === void 0 ? {} : { position },
|
|
832
|
-
interruptible: flag !== false
|
|
846
|
+
interruptible: flag !== false,
|
|
847
|
+
...sleep === true ? { sleep: true } : {}
|
|
833
848
|
}];
|
|
834
849
|
});
|
|
835
850
|
if (windows.length > MAX_ROUTINE_WINDOWS) reader.fail("routine", `a character has at most ${MAX_ROUTINE_WINDOWS} windows in its day`);
|
|
@@ -1390,6 +1405,7 @@ function readDefinition(reader) {
|
|
|
1390
1405
|
subject,
|
|
1391
1406
|
visibility,
|
|
1392
1407
|
...reader.raw("description") === void 0 ? {} : { description: reader.text("description") },
|
|
1408
|
+
...reader.raw("update") === void 0 ? {} : { update: reader.text("update") },
|
|
1393
1409
|
only,
|
|
1394
1410
|
options,
|
|
1395
1411
|
bands,
|
|
@@ -1514,34 +1530,6 @@ function variableProblems(world) {
|
|
|
1514
1530
|
}
|
|
1515
1531
|
return problems;
|
|
1516
1532
|
}
|
|
1517
|
-
// src/shared/authoring-commands.ts
|
|
1518
|
-
/** The command a message starts with, when its name is one of `names` (not a longer word that starts with it). */
|
|
1519
|
-
function parseAuthoringCommand(text, names) {
|
|
1520
|
-
const value = text.trimStart();
|
|
1521
|
-
if (!value.startsWith("/")) return void 0;
|
|
1522
|
-
const end = value.search(/\s/u);
|
|
1523
|
-
const word = (end < 0 ? value : value.slice(0, end)).slice(1).toLowerCase();
|
|
1524
|
-
return names.includes(word) ? {
|
|
1525
|
-
name: word,
|
|
1526
|
-
rest: end < 0 ? "" : value.slice(end).trim()
|
|
1527
|
-
} : void 0;
|
|
1528
|
-
}
|
|
1529
|
-
// src/shared/import-card.ts
|
|
1530
|
-
/** The message the plugin sends on the player's behalf to start the import in the new world's authoring chat. */
|
|
1531
|
-
const IMPORT_COMMAND = "/import-st";
|
|
1532
|
-
/** The command in a message, with the card it names, or nothing when the message is not the command. */
|
|
1533
|
-
function parseImportCommand(text) {
|
|
1534
|
-
const command = parseAuthoringCommand(text, [IMPORT_COMMAND.slice(1)]);
|
|
1535
|
-
if (command === void 0) return void 0;
|
|
1536
|
-
const boundary = command.rest.search(/\s/u);
|
|
1537
|
-
return boundary < 0 ? {
|
|
1538
|
-
card: command.rest,
|
|
1539
|
-
request: ""
|
|
1540
|
-
} : {
|
|
1541
|
-
card: command.rest.slice(0, boundary),
|
|
1542
|
-
request: command.rest.slice(boundary).trim()
|
|
1543
|
-
};
|
|
1544
|
-
}
|
|
1545
1533
|
// src/host/import/dialect.ts
|
|
1546
1534
|
const MAX_NAMES = 8;
|
|
1547
1535
|
const PLAIN_MACROS = /* @__PURE__ */ new Set([
|
|
@@ -1636,6 +1624,211 @@ function sourceSummary(card, language) {
|
|
|
1636
1624
|
if (left.length > 0) lines.push(tr("Nothing runs them, so they are not carried: {parts}. Their effect is kept only where the card also says it in words.", { parts: left.join("; ") }));
|
|
1637
1625
|
return lines.join(" ");
|
|
1638
1626
|
}
|
|
1627
|
+
// src/host/import/panels.ts
|
|
1628
|
+
const FENCE = /```[^\n]*\n[\s\S]*?```/g;
|
|
1629
|
+
const TAG = /<(\/?)([\p{L}][\p{L}\p{N}_-]*)(?=[\s>/])[^>]*>/gu;
|
|
1630
|
+
const BLOCKS = /* @__PURE__ */ new Set([
|
|
1631
|
+
"div",
|
|
1632
|
+
"table",
|
|
1633
|
+
"details",
|
|
1634
|
+
"pre",
|
|
1635
|
+
"center",
|
|
1636
|
+
"section",
|
|
1637
|
+
"aside",
|
|
1638
|
+
"fieldset"
|
|
1639
|
+
]);
|
|
1640
|
+
const SEPARATORS = /\s[||│]\s|[||│]\s*\S+\s*[||│]/;
|
|
1641
|
+
const HEADER = /(?:^|\n)[ \t]*(?:【[^】\n]{1,30}】|\[[^\]\n]{1,30}\]|#+[ \t]*[^\n]{1,30})[ \t]*\n?\s*$/;
|
|
1642
|
+
const MAX_HTML_TEXT_CHARS = 600;
|
|
1643
|
+
const MAX_CUSTOM_CHARS = 4e3;
|
|
1644
|
+
/** A block of tags of a card's own invention (not markup) counts as a panel from this many tags: two or three tags are a form of address or an aside, a layout is more. */
|
|
1645
|
+
const MIN_CUSTOM_TAGS = 6;
|
|
1646
|
+
const MAX_PANELS = 6;
|
|
1647
|
+
const collapse = (text) => text.replace(/\n{3,}/g, "\n\n").trim();
|
|
1648
|
+
const plain = (html) => html.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
|
|
1649
|
+
/** The outermost elements of block markup and of invented tags in a text, balanced by their own names, with neighbours that only whitespace separates joined into one. */
|
|
1650
|
+
function tagBlocks(text) {
|
|
1651
|
+
const found = [];
|
|
1652
|
+
const open = [];
|
|
1653
|
+
let current = {
|
|
1654
|
+
from: 0,
|
|
1655
|
+
to: 0,
|
|
1656
|
+
custom: false,
|
|
1657
|
+
tags: 0
|
|
1658
|
+
};
|
|
1659
|
+
const closed = new Set([...text.matchAll(TAG)].filter((match) => match[1] === "/").map((match) => match[2].toLowerCase()));
|
|
1660
|
+
for (const match of text.matchAll(TAG)) {
|
|
1661
|
+
const name = match[2].toLowerCase();
|
|
1662
|
+
const custom = !MARKUP.has(name);
|
|
1663
|
+
if (!custom && !BLOCKS.has(name)) continue;
|
|
1664
|
+
if (match[1] === "" && !closed.has(name)) continue;
|
|
1665
|
+
if (match[1] === "") {
|
|
1666
|
+
if (open.length === 0) current = {
|
|
1667
|
+
from: match.index,
|
|
1668
|
+
to: 0,
|
|
1669
|
+
custom: false,
|
|
1670
|
+
tags: 0
|
|
1671
|
+
};
|
|
1672
|
+
open.push(name);
|
|
1673
|
+
current.tags += 1;
|
|
1674
|
+
current.custom ||= custom;
|
|
1675
|
+
} else if (open.includes(name)) {
|
|
1676
|
+
while (open.pop() !== name);
|
|
1677
|
+
current.tags += 1;
|
|
1678
|
+
if (open.length === 0) {
|
|
1679
|
+
current.to = match.index + match[0].length;
|
|
1680
|
+
found.push(current);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
const joined = [];
|
|
1685
|
+
for (const block of found) {
|
|
1686
|
+
const last = joined.at(-1);
|
|
1687
|
+
if (last !== void 0 && text.slice(last.to, block.from).trim() === "") {
|
|
1688
|
+
last.to = block.to;
|
|
1689
|
+
last.custom ||= block.custom;
|
|
1690
|
+
last.tags += block.tags;
|
|
1691
|
+
} else joined.push({ ...block });
|
|
1692
|
+
}
|
|
1693
|
+
return joined.map((block) => {
|
|
1694
|
+
const header = block.custom ? HEADER.exec(text.slice(0, block.from)) : null;
|
|
1695
|
+
return header === null ? block : {
|
|
1696
|
+
...block,
|
|
1697
|
+
from: header.index + (header[0].startsWith("\n") ? 1 : 0)
|
|
1698
|
+
};
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
const statusLine = (line) => SEPARATORS.test(line) && /\d/.test(line);
|
|
1702
|
+
/** An update call of a state-tracking framework: a block that holds one is a panel however few tags it has. */
|
|
1703
|
+
const CALL = /\b_\.\w+\(|\bstat_data\b|\bJSONPatch\b/;
|
|
1704
|
+
/** The text before a removed panel without its last line when that line only introduces the panel ("end every reply with this:"). */
|
|
1705
|
+
const withoutLeadIn = (before) => before.replace(/(?:^|\n)[^\n]*[::][ \t]*\n?\s*$/, "\n");
|
|
1706
|
+
function fencesWithoutLeadIn(text, panels) {
|
|
1707
|
+
let out = "";
|
|
1708
|
+
let last = 0;
|
|
1709
|
+
for (const match of text.matchAll(FENCE)) {
|
|
1710
|
+
panels.push(match[0].replace(/^```[^\n]*\n|```$/g, "").trim());
|
|
1711
|
+
out += `${withoutLeadIn(text.slice(last, match.index))}\n\n`;
|
|
1712
|
+
last = match.index + match[0].length;
|
|
1713
|
+
}
|
|
1714
|
+
return out + text.slice(last);
|
|
1715
|
+
}
|
|
1716
|
+
/**
|
|
1717
|
+
* Takes the status bars out of a message: fenced code blocks, blocks of tags of the card's own invention (a layout of nested tags, which names may be in any language), short blocks
|
|
1718
|
+
* of markup that carry numbers (when the message has story text besides them: a message wrapped whole in a block is only styled), and closing lines of values set apart by bars.
|
|
1719
|
+
* What is left is the story; the panels are what the card shows its state with.
|
|
1720
|
+
*/
|
|
1721
|
+
function splitPanels(text, options = {}) {
|
|
1722
|
+
const panels = [];
|
|
1723
|
+
let rest = options.leadIn === true ? fencesWithoutLeadIn(text, panels) : text.replace(FENCE, (block) => {
|
|
1724
|
+
panels.push(block.replace(/^```[^\n]*\n|```$/g, "").trim());
|
|
1725
|
+
return "\n\n";
|
|
1726
|
+
});
|
|
1727
|
+
const blocks = tagBlocks(rest);
|
|
1728
|
+
const outside = blocks.reduceRight((left, { from, to }) => left.slice(0, from) + left.slice(to), rest);
|
|
1729
|
+
if (blocks.length > 0 && (options.alone === true || plain(outside) !== "")) for (const block of [...blocks].reverse()) {
|
|
1730
|
+
const body = rest.slice(block.from, block.to);
|
|
1731
|
+
if (!(block.custom ? (block.tags >= MIN_CUSTOM_TAGS || CALL.test(body)) && body.length <= MAX_CUSTOM_CHARS : plain(body).length <= MAX_HTML_TEXT_CHARS && /\d/.test(body))) continue;
|
|
1732
|
+
panels.unshift(body.trim());
|
|
1733
|
+
rest = (options.leadIn === true ? withoutLeadIn(rest.slice(0, block.from)) : rest.slice(0, block.from)) + "\n\n" + rest.slice(block.to);
|
|
1734
|
+
}
|
|
1735
|
+
const paragraphs = collapse(rest).split(/\n{2,}/);
|
|
1736
|
+
while (paragraphs.length > 1 && paragraphs.at(-1).split("\n").every(statusLine)) panels.push(paragraphs.pop().trim());
|
|
1737
|
+
return {
|
|
1738
|
+
prose: collapse(paragraphs.join("\n\n")),
|
|
1739
|
+
panels: panels.filter((panel) => panel !== "")
|
|
1740
|
+
};
|
|
1741
|
+
}
|
|
1742
|
+
/** The distinct panels in a card's own messages (openings and examples): they show which values it keeps and where they start. */
|
|
1743
|
+
function panelsOfCard(card) {
|
|
1744
|
+
const texts = [
|
|
1745
|
+
card.firstMessage,
|
|
1746
|
+
...card.alternateGreetings,
|
|
1747
|
+
card.messageExample
|
|
1748
|
+
];
|
|
1749
|
+
return [...new Set(texts.flatMap((text) => splitPanels(text).panels))].filter((panel) => panel.length <= MAX_CUSTOM_CHARS).slice(0, MAX_PANELS);
|
|
1750
|
+
}
|
|
1751
|
+
/** The sentences of one line; a full stop inside a word or a call (`_.set(`) does not end one. */
|
|
1752
|
+
const sentencesOf = (line) => line.match(/(?:[^.!?。!?]|[.!?](?!\s|$))+(?:[.!?]+(?=\s|$)|[。!?]+|$)\s*/gu) ?? [line];
|
|
1753
|
+
const MIN_LEFT_OUT_WORDS = 3;
|
|
1754
|
+
const ECHO_SHARE = .6;
|
|
1755
|
+
/** A short sentence right after a dropped one ("Never skip it.") has nothing left to refer to. */
|
|
1756
|
+
const MAX_TAIL_WORDS = 4;
|
|
1757
|
+
function wordsOf(text) {
|
|
1758
|
+
const words = /* @__PURE__ */ new Set();
|
|
1759
|
+
for (const word of text.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? []) if (/[㐀-鿿]/.test(word)) for (let index = 0; index < word.length - 1; index += 1) words.add(word.slice(index, index + 2));
|
|
1760
|
+
else if (word.length >= 3) words.add(word);
|
|
1761
|
+
return words;
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* The sentences of a prose prompt that repeat something the same answer lists as left out. A model that is told to drop an instruction about the shape of the reply (a status bar after
|
|
1765
|
+
* every message) tends to list it and keep it in the same breath; what it listed is not carried.
|
|
1766
|
+
*/
|
|
1767
|
+
function withoutLeftOut(prose, leftOut) {
|
|
1768
|
+
const dropped = leftOut.map(wordsOf).filter((words) => words.size >= MIN_LEFT_OUT_WORDS);
|
|
1769
|
+
if (dropped.length === 0) return prose;
|
|
1770
|
+
const echoes = (sentence) => {
|
|
1771
|
+
const words = wordsOf(sentence);
|
|
1772
|
+
return dropped.some((left) => [...left].filter((word) => words.has(word)).length >= left.size * ECHO_SHARE);
|
|
1773
|
+
};
|
|
1774
|
+
const kept = (line) => {
|
|
1775
|
+
let after = false;
|
|
1776
|
+
return sentencesOf(line).filter((sentence) => {
|
|
1777
|
+
const echo = echoes(sentence);
|
|
1778
|
+
const tail = after && sentence.trim().split(/\s+/).length <= MAX_TAIL_WORDS;
|
|
1779
|
+
after = echo;
|
|
1780
|
+
return !echo && !tail;
|
|
1781
|
+
}).join("").trim();
|
|
1782
|
+
};
|
|
1783
|
+
return prose.split("\n").map(kept).filter((line) => line !== "").join("\n");
|
|
1784
|
+
}
|
|
1785
|
+
const OUTPUT_MARKUP = /<\/?[\p{L}][\p{L}\p{N}_-]*>|```|\b_\.\w+\(|\bstat_data\b|\{\{(?!\s*(?:user|char|bot)\s*\}\})[^{}]+\}\}/u;
|
|
1786
|
+
/** A text that is mostly a panel is a format specification, not a rule or a fact: it goes whole. */
|
|
1787
|
+
const PANEL_SHARE = .5;
|
|
1788
|
+
/** A standing rule without the panel it demands, the sentences that tell the game master to print markup, a code block or an update call after a reply, and the rule itself when the panel was most of it: the story shows its tracked values itself. */
|
|
1789
|
+
function withoutOutputMarkup(passage) {
|
|
1790
|
+
const { prose, panels } = splitPanels(passage, {
|
|
1791
|
+
alone: true,
|
|
1792
|
+
leadIn: true
|
|
1793
|
+
});
|
|
1794
|
+
if (panels.length > 0 && prose.length < passage.length * PANEL_SHARE) return "";
|
|
1795
|
+
return prose.split("\n").map((line) => sentencesOf(line).filter((sentence) => !OUTPUT_MARKUP.test(sentence)).join("").trim()).filter((line) => line !== "").join("\n");
|
|
1796
|
+
}
|
|
1797
|
+
const BARRED = /(?:\s[||│]\s[^||│\n]+){2,}/;
|
|
1798
|
+
/** The first status bar, panel or print-this-markup directive in a text, as written, or nothing: what a world should show with its tracked values rather than carry as text. */
|
|
1799
|
+
function findPanel(text) {
|
|
1800
|
+
const panel = splitPanels(text, { alone: true }).panels[0];
|
|
1801
|
+
if (panel !== void 0) return panel;
|
|
1802
|
+
for (const line of text.split("\n")) for (const sentence of sentencesOf(line)) if (OUTPUT_MARKUP.test(sentence) || BARRED.test(sentence) && /\d/.test(sentence)) return sentence.trim();
|
|
1803
|
+
}
|
|
1804
|
+
// src/shared/authoring-commands.ts
|
|
1805
|
+
/** The command a message starts with, when its name is one of `names` (not a longer word that starts with it). */
|
|
1806
|
+
function parseAuthoringCommand(text, names) {
|
|
1807
|
+
const value = text.trimStart();
|
|
1808
|
+
if (!value.startsWith("/")) return void 0;
|
|
1809
|
+
const end = value.search(/\s/u);
|
|
1810
|
+
const word = (end < 0 ? value : value.slice(0, end)).slice(1).toLowerCase();
|
|
1811
|
+
return names.includes(word) ? {
|
|
1812
|
+
name: word,
|
|
1813
|
+
rest: end < 0 ? "" : value.slice(end).trim()
|
|
1814
|
+
} : void 0;
|
|
1815
|
+
}
|
|
1816
|
+
// src/shared/import-card.ts
|
|
1817
|
+
/** The message the plugin sends on the player's behalf to start the import in the new world's authoring chat. */
|
|
1818
|
+
const IMPORT_COMMAND = "/import-st";
|
|
1819
|
+
/** The command in a message, with the card it names, or nothing when the message is not the command. */
|
|
1820
|
+
function parseImportCommand(text) {
|
|
1821
|
+
const command = parseAuthoringCommand(text, [IMPORT_COMMAND.slice(1)]);
|
|
1822
|
+
if (command === void 0) return void 0;
|
|
1823
|
+
const boundary = command.rest.search(/\s/u);
|
|
1824
|
+
return boundary < 0 ? {
|
|
1825
|
+
card: command.rest,
|
|
1826
|
+
request: ""
|
|
1827
|
+
} : {
|
|
1828
|
+
card: command.rest.slice(0, boundary),
|
|
1829
|
+
request: command.rest.slice(boundary).trim()
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1639
1832
|
// src/host/import/store.ts
|
|
1640
1833
|
const IMPORT_FOLDER = ".import";
|
|
1641
1834
|
const CARD_FILE = "card.json";
|
|
@@ -1870,8 +2063,8 @@ function itemise(card, choices) {
|
|
|
1870
2063
|
...itemsOf("field:description", "description", "", [], card.description, name),
|
|
1871
2064
|
...itemsOf("field:personality", "personality", "", [], card.personality, name),
|
|
1872
2065
|
...itemsOf("field:scenario", "scenario", "", [], card.scenario, name),
|
|
1873
|
-
...itemsOf("field:example", "example messages", "", [], card.messageExample, name),
|
|
1874
|
-
...opening === void 0 ? [] : itemsOf("field:opening", "opening", "", [], opening, name),
|
|
2066
|
+
...itemsOf("field:example", "example messages", "", [], splitPanels(card.messageExample).prose, name),
|
|
2067
|
+
...opening === void 0 ? [] : itemsOf("field:opening", "opening", "", [], splitPanels(opening).prose, name),
|
|
1875
2068
|
...(card.book?.entries ?? []).filter((entry) => !off.has(entry.id)).flatMap((entry) => itemsOf(entry.id, entry.title === "" ? entry.id : `entry “${entry.title}”`, entry.title, entry.keys, entry.content, name, entry.constant))
|
|
1876
2069
|
];
|
|
1877
2070
|
}
|
|
@@ -3122,7 +3315,7 @@ const LORE_SUBJECT = {
|
|
|
3122
3315
|
function loreDocuments(answer, roster, taken) {
|
|
3123
3316
|
return objects(answer["entries"]).flatMap((entry) => {
|
|
3124
3317
|
const title = text(entry["title"]);
|
|
3125
|
-
const body = text(entry["body"]);
|
|
3318
|
+
const body = withoutOutputMarkup(text(entry["body"]));
|
|
3126
3319
|
if (title === "" || body === "") return [];
|
|
3127
3320
|
const notes = [];
|
|
3128
3321
|
const subjects = [];
|
|
@@ -3152,7 +3345,7 @@ function loreDocuments(answer, roster, taken) {
|
|
|
3152
3345
|
id: uniqueKey(slug(title, "lore"), taken),
|
|
3153
3346
|
title,
|
|
3154
3347
|
kind,
|
|
3155
|
-
summary: text(entry["summary"]),
|
|
3348
|
+
summary: withoutOutputMarkup(text(entry["summary"])),
|
|
3156
3349
|
body
|
|
3157
3350
|
};
|
|
3158
3351
|
put(document, "subjects", subjects);
|
|
@@ -3495,7 +3688,7 @@ async function extractEntities(ctx, card, items, classified, roster) {
|
|
|
3495
3688
|
result: GUIDANCE_SCHEMA,
|
|
3496
3689
|
check: (value) => passageProblem(value, item.text)
|
|
3497
3690
|
});
|
|
3498
|
-
const passages = (field) => answer[field].filter((passage) => passage.trim() !== "");
|
|
3691
|
+
const passages = (field) => answer[field].map(withoutOutputMarkup).filter((passage) => passage.trim() !== "");
|
|
3499
3692
|
return {
|
|
3500
3693
|
item,
|
|
3501
3694
|
casting: passages("casting"),
|
|
@@ -3622,14 +3815,15 @@ async function extractStyleFrom(ctx, name, pieces) {
|
|
|
3622
3815
|
result: STYLE_SCHEMA,
|
|
3623
3816
|
check: (value) => styleProblem("roleplay/style", text(value.narration), list(value.persona_names)) ?? styleProblem("roleplay/character-style", text(value.characters), list(value.persona_names))
|
|
3624
3817
|
});
|
|
3625
|
-
const
|
|
3818
|
+
const leftOut = list(answer.left_out);
|
|
3819
|
+
const prompts = [["roleplay/style", withoutLeftOut(text(answer.narration), leftOut)], ["roleplay/character-style", withoutLeftOut(text(answer.characters), leftOut)]].flatMap(([id, body]) => body === "" ? [] : [{
|
|
3626
3820
|
id,
|
|
3627
3821
|
text: body
|
|
3628
3822
|
}]);
|
|
3629
3823
|
if (!prompts.every((entry) => PROSE_PROMPTS.includes(entry.id))) throw new Error("only prose prompts can be made");
|
|
3630
3824
|
return {
|
|
3631
3825
|
prompts,
|
|
3632
|
-
notes: list(answer.left_out).map((entry) => `instructions
|
|
3826
|
+
notes: list(answer.left_out).map((entry) => `instructions left out on purpose: ${entry}`)
|
|
3633
3827
|
};
|
|
3634
3828
|
} catch (error) {
|
|
3635
3829
|
return {
|
|
@@ -3655,6 +3849,10 @@ const VARIABLES_SCHEMA = {
|
|
|
3655
3849
|
type: "string",
|
|
3656
3850
|
description: "What it measures, in a sentence."
|
|
3657
3851
|
},
|
|
3852
|
+
update: {
|
|
3853
|
+
type: "string",
|
|
3854
|
+
description: "When and how the card says it changes (its update rule: what makes it rise or fall, and by how much), in a sentence or two; empty when the card gives no rule."
|
|
3855
|
+
},
|
|
3658
3856
|
kind: {
|
|
3659
3857
|
type: "string",
|
|
3660
3858
|
enum: [
|
|
@@ -3727,6 +3925,7 @@ const VARIABLES_SCHEMA = {
|
|
|
3727
3925
|
"key",
|
|
3728
3926
|
"name",
|
|
3729
3927
|
"description",
|
|
3928
|
+
"update",
|
|
3730
3929
|
"kind",
|
|
3731
3930
|
"subject",
|
|
3732
3931
|
"visibility",
|
|
@@ -3752,12 +3951,14 @@ const VARIABLES_SCHEMA = {
|
|
|
3752
3951
|
/** The pieces that may describe what a card tracks: its panels and formats, and its instructions. */
|
|
3753
3952
|
/** What a card that keeps its game state in variables says of them: the tool that updates them names itself in the text, whatever role the piece was given. */
|
|
3754
3953
|
const STATE_SPEC = /stat_data|\[mvu_|<UpdateVariable>|<initvar>|JSON ?Patch/i;
|
|
3755
|
-
function trackingPieces(card, items, classified) {
|
|
3954
|
+
function trackingPieces(card, items, classified, tr) {
|
|
3756
3955
|
const specs = items.filter((item) => mainRole(classified[item.id] ?? { roles: [] }) !== "irrelevant" && STATE_SPEC.test(item.text)).map((item) => item.text);
|
|
3956
|
+
const panels = panelsOfCard(card).map((panel) => `${tr("A status panel from one of the card's own messages (it shows which values the card keeps and where they start):")}\n${panel}`);
|
|
3757
3957
|
return [.../* @__PURE__ */ new Set([
|
|
3758
3958
|
...items.filter((item) => mainRole(classified[item.id] ?? { roles: [] }) === "template").map((item) => item.text),
|
|
3759
3959
|
...instructionPieces(card, items, classified),
|
|
3760
|
-
...specs
|
|
3960
|
+
...specs,
|
|
3961
|
+
...panels
|
|
3761
3962
|
])];
|
|
3762
3963
|
}
|
|
3763
3964
|
/** The documents of `variables.json` an answer describes, with the roster's names turned into keys. */
|
|
@@ -3773,6 +3974,7 @@ function variableDocuments(answer, roster) {
|
|
|
3773
3974
|
subject: text(entry["subject"])
|
|
3774
3975
|
};
|
|
3775
3976
|
put(document, "description", text(entry["description"]));
|
|
3977
|
+
put(document, "update", text(entry["update"]));
|
|
3776
3978
|
put(document, "visibility", text(entry["visibility"]));
|
|
3777
3979
|
put(document, "only", list(entry["only"]).flatMap((name) => keyOf(name) ?? []));
|
|
3778
3980
|
for (const field of ["min", "max"]) if (typeof entry[field] === "number") document[field] = entry[field];
|
|
@@ -3827,7 +4029,8 @@ const MAX_VARIABLE_ROUNDS = 12;
|
|
|
3827
4029
|
const TOKENS_PER_VARIABLE = 600;
|
|
3828
4030
|
/** Finds what the card keeps track of, such as status panels and meters, and writes it as the world's tracked variables. Each group of the card's tracking text is read on its own, a request declares at most `variablesPerRequest` values and is asked again, told what is declared already, while it fills its share; the first declaration of a key stands. */
|
|
3829
4031
|
async function extractVariables(ctx, card, items, classified, roster) {
|
|
3830
|
-
const
|
|
4032
|
+
const tr = trOf(ctx);
|
|
4033
|
+
const groups = trackingGroups(trackingPieces(card, items, classified, tr));
|
|
3831
4034
|
if (groups.length === 0) return {
|
|
3832
4035
|
variables: [],
|
|
3833
4036
|
notes: [],
|
|
@@ -3835,7 +4038,6 @@ async function extractVariables(ctx, card, items, classified, roster) {
|
|
|
3835
4038
|
};
|
|
3836
4039
|
const perRequest = ctx.variablesPerRequest ?? DEFAULT_VARIABLES_PER_REQUEST;
|
|
3837
4040
|
const names = (kind) => roster.filter((entity) => entity.kind === kind).map((entity) => entity.name).join(", ");
|
|
3838
|
-
const tr = trOf(ctx);
|
|
3839
4041
|
const found = await mapLimit(groups, ctx.concurrency, async (pieces, index) => {
|
|
3840
4042
|
const documents = [];
|
|
3841
4043
|
const notes = [];
|
|
@@ -4145,6 +4347,6 @@ async function createPresetFromGuidance(root, request, guidance, shipped = shipp
|
|
|
4145
4347
|
});
|
|
4146
4348
|
}
|
|
4147
4349
|
}
|
|
4148
|
-
export { IMPORT_FOLDER as $, sourcesFor as A,
|
|
4350
|
+
export { IMPORT_FOLDER as $, sourcesFor as A, readVariableValues as At, modeFor as B, LORE_KINDS as Bt, inert as C, SLOTS_FILE_NAME as Ct, pruneLoreSubjects as D, parseFactionFile as Dt, pruneLinks as E, FACTION_FILE_NAME as Et, ROLE_TABLE as F, parseLoreEdit as Ft, deleteWorldPrompt as G, routeVerdicts as H, WEEKDAY_NAMES as Ht, isLeftOut as I, parsePlaceEdit as It, writeWorldPrompt as J, listWorldPrompts as K, announceProblem as L, parseRelationEdit as Lt, classifyItems as M, InvalidEditProblems as Mt, findEntity as N, parseCharacterEdit as Nt, pruneMembers as O, CHARACTER_FILE_NAME as Ot, ROLES as P, parseFactionEdit as Pt, withPlayer as Q, askYesNo as R, parseThingEdit as Rt, extractVariables as S, ITEM_FILE_NAME as St, pruneKnowledge as T, parseSlotsFile as Tt, yesAt as U, DEFAULT_SLOTS as Ut, noAt as V, LORE_SCOPES as Vt, PROSE_PROMPTS as W, INTENT_STATUSES as Wt, itemise as X, cleanText as Y, partsOf as Z, characterDocument as _, variableProblems as _t, isPresetName as a, readImportFolder as at, extractStyle as b, LOCATION_FILE_NAME as bt, presetDirectory as c, parseImportCommand as ct, savePresetFromWorld as d, splitPanels as dt, ImportNotFoundError as et, sha as f, dialectOf as ft, asWritten as g, parseVariablesFile as gt, addLore as h, loadVariables as ht, deletePreset as i, parseChoices as it, buildRoster as j, readIdentifier as jt, pruneRelationships as k, parseCharacterFile as kt, readPreset as l, parseAuthoringCommand as lt, STANDING_PROMPT as m, VARIABLES_FILE_NAME as mt, createPresetFromGuidance as n, PICTURE_FILE as nt, listPresets as o, writeChoices as ot, updatePresetInfo as p, sourceSummary as pt, readWorldPrompt as q, createPresetFromShipped as r, openingText as rt, loadPreset as s, IMPORT_COMMAND as st, PRESET_FILE as t, ImportStore as tt, reservePreset as u, findPanel as ut, emptyExtracted as v, LORE_FILE_NAME as vt, loreDocuments as w, parseItemFile as wt, extractStyleFrom as x, parseLocationFile as xt, extractEntities as y, parseLoreFile as yt, mergeReports as z, guarded as zt };
|
|
4149
4351
|
|
|
4150
|
-
//# sourceMappingURL=presets-
|
|
4352
|
+
//# sourceMappingURL=presets-DQ5rioMh.js.map
|