@dsh-agentic-roleplay/core 0.12.3 → 0.12.5
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-Csp80TFX.js → access-DjA0kvPM.js} +2 -2
- package/lib/{authoring-tools-hacA5fG-.js → authoring-tools-DqAttdUN.js} +260 -36
- package/lib/authoring.js +176 -10
- package/lib/{child-DTdY14S9.js → child-SMvjNsb8.js} +63 -9
- package/lib/client.js +2043 -1236
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +3 -3
- package/lib/doctor.js +3 -3
- package/lib/{gallery-BNg0rPTp.js → gallery-Dahi5TkO.js} +3 -3
- package/lib/{generator-9-5at9cZ.js → generator-BvSZGpzy.js} +2 -2
- package/lib/helper.js +2 -2
- package/lib/{hooks-DlrFO4aQ.js → hooks-OLl-1AOS.js} +67 -28
- package/lib/images.js +4 -4
- package/lib/index.js +45 -30
- package/lib/{jail-DVbPSC0R.js → jail-CDW5iymd.js} +2 -2
- package/lib/{library-DTxakw0z.js → library-D6AcyxGZ.js} +3 -3
- package/lib/{lorebook-author-tools-dupq-kb_.js → lorebook-author-tools-CXV1KD4Q.js} +7 -7
- package/lib/lorebook-authoring.js +5 -5
- package/lib/{narration--K2XVIHI.js → narration-Bnrvl0UQ.js} +2 -2
- package/lib/orchestration.js +37 -38
- package/lib/{pack-jail-Bq0fzKi4.js → pack-jail-CZAmlgE1.js} +16 -15
- package/lib/{packs-D-7EU3yU.js → packs-DUVCSHqi.js} +2 -2
- package/lib/{presenter-agent-vFOxIuWv.js → presenter-agent-CGCJrg7V.js} +7 -6
- package/lib/{preset-RHcOG55T.js → preset-BYfXYvp0.js} +4 -4
- package/lib/{preset-author-tools-Dwxnpv6V.js → preset-author-tools-DYxTLm9U.js} +7 -7
- package/lib/preset-authoring.js +5 -5
- package/lib/{reflection-DibpEUQK.js → reflection-C3zdufN9.js} +8 -8
- package/lib/{serial-CDGoXYh-.js → serial-Bh6gqb3f.js} +239 -51
- package/lib/{text-Dfv8S8eq.js → text-B-HsLdb-.js} +4 -1
- package/lib/{turn-guard-DDxikrq7.js → turn-guard-CNFvmz_F.js} +3 -3
- package/package.json +2 -2
- package/prompts/en/import/opening.md +17 -0
- package/prompts/en/roleplay/decide-opening.md +1 -0
- package/prompts/en/world/procedure.md +1 -1
- package/prompts/zh/import/opening.md +17 -0
- package/prompts/zh/roleplay/decide-opening.md +1 -0
- package/prompts/zh/world/procedure.md +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { A as chatSessionId } from "./child-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as encodeOutput } from "./narration
|
|
5
|
-
import { a as VARIABLE_KINDS, n as atomicWrite, o as VARIABLE_SUBJECTS, r as atomicWriteJson, s as VARIABLE_VISIBILITIES } from "./access-
|
|
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, Z as PROMPTS_FOLDER, gt as runCommandLine, it as shippedLanguages, lt as InvalidWorldError, mt as CommandRefusedError, pt as WorldNotFoundError, q as formatIssue, st as AgentUnavailableError, z as loadPlots } from "./hooks-
|
|
7
|
-
import { i as translator, r as languageOf } from "./text-
|
|
8
|
-
import { h as readImageFileMetadata, u as referenceImagePath, x as mapLimit } 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-
|
|
1
|
+
import { A as chatSessionId } from "./child-SMvjNsb8.js";
|
|
2
|
+
import { $t as authoringChatSessionId, A as loadWorldParts, Bt as loadCommands, Ct as loadDice, D as worldFieldChanges, Dt as parseCalendarFile, Et as loadCalendar, F as editsSince, G as addressesToFetch, Ht as TRIGGERS_FILE_NAME, I as writeSnapshot, K as candidateUrls, Mt as UPDATE_FOLDER, Nt as baseId, O as editWorldInfo, Ot as CHARACTERS_DIR, P as recordProvenance, Pt as cardPieces, Q as writePortrait, Qt as authoredWorldOf, Rt as COMMANDS_FILE_NAME, St as DICE_FILE_NAME, T as matchPieces, Tt as CALENDAR_FILE_NAME, Ut as loadTriggers, Vt as parseCommandsFile, W as addressKey, Xt as DICE_READINGS, Y as mergeReports, Yt as DICE_COMPARISONS, Z as cardCharacter, Zt as DICE_RESULTS, _t as loadLocations, bt as FACTIONS_DIR, et as loadValidatedWorld, f as importPhase, gt as LOCATIONS_DIR, ht as routineProblems, kt as loadCharacters, nt as knowsCharacter, o as contextOf, q as fetchPictures, tt as withScratchStory, u as worldOf, vt as ITEMS_DIR, wt as parseDiceFile, xt as loadFactions, yt as loadItems, zt as commandVariable } from "./authoring-tools-DqAttdUN.js";
|
|
3
|
+
import { $t as LOCATION_FILE_NAME, Et as IMPORT_FOLDER, Jt as loadVariables, M as WORLD_FILE_NAME, Mt as readImportFolder, N as parseWorldFile, Nt as writeChoices, Pt as InvalidEditProblems, Qt as parseLoreFile, Tt as withPlayer, Xt as variableProblems, Yt as parseVariablesFile, Zt as LORE_FILE_NAME, an as FACTION_FILE_NAME, at as writeWorldPrompt, bt as loadLore, cn as parseCharacterFile, en as parseLocationFile, kt as PICTURE_FILE, l as extractStyleFrom, on as parseFactionFile, qt as VARIABLES_FILE_NAME, rn as parseItemFile, sn as CHARACTER_FILE_NAME, tn as ITEM_FILE_NAME, xt as subfolders, yt as LORE_DIR } from "./serial-Bh6gqb3f.js";
|
|
4
|
+
import { n as encodeOutput } from "./narration-Bnrvl0UQ.js";
|
|
5
|
+
import { a as VARIABLE_KINDS, n as atomicWrite, o as VARIABLE_SUBJECTS, r as atomicWriteJson, s as VARIABLE_VISIBILITIES } from "./access-DjA0kvPM.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, Z as PROMPTS_FOLDER, gt as runCommandLine, it as shippedLanguages, lt as InvalidWorldError, mt as CommandRefusedError, pt as WorldNotFoundError, q as formatIssue, st as AgentUnavailableError, z as loadPlots } from "./hooks-OLl-1AOS.js";
|
|
7
|
+
import { i as translator, r as languageOf } from "./text-B-HsLdb-.js";
|
|
8
|
+
import { h as readImageFileMetadata, u as referenceImagePath, x as mapLimit } from "./library-D6AcyxGZ.js";
|
|
9
|
+
import { n as readPreset } from "./preset-BYfXYvp0.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-DUVCSHqi.js";
|
|
11
|
+
import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-BvSZGpzy.js";
|
|
12
12
|
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
13
13
|
import { readTriggerDefinition, triggerReferenceProblems } from "@dsh-agentic-roleplay/state";
|
|
14
14
|
import { existsSync, lstatSync, statSync } from "node:fs";
|
|
@@ -257,7 +257,7 @@ function agentServicesOf(ctx) {
|
|
|
257
257
|
const persistence = ctx.get("sessionPersistence");
|
|
258
258
|
const agents = ctx.get("agents");
|
|
259
259
|
const command = agents === void 0 ? void 0 : async (chat, line) => {
|
|
260
|
-
const live = agents.get(chat);
|
|
260
|
+
const live = agents.get(SessionId(chat));
|
|
261
261
|
return live === void 0 ? void 0 : await runCommandLine(ctx, live, line, new AbortController().signal);
|
|
262
262
|
};
|
|
263
263
|
return {
|
|
@@ -278,7 +278,7 @@ const UNLOAD_WAIT_MS = 5e3;
|
|
|
278
278
|
*/
|
|
279
279
|
function unloader(ctx, agents) {
|
|
280
280
|
return async (chat) => {
|
|
281
|
-
const live = agents.get(chat);
|
|
281
|
+
const live = agents.get(SessionId(chat));
|
|
282
282
|
if (live === void 0) return;
|
|
283
283
|
let off = () => {};
|
|
284
284
|
try {
|
|
@@ -302,7 +302,7 @@ function unloader(ctx, agents) {
|
|
|
302
302
|
} finally {
|
|
303
303
|
off();
|
|
304
304
|
}
|
|
305
|
-
if (agents.get(chat) !== void 0) throw new Error(`the chat ${chat} is still loaded and cannot be replaced`);
|
|
305
|
+
if (agents.get(SessionId(chat)) !== void 0) throw new Error(`the chat ${chat} is still loaded and cannot be replaced`);
|
|
306
306
|
};
|
|
307
307
|
}
|
|
308
308
|
/**
|
|
@@ -889,6 +889,7 @@ const FIELDS$1 = {
|
|
|
889
889
|
"opening_message[].text",
|
|
890
890
|
"alternate_openings[].title",
|
|
891
891
|
"alternate_openings[].text",
|
|
892
|
+
"alternate_openings[].parts[].text",
|
|
892
893
|
"start_questions[].text",
|
|
893
894
|
"start_questions[].options[].label",
|
|
894
895
|
"start_questions[].options[].description",
|
|
@@ -3226,4 +3227,4 @@ function registerPackJail(ctx, deps) {
|
|
|
3226
3227
|
}
|
|
3227
3228
|
export { languageOfDocuments as $, generateWorldCharacterPortrait as A, deleteTriggerDocument as B, editWorldFaction as C, editWorldPlots as D, editWorldPlace as E, uploadWorldCharacterPortrait as F, parseVariablesEdit as G, writeTriggerDocument as H, uploadWorldEntityImage as I, PRESET_FILE as J, parseDiceEdit as K, worldCharacterPortraitFile as L, readWorldEditor as M, readWorldTrigger as N, editWorldRelation as O, removeWorldTrigger as P, translateTools as Q, worldEntityImageFile as R, editWorldCharacter as S, editWorldNarrationVoice as T, parseCalendarEdit as U, readTriggerDocuments as V, parseRoutineEdit as W, presetTools as X, presetMessage as Y, translateMessage as Z, readCalendarDocument as _, deleteWorldPackFile as a, startUpdate as at, readRoutines as b, createAuthoredEntity as c, authoringTitle as ct, replaceAuthoredEntity as d, agentServicesOf as dt, readWorldDocuments as et, editCalendar as f, DOCTOR_OPENING_SOURCE as ft, editVariables as g, editRoutine as h, checkWorldPack as i, revertUpdate as it, generateWorldEntityImage as j, editWorldThing as k, deleteAuthoredEntity as l, ensureAuthoringChat as lt, editDice as m, appendNarratedTurn as mt, packFileProblem as n, finishUpdate as nt, listWorldPacks as o, updateStatus as ot, editCommands as p, appendEmptyTurn as pt, parseCommandsEdit as q, registerPackJail as r, pendingUpdate as rt, AUTHORED_ENTITY_KINDS as s, AuthoringSessions as st, MAX_PACK_TEXT as t, findTargets as tt, readAuthoredEntityDocument as u, AgentSessions as ut, readCommandsDocument as v, editWorldLore as w, readVariables as x, readDiceDocument as y, writeWorldTrigger as z };
|
|
3228
3229
|
|
|
3229
|
-
//# sourceMappingURL=pack-jail-
|
|
3230
|
+
//# sourceMappingURL=pack-jail-CZAmlgE1.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as Reader } from "./hooks-
|
|
1
|
+
import { K as Reader } from "./hooks-OLl-1AOS.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-DUVCSHqi.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-DjA0kvPM.js";
|
|
2
|
+
import { l as runChild } from "./child-SMvjNsb8.js";
|
|
3
|
+
import { n as generateTransientImage, t as generateReferenceImage } from "./generator-BvSZGpzy.js";
|
|
4
|
+
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-Dahi5TkO.js";
|
|
5
|
+
import { c as nextSceneSerial, u as referenceImagePath } from "./library-D6AcyxGZ.js";
|
|
6
6
|
import { join, relative, sep } from "node:path";
|
|
7
7
|
import { characterKey, itemKey, locationKey } from "@dsh-agentic-roleplay/state";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
@@ -837,6 +837,7 @@ async function runImagePresenter(job) {
|
|
|
837
837
|
}),
|
|
838
838
|
result: RESULT,
|
|
839
839
|
beforeSubmit: () => generated.length === 0 ? "you have not shown or generated an image: use the appropriate tool before finishing" : void 0,
|
|
840
|
+
...job.trace === void 0 ? {} : { trace: job.trace },
|
|
840
841
|
maxCalls: 16
|
|
841
842
|
})).summary,
|
|
842
843
|
images: [...generated]
|
|
@@ -844,4 +845,4 @@ async function runImagePresenter(job) {
|
|
|
844
845
|
}
|
|
845
846
|
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 };
|
|
846
847
|
|
|
847
|
-
//# sourceMappingURL=presenter-agent-
|
|
848
|
+
//# sourceMappingURL=presenter-agent-CGCJrg7V.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { p as SAMPLING_RANGES } from "./child-
|
|
3
|
-
import {
|
|
1
|
+
import { Wt as ImportCardError, r as MAX_PREVIEW_TEXT } from "./authoring-tools-DqAttdUN.js";
|
|
2
|
+
import { p as SAMPLING_RANGES } from "./child-SMvjNsb8.js";
|
|
3
|
+
import { St as cleanText } from "./serial-Bh6gqb3f.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-BYfXYvp0.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./access-
|
|
2
|
-
import {
|
|
3
|
-
import { n as readPreset$1 } from "./preset-
|
|
4
|
-
import { o as contextOf } from "./authoring-tools-
|
|
5
|
-
import { i as translator, r as languageOf } from "./text-
|
|
6
|
-
import { at as shippedPromptsDirectory, it as shippedLanguages, tt as languageOf$1 } from "./hooks-
|
|
1
|
+
import "./access-DjA0kvPM.js";
|
|
2
|
+
import { Et as IMPORT_FOLDER, H as PRESET_FILE, Tt as withPlayer, X as readPreset, Y as presetDirectory, at as writeWorldPrompt, et as updatePresetInfo, it as readWorldPrompt, l as extractStyleFrom, nt as deleteWorldPrompt, rt as listWorldPrompts, tt as PROSE_PROMPTS } from "./serial-Bh6gqb3f.js";
|
|
3
|
+
import { n as readPreset$1 } from "./preset-BYfXYvp0.js";
|
|
4
|
+
import { o as contextOf } from "./authoring-tools-DqAttdUN.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-B-HsLdb-.js";
|
|
6
|
+
import { at as shippedPromptsDirectory, it as shippedLanguages, tt as languageOf$1 } from "./hooks-OLl-1AOS.js";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { readFile, rm } from "node:fs/promises";
|
|
@@ -279,4 +279,4 @@ async function presetApproval(exec, next, carries, auto = () => false) {
|
|
|
279
279
|
}
|
|
280
280
|
export { presetChatSessionId as a, presetAuthorTools as i, narrationImportMessage as n, presetOfChat as o, presetApproval as r, PresetReader as t };
|
|
281
281
|
|
|
282
|
-
//# sourceMappingURL=preset-author-tools-
|
|
282
|
+
//# sourceMappingURL=preset-author-tools-DYxTLm9U.js.map
|
package/lib/preset-authoring.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as limitAuthoringAgents } from "./authoring-tools-
|
|
2
|
-
import { t as guardAuthoringTurns } from "./turn-guard-
|
|
1
|
+
import { n as limitAuthoringAgents } from "./authoring-tools-DqAttdUN.js";
|
|
2
|
+
import { t as guardAuthoringTurns } from "./turn-guard-CNFvmz_F.js";
|
|
3
3
|
import { n as silenceRuntimeContext, t as silenceHarnessDevContext } from "./dev-context-Cgv_wZbG.js";
|
|
4
|
-
import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-
|
|
5
|
-
import "./hooks-
|
|
6
|
-
import {
|
|
4
|
+
import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-DYxTLm9U.js";
|
|
5
|
+
import "./hooks-OLl-1AOS.js";
|
|
6
|
+
import { Y as presetDirectory } from "./serial-Bh6gqb3f.js";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
// src/preset-authoring.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { O as estimateAnswer, a as childTrace, j as roleplaySessionOf, l as runChild, n as childModel, r as childSampling } from "./child-
|
|
2
|
-
import { A as routeVerdicts, D as mergeReports, E as askYesNo,
|
|
3
|
-
import { t as promptFor } from "./access-
|
|
4
|
-
import { D as referent, I as wrongLanguage, Z as PROMPTS_FOLDER, et as inheritPrompts, vt as describeWhen } from "./hooks-
|
|
5
|
-
import { i as translator, r as languageOf } from "./text-
|
|
6
|
-
import { s as inheritImages } from "./library-
|
|
7
|
-
import { i as inheritPacks } from "./packs-
|
|
1
|
+
import { O as estimateAnswer, a as childTrace, j as roleplaySessionOf, l as runChild, n as childModel, r as childSampling } from "./child-SMvjNsb8.js";
|
|
2
|
+
import { $ as sha, A as routeVerdicts, D as mergeReports, E as askYesNo, J as loadPreset, T as announceProblem, j as yesAt, k as noAt, q as listPresets, t as SerialQueue } from "./serial-Bh6gqb3f.js";
|
|
3
|
+
import { t as promptFor } from "./access-DjA0kvPM.js";
|
|
4
|
+
import { D as referent, I as wrongLanguage, Z as PROMPTS_FOLDER, et as inheritPrompts, vt as describeWhen } from "./hooks-OLl-1AOS.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-B-HsLdb-.js";
|
|
6
|
+
import { s as inheritImages } from "./library-D6AcyxGZ.js";
|
|
7
|
+
import { i as inheritPacks } from "./packs-DUVCSHqi.js";
|
|
8
8
|
import { dirname, join } from "node:path";
|
|
9
9
|
import { characterKey, locationKey, sessionDatabase, sessionFolder, tokens } from "@dsh-agentic-roleplay/state";
|
|
10
10
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -1504,4 +1504,4 @@ function memoryReflector(deps) {
|
|
|
1504
1504
|
}
|
|
1505
1505
|
export { snapshotOf as _, whereabouts as a, copyPreset as c, switchPreset as d, readTimeline as f, pathTo as g, childrenOf as h, reflectionStatus as i, presetStatus as l, START_SNAPSHOT as m, memoryReflector as n, TimelineError as o, writeTimeline as p, recordFailure as r, Timelines as s, dueReflection as t, recordPreset as u };
|
|
1506
1506
|
|
|
1507
|
-
//# sourceMappingURL=reflection-
|
|
1507
|
+
//# sourceMappingURL=reflection-C3zdufN9.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { m as parseSampling } from "./child-
|
|
2
|
-
import { f as parseSwitchboard } from "./narration
|
|
3
|
-
import { a as VARIABLE_KINDS, n as atomicWrite, o as VARIABLE_SUBJECTS, s as VARIABLE_VISIBILITIES } from "./access-
|
|
4
|
-
import { G as readDocument, J as errorMessage, K as Reader, X as LANGUAGE_TAG, Y as LANGUAGE_FOLDER, Z as PROMPTS_FOLDER, at as shippedPromptsDirectory, it as shippedLanguages, nt as listFiles, q as formatIssue, rt as promptProblem, tt as languageOf } from "./hooks-
|
|
5
|
-
import { i as translator, r as languageOf$1 } from "./text-
|
|
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-SMvjNsb8.js";
|
|
2
|
+
import { f as parseSwitchboard } from "./narration-Bnrvl0UQ.js";
|
|
3
|
+
import { a as VARIABLE_KINDS, n as atomicWrite, o as VARIABLE_SUBJECTS, s as VARIABLE_VISIBILITIES } from "./access-DjA0kvPM.js";
|
|
4
|
+
import { G as readDocument, J as errorMessage, K as Reader, X as LANGUAGE_TAG, Y as LANGUAGE_FOLDER, Z as PROMPTS_FOLDER, at as shippedPromptsDirectory, it as shippedLanguages, nt as listFiles, q as formatIssue, rt as promptProblem, tt as languageOf } from "./hooks-OLl-1AOS.js";
|
|
5
|
+
import { i as translator, r as languageOf$1 } from "./text-B-HsLdb-.js";
|
|
6
|
+
import { C as slug, S as norm, T as uniqueKey, w as trOf, x as mapLimit } from "./library-D6AcyxGZ.js";
|
|
7
7
|
import { dirname, join } from "node:path";
|
|
8
8
|
import { MAX_ROUTINE_WINDOWS, createSessionStore, dayTokenProblems, isTimeZone, parseInstant, valueIssue } from "@dsh-agentic-roleplay/state";
|
|
9
9
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
@@ -1086,7 +1086,6 @@ function sourceSummary(card, language) {
|
|
|
1086
1086
|
return lines.join(" ");
|
|
1087
1087
|
}
|
|
1088
1088
|
// src/host/import/panels.ts
|
|
1089
|
-
const FENCE = /```[^\n]*\n[\s\S]*?```/g;
|
|
1090
1089
|
const TAG = /<(\/?)([\p{L}][\p{L}\p{N}_-]*)(?=[\s>/])[^>]*>/gu;
|
|
1091
1090
|
const BLOCKS = /* @__PURE__ */ new Set([
|
|
1092
1091
|
"div",
|
|
@@ -1099,14 +1098,64 @@ const BLOCKS = /* @__PURE__ */ new Set([
|
|
|
1099
1098
|
"fieldset"
|
|
1100
1099
|
]);
|
|
1101
1100
|
const SEPARATORS = /\s[||│]\s|[||│]\s*\S+\s*[||│]/;
|
|
1102
|
-
const HEADER = /(?:^|\n)[ \t]*(?:【[^】\n]{1,30}】|\[[^\]\n]{1,30}\]|#+[ \t]*[^\n]{1,30})[ \t]*\n?\s*$/;
|
|
1103
1101
|
const MAX_HTML_TEXT_CHARS = 600;
|
|
1104
1102
|
const MAX_CUSTOM_CHARS = 4e3;
|
|
1105
1103
|
/** 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. */
|
|
1106
1104
|
const MIN_CUSTOM_TAGS = 6;
|
|
1107
1105
|
const MAX_PANELS = 6;
|
|
1106
|
+
/** The most a header line that introduces a panel may say: `【状态】`, `[Status]`, `## Sheet`. */
|
|
1107
|
+
const MAX_HEADER_CHARS = 30;
|
|
1108
|
+
/**
|
|
1109
|
+
* The fenced blocks of a message, as offsets from the opening fence to the end of the closing one.
|
|
1110
|
+
* Found by scanning rather than by a regular expression: a lazy `[\s\S]*?` over a long message is quadratic when no closing fence follows.
|
|
1111
|
+
*/
|
|
1112
|
+
function fencedBlocks(text) {
|
|
1113
|
+
const blocks = [];
|
|
1114
|
+
let from = 0;
|
|
1115
|
+
for (;;) {
|
|
1116
|
+
const open = text.indexOf("```", from);
|
|
1117
|
+
if (open === -1) return blocks;
|
|
1118
|
+
const lineEnd = text.indexOf("\n", open);
|
|
1119
|
+
const close = lineEnd === -1 ? -1 : text.indexOf("```", lineEnd + 1);
|
|
1120
|
+
if (close === -1) return blocks;
|
|
1121
|
+
blocks.push({
|
|
1122
|
+
from: open,
|
|
1123
|
+
to: close + 3
|
|
1124
|
+
});
|
|
1125
|
+
from = close + 3;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
/** The fenced block's text without its fence lines. */
|
|
1129
|
+
const unfenced = (block) => block.replace(/^```[^\n]*\n|```$/g, "").trim();
|
|
1130
|
+
/** Whether a character is whitespace, without a regular expression to say so. */
|
|
1131
|
+
const isSpace = (char) => char.trim() === "";
|
|
1132
|
+
/** Whether a line is a header that introduces a panel: a short bracketed name or a short heading. */
|
|
1133
|
+
function headerLine(line) {
|
|
1134
|
+
const text = line.trim();
|
|
1135
|
+
if (text === "") return false;
|
|
1136
|
+
for (const [open, close] of [["【", "】"], ["[", "]"]]) {
|
|
1137
|
+
if (!text.startsWith(open) || !text.endsWith(close)) continue;
|
|
1138
|
+
const name = text.slice(open.length, text.length - close.length);
|
|
1139
|
+
if (name.length >= 1 && name.length <= MAX_HEADER_CHARS) return true;
|
|
1140
|
+
}
|
|
1141
|
+
let hashes = 0;
|
|
1142
|
+
while (hashes < text.length && text[hashes] === "#") hashes += 1;
|
|
1143
|
+
if (hashes === 0) return false;
|
|
1144
|
+
const heading = text.slice(hashes).trim();
|
|
1145
|
+
return heading !== "" && heading.length <= MAX_HEADER_CHARS;
|
|
1146
|
+
}
|
|
1147
|
+
/** Where the header line that introduces a panel starts, when the text before the panel ends with one; the panel is taken from there. */
|
|
1148
|
+
function headerBefore(before) {
|
|
1149
|
+
let end = before.length;
|
|
1150
|
+
while (end > 0 && isSpace(before[end - 1])) end -= 1;
|
|
1151
|
+
if (end === 0) return void 0;
|
|
1152
|
+
const start = before.lastIndexOf("\n", end - 1) + 1;
|
|
1153
|
+
return headerLine(before.slice(start, end)) ? start : void 0;
|
|
1154
|
+
}
|
|
1108
1155
|
const collapse = (text) => text.replace(/\n{3,}/g, "\n\n").trim();
|
|
1109
|
-
|
|
1156
|
+
/** A tag is one class and a closing bracket: linear, so the warning about backtracking does not apply. */
|
|
1157
|
+
const withoutTags = (html) => html.replace(/<[^>]*>/g, " ");
|
|
1158
|
+
const plain = (html) => withoutTags(html).replace(/\s+/g, " ").trim();
|
|
1110
1159
|
/** 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. */
|
|
1111
1160
|
function tagBlocks(text) {
|
|
1112
1161
|
const found = [];
|
|
@@ -1152,10 +1201,11 @@ function tagBlocks(text) {
|
|
|
1152
1201
|
} else joined.push({ ...block });
|
|
1153
1202
|
}
|
|
1154
1203
|
return joined.map((block) => {
|
|
1155
|
-
|
|
1156
|
-
|
|
1204
|
+
if (!block.custom) return block;
|
|
1205
|
+
const header = headerBefore(text.slice(0, block.from));
|
|
1206
|
+
return header === void 0 ? block : {
|
|
1157
1207
|
...block,
|
|
1158
|
-
from: header
|
|
1208
|
+
from: header
|
|
1159
1209
|
};
|
|
1160
1210
|
});
|
|
1161
1211
|
}
|
|
@@ -1163,14 +1213,21 @@ const statusLine = (line) => SEPARATORS.test(line) && /\d/.test(line);
|
|
|
1163
1213
|
/** An update call of a state-tracking framework: a block that holds one is a panel however few tags it has. */
|
|
1164
1214
|
const CALL = /\b_\.\w+\(|\bstat_data\b|\bJSONPatch\b/;
|
|
1165
1215
|
/** The text before a removed panel without its last line when that line only introduces the panel ("end every reply with this:"). */
|
|
1166
|
-
|
|
1167
|
-
|
|
1216
|
+
function withoutLeadIn(before) {
|
|
1217
|
+
let end = before.length;
|
|
1218
|
+
while (end > 0 && isSpace(before[end - 1])) end -= 1;
|
|
1219
|
+
if (end === 0 || before[end - 1] !== ":" && before[end - 1] !== ":") return before;
|
|
1220
|
+
const lineStart = before.lastIndexOf("\n", end - 1);
|
|
1221
|
+
return lineStart === -1 ? "\n" : `${before.slice(0, lineStart)}\n`;
|
|
1222
|
+
}
|
|
1223
|
+
/** The text with its fenced blocks taken out into `panels`, each gap passed through `gap`. */
|
|
1224
|
+
function withoutFences(text, panels, gap) {
|
|
1168
1225
|
let out = "";
|
|
1169
1226
|
let last = 0;
|
|
1170
|
-
for (const
|
|
1171
|
-
panels.push(
|
|
1172
|
-
out += `${
|
|
1173
|
-
last =
|
|
1227
|
+
for (const block of fencedBlocks(text)) {
|
|
1228
|
+
panels.push(unfenced(text.slice(block.from, block.to)));
|
|
1229
|
+
out += `${gap(text.slice(last, block.from))}\n\n`;
|
|
1230
|
+
last = block.to;
|
|
1174
1231
|
}
|
|
1175
1232
|
return out + text.slice(last);
|
|
1176
1233
|
}
|
|
@@ -1181,10 +1238,7 @@ function fencesWithoutLeadIn(text, panels) {
|
|
|
1181
1238
|
*/
|
|
1182
1239
|
function splitPanels(text, options = {}) {
|
|
1183
1240
|
const panels = [];
|
|
1184
|
-
let rest = options.leadIn === true ?
|
|
1185
|
-
panels.push(block.replace(/^```[^\n]*\n|```$/g, "").trim());
|
|
1186
|
-
return "\n\n";
|
|
1187
|
-
});
|
|
1241
|
+
let rest = options.leadIn === true ? withoutFences(text, panels, withoutLeadIn) : withoutFences(text, panels, (gap) => gap);
|
|
1188
1242
|
const blocks = tagBlocks(rest);
|
|
1189
1243
|
const outside = blocks.reduceRight((left, { from, to }) => left.slice(0, from) + left.slice(to), rest);
|
|
1190
1244
|
if (blocks.length > 0 && (options.alone === true || plain(outside) !== "")) for (const block of [...blocks].reverse()) {
|
|
@@ -1209,8 +1263,43 @@ function panelsOfCard(card) {
|
|
|
1209
1263
|
];
|
|
1210
1264
|
return [...new Set(texts.flatMap((text) => splitPanels(text).panels))].filter((panel) => panel.length <= MAX_CUSTOM_CHARS).slice(0, MAX_PANELS);
|
|
1211
1265
|
}
|
|
1212
|
-
|
|
1213
|
-
|
|
1266
|
+
const ASCII_STOPS = /* @__PURE__ */ new Set([
|
|
1267
|
+
".",
|
|
1268
|
+
"!",
|
|
1269
|
+
"?"
|
|
1270
|
+
]);
|
|
1271
|
+
const WIDE_STOPS = /* @__PURE__ */ new Set([
|
|
1272
|
+
"。",
|
|
1273
|
+
"!",
|
|
1274
|
+
"?"
|
|
1275
|
+
]);
|
|
1276
|
+
/**
|
|
1277
|
+
* The sentences of one line; a full stop inside a word or a call (`_.set(`) does not end one: a run of terminal marks ends a sentence only when a space or the end of the line follows it,
|
|
1278
|
+
* except for the wide marks, which end one wherever they are. Found by scanning, so that a line of full stops and letters cannot make the matcher backtrack over itself.
|
|
1279
|
+
*/
|
|
1280
|
+
function sentencesOf(line) {
|
|
1281
|
+
const sentences = [];
|
|
1282
|
+
let from = 0;
|
|
1283
|
+
let at = 0;
|
|
1284
|
+
while (at < line.length) {
|
|
1285
|
+
if (!ASCII_STOPS.has(line[at]) && !WIDE_STOPS.has(line[at])) {
|
|
1286
|
+
at += 1;
|
|
1287
|
+
continue;
|
|
1288
|
+
}
|
|
1289
|
+
let end = at;
|
|
1290
|
+
while (end < line.length && (ASCII_STOPS.has(line[end]) || WIDE_STOPS.has(line[end]))) end += 1;
|
|
1291
|
+
if (!(!ASCII_STOPS.has(line[at]) || end === line.length || isSpace(line[end]))) {
|
|
1292
|
+
at = end;
|
|
1293
|
+
continue;
|
|
1294
|
+
}
|
|
1295
|
+
while (end < line.length && isSpace(line[end])) end += 1;
|
|
1296
|
+
sentences.push(line.slice(from, end));
|
|
1297
|
+
from = end;
|
|
1298
|
+
at = end;
|
|
1299
|
+
}
|
|
1300
|
+
if (from < line.length) sentences.push(line.slice(from));
|
|
1301
|
+
return sentences.length === 0 ? [line] : sentences;
|
|
1302
|
+
}
|
|
1214
1303
|
const MIN_LEFT_OUT_WORDS = 3;
|
|
1215
1304
|
const ECHO_SHARE = .6;
|
|
1216
1305
|
/** A short sentence right after a dropped one ("Never skip it.") has nothing left to refer to. */
|
|
@@ -2779,7 +2868,62 @@ function parseStartQuestionsEdit(value, problems) {
|
|
|
2779
2868
|
}
|
|
2780
2869
|
return questions;
|
|
2781
2870
|
}
|
|
2782
|
-
const
|
|
2871
|
+
const MAX_OPENING_TEXT = 2e4;
|
|
2872
|
+
/** The words of an opening as one text: its parts, a blank line between. */
|
|
2873
|
+
const partsText = (parts) => parts.map((part) => part.text).join("\n\n");
|
|
2874
|
+
/** Whether any part is spoken by a character: an opening with none is only narration, which a plain text says as well. */
|
|
2875
|
+
const hasSpeech = (parts) => parts.some((part) => part.type === "utterance");
|
|
2876
|
+
/**
|
|
2877
|
+
* Reads the parts of an opening from a body that came from a browser or a model: every part is checked and each problem is reported. Blank parts are left out.
|
|
2878
|
+
* @returns the parts, or nothing when the value is no list of parts (the problems say why).
|
|
2879
|
+
*/
|
|
2880
|
+
function parseOpeningParts(value, where, problems) {
|
|
2881
|
+
if (!Array.isArray(value)) {
|
|
2882
|
+
problems.push(`${where} must be a list of parts`);
|
|
2883
|
+
return;
|
|
2884
|
+
}
|
|
2885
|
+
const parts = [];
|
|
2886
|
+
for (const [index, entry] of value.entries()) {
|
|
2887
|
+
const at = `${where}[${index}]`;
|
|
2888
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
|
|
2889
|
+
problems.push(`${at} must be an object`);
|
|
2890
|
+
continue;
|
|
2891
|
+
}
|
|
2892
|
+
const part = entry;
|
|
2893
|
+
const type = part["type"] ?? "narration";
|
|
2894
|
+
if (type !== "narration" && type !== "utterance") {
|
|
2895
|
+
problems.push(`${at}.type must be "narration" or "utterance"`);
|
|
2896
|
+
continue;
|
|
2897
|
+
}
|
|
2898
|
+
if (typeof part["text"] !== "string") {
|
|
2899
|
+
problems.push(`${at}.text must be text`);
|
|
2900
|
+
continue;
|
|
2901
|
+
}
|
|
2902
|
+
const text = part["text"].trim();
|
|
2903
|
+
if (text === "") continue;
|
|
2904
|
+
if (type === "narration") {
|
|
2905
|
+
parts.push({
|
|
2906
|
+
type,
|
|
2907
|
+
text
|
|
2908
|
+
});
|
|
2909
|
+
continue;
|
|
2910
|
+
}
|
|
2911
|
+
const character = typeof part["character"] === "string" ? part["character"].trim() : "";
|
|
2912
|
+
if (character === "") {
|
|
2913
|
+
problems.push(`${at}.character is needed for a line a character speaks`);
|
|
2914
|
+
continue;
|
|
2915
|
+
}
|
|
2916
|
+
parts.push({
|
|
2917
|
+
type,
|
|
2918
|
+
character,
|
|
2919
|
+
text
|
|
2920
|
+
});
|
|
2921
|
+
}
|
|
2922
|
+
if (parts.length > 60) problems.push(`${where} has more than 60 parts`);
|
|
2923
|
+
if (partsText(parts).length > 2e4) problems.push(`${where} is longer than ${MAX_OPENING_TEXT} characters`);
|
|
2924
|
+
return parts;
|
|
2925
|
+
}
|
|
2926
|
+
const MAX_OPENING_CHARS = MAX_OPENING_TEXT;
|
|
2783
2927
|
const TEXT_FIELDS = [
|
|
2784
2928
|
"name",
|
|
2785
2929
|
"description",
|
|
@@ -2803,7 +2947,7 @@ function parseWorldInfoEdit(value) {
|
|
|
2803
2947
|
const input = typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
2804
2948
|
if (input === void 0) throw new InvalidEditProblems(["the changes must be an object"]);
|
|
2805
2949
|
const edit = {};
|
|
2806
|
-
for (const key of Object.keys(input)) if (!TEXT_FIELDS.includes(key) && !LIST_FIELDS.includes(key) && key !== "alternateOpenings" && key !== "startQuestions" && key !== "tools" && key !== "sampling" && key !== "autonomy") problems.push(`there is no field "${key}"`);
|
|
2950
|
+
for (const key of Object.keys(input)) if (!TEXT_FIELDS.includes(key) && !LIST_FIELDS.includes(key) && key !== "alternateOpenings" && key !== "openingParts" && key !== "startQuestions" && key !== "tools" && key !== "sampling" && key !== "autonomy") problems.push(`there is no field "${key}"`);
|
|
2807
2951
|
for (const key of TEXT_FIELDS) {
|
|
2808
2952
|
if (input[key] === void 0) continue;
|
|
2809
2953
|
if (typeof input[key] === "string") edit[key] = input[key].trim();
|
|
@@ -2814,18 +2958,54 @@ function parseWorldInfoEdit(value) {
|
|
|
2814
2958
|
if (Array.isArray(input[key]) && input[key].every((entry) => typeof entry === "string")) edit[key] = input[key].map((entry) => entry.trim()).filter((entry) => entry !== "");
|
|
2815
2959
|
else problems.push(`${key} must be a list of text`);
|
|
2816
2960
|
}
|
|
2961
|
+
if (input["openingParts"] !== void 0) {
|
|
2962
|
+
if (input["opening"] !== void 0) problems.push("give the opening as text or as parts, not both");
|
|
2963
|
+
const parts = parseOpeningParts(input["openingParts"], "openingParts", problems);
|
|
2964
|
+
if (parts !== void 0) edit["openingParts"] = parts;
|
|
2965
|
+
}
|
|
2817
2966
|
if (input["alternateOpenings"] !== void 0) {
|
|
2818
2967
|
const list = input["alternateOpenings"];
|
|
2819
2968
|
const entries = Array.isArray(list) ? list.map((entry) => typeof entry === "object" && entry !== null ? entry : void 0) : void 0;
|
|
2820
|
-
|
|
2969
|
+
const kept = [];
|
|
2970
|
+
if (entries === void 0) problems.push("alternateOpenings must be a list of { title, text or parts, character? }");
|
|
2821
2971
|
else {
|
|
2822
|
-
const
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2972
|
+
for (const [index, entry] of entries.entries()) {
|
|
2973
|
+
const at = `alternateOpenings[${index}]`;
|
|
2974
|
+
if (entry === void 0) {
|
|
2975
|
+
problems.push(`${at} must be an object`);
|
|
2976
|
+
continue;
|
|
2977
|
+
}
|
|
2978
|
+
if (entry["title"] !== void 0 && typeof entry["title"] !== "string" || entry["character"] !== void 0 && typeof entry["character"] !== "string") {
|
|
2979
|
+
problems.push(`${at}: title and character must be text`);
|
|
2980
|
+
continue;
|
|
2981
|
+
}
|
|
2982
|
+
const title = String(entry["title"] ?? "").trim();
|
|
2983
|
+
const character = String(entry["character"] ?? "").trim();
|
|
2984
|
+
const named = character === "" ? {} : { character };
|
|
2985
|
+
if (entry["parts"] !== void 0) {
|
|
2986
|
+
if (entry["text"] !== void 0) problems.push(`${at}: give the opening as text or as parts, not both`);
|
|
2987
|
+
const parts = parseOpeningParts(entry["parts"], `${at}.parts`, problems);
|
|
2988
|
+
if (parts !== void 0 && parts.length > 0) kept.push({
|
|
2989
|
+
title,
|
|
2990
|
+
text: partsText(parts),
|
|
2991
|
+
parts,
|
|
2992
|
+
...named
|
|
2993
|
+
});
|
|
2994
|
+
continue;
|
|
2995
|
+
}
|
|
2996
|
+
if (typeof entry["text"] !== "string") {
|
|
2997
|
+
problems.push(`${at}.text must be text`);
|
|
2998
|
+
continue;
|
|
2999
|
+
}
|
|
3000
|
+
const text = entry["text"].trim();
|
|
3001
|
+
if (text !== "") kept.push({
|
|
3002
|
+
title,
|
|
3003
|
+
text,
|
|
3004
|
+
...named
|
|
3005
|
+
});
|
|
3006
|
+
}
|
|
2827
3007
|
if (kept.length > 30) problems.push(`there are more than 30 alternate openings`);
|
|
2828
|
-
if (kept.some((entry) => entry.text.length >
|
|
3008
|
+
if (kept.some((entry) => entry.text.length > MAX_OPENING_CHARS)) problems.push(`an alternate opening is longer than ${MAX_OPENING_CHARS} characters`);
|
|
2829
3009
|
edit["alternateOpenings"] = kept;
|
|
2830
3010
|
}
|
|
2831
3011
|
}
|
|
@@ -2851,7 +3031,7 @@ function parseWorldInfoEdit(value) {
|
|
|
2851
3031
|
}
|
|
2852
3032
|
// src/host/worlds/world-file.ts
|
|
2853
3033
|
const WORLD_FILE_NAME = "world.json";
|
|
2854
|
-
/** `alternate_openings` is a list of `{ title, text, character? }`: other first messages the player may start with, each for any character or for one playable character. */
|
|
3034
|
+
/** `alternate_openings` is a list of `{ title, text | parts, character? }`: other first messages the player may start with, each for any character or for one playable character. */
|
|
2855
3035
|
function readAlternateOpenings(reader) {
|
|
2856
3036
|
const value = reader.raw("alternate_openings");
|
|
2857
3037
|
if (value === void 0 || value === null) return void 0;
|
|
@@ -2862,13 +3042,16 @@ function readAlternateOpenings(reader) {
|
|
|
2862
3042
|
if (value.length > 30) reader.fail("alternate_openings", `has more than 30 openings`);
|
|
2863
3043
|
const openings = [];
|
|
2864
3044
|
for (const entry of reader.objects("alternate_openings")) {
|
|
2865
|
-
const
|
|
3045
|
+
const given = entry.raw("parts");
|
|
3046
|
+
const parts = given === void 0 || given === null ? void 0 : readParts(entry, "parts");
|
|
3047
|
+
const text = parts === void 0 ? entry.string("text", { required: true })?.trim() : partsText(parts);
|
|
2866
3048
|
if (text === void 0 || text === "") continue;
|
|
2867
|
-
if (text.length >
|
|
3049
|
+
if (text.length > MAX_OPENING_CHARS) entry.fail(parts === void 0 ? "text" : "parts", `is longer than ${MAX_OPENING_CHARS} characters`);
|
|
2868
3050
|
const character = entry.string("character")?.trim();
|
|
2869
3051
|
openings.push({
|
|
2870
3052
|
title: entry.string("title")?.trim() || text.slice(0, 40),
|
|
2871
3053
|
text,
|
|
3054
|
+
...parts === void 0 ? {} : { parts },
|
|
2872
3055
|
...character === void 0 || character === "" ? {} : { character }
|
|
2873
3056
|
});
|
|
2874
3057
|
}
|
|
@@ -3004,20 +3187,10 @@ function readRules(reader) {
|
|
|
3004
3187
|
if (long >= 0) reader.fail("rules", `rule ${long + 1} is longer than 300 characters: keep rules short`);
|
|
3005
3188
|
return kept.length === 0 ? void 0 : kept;
|
|
3006
3189
|
}
|
|
3007
|
-
/**
|
|
3008
|
-
function
|
|
3009
|
-
const value = reader.raw("opening_message");
|
|
3010
|
-
if (value === void 0 || value === null) return void 0;
|
|
3011
|
-
if (typeof value === "string") return value.trim() === "" ? void 0 : [{
|
|
3012
|
-
type: "narration",
|
|
3013
|
-
text: value.trim()
|
|
3014
|
-
}];
|
|
3015
|
-
if (!Array.isArray(value)) {
|
|
3016
|
-
reader.fail("opening_message", "must be text or a list of parts");
|
|
3017
|
-
return;
|
|
3018
|
-
}
|
|
3190
|
+
/** The parts of an opening in the order the player reads them, from the list `reader` holds under `key`; a problem is reported for each part that cannot be read. */
|
|
3191
|
+
function readParts(reader, key) {
|
|
3019
3192
|
const parts = [];
|
|
3020
|
-
for (const part of reader.objects(
|
|
3193
|
+
for (const part of reader.objects(key)) {
|
|
3021
3194
|
const type = part.oneOf("type", ["narration", "utterance"], "narration");
|
|
3022
3195
|
const text = part.string("text", { required: true })?.trim();
|
|
3023
3196
|
if (text === void 0 || text === "") continue;
|
|
@@ -3035,8 +3208,23 @@ function readOpening(reader) {
|
|
|
3035
3208
|
text
|
|
3036
3209
|
});
|
|
3037
3210
|
}
|
|
3211
|
+
if (parts.length > 60) reader.fail(key, `has more than 60 parts`);
|
|
3038
3212
|
return parts.length === 0 ? void 0 : parts;
|
|
3039
3213
|
}
|
|
3214
|
+
/** `opening_message` is plain text (one narration), or a list of parts in the order the player reads them. */
|
|
3215
|
+
function readOpening(reader) {
|
|
3216
|
+
const value = reader.raw("opening_message");
|
|
3217
|
+
if (value === void 0 || value === null) return void 0;
|
|
3218
|
+
if (typeof value === "string") return value.trim() === "" ? void 0 : [{
|
|
3219
|
+
type: "narration",
|
|
3220
|
+
text: value.trim()
|
|
3221
|
+
}];
|
|
3222
|
+
if (!Array.isArray(value)) {
|
|
3223
|
+
reader.fail("opening_message", "must be text or a list of parts");
|
|
3224
|
+
return;
|
|
3225
|
+
}
|
|
3226
|
+
return readParts(reader, "opening_message");
|
|
3227
|
+
}
|
|
3040
3228
|
/** `time_zone` (an IANA name) and `starting_time` (an ISO 8601 date and time, in `time_zone` unless it carries an offset). */
|
|
3041
3229
|
function readClock(reader) {
|
|
3042
3230
|
const timeZone = reader.string("time_zone");
|
|
@@ -5179,6 +5367,6 @@ var SerialQueue = class {
|
|
|
5179
5367
|
return this.tails.size;
|
|
5180
5368
|
}
|
|
5181
5369
|
};
|
|
5182
|
-
export {
|
|
5370
|
+
export { sha as $, LOCATION_FILE_NAME as $t, routeVerdicts as A, openingText as At, questionView as B, parseThingEdit as Bt, ROLE_TABLE as C, itemise as Ct, mergeReports as D, ImportNotFoundError as Dt, askYesNo as E, IMPORT_FOLDER as Et, parseWorldInfoEdit as F, parseCharacterEdit as Ft, deletePreset as G, dialectOf as Gt, PRESET_FILE as H, importRequestOf as Ht, hasSpeech as I, parseFactionEdit as It, loadPreset as J, loadVariables as Jt, isPresetName as K, sourceSummary as Kt, parseOpeningParts as L, parseLoreEdit as Lt, WORLD_FILE_NAME as M, readImportFolder as Mt, parseWorldFile as N, writeChoices as Nt, modeFor as O, ImportStore as Ot, MAX_OPENING_CHARS as P, InvalidEditProblems as Pt, savePresetFromWorld as Q, parseLoreFile as Qt, partsText as R, parsePlaceEdit as Rt, ROLES as S, cleanText as St, announceProblem as T, withPlayer as Tt, createPresetFromGuidance as U, findPanel as Ut, startQuestionsToFile as V, IMPORT_COMMAND as Vt, createPresetFromShipped as W, splitPanels as Wt, readPreset as X, variableProblems as Xt, presetDirectory as Y, parseVariablesFile as Yt, reservePreset as Z, LORE_FILE_NAME as Zt, pruneRelationships as _, updateLorebookInfo as _t, characterDocument as a, FACTION_FILE_NAME as an, writeWorldPrompt as at, classifyItems as b, loadLore as bt, extractStyle as c, parseCharacterFile as cn, deleteLorebook as ct, inert as d, LORE_SCOPES as dn, isLorebookName as dt, parseLocationFile as en, updatePresetInfo as et, loreDocuments as f, WEEKDAY_NAMES as fn, listLorebooks as ft, pruneMembers as g, reserveLorebook as gt, pruneLoreSubjects as h, readLorebook as ht, asWritten as i, parseSlotsFile as in, readWorldPrompt as it, yesAt as j, parseChoices as jt, noAt as k, PICTURE_FILE as kt, extractStyleFrom as l, guarded as ln, deleteLorebookEntry as lt, pruneLinks as m, INTENT_STATUSES as mn, lorebookDirectory as mt, STANDING_PROMPT as n, SLOTS_FILE_NAME as nn, deleteWorldPrompt as nt, emptyExtracted as o, parseFactionFile as on, addLorebookEntries as ot, pruneKnowledge as p, DEFAULT_SLOTS as pn, loadLorebook as pt, listPresets as q, VARIABLES_FILE_NAME as qt, addLore as r, parseItemFile as rn, listWorldPrompts as rt, extractEntities as s, CHARACTER_FILE_NAME as sn, createLorebook as st, SerialQueue as t, ITEM_FILE_NAME as tn, PROSE_PROMPTS as tt, extractVariables as u, LORE_KINDS as un, entriesOf as ut, sourcesFor as v, writeLorebookEntry as vt, isLeftOut as w, partsOf as wt, findEntity as x, subfolders as xt, buildRoster as y, LORE_DIR as yt, combineAnswers as z, parseRelationEdit as zt };
|
|
5183
5371
|
|
|
5184
|
-
//# sourceMappingURL=serial-
|
|
5372
|
+
//# sourceMappingURL=serial-Bh6gqb3f.js.map
|