@dsh-agentic-roleplay/core 0.3.1 → 0.3.2
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/authoring.js +2 -2
- package/lib/client.js +1299 -375
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +1 -1
- package/lib/{deliver-BDW5WZvc.js → deliver-BSsDtF6X.js} +1198 -17
- package/lib/{documents-DtlY2IRt.js → documents-B5XAdfo2.js} +141 -8
- package/lib/{gallery-DACG5eh2.js → gallery-DS5-qH9F.js} +2 -2
- package/lib/{generator-DGYcLMp7.js → generator-BzeepLd2.js} +2 -2
- package/lib/images.js +3 -3
- package/lib/index.js +178 -10
- package/lib/narration-DK2kiIjE.js +141 -0
- package/lib/orchestration.js +684 -1456
- package/lib/{packs-CkRZDCsV.js → packs-BCGK9KZV.js} +3 -3
- package/lib/{presenter-agent-PK9JYExk.js → presenter-agent-Cp-J0onD.js} +3 -3
- package/lib/{narration-5ig7Dg28.js → settings-CA6icLL_.js} +156 -141
- package/package.json +2 -2
- package/prompts/en/roleplay/dice.md +7 -0
- package/prompts/en/roleplay/game-master.md +2 -0
- package/prompts/en/roleplay/reflection.md +3 -1
- package/prompts/zh/roleplay/dice.md +7 -0
- package/prompts/zh/roleplay/game-master.md +2 -0
- package/prompts/zh/roleplay/reflection.md +3 -1
- package/lib/src-CWTNeL6Y.js +0 -128
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { A as formatIssue, C as PLOTS_FILE_NAME, D as readDocument, E as plotReferenceProblems, F as languageOf, I as listFiles, J as INTENT_HORIZONS, L as promptProblem, O as errorMessage, R as shippedLanguages, T as parsePlotsFile, U as InvalidWorldError, X as INTENT_TYPES, Y as INTENT_STATUSES, _ as API_PREFIX, b as isStoryLanguage, j as PROMPTS_FOLDER, k as Reader, v as LANGUAGE_NAMES, w as loadPlots, x as textLanguage, y as STORY_LANGUAGES, z as shippedPromptsDirectory } from "./packs-
|
|
2
|
-
import {
|
|
3
|
-
import { A as runChild, C as norm, S as mapLimit, T as uniqueKey, a as uploadReferenceImage, h as MEDIA_TYPES, o as addToLibrary, p as referenceImagePath, s as imageExtensionOf, t as generateReferenceImage, w as slug, y as writeImageFileMetadata } from "./generator-
|
|
1
|
+
import { A as formatIssue, C as PLOTS_FILE_NAME, D as readDocument, E as plotReferenceProblems, F as languageOf, I as listFiles, J as INTENT_HORIZONS, L as promptProblem, O as errorMessage, R as shippedLanguages, T as parsePlotsFile, U as InvalidWorldError, X as INTENT_TYPES, Y as INTENT_STATUSES, _ as API_PREFIX, b as isStoryLanguage, j as PROMPTS_FOLDER, k as Reader, v as LANGUAGE_NAMES, w as loadPlots, x as textLanguage, y as STORY_LANGUAGES, z as shippedPromptsDirectory } from "./packs-BCGK9KZV.js";
|
|
2
|
+
import { c as VARIABLE_SUBJECTS, i as parseSwitchboard, l as VARIABLE_VISIBILITIES, s as VARIABLE_KINDS } from "./settings-CA6icLL_.js";
|
|
3
|
+
import { A as runChild, C as norm, S as mapLimit, T as uniqueKey, a as uploadReferenceImage, h as MEDIA_TYPES, o as addToLibrary, p as referenceImagePath, s as imageExtensionOf, t as generateReferenceImage, w as slug, y as writeImageFileMetadata } from "./generator-BzeepLd2.js";
|
|
4
4
|
import { basename, dirname, join, relative, sep } from "node:path";
|
|
5
5
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
6
6
|
import { createHash, randomUUID } from "node:crypto";
|
|
7
7
|
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
8
8
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
9
9
|
import { chmod, cp, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
10
|
-
import { MAX_ROUTINE_WINDOWS, MINUTE, MONTH_NAMES, SEASONS, createSessionStore, dayTokenProblems, isTimeZone, parseInstant, parseTimeOfDay, readTriggerDefinition, triggerReferenceProblems, valueIssue, writeCalendar } from "@dsh-agentic-roleplay/state";
|
|
10
|
+
import { MAX_ROUTINE_WINDOWS, MINUTE, MONTH_NAMES, SEASONS, checkProblems, createSessionStore, dayTokenProblems, isTimeZone, parseInstant, parseTimeOfDay, readTriggerDefinition, triggerReferenceProblems, valueIssue, writeCalendar } from "@dsh-agentic-roleplay/state";
|
|
11
11
|
import { lookup } from "node:dns";
|
|
12
12
|
import { request } from "node:http";
|
|
13
13
|
import { request as request$1 } from "node:https";
|
|
@@ -113,6 +113,25 @@ const WEEKDAY_NAMES = [
|
|
|
113
113
|
"sat"
|
|
114
114
|
];
|
|
115
115
|
//#endregion
|
|
116
|
+
//#region ../dsh-roleplay-model/src/dice.ts
|
|
117
|
+
/** What a band of a check makes of an attempt; the same three results a round's outcome has. */
|
|
118
|
+
const DICE_RESULTS = [
|
|
119
|
+
"succeeded",
|
|
120
|
+
"partial",
|
|
121
|
+
"failed"
|
|
122
|
+
];
|
|
123
|
+
/** How a roll is read: by its total, or by how many of the dice came up high enough. */
|
|
124
|
+
const DICE_READINGS = ["total", "successes"];
|
|
125
|
+
/**
|
|
126
|
+
* What the value is compared with: `absolute` reads the value itself, `over` the amount by which it beats the target
|
|
127
|
+
* (a difficulty to meet or exceed), `under` the amount by which it stays below the target (a skill to roll under).
|
|
128
|
+
*/
|
|
129
|
+
const DICE_COMPARISONS = [
|
|
130
|
+
"absolute",
|
|
131
|
+
"over",
|
|
132
|
+
"under"
|
|
133
|
+
];
|
|
134
|
+
//#endregion
|
|
116
135
|
//#region ../dsh-roleplay-model/src/lore.ts
|
|
117
136
|
const LORE_KINDS = [
|
|
118
137
|
"history",
|
|
@@ -719,7 +738,7 @@ function parseWorldInfoEdit(value) {
|
|
|
719
738
|
const input = typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
720
739
|
if (input === void 0) throw new InvalidEditProblems(["the changes must be an object"]);
|
|
721
740
|
const edit = {};
|
|
722
|
-
for (const key of Object.keys(input)) if (!TEXT_FIELDS.includes(key) && !LIST_FIELDS.includes(key) && key !== "alternateOpenings") problems.push(`there is no field "${key}"`);
|
|
741
|
+
for (const key of Object.keys(input)) if (!TEXT_FIELDS.includes(key) && !LIST_FIELDS.includes(key) && key !== "alternateOpenings" && key !== "tools") problems.push(`there is no field "${key}"`);
|
|
723
742
|
for (const key of TEXT_FIELDS) {
|
|
724
743
|
if (input[key] === void 0) continue;
|
|
725
744
|
if (typeof input[key] === "string") edit[key] = input[key].trim();
|
|
@@ -744,6 +763,11 @@ function parseWorldInfoEdit(value) {
|
|
|
744
763
|
edit["alternateOpenings"] = kept;
|
|
745
764
|
}
|
|
746
765
|
}
|
|
766
|
+
if (input["tools"] !== void 0) {
|
|
767
|
+
const board = parseSwitchboard(input["tools"], "tools");
|
|
768
|
+
if (typeof board === "string") problems.push(board);
|
|
769
|
+
else edit["tools"] = board;
|
|
770
|
+
}
|
|
747
771
|
if (typeof edit["version"] === "string" && edit["version"].length > 40) problems.push(`the version is longer than 40 characters`);
|
|
748
772
|
if (edit["name"] === "") problems.push("the world needs a name");
|
|
749
773
|
if (typeof edit["name"] === "string" && edit["name"].length > 200) problems.push(`the name is longer than 200 characters`);
|
|
@@ -774,6 +798,17 @@ function readAlternateOpenings(reader) {
|
|
|
774
798
|
}
|
|
775
799
|
return openings.length === 0 ? void 0 : openings;
|
|
776
800
|
}
|
|
801
|
+
/** `tools`: switches by kind of agent and tool name; a world carried from a version with other tools still loads. */
|
|
802
|
+
function readTools(reader) {
|
|
803
|
+
const value = reader.raw("tools");
|
|
804
|
+
if (value === void 0) return void 0;
|
|
805
|
+
const board = parseSwitchboard(value, "tools");
|
|
806
|
+
if (typeof board === "string") {
|
|
807
|
+
reader.fail("tools", board.replace(/^"tools"\s*/, ""));
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
return Object.keys(board).length === 0 ? void 0 : board;
|
|
811
|
+
}
|
|
777
812
|
/** `rules` is one rule as text, or a list of them; blank ones are left out. */
|
|
778
813
|
function readRules(reader) {
|
|
779
814
|
const value = reader.raw("rules");
|
|
@@ -867,6 +902,7 @@ function parseWorldFile(text) {
|
|
|
867
902
|
const clock = readClock(reader);
|
|
868
903
|
const variables = readVariableValues(reader);
|
|
869
904
|
const rules = readRules(reader);
|
|
905
|
+
const tools = readTools(reader);
|
|
870
906
|
const alternateOpenings = readAlternateOpenings(reader);
|
|
871
907
|
const narrationVoice = reader.string("narration_voice")?.trim() || void 0;
|
|
872
908
|
if (name === void 0 || issues.length > 0) return {
|
|
@@ -887,6 +923,7 @@ function parseWorldFile(text) {
|
|
|
887
923
|
...clock === void 0 ? {} : { clock },
|
|
888
924
|
...variables === void 0 ? {} : { variables },
|
|
889
925
|
...rules === void 0 ? {} : { rules },
|
|
926
|
+
...tools === void 0 ? {} : { tools },
|
|
890
927
|
...alternateOpenings === void 0 ? {} : { alternateOpenings },
|
|
891
928
|
...narrationVoice === void 0 ? {} : { narrationVoice }
|
|
892
929
|
}
|
|
@@ -3736,6 +3773,95 @@ async function loadCalendar(worldDir) {
|
|
|
3736
3773
|
return result;
|
|
3737
3774
|
}
|
|
3738
3775
|
//#endregion
|
|
3776
|
+
//#region src/host/dice/load.ts
|
|
3777
|
+
const DICE_FILE_NAME = "dice.json";
|
|
3778
|
+
function readBand(band) {
|
|
3779
|
+
const label = band.string("label", { required: true });
|
|
3780
|
+
const result = band.oneOf("result", DICE_RESULTS, "failed");
|
|
3781
|
+
const min = band.number("min");
|
|
3782
|
+
const max = band.number("max");
|
|
3783
|
+
const critical = band.raw("critical");
|
|
3784
|
+
if (critical !== void 0 && critical !== null && typeof critical !== "boolean") band.fail("critical", "must be true or false");
|
|
3785
|
+
if (band.raw("result") === void 0) band.fail("result", `is required: one of ${DICE_RESULTS.join(", ")}`);
|
|
3786
|
+
return label === void 0 ? void 0 : {
|
|
3787
|
+
label,
|
|
3788
|
+
result,
|
|
3789
|
+
...min === void 0 ? {} : { min },
|
|
3790
|
+
...max === void 0 ? {} : { max },
|
|
3791
|
+
...critical === true ? { critical: true } : {}
|
|
3792
|
+
};
|
|
3793
|
+
}
|
|
3794
|
+
/**
|
|
3795
|
+
* Read `dice.json`: the checks a world settles uncertain attempts with (docs/world-format.md). The dice and how their result is read are the world's:
|
|
3796
|
+
* the game master rolls a check and is told the band the roll fell in, never a number to interpret.
|
|
3797
|
+
*/
|
|
3798
|
+
function parseDiceFile(text) {
|
|
3799
|
+
const issues = [];
|
|
3800
|
+
const reader = Reader.fromJson(text, issues);
|
|
3801
|
+
if (reader === void 0) return {
|
|
3802
|
+
ok: false,
|
|
3803
|
+
issues
|
|
3804
|
+
};
|
|
3805
|
+
const checks = reader.objects("checks").flatMap((entry) => {
|
|
3806
|
+
const key = entry.string("key", { required: true });
|
|
3807
|
+
const name = entry.string("name", { required: true });
|
|
3808
|
+
const use = entry.string("use", { required: true });
|
|
3809
|
+
const dice = entry.string("dice", { required: true });
|
|
3810
|
+
const reading = entry.oneOf("reading", DICE_READINGS, "total");
|
|
3811
|
+
const compare = entry.oneOf("compare", DICE_COMPARISONS, "absolute");
|
|
3812
|
+
const hit = entry.number("hit", { min: 1 });
|
|
3813
|
+
const modifier = entry.string("modifier");
|
|
3814
|
+
const bands = entry.objects("bands").flatMap((band) => {
|
|
3815
|
+
const read = readBand(band);
|
|
3816
|
+
return read === void 0 ? [] : [read];
|
|
3817
|
+
});
|
|
3818
|
+
if (key === void 0 || name === void 0 || use === void 0 || dice === void 0) return [];
|
|
3819
|
+
const definition = {
|
|
3820
|
+
key,
|
|
3821
|
+
name,
|
|
3822
|
+
use,
|
|
3823
|
+
dice,
|
|
3824
|
+
reading,
|
|
3825
|
+
compare,
|
|
3826
|
+
bands,
|
|
3827
|
+
...hit === void 0 ? {} : { hit },
|
|
3828
|
+
...modifier === void 0 || modifier === "" ? {} : { modifier }
|
|
3829
|
+
};
|
|
3830
|
+
for (const problem of checkProblems(definition)) entry.fail("", problem);
|
|
3831
|
+
return [definition];
|
|
3832
|
+
});
|
|
3833
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3834
|
+
for (const check of checks) {
|
|
3835
|
+
if (seen.has(check.key)) reader.fail("checks", `the key "${check.key}" is used by more than one check`);
|
|
3836
|
+
seen.add(check.key);
|
|
3837
|
+
}
|
|
3838
|
+
if (checks.length > 40) reader.fail("checks", `a world has at most 40 checks`);
|
|
3839
|
+
return issues.length > 0 ? {
|
|
3840
|
+
ok: false,
|
|
3841
|
+
issues
|
|
3842
|
+
} : {
|
|
3843
|
+
ok: true,
|
|
3844
|
+
value: checks
|
|
3845
|
+
};
|
|
3846
|
+
}
|
|
3847
|
+
/** The checks of a world: an optional `<world>/dice.json`; a world without one has none, and its game master rolls plain dice only. */
|
|
3848
|
+
async function loadDice(worldDir) {
|
|
3849
|
+
const result = {
|
|
3850
|
+
checks: [],
|
|
3851
|
+
problems: []
|
|
3852
|
+
};
|
|
3853
|
+
const file = join(worldDir, DICE_FILE_NAME);
|
|
3854
|
+
try {
|
|
3855
|
+
result.checks = await readDocument(file, parseDiceFile, result.problems) ?? [];
|
|
3856
|
+
} catch (error) {
|
|
3857
|
+
if (error.code !== "ENOENT") result.problems.push({
|
|
3858
|
+
path: file,
|
|
3859
|
+
message: errorMessage(error)
|
|
3860
|
+
});
|
|
3861
|
+
}
|
|
3862
|
+
return result;
|
|
3863
|
+
}
|
|
3864
|
+
//#endregion
|
|
3739
3865
|
//#region src/host/triggers/load.ts
|
|
3740
3866
|
const TRIGGERS_FILE_NAME = "triggers.json";
|
|
3741
3867
|
/** Read `triggers.json`: a list of what the world does by itself when something comes true (docs/world-format.md). */
|
|
@@ -3911,6 +4037,10 @@ function routineProblems(characters, locations, calendar = {
|
|
|
3911
4037
|
return [];
|
|
3912
4038
|
}));
|
|
3913
4039
|
}
|
|
4040
|
+
/** Keeps the checks of the world with the story: what its game master rolls and how the dice are read. */
|
|
4041
|
+
function populateDice(session, checks) {
|
|
4042
|
+
for (const check of checks) session.dice.define(check);
|
|
4043
|
+
}
|
|
3914
4044
|
/** Keeps the world's calendar with the story, for the days a routine or a trigger waits for. */
|
|
3915
4045
|
function populateCalendar(session, calendar) {
|
|
3916
4046
|
if (calendar.holidays.length > 0 || calendar.hemisphere !== "north") writeCalendar(session.metadata, calendar);
|
|
@@ -4183,6 +4313,8 @@ async function loadValidatedWorld(world) {
|
|
|
4183
4313
|
})));
|
|
4184
4314
|
const { calendar, problems: calendarProblems } = await loadCalendar(world.directory);
|
|
4185
4315
|
if (calendarProblems.length > 0) throw new InvalidWorldError(`the calendar of "${world.summary.name}" has ${calendarProblems.length} problem(s)`, calendarProblems);
|
|
4316
|
+
const dice = await loadDice(world.directory);
|
|
4317
|
+
if (dice.problems.length > 0) throw new InvalidWorldError(`the dice checks of "${world.summary.name}" have ${dice.problems.length} problem(s)`, dice.problems);
|
|
4186
4318
|
const days = routineProblems(characters, locations, calendar);
|
|
4187
4319
|
if (days.length > 0) throw new InvalidWorldError(`the days of the characters of "${world.summary.name}" have ${days.length} problem(s)`, days.map((message) => ({
|
|
4188
4320
|
path: world.directory,
|
|
@@ -4253,7 +4385,8 @@ async function loadValidatedWorld(world) {
|
|
|
4253
4385
|
declared,
|
|
4254
4386
|
scripted,
|
|
4255
4387
|
authoredPlots,
|
|
4256
|
-
calendar
|
|
4388
|
+
calendar,
|
|
4389
|
+
checks: dice.checks
|
|
4257
4390
|
};
|
|
4258
4391
|
}
|
|
4259
4392
|
//#endregion
|
|
@@ -6871,6 +7004,6 @@ async function deleteAuthoredEntity(world, kind, key) {
|
|
|
6871
7004
|
return destination;
|
|
6872
7005
|
}
|
|
6873
7006
|
//#endregion
|
|
6874
|
-
export {
|
|
7007
|
+
export { loadLocations as $, isReviewing as A, DICE_COMPARISONS as At, populateLocations as B, translateTools as C, parseCharacterEdit as Ct, authoringChatSessionId as D, parseRelationEdit as Dt, authoredWorldOf as E, parsePlaceEdit as Et, populateClock as F, routineProblems as G, populateRoutines as H, populateDice as I, loadDice as J, TRIGGERS_FILE_NAME as K, populateFactions as L, loadValidatedWorld as M, DICE_RESULTS as Mt, populateCalendar as N, languageOfDocuments as O, parseThingEdit as Ot, populateCharacters as P, parseCalendarFile as Q, populateItems as R, translateMessage as S, InvalidEditProblems as St, importTools as T, parseLoreEdit as Tt, populateTriggers as U, populateLore as V, populateVariables as W, CALENDAR_FILE_NAME as X, parseDiceFile as Y, loadCalendar as Z, replaceFile$1 as _, ImportStore as _t, replaceAuthoredEntity as a, deleteWorldPrompt as at, triggerProblemsOf as b, parseWorldFile as bt, editWorldLore as c, writeWorldPrompt as ct, editWorldPlots as d, parseVariablesFile as dt, loadItems as et, editWorldRelation as f, variableProblems as ft, readWorldEditor as g, ImportNotFoundError as gt, generateWorldCharacterPortrait as h, IMPORT_FOLDER as ht, readAuthoredEntityDocument as i, PROSE_PROMPTS as it, markReady as j, DICE_READINGS as jt, readWorldDocuments as k, IMPORT_COMMAND as kt, editWorldNarrationVoice as l, VARIABLES_FILE_NAME as lt, entityFolder as m, parseCharacterFile as mt, createAuthoredEntity as n, loadCharacters as nt, editWorldCharacter as o, listWorldPrompts as ot, editWorldThing as p, CHARACTER_FILE_NAME as pt, DICE_FILE_NAME as q, deleteAuthoredEntity as r, subfolders as rt, editWorldFaction as s, readWorldPrompt as st, AUTHORED_ENTITY_KINDS as t, CHARACTERS_DIR as tt, editWorldPlace as u, loadVariables as ut, uploadWorldCharacterPortrait as v, parseChoices as vt, importHooks as w, parseFactionEdit as wt, loadWorldParts as x, parseWorldInfoEdit as xt, worldCharacterPortraitFile as y, WORLD_FILE_NAME as yt, populateKnowledge as z };
|
|
6875
7008
|
|
|
6876
|
-
//# sourceMappingURL=documents-
|
|
7009
|
+
//# sourceMappingURL=documents-B5XAdfo2.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as mapLimit, _ as readImageFileMetadata, c as LIBRARY_FOLDER, g as mediaTypeOf, v as sidecarOf, y as writeImageFileMetadata } from "./generator-
|
|
1
|
+
import { S as mapLimit, _ as readImageFileMetadata, c as LIBRARY_FOLDER, g as mediaTypeOf, v as sidecarOf, y as writeImageFileMetadata } from "./generator-BzeepLd2.js";
|
|
2
2
|
import { join, sep } from "node:path";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { lstat, mkdir, readFile, readdir, realpath, rename, stat, writeFile } from "node:fs/promises";
|
|
@@ -192,4 +192,4 @@ async function updateImage(sessionFolder, path, update) {
|
|
|
192
192
|
//#endregion
|
|
193
193
|
export { updateImage as i, galleryFile as n, listGallery as r, describeGalleryImage as t };
|
|
194
194
|
|
|
195
|
-
//# sourceMappingURL=gallery-
|
|
195
|
+
//# sourceMappingURL=gallery-DS5-qH9F.js.map
|
|
@@ -311,7 +311,7 @@ async function execute(task, stats) {
|
|
|
311
311
|
appendDelegatedPolicyOverrides(child.session, inherited);
|
|
312
312
|
applyChildComposition(childCtx, parent, {
|
|
313
313
|
persona: `${task.persona}\n\n${SUBMIT_RULE}`,
|
|
314
|
-
toolFilter: { allow: [] }
|
|
314
|
+
toolFilter: { allow: [...task.external ?? []] }
|
|
315
315
|
});
|
|
316
316
|
const registered = (task.tools ?? []).map((tool) => childCtx.tools.register(counted(tool)));
|
|
317
317
|
retire = () => {
|
|
@@ -848,4 +848,4 @@ async function generateTransientImage(service, request) {
|
|
|
848
848
|
//#endregion
|
|
849
849
|
export { runChild as A, norm as C, childSampling as D, childModel as E, tokensOf as M, childSamplingOf as O, mapLimit as S, uniqueKey as T, readImageFileMetadata as _, uploadReferenceImage as a, readPngMetadata as b, LIBRARY_FOLDER as c, nextSceneSerial as d, readImageMetadata as f, mediaTypeOf as g, MEDIA_TYPES as h, transientPrompt as i, estimateAnswer as j, childTrace as k, entityImageDirectory as l, sceneImagePath as m, generateTransientImage as n, addToLibrary as o, referenceImagePath as p, referencePrompt as r, imageExtensionOf as s, generateReferenceImage as t, inheritImages as u, sidecarOf as v, slug as w, withPngMetadata as x, writeImageFileMetadata as y };
|
|
850
850
|
|
|
851
|
-
//# sourceMappingURL=generator-
|
|
851
|
+
//# sourceMappingURL=generator-BzeepLd2.js.map
|
package/lib/images.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as readPngMetadata, d as nextSceneSerial, f as readImageMetadata, i as transientPrompt, l as entityImageDirectory, m as sceneImagePath, n as generateTransientImage, o as addToLibrary, p as referenceImagePath, r as referencePrompt, t as generateReferenceImage, u as inheritImages, x as withPngMetadata } from "./generator-
|
|
2
|
-
import { i as updateImage, r as listGallery } from "./gallery-
|
|
3
|
-
import { a as tokensOf, i as searchImages, n as interpretImage, o as present, r as imageTools, s as presentedFor, t as runImagePresenter } from "./presenter-agent-
|
|
1
|
+
import { b as readPngMetadata, d as nextSceneSerial, f as readImageMetadata, i as transientPrompt, l as entityImageDirectory, m as sceneImagePath, n as generateTransientImage, o as addToLibrary, p as referenceImagePath, r as referencePrompt, t as generateReferenceImage, u as inheritImages, x as withPngMetadata } from "./generator-BzeepLd2.js";
|
|
2
|
+
import { i as updateImage, r as listGallery } from "./gallery-DS5-qH9F.js";
|
|
3
|
+
import { a as tokensOf, i as searchImages, n as interpretImage, o as present, r as imageTools, s as presentedFor, t as runImagePresenter } from "./presenter-agent-Cp-J0onD.js";
|
|
4
4
|
export { addToLibrary, entityImageDirectory, generateReferenceImage, generateTransientImage, imageTools, inheritImages, interpretImage, listGallery, nextSceneSerial, present, presentedFor, readImageMetadata, readPngMetadata, referenceImagePath, referencePrompt, runImagePresenter, sceneImagePath, searchImages, tokensOf, transientPrompt, updateImage, withPngMetadata };
|
package/lib/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { n as chatSessionId, r as roleplaySessionOf } from "./access-EbNdZFbk.js";
|
|
2
|
-
import { $ as
|
|
3
|
-
import { A as formatIssue, D as readDocument$1, E as plotReferenceProblems, F as languageOf, G as SessionArchivedError, H as InvalidStartError, K as SessionNotFoundError, M as PromptLibrary, N as copyWorldPrompts, O as errorMessage, T as parsePlotsFile, U as InvalidWorldError, V as AgentUnavailableError, W as ReflectionRefusedError, _ as API_PREFIX, a as packIds, c as describePack, f as readPack, l as isPackId, m as PACK_LIMITS, n as anyTab, o as syncWorldPacks, q as WorldNotFoundError, r as copyWorldPacks, s as worldPackStates, t as activePack, u as packFile } from "./packs-
|
|
4
|
-
import { A as
|
|
5
|
-
import { a as
|
|
6
|
-
import { n as
|
|
7
|
-
import { O as childSamplingOf, T as uniqueKey, a as uploadReferenceImage, m as sceneImagePath, o as addToLibrary, p as referenceImagePath, t as generateReferenceImage, u as inheritImages, w as slug } from "./generator-
|
|
8
|
-
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-
|
|
2
|
+
import { $ as loadLocations, At as DICE_COMPARISONS, B as populateLocations, Ct as parseCharacterEdit, D as authoringChatSessionId, Dt as parseRelationEdit, Et as parsePlaceEdit, F as populateClock, G as routineProblems, H as populateRoutines, I as populateDice, J as loadDice, K as TRIGGERS_FILE_NAME, L as populateFactions, M as loadValidatedWorld, Mt as DICE_RESULTS, N as populateCalendar, O as languageOfDocuments, Ot as parseThingEdit, P as populateCharacters, Q as parseCalendarFile, R as populateItems, S as translateMessage, St as InvalidEditProblems, Tt as parseLoreEdit, U as populateTriggers, V as populateLore, W as populateVariables, X as CALENDAR_FILE_NAME, Y as parseDiceFile, Z as loadCalendar, _ as replaceFile$1, _t as ImportStore, at as deleteWorldPrompt, bt as parseWorldFile, c as editWorldLore$1, ct as writeWorldPrompt, d as editWorldPlots$1, dt as parseVariablesFile, et as loadItems, f as editWorldRelation$1, ft as variableProblems, g as readWorldEditor, gt as ImportNotFoundError, h as generateWorldCharacterPortrait, ht as IMPORT_FOLDER, i as readAuthoredEntityDocument, j as markReady, jt as DICE_READINGS, k as readWorldDocuments, kt as IMPORT_COMMAND, l as editWorldNarrationVoice, lt as VARIABLES_FILE_NAME, m as entityFolder, mt as parseCharacterFile, n as createAuthoredEntity, nt as loadCharacters, o as editWorldCharacter$1, ot as listWorldPrompts, p as editWorldThing$1, pt as CHARACTER_FILE_NAME, q as DICE_FILE_NAME, r as deleteAuthoredEntity, rt as subfolders, s as editWorldFaction$1, st as readWorldPrompt, tt as CHARACTERS_DIR, u as editWorldPlace$1, ut as loadVariables, v as uploadWorldCharacterPortrait, vt as parseChoices, wt as parseFactionEdit, x as loadWorldParts, xt as parseWorldInfoEdit, y as worldCharacterPortraitFile, yt as WORLD_FILE_NAME, z as populateKnowledge } from "./documents-B5XAdfo2.js";
|
|
3
|
+
import { A as formatIssue, D as readDocument$1, E as plotReferenceProblems, F as languageOf, G as SessionArchivedError, H as InvalidStartError, K as SessionNotFoundError, M as PromptLibrary, N as copyWorldPrompts, O as errorMessage, T as parsePlotsFile, U as InvalidWorldError, V as AgentUnavailableError, W as ReflectionRefusedError, _ as API_PREFIX, a as packIds, c as describePack, f as readPack, l as isPackId, m as PACK_LIMITS, n as anyTab, o as syncWorldPacks, q as WorldNotFoundError, r as copyWorldPacks, s as worldPackStates, t as activePack, u as packFile } from "./packs-BCGK9KZV.js";
|
|
4
|
+
import { A as notesOfSession, C as plotProgressOf, F as TimelineError, L as readTimeline, M as readNotes, N as observeAsPlayer, O as addToNote, R as pathTo, a as readActivity, d as reflectionStatus, m as externalTools, n as readWithdrawn, o as readRunDetail, q as zoneOf, w as populatePlots, y as PLOTS_METADATA_KEY, z as defaultBoundaries } from "./deliver-BSsDtF6X.js";
|
|
5
|
+
import { a as WORLD_RULES_KEY, c as VARIABLE_SUBJECTS, i as parseSwitchboard, l as VARIABLE_VISIBILITIES, n as SETTINGS_SPEC, r as parseSettings, s as VARIABLE_KINDS, t as DEFAULT_SETTINGS } from "./settings-CA6icLL_.js";
|
|
6
|
+
import { a as liveSettings, c as writeSettings, i as InvalidSettingsError, n as encodeOutput, o as readSettings, s as useChildReasoning } from "./narration-DK2kiIjE.js";
|
|
7
|
+
import { O as childSamplingOf, T as uniqueKey, a as uploadReferenceImage, m as sceneImagePath, o as addToLibrary, p as referenceImagePath, t as generateReferenceImage, u as inheritImages, w as slug } from "./generator-BzeepLd2.js";
|
|
8
|
+
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-DS5-qH9F.js";
|
|
9
9
|
import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve } from "node:path";
|
|
10
10
|
import { cpSync, createReadStream, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
11
11
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
@@ -740,6 +740,96 @@ var RoleplayOrchestration = class extends Service {
|
|
|
740
740
|
}
|
|
741
741
|
};
|
|
742
742
|
//#endregion
|
|
743
|
+
//#region src/shared/world-dice.ts
|
|
744
|
+
const isObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
745
|
+
const CHECK_FIELDS = [
|
|
746
|
+
"key",
|
|
747
|
+
"name",
|
|
748
|
+
"use",
|
|
749
|
+
"dice",
|
|
750
|
+
"reading",
|
|
751
|
+
"hit",
|
|
752
|
+
"compare",
|
|
753
|
+
"modifier",
|
|
754
|
+
"bands"
|
|
755
|
+
];
|
|
756
|
+
const BAND_FIELDS = [
|
|
757
|
+
"min",
|
|
758
|
+
"max",
|
|
759
|
+
"label",
|
|
760
|
+
"result",
|
|
761
|
+
"critical"
|
|
762
|
+
];
|
|
763
|
+
/** 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. */
|
|
764
|
+
function parseDiceEdit(value) {
|
|
765
|
+
const problems = [];
|
|
766
|
+
if (!isObject$1(value) || !Array.isArray(value["checks"])) throw new InvalidEditProblems(["the dice must be { checks: [...] }"]);
|
|
767
|
+
const checks = value["checks"].map((entry, index) => {
|
|
768
|
+
const at = `checks[${index}]`;
|
|
769
|
+
const empty = {
|
|
770
|
+
key: "",
|
|
771
|
+
name: "",
|
|
772
|
+
use: "",
|
|
773
|
+
dice: "",
|
|
774
|
+
bands: []
|
|
775
|
+
};
|
|
776
|
+
if (!isObject$1(entry)) {
|
|
777
|
+
problems.push(`${at} must be an object`);
|
|
778
|
+
return empty;
|
|
779
|
+
}
|
|
780
|
+
for (const key of Object.keys(entry)) if (!CHECK_FIELDS.includes(key)) problems.push(`${at}.${key} is not a field of a check`);
|
|
781
|
+
for (const key of [
|
|
782
|
+
"key",
|
|
783
|
+
"name",
|
|
784
|
+
"use",
|
|
785
|
+
"dice"
|
|
786
|
+
]) if (typeof entry[key] !== "string") problems.push(`${at}.${key} must be text`);
|
|
787
|
+
if (entry["reading"] !== void 0 && !DICE_READINGS.includes(entry["reading"])) problems.push(`${at}.reading must be one of: ${DICE_READINGS.join(", ")}`);
|
|
788
|
+
if (entry["compare"] !== void 0 && !DICE_COMPARISONS.includes(entry["compare"])) problems.push(`${at}.compare must be one of: ${DICE_COMPARISONS.join(", ")}`);
|
|
789
|
+
if (entry["hit"] !== void 0 && (typeof entry["hit"] !== "number" || !Number.isInteger(entry["hit"]))) problems.push(`${at}.hit must be a whole number`);
|
|
790
|
+
if (entry["modifier"] !== void 0 && typeof entry["modifier"] !== "string") problems.push(`${at}.modifier must be text`);
|
|
791
|
+
const bands = Array.isArray(entry["bands"]) ? entry["bands"] : void 0;
|
|
792
|
+
if (bands === void 0) problems.push(`${at}.bands must be a list`);
|
|
793
|
+
const text = (field) => typeof field === "string" ? field.trim() : "";
|
|
794
|
+
const hit = entry["hit"];
|
|
795
|
+
return {
|
|
796
|
+
key: text(entry["key"]),
|
|
797
|
+
name: text(entry["name"]),
|
|
798
|
+
use: text(entry["use"]),
|
|
799
|
+
dice: text(entry["dice"]),
|
|
800
|
+
...entry["reading"] === void 0 ? {} : { reading: entry["reading"] },
|
|
801
|
+
...typeof hit === "number" ? { hit } : {},
|
|
802
|
+
...entry["compare"] === void 0 ? {} : { compare: entry["compare"] },
|
|
803
|
+
...text(entry["modifier"]) === "" ? {} : { modifier: text(entry["modifier"]) },
|
|
804
|
+
bands: (bands ?? []).map((band, bandIndex) => {
|
|
805
|
+
const where = `${at}.bands[${bandIndex}]`;
|
|
806
|
+
if (!isObject$1(band)) {
|
|
807
|
+
problems.push(`${where} must be an object`);
|
|
808
|
+
return {
|
|
809
|
+
label: "",
|
|
810
|
+
result: "failed"
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
for (const key of Object.keys(band)) if (!BAND_FIELDS.includes(key)) problems.push(`${where}.${key} is not a field of a band`);
|
|
814
|
+
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`);
|
|
815
|
+
if (typeof band["label"] !== "string") problems.push(`${where}.label must be text`);
|
|
816
|
+
if (!DICE_RESULTS.includes(band["result"])) problems.push(`${where}.result must be one of: ${DICE_RESULTS.join(", ")}`);
|
|
817
|
+
const min = band["min"];
|
|
818
|
+
const max = band["max"];
|
|
819
|
+
return {
|
|
820
|
+
label: text(band["label"]),
|
|
821
|
+
result: band["result"],
|
|
822
|
+
...typeof min === "number" ? { min } : {},
|
|
823
|
+
...typeof max === "number" ? { max } : {},
|
|
824
|
+
...band["critical"] === true ? { critical: true } : {}
|
|
825
|
+
};
|
|
826
|
+
})
|
|
827
|
+
};
|
|
828
|
+
});
|
|
829
|
+
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
830
|
+
return { checks };
|
|
831
|
+
}
|
|
832
|
+
//#endregion
|
|
743
833
|
//#region src/shared/world-daily.ts
|
|
744
834
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
745
835
|
const ROUTINE_FIELDS = [
|
|
@@ -1842,7 +1932,7 @@ function languageField(value) {
|
|
|
1842
1932
|
throw new InvalidEditProblems([error instanceof Error ? error.message : String(error)]);
|
|
1843
1933
|
}
|
|
1844
1934
|
}
|
|
1845
|
-
function createApiHandler({ worlds, createWorld, starter, authorWorld, translation, worldCharacters, importer, avatars, worldFiles, worldEditor, sessions, packs, connection, speech }) {
|
|
1935
|
+
function createApiHandler({ worlds, createWorld, starter, authorWorld, translation, worldCharacters, importer, avatars, worldFiles, worldEditor, sessions, packs, connection, speech, externalTools }) {
|
|
1846
1936
|
const routes = {
|
|
1847
1937
|
"/speech/capabilities": { GET: async (_req, res) => {
|
|
1848
1938
|
sendJson(res, 200, { streaming: speech.streaming() });
|
|
@@ -2168,6 +2258,28 @@ function createApiHandler({ worlds, createWorld, starter, authorWorld, translati
|
|
|
2168
2258
|
throw error;
|
|
2169
2259
|
}
|
|
2170
2260
|
} },
|
|
2261
|
+
"/worlds/dice": {
|
|
2262
|
+
GET: async (_req, res, url) => {
|
|
2263
|
+
try {
|
|
2264
|
+
sendJson(res, 200, await worldFiles.dice(url.searchParams.get("id") ?? ""));
|
|
2265
|
+
} catch (error) {
|
|
2266
|
+
if (error instanceof WorldNotFoundError) return sendError(res, 404, error.message);
|
|
2267
|
+
throw error;
|
|
2268
|
+
}
|
|
2269
|
+
},
|
|
2270
|
+
PUT: async (req, res, url) => {
|
|
2271
|
+
try {
|
|
2272
|
+
sendJson(res, 200, await worldFiles.editDice(url.searchParams.get("id") ?? "", parseDiceEdit(await readJsonBody(req))));
|
|
2273
|
+
} catch (error) {
|
|
2274
|
+
if (error instanceof WorldNotFoundError) return sendError(res, 404, error.message);
|
|
2275
|
+
if (error instanceof InvalidEditProblems) return sendJson(res, 422, {
|
|
2276
|
+
message: error.message,
|
|
2277
|
+
problems: error.problems
|
|
2278
|
+
});
|
|
2279
|
+
throw error;
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
},
|
|
2171
2283
|
"/worlds/calendar": {
|
|
2172
2284
|
GET: async (_req, res, url) => {
|
|
2173
2285
|
try {
|
|
@@ -2498,6 +2610,9 @@ function createApiHandler({ worlds, createWorld, starter, authorWorld, translati
|
|
|
2498
2610
|
}
|
|
2499
2611
|
await sendImage(res, image);
|
|
2500
2612
|
} },
|
|
2613
|
+
"/tools": { GET: async (_req, res) => {
|
|
2614
|
+
sendJson(res, 200, { tools: externalTools?.() ?? [] });
|
|
2615
|
+
} },
|
|
2501
2616
|
"/sessions/settings": {
|
|
2502
2617
|
GET: async (_req, res, url) => {
|
|
2503
2618
|
try {
|
|
@@ -3085,6 +3200,36 @@ async function editCalendar(world, calendar) {
|
|
|
3085
3200
|
else await replaceFileOrCreate(join(world.directory, CALENDAR_FILE_NAME), text);
|
|
3086
3201
|
return await readCalendarDocument(world);
|
|
3087
3202
|
}
|
|
3203
|
+
/** The checks of a world as its `dice.json` has them; none without the file. */
|
|
3204
|
+
async function readDiceDocument(world) {
|
|
3205
|
+
const { checks } = await loadDice(world.directory);
|
|
3206
|
+
return { checks };
|
|
3207
|
+
}
|
|
3208
|
+
/**
|
|
3209
|
+
* 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
|
|
3210
|
+
* declares for characters. No checks is no file at all.
|
|
3211
|
+
* @throws {InvalidEditProblems} naming each problem; nothing is written.
|
|
3212
|
+
*/
|
|
3213
|
+
async function editDice(world, dice) {
|
|
3214
|
+
const written = dice.checks.map(({ reading, compare, ...check }) => ({
|
|
3215
|
+
...check,
|
|
3216
|
+
...reading === void 0 || reading === "total" ? {} : { reading },
|
|
3217
|
+
...compare === void 0 || compare === "absolute" ? {} : { compare }
|
|
3218
|
+
}));
|
|
3219
|
+
const text = `${JSON.stringify({ checks: written }, null, 2)}\n`;
|
|
3220
|
+
const parsed = parseDiceFile(text);
|
|
3221
|
+
if (!parsed.ok) throw new InvalidEditProblems(parsed.issues.map(formatIssue));
|
|
3222
|
+
const declared = await loadVariables(world.directory);
|
|
3223
|
+
const problems = parsed.value.flatMap((check) => {
|
|
3224
|
+
if (check.modifier === void 0) return [];
|
|
3225
|
+
const variable = declared.defs.find((def) => def.key === check.modifier);
|
|
3226
|
+
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)`] : [];
|
|
3227
|
+
});
|
|
3228
|
+
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
3229
|
+
if (dice.checks.length === 0) await rm(join(world.directory, DICE_FILE_NAME), { force: true });
|
|
3230
|
+
else await replaceFileOrCreate(join(world.directory, DICE_FILE_NAME), text);
|
|
3231
|
+
return await readDiceDocument(world);
|
|
3232
|
+
}
|
|
3088
3233
|
//#endregion
|
|
3089
3234
|
//#region src/host/worlds/lore-entries.ts
|
|
3090
3235
|
const MAX_TITLE = 200;
|
|
@@ -3905,6 +4050,10 @@ async function replaceFile(file, text) {
|
|
|
3905
4050
|
}
|
|
3906
4051
|
}
|
|
3907
4052
|
const textOf = (value) => typeof value === "string" ? value : "";
|
|
4053
|
+
const toolsOf = (value) => {
|
|
4054
|
+
const board = value === void 0 ? {} : parseSwitchboard(value, "tools");
|
|
4055
|
+
return typeof board === "string" ? {} : board;
|
|
4056
|
+
};
|
|
3908
4057
|
function infoOf(document) {
|
|
3909
4058
|
const opening = document["opening_message"];
|
|
3910
4059
|
const parts = Array.isArray(opening) && opening.some((part) => typeof part === "object" && part !== null && part["type"] === "utterance");
|
|
@@ -3924,6 +4073,7 @@ function infoOf(document) {
|
|
|
3924
4073
|
timeZone: textOf(document["time_zone"]),
|
|
3925
4074
|
startingTime: textOf(document["starting_time"]),
|
|
3926
4075
|
version: typeof document["version"] === "number" ? String(document["version"]) : textOf(document["version"]),
|
|
4076
|
+
tools: toolsOf(document["tools"]),
|
|
3927
4077
|
alternateOpenings: Array.isArray(document["alternate_openings"]) ? document["alternate_openings"].flatMap((entry) => typeof entry === "object" && entry !== null && typeof entry["text"] === "string" ? [{
|
|
3928
4078
|
title: textOf(entry["title"]),
|
|
3929
4079
|
text: entry["text"]
|
|
@@ -3986,6 +4136,10 @@ async function editWorldInfo(directory, edit) {
|
|
|
3986
4136
|
text: entry.text
|
|
3987
4137
|
}));
|
|
3988
4138
|
}
|
|
4139
|
+
if (edit.tools !== void 0) {
|
|
4140
|
+
if (Object.keys(edit.tools).length === 0) delete document["tools"];
|
|
4141
|
+
else document["tools"] = edit.tools;
|
|
4142
|
+
}
|
|
3989
4143
|
const next = JSON.stringify(document, null, /^([ \t]+)"/m.exec(text)?.[1] ?? " ") + (text.endsWith("\n") ? "\n" : "");
|
|
3990
4144
|
const parsed = parseWorldFile(next);
|
|
3991
4145
|
if (!parsed.ok) throw new InvalidEditProblems(parsed.issues.map(formatIssue));
|
|
@@ -4012,7 +4166,7 @@ function worldFindings(session) {
|
|
|
4012
4166
|
async function startSession(deps, request) {
|
|
4013
4167
|
const world = await deps.worlds.find(request.worldId);
|
|
4014
4168
|
if (world === void 0) throw new WorldNotFoundError(`there is no world with id "${request.worldId}"`);
|
|
4015
|
-
const { characters: authored, factions, locations, items, slots, authoredLore, declared, scripted, authoredPlots, calendar } = await loadValidatedWorld(world);
|
|
4169
|
+
const { characters: authored, factions, locations, items, slots, authoredLore, declared, scripted, authoredPlots, calendar, checks } = await loadValidatedWorld(world);
|
|
4016
4170
|
if (request.opening !== void 0 && (!Number.isInteger(request.opening) || request.opening < 0 || request.opening >= (world.alternateOpenings?.length ?? 0))) throw new InvalidStartError(`the world has no alternate opening ${String(request.opening)}`);
|
|
4017
4171
|
const opening = request.opening === void 0 ? openingOf(world, authored) : [{
|
|
4018
4172
|
type: "narration",
|
|
@@ -4037,12 +4191,17 @@ async function startSession(deps, request) {
|
|
|
4037
4191
|
settings = parsed.value;
|
|
4038
4192
|
}
|
|
4039
4193
|
const timeZone = settings.clock.timeZone !== "" ? settings.clock.timeZone : settings.clock.mode === "real" ? systemTimeZone() : world.clock?.timeZone ?? "UTC";
|
|
4194
|
+
const tools = Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(world.tools ?? {}), ...Object.keys(settings.tools)])].map((agent) => [agent, {
|
|
4195
|
+
...world.tools?.[agent],
|
|
4196
|
+
...settings.tools[agent]
|
|
4197
|
+
}]));
|
|
4040
4198
|
settings = {
|
|
4041
4199
|
...settings,
|
|
4042
4200
|
clock: {
|
|
4043
4201
|
...settings.clock,
|
|
4044
4202
|
timeZone
|
|
4045
|
-
}
|
|
4203
|
+
},
|
|
4204
|
+
tools
|
|
4046
4205
|
};
|
|
4047
4206
|
let startsAt = world.clock?.startingTime;
|
|
4048
4207
|
if (request.startingTime !== void 0 && request.startingTime.trim() !== "") {
|
|
@@ -4071,6 +4230,7 @@ async function startSession(deps, request) {
|
|
|
4071
4230
|
populateCharacters(session, characters, player.id);
|
|
4072
4231
|
populateFactions(session, factions);
|
|
4073
4232
|
populateCalendar(session, calendar);
|
|
4233
|
+
populateDice(session, checks);
|
|
4074
4234
|
populateRoutines(session, characters);
|
|
4075
4235
|
populateItems(session, items, slots, locations);
|
|
4076
4236
|
populateLore(session, authoredLore.lore);
|
|
@@ -4574,6 +4734,7 @@ async function loadWorld(folder, dir, file, problems) {
|
|
|
4574
4734
|
...world.variables === void 0 ? {} : { variables: world.variables },
|
|
4575
4735
|
...world.alternateOpenings === void 0 ? {} : { alternateOpenings: world.alternateOpenings },
|
|
4576
4736
|
...world.rules === void 0 ? {} : { rules: world.rules },
|
|
4737
|
+
...world.tools === void 0 ? {} : { tools: world.tools },
|
|
4577
4738
|
...world.narrationVoice === void 0 ? {} : { narrationVoice: world.narrationVoice }
|
|
4578
4739
|
};
|
|
4579
4740
|
if (world.coverMediaId !== void 0) try {
|
|
@@ -4896,6 +5057,10 @@ function apply(ctx, config) {
|
|
|
4896
5057
|
return await addAvatarsToWorld(await avatarsWorld(root.path), world, keys, locations);
|
|
4897
5058
|
}
|
|
4898
5059
|
},
|
|
5060
|
+
externalTools: () => {
|
|
5061
|
+
const registry = ctx.get("tools");
|
|
5062
|
+
return registry === void 0 ? [] : externalTools(registry);
|
|
5063
|
+
},
|
|
4899
5064
|
worldFiles: {
|
|
4900
5065
|
info: async (worldId) => await readWorldInfo((await editableWorld(worlds, worldId, root.path)).directory),
|
|
4901
5066
|
editInfo: async (worldId, edit) => {
|
|
@@ -4905,6 +5070,8 @@ function apply(ctx, config) {
|
|
|
4905
5070
|
},
|
|
4906
5071
|
routines: async (worldId) => await readRoutines(await editableWorld(worlds, worldId, root.path)),
|
|
4907
5072
|
editRoutine: async (worldId, key, windows) => await editRoutine(await editableWorld(worlds, worldId, root.path), key, windows),
|
|
5073
|
+
dice: async (worldId) => await readDiceDocument(await editableWorld(worlds, worldId, root.path)),
|
|
5074
|
+
editDice: async (worldId, dice) => await editDice(await editableWorld(worlds, worldId, root.path), dice),
|
|
4908
5075
|
calendar: async (worldId) => await readCalendarDocument(await editableWorld(worlds, worldId, root.path)),
|
|
4909
5076
|
editCalendar: async (worldId, calendar) => await editCalendar(await editableWorld(worlds, worldId, root.path), calendar),
|
|
4910
5077
|
variables: async (worldId) => await readVariables(await editableWorld(worlds, worldId, root.path)),
|
|
@@ -5028,6 +5195,7 @@ function apply(ctx, config) {
|
|
|
5028
5195
|
reflect: async (id) => {
|
|
5029
5196
|
const sessions = join(root.path, "sessions");
|
|
5030
5197
|
if (!isSessionId(id) || !existsSync(sessionDatabase(sessions, id))) throw new SessionNotFoundError(`no session "${id}"`);
|
|
5198
|
+
await agent.ensure(id, ctx.roleplayState.openSession(sessions, id).metadata.get().name);
|
|
5031
5199
|
await ctx.roleplayOrchestration.reflect(chatSessionId(id));
|
|
5032
5200
|
},
|
|
5033
5201
|
resetVectors: (id) => {
|