@dsh-agentic-roleplay/core 0.11.1 → 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-Md1YTSX1.js → access-DAw54-NI.js} +3 -15
- package/lib/{authoring-tools-BFdw7ahj.js → authoring-tools-4NgDhIJV.js} +51 -11
- package/lib/authoring.js +8 -8
- package/lib/{child-C9nPIy9j.js → child-D3QUNb3m.js} +121 -2
- package/lib/client.js +1013 -449
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +3 -3
- package/lib/doctor.js +3 -3
- package/lib/{gallery-BWHmjogd.js → gallery-Ct6nm4UQ.js} +3 -3
- package/lib/{generator-QCdm8nUh.js → generator-CI8fOnXy.js} +2 -2
- package/lib/helper.js +13 -1
- package/lib/{hooks-C2U1-8ur.js → hooks-BNeoGMHZ.js} +722 -334
- package/lib/images.js +4 -4
- package/lib/index.js +234 -20
- package/lib/jail-BIF79PJO.js +107 -0
- package/lib/{library-4zmCAshR.js → library-BF9ZMSFz.js} +3 -3
- package/lib/{lorebook-author-tools-Bjfjt3bg.js → lorebook-author-tools-DBk-V0hp.js} +7 -7
- package/lib/lorebook-authoring.js +4 -4
- package/lib/{narration-b_VBEUWn.js → narration-xvErE2yp.js} +29 -2
- package/lib/orchestration.js +593 -47
- package/lib/{pack-jail-Ci9bIeDI.js → pack-jail-C8EyX9Ix.js} +12 -11
- package/lib/{packs-CYkozh8Q.js → packs-S0SzrVv-.js} +2 -2
- package/lib/{presenter-agent-CqkAL03Q.js → presenter-agent-Bc478nTA.js} +6 -6
- package/lib/{preset-B-35yUmt.js → preset-SJZyw0kt.js} +4 -4
- package/lib/{preset-author-tools-BUymqZM5.js → preset-author-tools-CzogjK42.js} +7 -7
- package/lib/preset-authoring.js +5 -5
- package/lib/{presets-_U-xroo0.js → presets-DQ5rioMh.js} +231 -48
- package/lib/{reflection-B9N0z3KY.js → reflection-buQiSdvq.js} +15 -8
- package/lib/service-mRKwpWjX.js +140 -0
- package/lib/{text-C2AGl7Je.js → text-Dfv8S8eq.js} +27 -2
- package/lib/{turn-guard-C0M3rXEN.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 +2 -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/dream.md +1 -0
- package/prompts/en/roleplay/gate-repeat.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 +2 -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/dream.md +1 -0
- package/prompts/zh/roleplay/gate-repeat.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";
|
|
@@ -2663,4 +2664,4 @@ function registerPackJail(ctx, deps) {
|
|
|
2663
2664
|
}
|
|
2664
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 };
|
|
2665
2666
|
|
|
2666
|
-
//# sourceMappingURL=pack-jail-
|
|
2667
|
+
//# sourceMappingURL=pack-jail-C8EyX9Ix.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as Reader } from "./hooks-
|
|
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";
|
|
@@ -844,4 +844,4 @@ async function runImagePresenter(job) {
|
|
|
844
844
|
}
|
|
845
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 };
|
|
846
846
|
|
|
847
|
-
//# 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 { et as languageOf$1, it as shippedPromptsDirectory, rt as shippedLanguages } from "./hooks-
|
|
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";
|
|
@@ -831,6 +831,8 @@ function readRoutine(reader) {
|
|
|
831
831
|
if (location === void 0 && feature !== void 0) window.fail("feature", "needs a location");
|
|
832
832
|
const flag = window.raw("interruptible");
|
|
833
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");
|
|
834
836
|
if (from === void 0 || to === void 0 || activity === void 0) return [];
|
|
835
837
|
return [{
|
|
836
838
|
days,
|
|
@@ -841,7 +843,8 @@ function readRoutine(reader) {
|
|
|
841
843
|
...location === void 0 ? {} : { location },
|
|
842
844
|
...feature === void 0 ? {} : { feature },
|
|
843
845
|
...position === void 0 ? {} : { position },
|
|
844
|
-
interruptible: flag !== false
|
|
846
|
+
interruptible: flag !== false,
|
|
847
|
+
...sleep === true ? { sleep: true } : {}
|
|
845
848
|
}];
|
|
846
849
|
});
|
|
847
850
|
if (windows.length > MAX_ROUTINE_WINDOWS) reader.fail("routine", `a character has at most ${MAX_ROUTINE_WINDOWS} windows in its day`);
|
|
@@ -1527,34 +1530,6 @@ function variableProblems(world) {
|
|
|
1527
1530
|
}
|
|
1528
1531
|
return problems;
|
|
1529
1532
|
}
|
|
1530
|
-
// src/shared/authoring-commands.ts
|
|
1531
|
-
/** The command a message starts with, when its name is one of `names` (not a longer word that starts with it). */
|
|
1532
|
-
function parseAuthoringCommand(text, names) {
|
|
1533
|
-
const value = text.trimStart();
|
|
1534
|
-
if (!value.startsWith("/")) return void 0;
|
|
1535
|
-
const end = value.search(/\s/u);
|
|
1536
|
-
const word = (end < 0 ? value : value.slice(0, end)).slice(1).toLowerCase();
|
|
1537
|
-
return names.includes(word) ? {
|
|
1538
|
-
name: word,
|
|
1539
|
-
rest: end < 0 ? "" : value.slice(end).trim()
|
|
1540
|
-
} : void 0;
|
|
1541
|
-
}
|
|
1542
|
-
// src/shared/import-card.ts
|
|
1543
|
-
/** The message the plugin sends on the player's behalf to start the import in the new world's authoring chat. */
|
|
1544
|
-
const IMPORT_COMMAND = "/import-st";
|
|
1545
|
-
/** The command in a message, with the card it names, or nothing when the message is not the command. */
|
|
1546
|
-
function parseImportCommand(text) {
|
|
1547
|
-
const command = parseAuthoringCommand(text, [IMPORT_COMMAND.slice(1)]);
|
|
1548
|
-
if (command === void 0) return void 0;
|
|
1549
|
-
const boundary = command.rest.search(/\s/u);
|
|
1550
|
-
return boundary < 0 ? {
|
|
1551
|
-
card: command.rest,
|
|
1552
|
-
request: ""
|
|
1553
|
-
} : {
|
|
1554
|
-
card: command.rest.slice(0, boundary),
|
|
1555
|
-
request: command.rest.slice(boundary).trim()
|
|
1556
|
-
};
|
|
1557
|
-
}
|
|
1558
1533
|
// src/host/import/dialect.ts
|
|
1559
1534
|
const MAX_NAMES = 8;
|
|
1560
1535
|
const PLAIN_MACROS = /* @__PURE__ */ new Set([
|
|
@@ -1649,6 +1624,211 @@ function sourceSummary(card, language) {
|
|
|
1649
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("; ") }));
|
|
1650
1625
|
return lines.join(" ");
|
|
1651
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
|
+
}
|
|
1652
1832
|
// src/host/import/store.ts
|
|
1653
1833
|
const IMPORT_FOLDER = ".import";
|
|
1654
1834
|
const CARD_FILE = "card.json";
|
|
@@ -1883,8 +2063,8 @@ function itemise(card, choices) {
|
|
|
1883
2063
|
...itemsOf("field:description", "description", "", [], card.description, name),
|
|
1884
2064
|
...itemsOf("field:personality", "personality", "", [], card.personality, name),
|
|
1885
2065
|
...itemsOf("field:scenario", "scenario", "", [], card.scenario, name),
|
|
1886
|
-
...itemsOf("field:example", "example messages", "", [], card.messageExample, name),
|
|
1887
|
-
...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),
|
|
1888
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))
|
|
1889
2069
|
];
|
|
1890
2070
|
}
|
|
@@ -3135,7 +3315,7 @@ const LORE_SUBJECT = {
|
|
|
3135
3315
|
function loreDocuments(answer, roster, taken) {
|
|
3136
3316
|
return objects(answer["entries"]).flatMap((entry) => {
|
|
3137
3317
|
const title = text(entry["title"]);
|
|
3138
|
-
const body = text(entry["body"]);
|
|
3318
|
+
const body = withoutOutputMarkup(text(entry["body"]));
|
|
3139
3319
|
if (title === "" || body === "") return [];
|
|
3140
3320
|
const notes = [];
|
|
3141
3321
|
const subjects = [];
|
|
@@ -3165,7 +3345,7 @@ function loreDocuments(answer, roster, taken) {
|
|
|
3165
3345
|
id: uniqueKey(slug(title, "lore"), taken),
|
|
3166
3346
|
title,
|
|
3167
3347
|
kind,
|
|
3168
|
-
summary: text(entry["summary"]),
|
|
3348
|
+
summary: withoutOutputMarkup(text(entry["summary"])),
|
|
3169
3349
|
body
|
|
3170
3350
|
};
|
|
3171
3351
|
put(document, "subjects", subjects);
|
|
@@ -3508,7 +3688,7 @@ async function extractEntities(ctx, card, items, classified, roster) {
|
|
|
3508
3688
|
result: GUIDANCE_SCHEMA,
|
|
3509
3689
|
check: (value) => passageProblem(value, item.text)
|
|
3510
3690
|
});
|
|
3511
|
-
const passages = (field) => answer[field].filter((passage) => passage.trim() !== "");
|
|
3691
|
+
const passages = (field) => answer[field].map(withoutOutputMarkup).filter((passage) => passage.trim() !== "");
|
|
3512
3692
|
return {
|
|
3513
3693
|
item,
|
|
3514
3694
|
casting: passages("casting"),
|
|
@@ -3635,14 +3815,15 @@ async function extractStyleFrom(ctx, name, pieces) {
|
|
|
3635
3815
|
result: STYLE_SCHEMA,
|
|
3636
3816
|
check: (value) => styleProblem("roleplay/style", text(value.narration), list(value.persona_names)) ?? styleProblem("roleplay/character-style", text(value.characters), list(value.persona_names))
|
|
3637
3817
|
});
|
|
3638
|
-
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 === "" ? [] : [{
|
|
3639
3820
|
id,
|
|
3640
3821
|
text: body
|
|
3641
3822
|
}]);
|
|
3642
3823
|
if (!prompts.every((entry) => PROSE_PROMPTS.includes(entry.id))) throw new Error("only prose prompts can be made");
|
|
3643
3824
|
return {
|
|
3644
3825
|
prompts,
|
|
3645
|
-
notes: list(answer.left_out).map((entry) => `instructions
|
|
3826
|
+
notes: list(answer.left_out).map((entry) => `instructions left out on purpose: ${entry}`)
|
|
3646
3827
|
};
|
|
3647
3828
|
} catch (error) {
|
|
3648
3829
|
return {
|
|
@@ -3770,12 +3951,14 @@ const VARIABLES_SCHEMA = {
|
|
|
3770
3951
|
/** The pieces that may describe what a card tracks: its panels and formats, and its instructions. */
|
|
3771
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. */
|
|
3772
3953
|
const STATE_SPEC = /stat_data|\[mvu_|<UpdateVariable>|<initvar>|JSON ?Patch/i;
|
|
3773
|
-
function trackingPieces(card, items, classified) {
|
|
3954
|
+
function trackingPieces(card, items, classified, tr) {
|
|
3774
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}`);
|
|
3775
3957
|
return [.../* @__PURE__ */ new Set([
|
|
3776
3958
|
...items.filter((item) => mainRole(classified[item.id] ?? { roles: [] }) === "template").map((item) => item.text),
|
|
3777
3959
|
...instructionPieces(card, items, classified),
|
|
3778
|
-
...specs
|
|
3960
|
+
...specs,
|
|
3961
|
+
...panels
|
|
3779
3962
|
])];
|
|
3780
3963
|
}
|
|
3781
3964
|
/** The documents of `variables.json` an answer describes, with the roster's names turned into keys. */
|
|
@@ -3846,7 +4029,8 @@ const MAX_VARIABLE_ROUNDS = 12;
|
|
|
3846
4029
|
const TOKENS_PER_VARIABLE = 600;
|
|
3847
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. */
|
|
3848
4031
|
async function extractVariables(ctx, card, items, classified, roster) {
|
|
3849
|
-
const
|
|
4032
|
+
const tr = trOf(ctx);
|
|
4033
|
+
const groups = trackingGroups(trackingPieces(card, items, classified, tr));
|
|
3850
4034
|
if (groups.length === 0) return {
|
|
3851
4035
|
variables: [],
|
|
3852
4036
|
notes: [],
|
|
@@ -3854,7 +4038,6 @@ async function extractVariables(ctx, card, items, classified, roster) {
|
|
|
3854
4038
|
};
|
|
3855
4039
|
const perRequest = ctx.variablesPerRequest ?? DEFAULT_VARIABLES_PER_REQUEST;
|
|
3856
4040
|
const names = (kind) => roster.filter((entity) => entity.kind === kind).map((entity) => entity.name).join(", ");
|
|
3857
|
-
const tr = trOf(ctx);
|
|
3858
4041
|
const found = await mapLimit(groups, ctx.concurrency, async (pieces, index) => {
|
|
3859
4042
|
const documents = [];
|
|
3860
4043
|
const notes = [];
|
|
@@ -4164,6 +4347,6 @@ async function createPresetFromGuidance(root, request, guidance, shipped = shipp
|
|
|
4164
4347
|
});
|
|
4165
4348
|
}
|
|
4166
4349
|
}
|
|
4167
|
-
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 };
|
|
4168
4351
|
|
|
4169
|
-
//# sourceMappingURL=presets-
|
|
4352
|
+
//# sourceMappingURL=presets-DQ5rioMh.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { H as routeVerdicts, L as announceProblem, R as askYesNo, U as yesAt, V as noAt, f as sha, o as listPresets, s as loadPreset, z as mergeReports } from "./presets-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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-D3QUNb3m.js";
|
|
2
|
+
import { H as routeVerdicts, L as announceProblem, R as askYesNo, U as yesAt, V as noAt, f as sha, o as listPresets, s as loadPreset, z as mergeReports } from "./presets-DQ5rioMh.js";
|
|
3
|
+
import { t as promptFor } from "./access-DAw54-NI.js";
|
|
4
|
+
import { $ as inheritPrompts, D as referent, I as wrongLanguage, X as PROMPTS_FOLDER, mt as describeWhen } from "./hooks-BNeoGMHZ.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-Dfv8S8eq.js";
|
|
6
|
+
import { s as inheritImages } from "./library-BF9ZMSFz.js";
|
|
7
|
+
import { i as inheritPacks } from "./packs-S0SzrVv-.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";
|
|
@@ -365,6 +365,13 @@ var Timelines = class {
|
|
|
365
365
|
view(id) {
|
|
366
366
|
return viewOf(this.read(id));
|
|
367
367
|
}
|
|
368
|
+
/** What the narration of the last `count` turns before the one being played told, oldest first, on the path the story has taken; never what an alternative or a withdrawn turn said. */
|
|
369
|
+
narrationBefore(chat, count) {
|
|
370
|
+
const id = roleplaySessionOf(chat);
|
|
371
|
+
if (id === void 0) return [];
|
|
372
|
+
const { path, head } = this.view(id);
|
|
373
|
+
return path.filter((turn) => turn.id !== head).slice(-count).flatMap((turn) => turn.output === void 0 ? [] : [turn.output.segments.flatMap((segment) => segment.type === "narration" ? [segment.text] : []).join("\n")]);
|
|
374
|
+
}
|
|
368
375
|
/**
|
|
369
376
|
* The player has said something and a turn begins: the turn is added to the timeline after the head, and the state the earlier one left is kept at once,
|
|
370
377
|
* with the records still waiting for the keeper in it (they are in the database, so a restored state carries them).
|
|
@@ -1498,4 +1505,4 @@ function memoryReflector(deps) {
|
|
|
1498
1505
|
}
|
|
1499
1506
|
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 };
|
|
1500
1507
|
|
|
1501
|
-
//# sourceMappingURL=reflection-
|
|
1508
|
+
//# sourceMappingURL=reflection-buQiSdvq.js.map
|