@dsh-agentic-roleplay/core 0.11.1 → 0.12.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-Md1YTSX1.js → access-DifaiHrI.js} +3 -15
- package/lib/{authoring-tools-BFdw7ahj.js → authoring-tools-VOaXzr_R.js} +58 -766
- package/lib/authoring.js +136 -13
- package/lib/{child-C9nPIy9j.js → child-DzZ-aI6k.js} +130 -2
- package/lib/client.js +17093 -2269
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +3 -3
- package/lib/dev-context-Bdm-eVer.js +40 -0
- package/lib/doctor.js +5 -3
- package/lib/{gallery-BWHmjogd.js → gallery-Ctz-UoFk.js} +3 -3
- package/lib/{generator-QCdm8nUh.js → generator-Cv6WWmZT.js} +2 -2
- package/lib/helper.js +15 -1
- package/lib/{hooks-C2U1-8ur.js → hooks-BdR3mBeM.js} +751 -344
- package/lib/images.js +4 -4
- package/lib/index.js +342 -463
- package/lib/jail-Cp4zEfip.js +107 -0
- package/lib/{library-4zmCAshR.js → library-BU2A_Dx8.js} +3 -3
- package/lib/{lorebook-author-tools-Bjfjt3bg.js → lorebook-author-tools-DUKcQu8P.js} +20 -7
- package/lib/lorebook-authoring.js +12 -5
- package/lib/{narration-b_VBEUWn.js → narration-CDsJ5wxH.js} +29 -2
- package/lib/orchestration.js +615 -48
- package/lib/{pack-jail-Ci9bIeDI.js → pack-jail-CzHQu0n3.js} +559 -23
- package/lib/{packs-CYkozh8Q.js → packs-BZ-45J4-.js} +2 -2
- package/lib/{presenter-agent-CqkAL03Q.js → presenter-agent-C2ZkoxZu.js} +9 -9
- package/lib/{preset-B-35yUmt.js → preset-BPnRPW-1.js} +4 -4
- package/lib/{preset-author-tools-BUymqZM5.js → preset-author-tools-DBqPwn-o.js} +9 -8
- package/lib/preset-authoring.js +11 -6
- package/lib/{reflection-B9N0z3KY.js → reflection-Cuy0YLv0.js} +22 -16
- package/lib/{presets-_U-xroo0.js → serial-BZNeK57v.js} +1305 -331
- 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-xaFxYc1T.js} +3 -3
- package/locale/de.json +6 -0
- package/locale/en.json +6 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +34 -34
- package/prompts/en/import/finish-ok.md +1 -1
- package/prompts/en/import/generator.md +1 -1
- package/prompts/en/import/style.md +2 -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/en/world/procedure.md +1 -1
- package/prompts/zh/import/finish-ok.md +1 -1
- package/prompts/zh/import/generator.md +1 -1
- package/prompts/zh/import/style.md +2 -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
- package/prompts/zh/world/procedure.md +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { $ as
|
|
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-DzZ-aI6k.js";
|
|
2
|
+
import { A as editsSince, At as loadCommands, B as addressesToFetch, C as worldFieldChanges, Ct as FACTIONS_DIR, Dt as parseDiceFile, E as loadWorldParts, Et as loadDice, Ft as CHARACTERS_DIR, Gt as DICE_RESULTS, H as fetchPictures, It as loadCharacters, J as UPDATE_FOLDER, K as cardCharacter, Kt as authoredWorldOf, Mt as CALENDAR_FILE_NAME, Nt as loadCalendar, Ot as COMMANDS_FILE_NAME, Pt as parseCalendarFile, St as loadItems, Tt as DICE_FILE_NAME, Ut as DICE_COMPARISONS, V as candidateUrls, W as mergeReports, Wt as DICE_READINGS, X as cardPieces, Y as baseId, _t as TRIGGERS_FILE_NAME, bt as loadLocations, c as importPhase, gt as routineProblems, i as contextOf, j as writeSnapshot, jt as parseCommandsFile, k as recordProvenance, kt as commandVariable, nt as withScratchStory, q as writePortrait, qt as authoringChatSessionId, rt as knowsCharacter, s as worldOf, tt as loadValidatedWorld, vt as loadTriggers, w as editWorldInfo, wt as loadFactions, x as matchPieces, xt as ITEMS_DIR, yt as LOCATIONS_DIR, z as addressKey } from "./authoring-tools-VOaXzr_R.js";
|
|
3
|
+
import { $t as subfolders, Bt as loadLore, Ct as PICTURE_FILE, Dt as writeChoices, Et as readImportFolder, Ft as VARIABLES_FILE_NAME, Gt as ITEM_FILE_NAME, Ht as parseLoreFile, It as loadVariables, Lt as parseVariablesFile, M as WORLD_FILE_NAME, N as parseWorldFile, Qt as parseCharacterFile, Rt as variableProblems, Ut as LOCATION_FILE_NAME, Vt as LORE_FILE_NAME, Wt as parseLocationFile, Xt as parseFactionFile, Yt as FACTION_FILE_NAME, Zt as CHARACTER_FILE_NAME, bt as IMPORT_FOLDER, en as InvalidEditProblems, l as extractStyleFrom, nt as writeWorldPrompt, qt as parseItemFile, yt as withPlayer, zt as LORE_DIR } from "./serial-BZNeK57v.js";
|
|
4
|
+
import { n as encodeOutput } from "./narration-CDsJ5wxH.js";
|
|
5
|
+
import { a as VARIABLE_KINDS, n as atomicWrite, o as VARIABLE_SUBJECTS, r as atomicWriteJson, s as VARIABLE_VISIBILITIES } from "./access-DifaiHrI.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-BdR3mBeM.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-BU2A_Dx8.js";
|
|
9
|
+
import { n as readPreset } from "./preset-BPnRPW-1.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-BZ-45J4-.js";
|
|
11
|
+
import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-Cv6WWmZT.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";
|
|
@@ -259,20 +260,44 @@ function agentServicesOf(ctx) {
|
|
|
259
260
|
controller,
|
|
260
261
|
registry,
|
|
261
262
|
...persistence === void 0 ? {} : { persistence },
|
|
262
|
-
...agents === void 0 ? {} : { unload: unloader(agents) }
|
|
263
|
+
...agents === void 0 ? {} : { unload: unloader(ctx, agents) }
|
|
263
264
|
};
|
|
264
265
|
};
|
|
265
266
|
}
|
|
266
|
-
/**
|
|
267
|
-
|
|
267
|
+
/** How long a disposed chat may take to leave DSH's agent registry before the replacement is refused. */
|
|
268
|
+
const UNLOAD_WAIT_MS = 5e3;
|
|
269
|
+
/**
|
|
270
|
+
* DSH has no call to unload an agent; disposing its scope is what its own teardown (a closed log, a released
|
|
271
|
+
* registration) hangs from. `agent/disposed` says when it has left the registry; the bound is only a guard for a
|
|
272
|
+
* teardown that never finishes.
|
|
273
|
+
*/
|
|
274
|
+
function unloader(ctx, agents) {
|
|
268
275
|
return async (chat) => {
|
|
269
276
|
const live = agents.get(chat);
|
|
270
277
|
if (live === void 0) return;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
278
|
+
let off = () => {};
|
|
279
|
+
try {
|
|
280
|
+
await new Promise((resolve, reject) => {
|
|
281
|
+
const timer = setTimeout(resolve, UNLOAD_WAIT_MS);
|
|
282
|
+
const settle = (done) => {
|
|
283
|
+
clearTimeout(timer);
|
|
284
|
+
done();
|
|
285
|
+
};
|
|
286
|
+
off = ctx.on("agent/disposed", ({ agent }) => {
|
|
287
|
+
if (agent.session.id === chat) settle(resolve);
|
|
288
|
+
});
|
|
289
|
+
(async () => {
|
|
290
|
+
try {
|
|
291
|
+
await (live.scope.rawDispose ?? live.scope.dispose.bind(live.scope))();
|
|
292
|
+
} catch (error) {
|
|
293
|
+
settle(() => reject(error));
|
|
294
|
+
}
|
|
295
|
+
})();
|
|
296
|
+
});
|
|
297
|
+
} finally {
|
|
298
|
+
off();
|
|
275
299
|
}
|
|
300
|
+
if (agents.get(chat) !== void 0) throw new Error(`the chat ${chat} is still loaded and cannot be replaced`);
|
|
276
301
|
};
|
|
277
302
|
}
|
|
278
303
|
/**
|
|
@@ -1279,7 +1304,7 @@ async function translateWorld(ctx, worlds, source, to, told) {
|
|
|
1279
1304
|
await loadValidatedWorld(record);
|
|
1280
1305
|
} catch (error) {
|
|
1281
1306
|
if (!(error instanceof InvalidWorldError)) throw error;
|
|
1282
|
-
problems.push(...error.problems.map((problem) => `${relative(destination, problem.path) || "."}: ${problem.message}`));
|
|
1307
|
+
problems.push(...error.problems.map((problem) => `${relative(destination, problem.path).split(sep).join("/") || "."}: ${problem.message}`));
|
|
1283
1308
|
}
|
|
1284
1309
|
return {
|
|
1285
1310
|
worldId: id,
|
|
@@ -1394,6 +1419,333 @@ function presetTools(worlds, settings, prompting) {
|
|
|
1394
1419
|
}
|
|
1395
1420
|
})];
|
|
1396
1421
|
}
|
|
1422
|
+
// src/shared/world-commands.ts
|
|
1423
|
+
const isObject$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1424
|
+
/**
|
|
1425
|
+
* The commands as the browser sends them. Whether the words are acceptable (letters, not one the game uses, not repeated) is checked as the file is read.
|
|
1426
|
+
* @throws {InvalidEditProblems} naming every field that has the wrong shape.
|
|
1427
|
+
*/
|
|
1428
|
+
function parseCommandsEdit(value) {
|
|
1429
|
+
const problems = [];
|
|
1430
|
+
if (!isObject$2(value) || !Array.isArray(value["commands"])) throw new InvalidEditProblems(["the commands must be { commands: [...] }"]);
|
|
1431
|
+
const commands = value["commands"].map((entry, index) => {
|
|
1432
|
+
const at = `commands[${index}]`;
|
|
1433
|
+
if (!isObject$2(entry)) {
|
|
1434
|
+
problems.push(`${at} must be an object`);
|
|
1435
|
+
return {
|
|
1436
|
+
word: "",
|
|
1437
|
+
description: ""
|
|
1438
|
+
};
|
|
1439
|
+
}
|
|
1440
|
+
for (const key of Object.keys(entry)) if (![
|
|
1441
|
+
"word",
|
|
1442
|
+
"description",
|
|
1443
|
+
"key"
|
|
1444
|
+
].includes(key)) problems.push(`${at}.${key} is not a field of a command`);
|
|
1445
|
+
for (const key of ["word", "description"]) if (typeof entry[key] !== "string") problems.push(`${at}.${key} must be text`);
|
|
1446
|
+
if (entry["key"] !== void 0 && typeof entry["key"] !== "string") problems.push(`${at}.key must be text`);
|
|
1447
|
+
const text = (field) => typeof field === "string" ? field.trim() : "";
|
|
1448
|
+
return {
|
|
1449
|
+
word: text(entry["word"]).replace(/^\//, ""),
|
|
1450
|
+
description: text(entry["description"]),
|
|
1451
|
+
...text(entry["key"]) === "" ? {} : { key: text(entry["key"]) }
|
|
1452
|
+
};
|
|
1453
|
+
});
|
|
1454
|
+
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
1455
|
+
return { commands };
|
|
1456
|
+
}
|
|
1457
|
+
// src/shared/world-dice.ts
|
|
1458
|
+
const isObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1459
|
+
const CHECK_FIELDS = [
|
|
1460
|
+
"key",
|
|
1461
|
+
"name",
|
|
1462
|
+
"use",
|
|
1463
|
+
"dice",
|
|
1464
|
+
"reading",
|
|
1465
|
+
"hit",
|
|
1466
|
+
"compare",
|
|
1467
|
+
"modifier",
|
|
1468
|
+
"bands"
|
|
1469
|
+
];
|
|
1470
|
+
const BAND_FIELDS = [
|
|
1471
|
+
"min",
|
|
1472
|
+
"max",
|
|
1473
|
+
"label",
|
|
1474
|
+
"result",
|
|
1475
|
+
"critical"
|
|
1476
|
+
];
|
|
1477
|
+
/** Reads a body that came from the browser: the shape of every field is checked here, and what the checks mean when the world is validated. */
|
|
1478
|
+
function parseDiceEdit(value) {
|
|
1479
|
+
const problems = [];
|
|
1480
|
+
if (!isObject$1(value) || !Array.isArray(value["checks"])) throw new InvalidEditProblems(["the dice must be { checks: [...] }"]);
|
|
1481
|
+
const checks = value["checks"].map((entry, index) => {
|
|
1482
|
+
const at = `checks[${index}]`;
|
|
1483
|
+
const empty = {
|
|
1484
|
+
key: "",
|
|
1485
|
+
name: "",
|
|
1486
|
+
use: "",
|
|
1487
|
+
dice: "",
|
|
1488
|
+
bands: []
|
|
1489
|
+
};
|
|
1490
|
+
if (!isObject$1(entry)) {
|
|
1491
|
+
problems.push(`${at} must be an object`);
|
|
1492
|
+
return empty;
|
|
1493
|
+
}
|
|
1494
|
+
for (const key of Object.keys(entry)) if (!CHECK_FIELDS.includes(key)) problems.push(`${at}.${key} is not a field of a check`);
|
|
1495
|
+
for (const key of [
|
|
1496
|
+
"key",
|
|
1497
|
+
"name",
|
|
1498
|
+
"use",
|
|
1499
|
+
"dice"
|
|
1500
|
+
]) if (typeof entry[key] !== "string") problems.push(`${at}.${key} must be text`);
|
|
1501
|
+
if (entry["reading"] !== void 0 && !DICE_READINGS.includes(entry["reading"])) problems.push(`${at}.reading must be one of: ${DICE_READINGS.join(", ")}`);
|
|
1502
|
+
if (entry["compare"] !== void 0 && !DICE_COMPARISONS.includes(entry["compare"])) problems.push(`${at}.compare must be one of: ${DICE_COMPARISONS.join(", ")}`);
|
|
1503
|
+
if (entry["hit"] !== void 0 && (typeof entry["hit"] !== "number" || !Number.isInteger(entry["hit"]))) problems.push(`${at}.hit must be a whole number`);
|
|
1504
|
+
if (entry["modifier"] !== void 0 && typeof entry["modifier"] !== "string") problems.push(`${at}.modifier must be text`);
|
|
1505
|
+
const bands = Array.isArray(entry["bands"]) ? entry["bands"] : void 0;
|
|
1506
|
+
if (bands === void 0) problems.push(`${at}.bands must be a list`);
|
|
1507
|
+
const text = (field) => typeof field === "string" ? field.trim() : "";
|
|
1508
|
+
const hit = entry["hit"];
|
|
1509
|
+
return {
|
|
1510
|
+
key: text(entry["key"]),
|
|
1511
|
+
name: text(entry["name"]),
|
|
1512
|
+
use: text(entry["use"]),
|
|
1513
|
+
dice: text(entry["dice"]),
|
|
1514
|
+
...entry["reading"] === void 0 ? {} : { reading: entry["reading"] },
|
|
1515
|
+
...typeof hit === "number" ? { hit } : {},
|
|
1516
|
+
...entry["compare"] === void 0 ? {} : { compare: entry["compare"] },
|
|
1517
|
+
...text(entry["modifier"]) === "" ? {} : { modifier: text(entry["modifier"]) },
|
|
1518
|
+
bands: (bands ?? []).map((band, bandIndex) => {
|
|
1519
|
+
const where = `${at}.bands[${bandIndex}]`;
|
|
1520
|
+
if (!isObject$1(band)) {
|
|
1521
|
+
problems.push(`${where} must be an object`);
|
|
1522
|
+
return {
|
|
1523
|
+
label: "",
|
|
1524
|
+
result: "failed"
|
|
1525
|
+
};
|
|
1526
|
+
}
|
|
1527
|
+
for (const key of Object.keys(band)) if (!BAND_FIELDS.includes(key)) problems.push(`${where}.${key} is not a field of a band`);
|
|
1528
|
+
for (const key of ["min", "max"]) if (band[key] !== void 0 && (typeof band[key] !== "number" || !Number.isFinite(band[key]))) problems.push(`${where}.${key} must be a number`);
|
|
1529
|
+
if (typeof band["label"] !== "string") problems.push(`${where}.label must be text`);
|
|
1530
|
+
if (!DICE_RESULTS.includes(band["result"])) problems.push(`${where}.result must be one of: ${DICE_RESULTS.join(", ")}`);
|
|
1531
|
+
const min = band["min"];
|
|
1532
|
+
const max = band["max"];
|
|
1533
|
+
return {
|
|
1534
|
+
label: text(band["label"]),
|
|
1535
|
+
result: band["result"],
|
|
1536
|
+
...typeof min === "number" ? { min } : {},
|
|
1537
|
+
...typeof max === "number" ? { max } : {},
|
|
1538
|
+
...band["critical"] === true ? { critical: true } : {}
|
|
1539
|
+
};
|
|
1540
|
+
})
|
|
1541
|
+
};
|
|
1542
|
+
});
|
|
1543
|
+
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
1544
|
+
return { checks };
|
|
1545
|
+
}
|
|
1546
|
+
// src/shared/world-daily.ts
|
|
1547
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1548
|
+
const ROUTINE_FIELDS = [
|
|
1549
|
+
"days",
|
|
1550
|
+
"on",
|
|
1551
|
+
"from",
|
|
1552
|
+
"to",
|
|
1553
|
+
"activity",
|
|
1554
|
+
"location",
|
|
1555
|
+
"feature",
|
|
1556
|
+
"position",
|
|
1557
|
+
"interruptible",
|
|
1558
|
+
"sleep"
|
|
1559
|
+
];
|
|
1560
|
+
/**
|
|
1561
|
+
* The windows of a day as the browser sends them.
|
|
1562
|
+
* @throws {InvalidEditProblems} naming every field that has the wrong shape; whether the times and places are acceptable is checked when the file is read back.
|
|
1563
|
+
*/
|
|
1564
|
+
function parseRoutineEdit(value) {
|
|
1565
|
+
const problems = [];
|
|
1566
|
+
const list = isObject(value) && Array.isArray(value["windows"]) ? value["windows"] : void 0;
|
|
1567
|
+
if (list === void 0) throw new InvalidEditProblems(["the day must be { windows: [...] }"]);
|
|
1568
|
+
const windows = list.map((entry, index) => {
|
|
1569
|
+
const at = `windows[${index}]`;
|
|
1570
|
+
if (!isObject(entry)) {
|
|
1571
|
+
problems.push(`${at} must be an object`);
|
|
1572
|
+
return {
|
|
1573
|
+
days: [],
|
|
1574
|
+
from: "",
|
|
1575
|
+
to: "",
|
|
1576
|
+
activity: "",
|
|
1577
|
+
interruptible: true
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
for (const key of Object.keys(entry)) if (!ROUTINE_FIELDS.includes(key)) problems.push(`${at}.${key} is not a field of a window`);
|
|
1581
|
+
for (const key of [
|
|
1582
|
+
"from",
|
|
1583
|
+
"to",
|
|
1584
|
+
"activity"
|
|
1585
|
+
]) if (typeof entry[key] !== "string") problems.push(`${at}.${key} must be text`);
|
|
1586
|
+
for (const key of [
|
|
1587
|
+
"location",
|
|
1588
|
+
"feature",
|
|
1589
|
+
"position"
|
|
1590
|
+
]) if (entry[key] !== void 0 && typeof entry[key] !== "string") problems.push(`${at}.${key} must be text`);
|
|
1591
|
+
if (entry["days"] !== void 0 && !(Array.isArray(entry["days"]) && entry["days"].every((day) => typeof day === "string"))) problems.push(`${at}.days must be a list of days`);
|
|
1592
|
+
if (entry["interruptible"] !== void 0 && typeof entry["interruptible"] !== "boolean") problems.push(`${at}.interruptible must be true or false`);
|
|
1593
|
+
if (entry["sleep"] !== void 0 && typeof entry["sleep"] !== "boolean") problems.push(`${at}.sleep must be true or false`);
|
|
1594
|
+
const text = (key) => typeof entry[key] === "string" ? entry[key].trim() : "";
|
|
1595
|
+
return {
|
|
1596
|
+
days: Array.isArray(entry["days"]) ? entry["days"].map((day) => day.trim().toLowerCase()).filter((day) => day !== "") : [],
|
|
1597
|
+
...Array.isArray(entry["on"]) && entry["on"].length > 0 ? { on: entry["on"].map((day) => String(day).trim()).filter((day) => day !== "") } : {},
|
|
1598
|
+
from: text("from"),
|
|
1599
|
+
to: text("to"),
|
|
1600
|
+
activity: text("activity"),
|
|
1601
|
+
...text("location") === "" ? {} : { location: text("location") },
|
|
1602
|
+
...text("feature") === "" ? {} : { feature: text("feature") },
|
|
1603
|
+
...text("position") === "" ? {} : { position: text("position") },
|
|
1604
|
+
interruptible: entry["interruptible"] !== false,
|
|
1605
|
+
...entry["sleep"] === true ? { sleep: true } : {}
|
|
1606
|
+
};
|
|
1607
|
+
});
|
|
1608
|
+
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
1609
|
+
return windows;
|
|
1610
|
+
}
|
|
1611
|
+
const VARIABLE_FIELDS = [
|
|
1612
|
+
"key",
|
|
1613
|
+
"name",
|
|
1614
|
+
"kind",
|
|
1615
|
+
"subject",
|
|
1616
|
+
"visibility",
|
|
1617
|
+
"description",
|
|
1618
|
+
"update",
|
|
1619
|
+
"min",
|
|
1620
|
+
"max",
|
|
1621
|
+
"integer",
|
|
1622
|
+
"baseline",
|
|
1623
|
+
"always",
|
|
1624
|
+
"default",
|
|
1625
|
+
"only",
|
|
1626
|
+
"options",
|
|
1627
|
+
"bands"
|
|
1628
|
+
];
|
|
1629
|
+
/**
|
|
1630
|
+
* The declarations as the browser sends them, with empty fields left out. Whether they are acceptable together is checked against the world's files.
|
|
1631
|
+
* @throws {InvalidEditProblems} naming every field that has the wrong shape.
|
|
1632
|
+
*/
|
|
1633
|
+
function parseVariablesEdit(value) {
|
|
1634
|
+
const problems = [];
|
|
1635
|
+
const list = isObject(value) && Array.isArray(value["variables"]) ? value["variables"] : void 0;
|
|
1636
|
+
if (list === void 0) throw new InvalidEditProblems(["the variables must be { variables: [...] }"]);
|
|
1637
|
+
const declarations = list.flatMap((entry, index) => {
|
|
1638
|
+
const at = `variables[${index}]`;
|
|
1639
|
+
if (!isObject(entry)) {
|
|
1640
|
+
problems.push(`${at} must be an object`);
|
|
1641
|
+
return [];
|
|
1642
|
+
}
|
|
1643
|
+
for (const key of Object.keys(entry)) if (!VARIABLE_FIELDS.includes(key)) problems.push(`${at}.${key} is not a field of a variable`);
|
|
1644
|
+
const text = (key) => typeof entry[key] === "string" ? entry[key].trim() : "";
|
|
1645
|
+
const number = (key) => {
|
|
1646
|
+
if (entry[key] === void 0 || entry[key] === null || entry[key] === "") return void 0;
|
|
1647
|
+
if (typeof entry[key] !== "number" || !Number.isFinite(entry[key])) {
|
|
1648
|
+
problems.push(`${at}.${key} must be a number`);
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1651
|
+
return entry[key];
|
|
1652
|
+
};
|
|
1653
|
+
const flag = (key) => {
|
|
1654
|
+
if (entry[key] === void 0) return void 0;
|
|
1655
|
+
if (typeof entry[key] !== "boolean") {
|
|
1656
|
+
problems.push(`${at}.${key} must be true or false`);
|
|
1657
|
+
return;
|
|
1658
|
+
}
|
|
1659
|
+
return entry[key];
|
|
1660
|
+
};
|
|
1661
|
+
const strings = (key) => {
|
|
1662
|
+
if (entry[key] === void 0) return [];
|
|
1663
|
+
if (!(Array.isArray(entry[key]) && entry[key].every((item) => typeof item === "string"))) {
|
|
1664
|
+
problems.push(`${at}.${key} must be a list of text`);
|
|
1665
|
+
return [];
|
|
1666
|
+
}
|
|
1667
|
+
return entry[key].map((item) => item.trim()).filter((item) => item !== "");
|
|
1668
|
+
};
|
|
1669
|
+
const bands = Array.isArray(entry["bands"]) ? entry["bands"].flatMap((band) => isObject(band) && typeof band["up_to"] === "number" && typeof band["label"] === "string" && band["label"].trim() !== "" ? [{
|
|
1670
|
+
up_to: band["up_to"],
|
|
1671
|
+
label: band["label"].trim()
|
|
1672
|
+
}] : (problems.push(`${at}.bands needs { up_to, label } entries`), [])) : [];
|
|
1673
|
+
const rawDefault = entry["default"];
|
|
1674
|
+
if (rawDefault !== void 0 && rawDefault !== null && rawDefault !== "" && typeof rawDefault !== "number" && typeof rawDefault !== "boolean" && typeof rawDefault !== "string") problems.push(`${at}.default must be a number, true or false, or text`);
|
|
1675
|
+
for (const [key, allowed] of [
|
|
1676
|
+
["kind", VARIABLE_KINDS],
|
|
1677
|
+
["subject", VARIABLE_SUBJECTS],
|
|
1678
|
+
["visibility", VARIABLE_VISIBILITIES]
|
|
1679
|
+
]) if (!allowed.includes(text(key))) problems.push(`${at}.${key} must be one of: ${allowed.join(", ")}`);
|
|
1680
|
+
const [min, max] = [number("min"), number("max")];
|
|
1681
|
+
const [integer, baseline, always] = [
|
|
1682
|
+
flag("integer"),
|
|
1683
|
+
flag("baseline"),
|
|
1684
|
+
flag("always")
|
|
1685
|
+
];
|
|
1686
|
+
const only = strings("only");
|
|
1687
|
+
const options = strings("options");
|
|
1688
|
+
return [{
|
|
1689
|
+
key: text("key"),
|
|
1690
|
+
name: text("name"),
|
|
1691
|
+
kind: text("kind"),
|
|
1692
|
+
subject: text("subject"),
|
|
1693
|
+
visibility: text("visibility"),
|
|
1694
|
+
...text("description") === "" ? {} : { description: text("description") },
|
|
1695
|
+
...text("update") === "" ? {} : { update: text("update") },
|
|
1696
|
+
...min === void 0 ? {} : { min },
|
|
1697
|
+
...max === void 0 ? {} : { max },
|
|
1698
|
+
...integer === true ? { integer } : {},
|
|
1699
|
+
...baseline === true ? { baseline } : {},
|
|
1700
|
+
...always === true ? { always } : {},
|
|
1701
|
+
...rawDefault === void 0 || rawDefault === null || rawDefault === "" ? {} : { default: rawDefault },
|
|
1702
|
+
...only.length === 0 ? {} : { only },
|
|
1703
|
+
...options.length === 0 ? {} : { options },
|
|
1704
|
+
...bands.length === 0 ? {} : { bands }
|
|
1705
|
+
}];
|
|
1706
|
+
});
|
|
1707
|
+
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
1708
|
+
return declarations;
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* The calendar as the browser sends it.
|
|
1712
|
+
* @throws {InvalidEditProblems} naming every field that has the wrong shape; whether the days and ids are acceptable is checked as the file is read.
|
|
1713
|
+
*/
|
|
1714
|
+
function parseCalendarEdit(value) {
|
|
1715
|
+
const problems = [];
|
|
1716
|
+
if (!isObject(value)) throw new InvalidEditProblems(["the calendar must be { hemisphere, holidays: [...] }"]);
|
|
1717
|
+
if (value["hemisphere"] !== "north" && value["hemisphere"] !== "south") problems.push("hemisphere must be \"north\" or \"south\"");
|
|
1718
|
+
const list = Array.isArray(value["holidays"]) ? value["holidays"] : void 0;
|
|
1719
|
+
if (list === void 0) problems.push("holidays must be a list");
|
|
1720
|
+
const holidays = (list ?? []).map((entry, index) => {
|
|
1721
|
+
const at = `holidays[${index}]`;
|
|
1722
|
+
if (!isObject(entry)) {
|
|
1723
|
+
problems.push(`${at} must be an object`);
|
|
1724
|
+
return {
|
|
1725
|
+
id: "",
|
|
1726
|
+
name: "",
|
|
1727
|
+
on: []
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
for (const key of Object.keys(entry)) if (![
|
|
1731
|
+
"id",
|
|
1732
|
+
"name",
|
|
1733
|
+
"on"
|
|
1734
|
+
].includes(key)) problems.push(`${at}.${key} is not a field of a holiday`);
|
|
1735
|
+
for (const key of ["id", "name"]) if (typeof entry[key] !== "string") problems.push(`${at}.${key} must be text`);
|
|
1736
|
+
if (!(Array.isArray(entry["on"]) && entry["on"].every((day) => typeof day === "string"))) problems.push(`${at}.on must be a list of days`);
|
|
1737
|
+
return {
|
|
1738
|
+
id: typeof entry["id"] === "string" ? entry["id"].trim() : "",
|
|
1739
|
+
name: typeof entry["name"] === "string" ? entry["name"].trim() : "",
|
|
1740
|
+
on: Array.isArray(entry["on"]) ? entry["on"].map((day) => String(day).trim()).filter((day) => day !== "") : []
|
|
1741
|
+
};
|
|
1742
|
+
});
|
|
1743
|
+
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
1744
|
+
return {
|
|
1745
|
+
hemisphere: value["hemisphere"],
|
|
1746
|
+
holidays
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1397
1749
|
// src/host/triggers/check.ts
|
|
1398
1750
|
/**
|
|
1399
1751
|
* What each trigger names that the world does not have (a character, place, item or variable in its condition, its cues or the words of a
|
|
@@ -2393,6 +2745,190 @@ async function removeWorldTrigger(world, key) {
|
|
|
2393
2745
|
await deleteTriggerDocument(world.directory, key);
|
|
2394
2746
|
return await readWorldEditor(world);
|
|
2395
2747
|
}
|
|
2748
|
+
// src/host/worlds/daily-life.ts
|
|
2749
|
+
/** The day each character lives, and the places its windows may name. */
|
|
2750
|
+
async function readRoutines(world) {
|
|
2751
|
+
const [{ characters }, { locations }] = await Promise.all([loadCharacters(world.directory), loadLocations(world.directory)]);
|
|
2752
|
+
return {
|
|
2753
|
+
characters: characters.map((character) => ({
|
|
2754
|
+
key: character.id,
|
|
2755
|
+
name: character.name,
|
|
2756
|
+
routine: character.routine ?? []
|
|
2757
|
+
})),
|
|
2758
|
+
places: locations.map((place) => ({
|
|
2759
|
+
key: place.id,
|
|
2760
|
+
name: place.name,
|
|
2761
|
+
features: place.features.map((feature) => ({
|
|
2762
|
+
key: feature.key,
|
|
2763
|
+
name: feature.name
|
|
2764
|
+
}))
|
|
2765
|
+
}))
|
|
2766
|
+
};
|
|
2767
|
+
}
|
|
2768
|
+
/**
|
|
2769
|
+
* Replaces the day of one character in its file, keeping everything else in it. The times, days and places are checked as the world is read at a start.
|
|
2770
|
+
* @throws {InvalidEditProblems} when the character does not exist or a window is not acceptable; nothing is written.
|
|
2771
|
+
*/
|
|
2772
|
+
async function editRoutine(world, key, windows) {
|
|
2773
|
+
const folder = await entityFolder(world.directory, CHARACTERS_DIR, CHARACTER_FILE_NAME, key, parseCharacterFile);
|
|
2774
|
+
if (folder === void 0) throw new InvalidEditProblems([`there is no character "${key}"`]);
|
|
2775
|
+
const file = join(world.directory, CHARACTERS_DIR, folder, CHARACTER_FILE_NAME);
|
|
2776
|
+
const text = (await readFile(file, "utf8")).replace(/^/, "");
|
|
2777
|
+
const document = JSON.parse(text);
|
|
2778
|
+
if (windows.length === 0) delete document["routine"];
|
|
2779
|
+
else document["routine"] = windows;
|
|
2780
|
+
const next = JSON.stringify(document, null, /^([ \t]+)"/m.exec(text)?.[1] ?? " ") + (text.endsWith("\n") ? "\n" : "");
|
|
2781
|
+
const parsed = parseCharacterFile(next, folder);
|
|
2782
|
+
if (!parsed.ok) throw new InvalidEditProblems(parsed.issues.map(formatIssue));
|
|
2783
|
+
const { locations } = await loadLocations(world.directory);
|
|
2784
|
+
const { calendar } = await loadCalendar(world.directory);
|
|
2785
|
+
const places = routineProblems([parsed.value], locations, calendar);
|
|
2786
|
+
if (places.length > 0) throw new InvalidEditProblems(places);
|
|
2787
|
+
await replaceFile(file, next);
|
|
2788
|
+
return await readRoutines(world);
|
|
2789
|
+
}
|
|
2790
|
+
/** The variables the world declares, as the file writes them. */
|
|
2791
|
+
async function readVariables(world) {
|
|
2792
|
+
try {
|
|
2793
|
+
const parsed = JSON.parse((await readFile(join(world.directory, VARIABLES_FILE_NAME), "utf8")).replace(/^/, ""));
|
|
2794
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
2795
|
+
} catch (error) {
|
|
2796
|
+
if (error.code === "ENOENT") return [];
|
|
2797
|
+
throw error;
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
/**
|
|
2801
|
+
* Replaces the world's declarations. They are read as the world is at a start and checked against everything that has a value for one: a variable a
|
|
2802
|
+
* character, item, place or the world still gives a value to cannot be removed, and a value must still fit its declaration.
|
|
2803
|
+
* @throws {InvalidEditProblems} naming each problem; nothing is written.
|
|
2804
|
+
*/
|
|
2805
|
+
async function editVariables(world, declarations, options = {}) {
|
|
2806
|
+
const text = `${JSON.stringify(declarations, null, 2)}\n`;
|
|
2807
|
+
const parsed = parseVariablesFile(text);
|
|
2808
|
+
if (!parsed.ok) throw new InvalidEditProblems(parsed.issues.map(formatIssue));
|
|
2809
|
+
const [{ characters }, { locations }] = await Promise.all([loadCharacters(world.directory), loadLocations(world.directory)]);
|
|
2810
|
+
const { items } = await loadItems(world.directory, {
|
|
2811
|
+
characters: characters.map((character) => character.id),
|
|
2812
|
+
locations
|
|
2813
|
+
});
|
|
2814
|
+
const worldFile = parseWorldFile(await readFile(join(world.directory, WORLD_FILE_NAME), "utf8"));
|
|
2815
|
+
const problems = variableProblems({
|
|
2816
|
+
defs: parsed.value,
|
|
2817
|
+
characters,
|
|
2818
|
+
items,
|
|
2819
|
+
locations,
|
|
2820
|
+
values: worldFile.ok ? worldFile.value.variables : void 0
|
|
2821
|
+
});
|
|
2822
|
+
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
2823
|
+
if (options.dryRun === true) return [...declarations];
|
|
2824
|
+
if (declarations.length === 0) await rm(join(world.directory, VARIABLES_FILE_NAME), { force: true });
|
|
2825
|
+
else await replaceFileOrCreate(join(world.directory, VARIABLES_FILE_NAME), text);
|
|
2826
|
+
return await readVariables(world);
|
|
2827
|
+
}
|
|
2828
|
+
async function replaceFileOrCreate(file, text) {
|
|
2829
|
+
try {
|
|
2830
|
+
await replaceFile(file, text);
|
|
2831
|
+
} catch (error) {
|
|
2832
|
+
if (error.code !== "ENOENT") throw error;
|
|
2833
|
+
await writeFile(file, text, { flag: "wx" });
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
/** The calendar of the world as `calendar.json` writes it; a world without one has the northern seasons and no holidays. */
|
|
2837
|
+
async function readCalendarDocument(world) {
|
|
2838
|
+
const { calendar } = await loadCalendar(world.directory);
|
|
2839
|
+
return {
|
|
2840
|
+
hemisphere: calendar.hemisphere,
|
|
2841
|
+
holidays: calendar.holidays.map((holiday) => ({
|
|
2842
|
+
id: holiday.id,
|
|
2843
|
+
name: holiday.name,
|
|
2844
|
+
on: [...holiday.on]
|
|
2845
|
+
}))
|
|
2846
|
+
};
|
|
2847
|
+
}
|
|
2848
|
+
/**
|
|
2849
|
+
* Replaces the calendar. The days are read as the file is at a start, and a holiday that a routine of a character or a trigger still names cannot be removed or renamed.
|
|
2850
|
+
* A calendar with no holidays and the northern seasons is no file at all.
|
|
2851
|
+
* @throws {InvalidEditProblems} naming each problem; nothing is written.
|
|
2852
|
+
*/
|
|
2853
|
+
async function editCalendar(world, calendar, options = {}) {
|
|
2854
|
+
const text = `${JSON.stringify(calendar, null, 2)}\n`;
|
|
2855
|
+
const parsed = parseCalendarFile(text);
|
|
2856
|
+
if (!parsed.ok) throw new InvalidEditProblems(parsed.issues.map(formatIssue));
|
|
2857
|
+
const [{ characters }, { locations }] = await Promise.all([loadCharacters(world.directory), loadLocations(world.directory)]);
|
|
2858
|
+
const problems = routineProblems(characters, locations, parsed.value);
|
|
2859
|
+
const triggers = await readFile(join(world.directory, TRIGGERS_FILE_NAME), "utf8").catch((error) => {
|
|
2860
|
+
if (error.code === "ENOENT") return "";
|
|
2861
|
+
throw error;
|
|
2862
|
+
});
|
|
2863
|
+
const named = new Set(calendar.holidays.map((holiday) => holiday.id));
|
|
2864
|
+
for (const id of new Set([...triggers.matchAll(/holiday:([\p{L}\p{N}_-]+)/gu)].map((match) => match[1]))) if (!named.has(id)) problems.push(`a trigger names the holiday "${id}", which the calendar does not have`);
|
|
2865
|
+
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
2866
|
+
if (options.dryRun === true) return calendar;
|
|
2867
|
+
if (calendar.holidays.length === 0 && calendar.hemisphere === "north") await rm(join(world.directory, CALENDAR_FILE_NAME), { force: true });
|
|
2868
|
+
else await replaceFileOrCreate(join(world.directory, CALENDAR_FILE_NAME), text);
|
|
2869
|
+
return await readCalendarDocument(world);
|
|
2870
|
+
}
|
|
2871
|
+
/** The checks of a world as its `dice.json` has them; none without the file. */
|
|
2872
|
+
async function readDiceDocument(world) {
|
|
2873
|
+
const { checks } = await loadDice(world.directory);
|
|
2874
|
+
return { checks };
|
|
2875
|
+
}
|
|
2876
|
+
/**
|
|
2877
|
+
* Replaces the world's checks. They are read as a story start reads them, and a quality of the character that a check adds must be a number the world
|
|
2878
|
+
* declares for characters. No checks is no file at all.
|
|
2879
|
+
* @throws {InvalidEditProblems} naming each problem; nothing is written.
|
|
2880
|
+
*/
|
|
2881
|
+
async function editDice(world, dice, options = {}) {
|
|
2882
|
+
const written = dice.checks.map(({ reading, compare, ...check }) => ({
|
|
2883
|
+
...check,
|
|
2884
|
+
...reading === void 0 || reading === "total" ? {} : { reading },
|
|
2885
|
+
...compare === void 0 || compare === "absolute" ? {} : { compare }
|
|
2886
|
+
}));
|
|
2887
|
+
const text = `${JSON.stringify({ checks: written }, null, 2)}\n`;
|
|
2888
|
+
const parsed = parseDiceFile(text);
|
|
2889
|
+
if (!parsed.ok) throw new InvalidEditProblems(parsed.issues.map(formatIssue));
|
|
2890
|
+
const declared = await loadVariables(world.directory);
|
|
2891
|
+
const problems = parsed.value.flatMap((check) => {
|
|
2892
|
+
if (check.modifier === void 0) return [];
|
|
2893
|
+
const variable = declared.defs.find((def) => def.key === check.modifier);
|
|
2894
|
+
return variable === void 0 || variable.kind !== "number" || variable.subject !== "character" ? [`the check "${check.key}" adds "${check.modifier}", which the world does not declare as a number about characters (Tracked values)`] : [];
|
|
2895
|
+
});
|
|
2896
|
+
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
2897
|
+
if (options.dryRun === true) return dice;
|
|
2898
|
+
if (dice.checks.length === 0) await rm(join(world.directory, DICE_FILE_NAME), { force: true });
|
|
2899
|
+
else await replaceFileOrCreate(join(world.directory, DICE_FILE_NAME), text);
|
|
2900
|
+
return await readDiceDocument(world);
|
|
2901
|
+
}
|
|
2902
|
+
/** The world's own slash commands as `commands.json` has them; none without the file. */
|
|
2903
|
+
async function readCommandsDocument(world) {
|
|
2904
|
+
const { commands } = await loadCommands(world.directory);
|
|
2905
|
+
return { commands: commands.map((command) => ({
|
|
2906
|
+
word: command.word,
|
|
2907
|
+
description: command.description,
|
|
2908
|
+
key: command.key
|
|
2909
|
+
})) };
|
|
2910
|
+
}
|
|
2911
|
+
/**
|
|
2912
|
+
* Replaces the world's commands. They are read as a story start reads them, and the flag a command raises must not be a value the world declares itself.
|
|
2913
|
+
* No commands is no file at all.
|
|
2914
|
+
* @throws {InvalidEditProblems} naming each problem; nothing is written.
|
|
2915
|
+
*/
|
|
2916
|
+
async function editCommands(world, document, options = {}) {
|
|
2917
|
+
const written = document.commands.map(({ key, ...command }) => ({
|
|
2918
|
+
...command,
|
|
2919
|
+
...key === void 0 || key === command.word ? {} : { key }
|
|
2920
|
+
}));
|
|
2921
|
+
const text = `${JSON.stringify({ commands: written }, null, 2)}\n`;
|
|
2922
|
+
const parsed = parseCommandsFile(text);
|
|
2923
|
+
if (!parsed.ok) throw new InvalidEditProblems(parsed.issues.map(formatIssue));
|
|
2924
|
+
const declared = new Set((await loadVariables(world.directory)).defs.map((def) => def.key));
|
|
2925
|
+
const problems = parsed.value.flatMap((command) => declared.has(commandVariable(command)) ? [`the command "/${command.word}" raises the flag "${commandVariable(command)}", which the world already declares as a tracked value`] : []);
|
|
2926
|
+
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
2927
|
+
if (options.dryRun === true) return document;
|
|
2928
|
+
if (document.commands.length === 0) await rm(join(world.directory, COMMANDS_FILE_NAME), { force: true });
|
|
2929
|
+
else await replaceFileOrCreate(join(world.directory, COMMANDS_FILE_NAME), text);
|
|
2930
|
+
return await readCommandsDocument(world);
|
|
2931
|
+
}
|
|
2396
2932
|
// src/host/authoring/documents.ts
|
|
2397
2933
|
const AUTHORED_ENTITY_KINDS = [
|
|
2398
2934
|
"character",
|
|
@@ -2600,8 +3136,8 @@ function packFileProblem(tool, path, world, texts = []) {
|
|
|
2600
3136
|
const ui = join(world, "ui");
|
|
2601
3137
|
const inside = relative(ui, path);
|
|
2602
3138
|
const segments = inside.split(sep);
|
|
2603
|
-
const hint = `in this chat the file tools reach only the text files of the world's interface packs,
|
|
2604
|
-
if (inside === "" || inside.startsWith("..") || isAbsolute(inside) || segments.length < 2) return `${path} is not a file of an interface pack: ${hint}`;
|
|
3139
|
+
const hint = `in this chat the file tools reach only the text files of the world's interface packs, ui/<pack>/<file>. Nothing, not another path and not sandbox_permissions, lifts that: do not try again for this file, tell the person that it cannot be changed from here`;
|
|
3140
|
+
if (inside === "" || inside.startsWith("..") || isAbsolute(inside) || segments.length < 2) return `${path} is not a file of an interface pack: ${hint}. The world's own files are changed with the world tools instead: write_world_file for variables, dice, commands and the calendar, edit_world_info for world.json (opening, rules, start questions), create_world_element and replace_world_element for characters, places, items, factions and lore`;
|
|
2605
3141
|
if (!isPackId(segments[0])) return `"${segments[0]}" is not a usable pack name (letters, digits, "-" and "_"): ${hint}`;
|
|
2606
3142
|
if (segments.some((segment) => segment.startsWith("."))) return `${path}: names may not start with a dot`;
|
|
2607
3143
|
if (!TEXT_EXTENSIONS.includes(extname(path).slice(1).toLowerCase())) return `${path} is not a text file of a pack (${TEXT_EXTENSIONS.join(", ")}); pictures and other files are added by hand`;
|
|
@@ -2647,7 +3183,7 @@ async function packJail(exec, next, deps) {
|
|
|
2647
3183
|
};
|
|
2648
3184
|
const decision = await next();
|
|
2649
3185
|
if (!writing || decision.kind !== "allow") return decision;
|
|
2650
|
-
const target = `“${relative(join(world, "ui"), path)}”`;
|
|
3186
|
+
const target = `“${relative(join(world, "ui"), path).split(sep).join("/")}”`;
|
|
2651
3187
|
return {
|
|
2652
3188
|
kind: "ask",
|
|
2653
3189
|
reason: `${exec.name} interface pack file ${target}`,
|
|
@@ -2661,6 +3197,6 @@ async function packJail(exec, next, deps) {
|
|
|
2661
3197
|
function registerPackJail(ctx, deps) {
|
|
2662
3198
|
ctx.on("tools/pre-execute", (exec, next) => packJail(exec, next, deps), { prepend: true });
|
|
2663
3199
|
}
|
|
2664
|
-
export {
|
|
3200
|
+
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 };
|
|
2665
3201
|
|
|
2666
|
-
//# sourceMappingURL=pack-jail-
|
|
3202
|
+
//# sourceMappingURL=pack-jail-CzHQu0n3.js.map
|