@dsh-agentic-roleplay/core 0.10.2 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{access-CXtaZNbx.js → access-Md1YTSX1.js} +4 -1
- package/lib/{authoring-tools-C9cmcUbD.js → authoring-tools-BFdw7ahj.js} +72 -9
- package/lib/authoring.js +38 -8
- package/lib/client.js +777 -427
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +2 -2
- package/lib/doctor.js +3 -3
- package/lib/{gallery-CtG-bDzz.js → gallery-BWHmjogd.js} +3 -3
- package/lib/{generator-nLoPM5MF.js → generator-QCdm8nUh.js} +9 -3
- package/lib/helper.js +9 -0
- package/lib/{hooks-BpLN_hhT.js → hooks-C2U1-8ur.js} +709 -67
- package/lib/images.js +4 -4
- package/lib/index.js +225 -19
- package/lib/{library-CH-ahlm0.js → library-4zmCAshR.js} +3 -3
- package/lib/{lorebook-author-tools-Cg7QQemi.js → lorebook-author-tools-Bjfjt3bg.js} +7 -7
- package/lib/lorebook-authoring.js +4 -4
- package/lib/{narration-B0hConSw.js → narration-b_VBEUWn.js} +7 -3
- package/lib/orchestration.js +338 -28
- package/lib/{pack-jail-D5j5mIq6.js → pack-jail-Ci9bIeDI.js} +25 -15
- package/lib/{packs-Cc05FrId.js → packs-CYkozh8Q.js} +2 -2
- package/lib/{presenter-agent-UKbKYXMO.js → presenter-agent-CqkAL03Q.js} +10 -7
- package/lib/{preset-Be4lz6vB.js → preset-B-35yUmt.js} +3 -3
- package/lib/{preset-author-tools-C3s0iSfv.js → preset-author-tools-BUymqZM5.js} +7 -7
- package/lib/preset-authoring.js +5 -5
- package/lib/{presets-Cl9sU3Qs.js → presets-_U-xroo0.js} +27 -8
- package/lib/{reflection-I9z-PvFK.js → reflection-B9N0z3KY.js} +9 -608
- package/lib/{text-CzqhC8sT.js → text-C2AGl7Je.js} +11 -2
- package/lib/{turn-guard-B9pGCeir.js → turn-guard-C0M3rXEN.js} +10 -10
- package/package.json +33 -32
- package/prompts/en/import/variables.md +1 -0
- package/prompts/en/roleplay/character-decide.md +1 -1
- package/prompts/en/roleplay/decide-reuse.md +3 -0
- package/prompts/en/roleplay/decide-variable.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/variables.md +1 -0
- package/prompts/zh/roleplay/character-decide.md +1 -1
- package/prompts/zh/roleplay/decide-reuse.md +3 -0
- package/prompts/zh/roleplay/decide-variable.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
|
@@ -42,6 +42,7 @@ const VARIABLE_VISIBILITIES = [
|
|
|
42
42
|
{
|
|
43
43
|
key: "valence",
|
|
44
44
|
name: "Valence",
|
|
45
|
+
update: "",
|
|
45
46
|
description: "How pleasant its mood is: -1 very unpleasant, 0 neutral, 1 very pleasant.",
|
|
46
47
|
labels: [
|
|
47
48
|
{
|
|
@@ -69,6 +70,7 @@ const VARIABLE_VISIBILITIES = [
|
|
|
69
70
|
{
|
|
70
71
|
key: "arousal",
|
|
71
72
|
name: "Arousal",
|
|
73
|
+
update: "",
|
|
72
74
|
description: "How worked up it is: -1 drowsy, 0 ordinary, 1 frantic.",
|
|
73
75
|
labels: [
|
|
74
76
|
{
|
|
@@ -96,6 +98,7 @@ const VARIABLE_VISIBILITIES = [
|
|
|
96
98
|
{
|
|
97
99
|
key: "dominance",
|
|
98
100
|
name: "Dominance",
|
|
101
|
+
update: "",
|
|
99
102
|
description: "How much in control it feels: -1 helpless, 0 even, 1 commanding.",
|
|
100
103
|
labels: [
|
|
101
104
|
{
|
|
@@ -192,4 +195,4 @@ function promptFor(agent, id, language, variables) {
|
|
|
192
195
|
}
|
|
193
196
|
export { VARIABLE_KINDS as a, chatSessionId as c, atomicWriteSync as i, roleplaySessionOf as l, atomicWrite as n, VARIABLE_SUBJECTS as o, atomicWriteJson as r, VARIABLE_VISIBILITIES as s, promptFor as t };
|
|
194
197
|
|
|
195
|
-
//# sourceMappingURL=access-
|
|
198
|
+
//# sourceMappingURL=access-Md1YTSX1.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { n as atomicWrite, r as atomicWriteJson } from "./access-
|
|
2
|
-
import { $ as IMPORT_FOLDER, A as sourcesFor, At as InvalidEditProblems, Bt as
|
|
3
|
-
import { f as parseSwitchboard } from "./narration-
|
|
4
|
-
import {
|
|
5
|
-
import { t as trimCharacters } from "./text-
|
|
1
|
+
import { n as atomicWrite, r as atomicWriteJson } from "./access-Md1YTSX1.js";
|
|
2
|
+
import { $ as IMPORT_FOLDER, A as sourcesFor, At as InvalidEditProblems, Bt as WEEKDAY_NAMES, C as inert, Ct as parseSlotsFile, D as pruneLoreSubjects, Dt as parseCharacterFile, E as pruneLinks, Et as CHARACTER_FILE_NAME, F as ROLE_TABLE, I as isLeftOut, Lt as guarded, M as classifyItems, N as findEntity, O as pruneMembers, Ot as readVariableValues, P as ROLES, Q as withPlayer, R as askYesNo, Rt as LORE_KINDS, S as extractVariables, St as parseItemFile, T as pruneKnowledge, Tt as parseFactionFile, U as yesAt, V as noAt, Vt as DEFAULT_SLOTS, X as itemise, Y as cleanText, _ as characterDocument, _t as parseLoreFile, a as isPresetName, at as readImportFolder, b as extractStyle, bt as ITEM_FILE_NAME, ft as VARIABLES_FILE_NAME, g as asWritten, gt as LORE_FILE_NAME, h as addLore, ht as variableProblems, j as buildRoster, k as pruneRelationships, kt as readIdentifier, nt as PICTURE_FILE, pt as loadVariables, rt as openingText, st as dialectOf, ut as parseImportCommand, v as emptyExtracted, vt as LOCATION_FILE_NAME, w as loreDocuments, wt as FACTION_FILE_NAME, xt as SLOTS_FILE_NAME, y as extractEntities, yt as parseLocationFile, zt as LORE_SCOPES } from "./presets-_U-xroo0.js";
|
|
3
|
+
import { f as parseSwitchboard } from "./narration-b_VBEUWn.js";
|
|
4
|
+
import { G as readDocument$1, J as errorMessage, K as Reader, Q as copyWorldPrompts, U as commandFlagKey, V as plotReferenceProblems, X as PROMPTS_FOLDER, _t as COMPARISONS, a as externalWithheld, at as shippedText, ct as InvalidWorldError, nt as promptProblem, q as formatIssue, r as externalGiven, rt as shippedLanguages, t as externalToolLimit, tt as listFiles, z as loadPlots } from "./hooks-C2U1-8ur.js";
|
|
5
|
+
import { t as trimCharacters } from "./text-C2AGl7Je.js";
|
|
6
6
|
import { S as currentTurn, c as namedModel, d as parseSampling, l as runChild, t as ChildTimeoutError } from "./child-C9nPIy9j.js";
|
|
7
|
-
import { C as slug, S as norm, T as uniqueKey, _ as writeImageFileMetadata, b as NoEmbeddingService, i as libraryHashes, n as addToLibraryOnce, p as MEDIA_TYPES, r as imageExtensionOf, u as referenceImagePath, w as trOf, x as mapLimit } from "./library-
|
|
7
|
+
import { C as slug, S as norm, T as uniqueKey, _ as writeImageFileMetadata, b as NoEmbeddingService, i as libraryHashes, n as addToLibraryOnce, p as MEDIA_TYPES, r as imageExtensionOf, u as referenceImagePath, w as trOf, x as mapLimit } from "./library-4zmCAshR.js";
|
|
8
8
|
import { dirname, join, relative } from "node:path";
|
|
9
9
|
import { MINUTE, MONTH_NAMES, SEASONS, checkProblems, createSessionStore, dayTokenProblems, isTimeZone, lintWorld, parseInstant, parseTimeOfDay, readTriggerDefinition, triggerReferenceProblems, writeCalendar } from "@dsh-agentic-roleplay/state";
|
|
10
10
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -4551,6 +4551,67 @@ const names$1 = {
|
|
|
4551
4551
|
return foundBy("name-clashes", found);
|
|
4552
4552
|
}
|
|
4553
4553
|
};
|
|
4554
|
+
const NUMERALS = /[\p{N}一二三四五六七八九十零〇两百千]/u;
|
|
4555
|
+
/** Whether two names differ in exactly one place: a letter changed, added, left out, or two neighbours swapped. A difference in a number (Room 3, Room 4) is a pattern, not a slip. */
|
|
4556
|
+
function oneApart(a, b) {
|
|
4557
|
+
const x = [...a];
|
|
4558
|
+
const y = [...b];
|
|
4559
|
+
if (Math.abs(x.length - y.length) > 1 || a === b) return false;
|
|
4560
|
+
let start = 0;
|
|
4561
|
+
while (start < x.length && start < y.length && x[start] === y[start]) start += 1;
|
|
4562
|
+
let endX = x.length;
|
|
4563
|
+
let endY = y.length;
|
|
4564
|
+
while (endX > start && endY > start && x[endX - 1] === y[endY - 1]) {
|
|
4565
|
+
endX -= 1;
|
|
4566
|
+
endY -= 1;
|
|
4567
|
+
}
|
|
4568
|
+
const left = x.slice(start, endX);
|
|
4569
|
+
const right = y.slice(start, endY);
|
|
4570
|
+
const swapped = left.length === 2 && right.length === 2 && left[0] === right[1] && left[1] === right[0];
|
|
4571
|
+
if (!(left.length <= 1 && right.length <= 1) && !swapped) return false;
|
|
4572
|
+
return ![...left, ...right].some((char) => NUMERALS.test(char));
|
|
4573
|
+
}
|
|
4574
|
+
/** The shortest name that is compared: a very short one differs from many others by one letter. */
|
|
4575
|
+
const MIN_CONFUSABLE = 4;
|
|
4576
|
+
const confusable = {
|
|
4577
|
+
id: "name-confusable",
|
|
4578
|
+
kit: "consistency",
|
|
4579
|
+
mode: "code",
|
|
4580
|
+
needs: [],
|
|
4581
|
+
description: "Two characters, places or organisations whose names differ by one letter (Mara and Mira): readers and the models mix them up, though they are two. Numbered names (Room 3, Room 4) are not reported.",
|
|
4582
|
+
async run(input) {
|
|
4583
|
+
const [{ characters }, { locations }, { factions }] = await Promise.all([
|
|
4584
|
+
loaded.characters(input),
|
|
4585
|
+
loaded.locations(input),
|
|
4586
|
+
loaded.factions(input)
|
|
4587
|
+
]);
|
|
4588
|
+
const kinds = [
|
|
4589
|
+
["characters", characters],
|
|
4590
|
+
["locations", locations],
|
|
4591
|
+
["factions", factions]
|
|
4592
|
+
];
|
|
4593
|
+
const found = [];
|
|
4594
|
+
for (const [kind, entries] of kinds) {
|
|
4595
|
+
const names = entries.map((entry) => ({
|
|
4596
|
+
id: entry.id,
|
|
4597
|
+
name: norm(entry.name)
|
|
4598
|
+
})).filter((entry) => [...entry.name].length >= (/[\u3400-\u9fff]/u.test(entry.name) ? 2 : MIN_CONFUSABLE));
|
|
4599
|
+
for (let a = 0; a < names.length; a++) for (let b = a + 1; b < names.length; b++) {
|
|
4600
|
+
if (!oneApart(names[a].name, names[b].name)) continue;
|
|
4601
|
+
const first = entries.find((entry) => entry.id === names[a].id);
|
|
4602
|
+
const second = entries.find((entry) => entry.id === names[b].id);
|
|
4603
|
+
found.push({
|
|
4604
|
+
severity: "info",
|
|
4605
|
+
code: "confusable-names",
|
|
4606
|
+
where: `${kind}/${second.id}`,
|
|
4607
|
+
message: `${kind}/${first.id} ("${first.name}") and ${kind}/${second.id} ("${second.name}") differ by one letter, so they are easy to mix up`,
|
|
4608
|
+
hint: "If they are two, give one a clearly different name; if they are one, keep one and point everything that names the other at it."
|
|
4609
|
+
});
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4612
|
+
return foundBy("name-confusable", found);
|
|
4613
|
+
}
|
|
4614
|
+
};
|
|
4554
4615
|
const prompts = {
|
|
4555
4616
|
id: "world-prompts",
|
|
4556
4617
|
kit: "consistency",
|
|
@@ -4586,6 +4647,7 @@ const consistencyChecks = [
|
|
|
4586
4647
|
graph,
|
|
4587
4648
|
values,
|
|
4588
4649
|
names$1,
|
|
4650
|
+
confusable,
|
|
4589
4651
|
prompts,
|
|
4590
4652
|
{
|
|
4591
4653
|
id: "unread-fields",
|
|
@@ -6523,6 +6585,7 @@ async function forgetJobs(directory) {
|
|
|
6523
6585
|
});
|
|
6524
6586
|
}
|
|
6525
6587
|
// src/host/import/tools.ts
|
|
6588
|
+
const residencyOf = (agent) => agent.ctx.get("roleplayOrchestration")?.residency;
|
|
6526
6589
|
const SURVEY_TOOL = "import_survey";
|
|
6527
6590
|
const BUILD_TOOL = "import_build";
|
|
6528
6591
|
const FINISH_TOOL = "import_finish";
|
|
@@ -6607,12 +6670,12 @@ function contextOf(exec, settings, text, language, keepIn) {
|
|
|
6607
6670
|
};
|
|
6608
6671
|
const run = keepIn === void 0 ? ask : cachedJobs(keepIn, ask);
|
|
6609
6672
|
const decide = settings.decisions === "decision" ? (state, asks) => {
|
|
6610
|
-
const service = agent.ctx.get("decisions");
|
|
6673
|
+
const service = guarded(residencyOf(agent), "decision", agent.ctx.get("decisions"), ["decide"]);
|
|
6611
6674
|
if (service === void 0) return Promise.reject(/* @__PURE__ */ new Error("no decision service is selected, or the selected one is not loaded"));
|
|
6612
6675
|
return askYesNo(service, state, asks, exec.signal);
|
|
6613
6676
|
} : void 0;
|
|
6614
6677
|
const embed = async (texts) => {
|
|
6615
|
-
const service = agent.ctx.get("embeddings");
|
|
6678
|
+
const service = guarded(residencyOf(agent), "embedding", agent.ctx.get("embeddings"), ["embed"]);
|
|
6616
6679
|
if (service === void 0) throw new NoEmbeddingService("no embedding provider is selected, or the selected one is not loaded");
|
|
6617
6680
|
const { vectors, model } = await service.embed(texts, {
|
|
6618
6681
|
inputType: "document",
|
|
@@ -6866,4 +6929,4 @@ function limitAuthoringAgents(ctx, kindOf) {
|
|
|
6866
6929
|
}
|
|
6867
6930
|
export { readSource as $, subfolders as $t, editsSince as A, populateLore as At, addressesToFetch as B, loadLocations as Bt, worldFieldChanges as C, populateCharacters as Ct, loadCardEvidence as D, populateItems as Dt, loadWorldParts as E, populateFactions as Et, localChanges as F, TRIGGERS_FILE_NAME as Ft, vetUrl as G, DICE_FILE_NAME as Gt, fetchPictures as H, loadItems as Ht, readOrigin as I, loadTriggers as It, UPDATE_FOLDER as J, CALENDAR_FILE_NAME as Jt, cardCharacter as K, loadDice as Kt, writeOrigin as L, LORE_DIR as Lt, describeChanges as M, populateTriggers as Mt, hashWorld as N, populateVariables as Nt, CHECK_COMMANDS as O, populateKnowledge as Ot, isUnchanged as P, routineProblems as Pt, entitiesByPiece as Q, loadCharacters as Qt, CatalogueError as R, loadLore as Rt, pictureChange as S, populateCalendar as St, readWorldInfo as T, populateDice as Tt, guardedLookup as U, FACTIONS_DIR as Ut, candidateUrls as V, ITEMS_DIR as Vt, mergeReports as W, loadFactions as Wt, cardPieces as X, parseCalendarFile as Xt, baseId as Y, loadCalendar as Yt, cardTools as Z, CHARACTERS_DIR as Zt, runChecks as _, writeLorebookEntry as _t, importHooks as a, readCard as an, addLorebookEntries as at, diffText as b, withScratchStory as bt, importPhase as c, DICE_RESULTS as cn, deleteLorebookEntry as ct, markReady as d, listLorebooks as dt, knownOutputCeiling as en, WORLD_FILE_NAME as et, settleDraft as f, loadLorebook as ft, CHECKS as g, updateLorebookInfo as gt, presentReport as h, reserveLorebook as ht, contextOf as i, pictureOf as in, questionView as it, writeSnapshot as j, populateRoutines as jt, recordProvenance as k, populateLocations as kt, isReviewing as l, authoredWorldOf as ln, entriesOf as lt, checkImported as m, readLorebook as mt, limitAuthoringAgents as n, cardFormat as nn, parseWorldInfoEdit as nt, importTools as o, DICE_COMPARISONS as on, createLorebook as ot, structureImport as p, lorebookDirectory as pt, writePortrait as q, parseDiceFile as qt, MAX_PREVIEW_TEXT as r, isPng as rn, combineAnswers as rt, worldOf as s, DICE_READINGS as sn, deleteLorebook as st, AuthoringTools as t, ImportCardError as tn, parseWorldFile as tt, keepDraft as u, authoringChatSessionId as un, isLorebookName as ut, addressChanges as v, checkWorld as vt, editWorldInfo as w, populateClock as wt, matchPieces as x, knowsCharacter as xt, cardChanges as y, loadValidatedWorld as yt, addressKey as z, LOCATIONS_DIR as zt };
|
|
6868
6931
|
|
|
6869
|
-
//# sourceMappingURL=authoring-tools-
|
|
6932
|
+
//# sourceMappingURL=authoring-tools-BFdw7ahj.js.map
|
package/lib/authoring.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { $ as readSource, A as editsSince, C as worldFieldChanges, D as loadCardEvidence, E as loadWorldParts, J as UPDATE_FOLDER, O as CHECK_COMMANDS, Q as entitiesByPiece, S as pictureChange, T as readWorldInfo, Z as cardTools, _ as runChecks, a as importHooks, b as diffText, g as CHECKS, h as presentReport, i as contextOf, l as isReviewing, ln as authoredWorldOf, m as checkImported, n as limitAuthoringAgents, nt as parseWorldInfoEdit, o as importTools, v as addressChanges, vt as checkWorld, w as editWorldInfo, x as matchPieces, y as cardChanges } from "./authoring-tools-
|
|
2
|
-
import { t as guardAuthoringTurns } from "./turn-guard-
|
|
3
|
-
import { C as readWorldEditor, L as presetTools, M as deleteTriggerDocument, N as readTriggerDocuments, P as writeTriggerDocument, U as finishUpdate, W as pendingUpdate, _ as editWorldPlots, a as deleteWorldPackFile, c as createAuthoredEntity, d as replaceAuthoredEntity, i as checkWorldPack, l as deleteAuthoredEntity, o as listWorldPacks, r as registerPackJail, s as AUTHORED_ENTITY_KINDS, u as readAuthoredEntityDocument, v as editWorldRelation, z as translateTools } from "./pack-jail-
|
|
4
|
-
import { $ as IMPORT_FOLDER, At as InvalidEditProblems, Ft as parseRelationEdit, G as deleteWorldPrompt, J as writeWorldPrompt, K as listWorldPrompts, W as PROSE_PROMPTS, dt as parseAuthoringCommand, nt as PICTURE_FILE, q as readWorldPrompt } from "./presets-
|
|
5
|
-
import { i as translator, r as languageOf } from "./text-
|
|
6
|
-
import {
|
|
7
|
-
import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-
|
|
8
|
-
import "./access-
|
|
1
|
+
import { $ as readSource, A as editsSince, C as worldFieldChanges, D as loadCardEvidence, E as loadWorldParts, J as UPDATE_FOLDER, O as CHECK_COMMANDS, Q as entitiesByPiece, S as pictureChange, T as readWorldInfo, Z as cardTools, _ as runChecks, a as importHooks, b as diffText, g as CHECKS, h as presentReport, i as contextOf, l as isReviewing, ln as authoredWorldOf, m as checkImported, n as limitAuthoringAgents, nt as parseWorldInfoEdit, o as importTools, v as addressChanges, vt as checkWorld, w as editWorldInfo, x as matchPieces, y as cardChanges } from "./authoring-tools-BFdw7ahj.js";
|
|
2
|
+
import { t as guardAuthoringTurns } from "./turn-guard-C0M3rXEN.js";
|
|
3
|
+
import { C as readWorldEditor, L as presetTools, M as deleteTriggerDocument, N as readTriggerDocuments, P as writeTriggerDocument, U as finishUpdate, W as pendingUpdate, _ as editWorldPlots, a as deleteWorldPackFile, c as createAuthoredEntity, d as replaceAuthoredEntity, i as checkWorldPack, l as deleteAuthoredEntity, o as listWorldPacks, r as registerPackJail, s as AUTHORED_ENTITY_KINDS, u as readAuthoredEntityDocument, v as editWorldRelation, z as translateTools } from "./pack-jail-Ci9bIeDI.js";
|
|
4
|
+
import { $ as IMPORT_FOLDER, At as InvalidEditProblems, Ft as parseRelationEdit, G as deleteWorldPrompt, J as writeWorldPrompt, K as listWorldPrompts, W as PROSE_PROMPTS, dt as parseAuthoringCommand, nt as PICTURE_FILE, q as readWorldPrompt } from "./presets-_U-xroo0.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-C2AGl7Je.js";
|
|
6
|
+
import { B as parsePlotsFile, it as shippedPromptsDirectory, q as formatIssue } from "./hooks-C2U1-8ur.js";
|
|
7
|
+
import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-CYkozh8Q.js";
|
|
8
|
+
import "./access-Md1YTSX1.js";
|
|
9
9
|
import { join, relative } from "node:path";
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
import { readFile, readdir } from "node:fs/promises";
|
|
@@ -589,6 +589,25 @@ function plotDocument(value) {
|
|
|
589
589
|
if (!parsed.ok) throw new InvalidEditProblems(parsed.issues.map(formatIssue));
|
|
590
590
|
return parsed.value[0];
|
|
591
591
|
}
|
|
592
|
+
/** Checks a write the way its tool will, and writes nothing: a change the tool would refuse is not put to the person. @throws {InvalidEditProblems} */
|
|
593
|
+
async function validateMutation(reader, exec) {
|
|
594
|
+
const args = exec.arguments;
|
|
595
|
+
if (exec.name !== "create_world_element" && exec.name !== "replace_world_element" && exec.name !== "write_world_trigger") return;
|
|
596
|
+
const { record } = await reader.read(exec);
|
|
597
|
+
const world = {
|
|
598
|
+
id: record.summary.id,
|
|
599
|
+
directory: record.directory
|
|
600
|
+
};
|
|
601
|
+
const key = String(args["key"]);
|
|
602
|
+
if (exec.name === "write_world_trigger") {
|
|
603
|
+
await writeTriggerDocument(record.directory, await loadWorldParts(record.directory), key, args["document"], { dryRun: true });
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
await (exec.name === "create_world_element" ? createAuthoredEntity : replaceAuthoredEntity)(world, args["kind"], key, args["document"], {
|
|
607
|
+
refuseUnread: true,
|
|
608
|
+
dryRun: true
|
|
609
|
+
});
|
|
610
|
+
}
|
|
592
611
|
/** The most problems a write reports back; `check_world` lists the rest. */
|
|
593
612
|
const REPORTED_PROBLEMS = 8;
|
|
594
613
|
/**
|
|
@@ -821,6 +840,16 @@ async function authoringApproval(exec, next, reviewing = () => Promise.resolve(f
|
|
|
821
840
|
reason: `an import may change only the prose prompts (${PROSE_PROMPTS.join(", ")}); "${String(args["id"])}" holds rules of the game and is left to the person`
|
|
822
841
|
};
|
|
823
842
|
if (importing || auto) return await next();
|
|
843
|
+
try {
|
|
844
|
+
if (exec.name === "edit_world_relationship") parseRelationEdit(args["change"]);
|
|
845
|
+
else await options.validate?.(exec);
|
|
846
|
+
} catch (error) {
|
|
847
|
+
if (error instanceof InvalidEditProblems) return {
|
|
848
|
+
kind: "deny",
|
|
849
|
+
reason: error.message
|
|
850
|
+
};
|
|
851
|
+
throw error;
|
|
852
|
+
}
|
|
824
853
|
if (pack) {
|
|
825
854
|
const target = `file “${String(args["path"])}” of interface pack “${String(args["pack"])}”`;
|
|
826
855
|
const remove = exec.name.startsWith("delete");
|
|
@@ -1282,6 +1311,7 @@ function apply(ctx) {
|
|
|
1282
1311
|
};
|
|
1283
1312
|
ctx.on("tools/pre-execute", (exec, next) => authoringApproval(exec, next, reviewing, {
|
|
1284
1313
|
auto: () => ctx.roleplayImport.settings.approval === "auto",
|
|
1314
|
+
validate: (exec) => validateMutation(reader, exec),
|
|
1285
1315
|
current,
|
|
1286
1316
|
info
|
|
1287
1317
|
}));
|