@dsh-agentic-roleplay/core 0.5.0 → 0.6.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-EbNdZFbk.js +25 -0
- package/lib/{authoring-tools-Ch_3oIKC.js → authoring-tools-BGzzW6O5.js} +5 -5
- package/lib/authoring.js +5 -5
- package/lib/{access-tN5D3WI8.js → child-D5SVNk4O.js} +58 -78
- package/lib/client.js +819 -327
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +3 -2
- package/lib/doctor.js +3 -3
- package/lib/helper.js +26 -0
- package/lib/{hooks-C7gt2c01.js → hooks-BLperIIB.js} +70 -7
- package/lib/images.js +1 -1
- package/lib/index.js +43 -11
- package/lib/{lorebook-author-tools-DII7Xt7Q.js → lorebook-author-tools-C-cFiE6E.js} +5 -5
- package/lib/lorebook-authoring.js +3 -3
- package/lib/{narration-DstnwrvX.js → narration-_dA9oIt2.js} +57 -2
- package/lib/orchestration.js +364 -46
- package/lib/{pack-jail-AzR6dCNm.js → pack-jail-BKFmbYP8.js} +8 -8
- package/lib/{packs-C7g534Mi.js → packs-ZTG7fWut.js} +2 -2
- package/lib/{presenter-agent-BsC6Vftz.js → presenter-agent-BHSbyWwZ.js} +3 -2
- package/lib/{preset-Drfu_K-H.js → preset-CJLW8Mp0.js} +3 -3
- package/lib/{preset-author-tools-CdIsFhQw.js → preset-author-tools-1RstgEZs.js} +5 -5
- package/lib/preset-authoring.js +4 -4
- package/lib/{presets-CADd77WB.js → presets-DcPCnn8O.js} +3 -3
- package/lib/{reflection-CUGuPAZR.js → reflection-6qfOC5OT.js} +235 -31
- package/package.json +4 -3
- package/prompts/en/roleplay/check-rule.md +3 -0
- package/prompts/en/roleplay/decide-reflection.md +3 -0
- package/prompts/en/roleplay/decide-trigger.md +3 -0
- package/prompts/en/roleplay/gate-agency.md +1 -0
- package/prompts/en/roleplay/gate-refusal.md +1 -0
- package/prompts/en/roleplay/gate-secret.md +3 -0
- package/prompts/zh/roleplay/check-rule.md +3 -0
- package/prompts/zh/roleplay/decide-reflection.md +3 -0
- package/prompts/zh/roleplay/decide-trigger.md +3 -0
- package/prompts/zh/roleplay/gate-agency.md +1 -0
- package/prompts/zh/roleplay/gate-refusal.md +1 -0
- package/prompts/zh/roleplay/gate-secret.md +3 -0
package/lib/compaction.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as liveSettings, t as decodeOutput } from "./narration-
|
|
1
|
+
import { r as roleplaySessionOf, t as promptFor } from "./access-EbNdZFbk.js";
|
|
2
|
+
import { a as liveSettings, t as decodeOutput } from "./narration-_dA9oIt2.js";
|
|
3
|
+
import { h as tokensOf, n as childSampling, o as runChild, t as childModel } from "./child-D5SVNk4O.js";
|
|
3
4
|
import { join } from "node:path";
|
|
4
5
|
import { sessionFolder } from "@dsh-agentic-roleplay/state";
|
|
5
6
|
import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
|
package/lib/doctor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as liveSettings } from "./narration-
|
|
3
|
-
import { i as externalTools, t as externalToolLimit } from "./hooks-
|
|
1
|
+
import { n as chatSessionId } from "./access-EbNdZFbk.js";
|
|
2
|
+
import { a as liveSettings } from "./narration-_dA9oIt2.js";
|
|
3
|
+
import { i as externalTools, t as externalToolLimit } from "./hooks-BLperIIB.js";
|
|
4
4
|
import { n as doctorSessionOf } from "./doctor-chat-ByDfCMeo.js";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { existsSync } from "node:fs";
|
package/lib/helper.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { a as helpers } from "./child-D5SVNk4O.js";
|
|
2
|
+
//#region src/helper.ts
|
|
3
|
+
const name = "@dsh-agentic-roleplay/core/helper";
|
|
4
|
+
const inject = ["tools", "systemPrompt"];
|
|
5
|
+
/**
|
|
6
|
+
* The preset every helper agent (a character, the record keeper, the author, the chronicler) runs under. The preset is shared by all of them, so what is
|
|
7
|
+
* one child's is found by its session id: its persona, and the equipment its caller set up for it when it was created.
|
|
8
|
+
*/
|
|
9
|
+
function apply(ctx) {
|
|
10
|
+
ctx.systemPrompt.section({
|
|
11
|
+
name: "ROLEPLAY_HELPER_PERSONA",
|
|
12
|
+
order: ctx.systemPrompt.getSectionOrder("DEPLOYMENT_PERSONA_PREFIX"),
|
|
13
|
+
interpolate: false,
|
|
14
|
+
text: (context) => {
|
|
15
|
+
const agent = context.agent;
|
|
16
|
+
return agent === void 0 ? "" : helpers.get(agent.session.id)?.persona ?? "";
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
ctx.on("agent/created", ({ agent }) => {
|
|
20
|
+
helpers.get(agent.session.id)?.setup(agent);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { apply, inject, name };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as liveSettings, m as rulesOf, n as encodeOutput, p as WORLD_RULES_KEY, r as encodePreview } from "./narration-
|
|
1
|
+
import { r as roleplaySessionOf, t as promptFor } from "./access-EbNdZFbk.js";
|
|
2
|
+
import { _ as emptyStats, a as liveSettings, h as DECISION_SITES, m as rulesOf, n as encodeOutput, p as WORLD_RULES_KEY, r as encodePreview } from "./narration-_dA9oIt2.js";
|
|
3
3
|
import { t as trimCharacters } from "./text-CT1re6XT.js";
|
|
4
|
+
import { d as NO_TOKENS, f as addTokens, i as childTrace, m as estimateAnswer, n as childSampling, o as runChild, t as childModel, u as tokensOf } from "./child-D5SVNk4O.js";
|
|
4
5
|
import { dirname, join } from "node:path";
|
|
5
6
|
import { copyFileSync, cpSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
6
7
|
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
@@ -1462,6 +1463,61 @@ function forgetRunDetails(folder, dropped) {
|
|
|
1462
1463
|
for (const entry of dropped) if (entry.run !== void 0) rmSync(runFile(folder, entry.run), { force: true });
|
|
1463
1464
|
}
|
|
1464
1465
|
//#endregion
|
|
1466
|
+
//#region src/host/decisions/stats.ts
|
|
1467
|
+
const DECISIONS_FILE = "decisions.json";
|
|
1468
|
+
const isSite = (value) => typeof value === "object" && value !== null && [
|
|
1469
|
+
"runs",
|
|
1470
|
+
"items",
|
|
1471
|
+
"decided",
|
|
1472
|
+
"escalated",
|
|
1473
|
+
"fallbacks",
|
|
1474
|
+
"agreed",
|
|
1475
|
+
"disagreed",
|
|
1476
|
+
"decisionMs",
|
|
1477
|
+
"llmMs"
|
|
1478
|
+
].every((field) => typeof value[field] === "number") && Array.isArray(value.samples);
|
|
1479
|
+
/**
|
|
1480
|
+
* What was kept about the story's decisions. The file only holds measurements, so one that cannot be read is
|
|
1481
|
+
* started again, not a reason to stop the story.
|
|
1482
|
+
*/
|
|
1483
|
+
function readDecisionStats(folder, now = () => /* @__PURE__ */ new Date()) {
|
|
1484
|
+
let value;
|
|
1485
|
+
try {
|
|
1486
|
+
value = JSON.parse(readFileSync(join(folder, DECISIONS_FILE), "utf8"));
|
|
1487
|
+
} catch {
|
|
1488
|
+
return emptyStats(now().toISOString());
|
|
1489
|
+
}
|
|
1490
|
+
const given = value;
|
|
1491
|
+
const fresh = emptyStats(typeof given?.since === "string" ? given.since : now().toISOString());
|
|
1492
|
+
for (const site of DECISION_SITES) {
|
|
1493
|
+
const entry = given?.sites?.[site];
|
|
1494
|
+
if (isSite(entry)) fresh.sites[site] = entry;
|
|
1495
|
+
}
|
|
1496
|
+
return fresh;
|
|
1497
|
+
}
|
|
1498
|
+
/** Adds one run of a site to what is kept; the file is written aside and renamed, and stays beside the database, so putting the story back does not change it. */
|
|
1499
|
+
function recordDecisions(folder, site, report, now = () => /* @__PURE__ */ new Date()) {
|
|
1500
|
+
const stats = readDecisionStats(folder, now);
|
|
1501
|
+
const kept = stats.sites[site];
|
|
1502
|
+
stats.sites[site] = {
|
|
1503
|
+
runs: kept.runs + 1,
|
|
1504
|
+
items: kept.items + report.items,
|
|
1505
|
+
decided: kept.decided + report.decided,
|
|
1506
|
+
escalated: kept.escalated + report.escalated,
|
|
1507
|
+
fallbacks: kept.fallbacks + report.fallbacks,
|
|
1508
|
+
agreed: kept.agreed + report.agreed,
|
|
1509
|
+
disagreed: kept.disagreed + report.disagreed,
|
|
1510
|
+
decisionMs: kept.decisionMs + report.decisionMs,
|
|
1511
|
+
llmMs: kept.llmMs + report.llmMs,
|
|
1512
|
+
samples: [...kept.samples, ...report.samples].slice(-20),
|
|
1513
|
+
...report.problem === void 0 ? {} : { problem: report.problem }
|
|
1514
|
+
};
|
|
1515
|
+
const target = join(folder, DECISIONS_FILE);
|
|
1516
|
+
const aside = `${target}.writing`;
|
|
1517
|
+
writeFileSync(aside, JSON.stringify(stats, null, 2));
|
|
1518
|
+
renameSync(aside, target);
|
|
1519
|
+
}
|
|
1520
|
+
//#endregion
|
|
1465
1521
|
//#region src/host/sessions/usage.ts
|
|
1466
1522
|
const KEY = "usage";
|
|
1467
1523
|
const isCount = (value) => typeof value === "object" && value !== null && [
|
|
@@ -2197,6 +2253,9 @@ function storeOf(session, folder, problem, queryVector, wall, prompt) {
|
|
|
2197
2253
|
forgetRunDetails(folder, recordActivity(session, entry));
|
|
2198
2254
|
if (entry.turn !== void 0 && entry.tokens !== void 0) addUsage(session, entry.turn, "helper", entry.tokens);
|
|
2199
2255
|
},
|
|
2256
|
+
recordDecisions: (site, report) => {
|
|
2257
|
+
recordDecisions(folder, site, report);
|
|
2258
|
+
},
|
|
2200
2259
|
recordUsage: (turn, tokens) => {
|
|
2201
2260
|
addUsage(session, turn, "master", tokens);
|
|
2202
2261
|
},
|
|
@@ -3410,9 +3469,10 @@ function createTools$1(deps) {
|
|
|
3410
3469
|
}]
|
|
3411
3470
|
},
|
|
3412
3471
|
isConcurrencySafe: () => false,
|
|
3413
|
-
execute(args, exec) {
|
|
3472
|
+
async execute(args, exec) {
|
|
3414
3473
|
const { owner } = ownerOf(exec.agent);
|
|
3415
|
-
|
|
3474
|
+
await deps.engine.checkRules(owner, args.allowed);
|
|
3475
|
+
return record(deps.engine.judge(owner, args.allowed, args.reason, args.at, args.uncertain));
|
|
3416
3476
|
}
|
|
3417
3477
|
}),
|
|
3418
3478
|
preview,
|
|
@@ -3606,7 +3666,10 @@ function installHooks(ctx, deps) {
|
|
|
3606
3666
|
cast
|
|
3607
3667
|
}) : { ok: true };
|
|
3608
3668
|
if (ooc !== void 0 && ooc.request !== "") engine.beginOoc(owner, ooc.request, ooc.question);
|
|
3609
|
-
else if (ooc === void 0)
|
|
3669
|
+
else if (ooc === void 0) {
|
|
3670
|
+
engine.expectJudgement(owner);
|
|
3671
|
+
engine.noteInput(owner, text);
|
|
3672
|
+
}
|
|
3610
3673
|
const queryVector = await store.queryVector(ooc?.request ?? text);
|
|
3611
3674
|
store.clearNotes();
|
|
3612
3675
|
store.lapseNotes(payload.turn);
|
|
@@ -3689,6 +3752,6 @@ function installHooks(ctx, deps) {
|
|
|
3689
3752
|
});
|
|
3690
3753
|
}
|
|
3691
3754
|
//#endregion
|
|
3692
|
-
export {
|
|
3755
|
+
export { listFiles as $, answerLimits as A, loadPlots as B, readNotes as C, describeWhen as D, describeTime as E, STORY_LANGUAGES as F, formatIssue as G, plotReferenceProblems as H, isStoryLanguage as I, PROMPTS_FOLDER as J, errorMessage as K, textLanguage as L, plotProgressOf as M, populatePlots as N, zoneOf as O, LANGUAGE_NAMES as P, languageOf as Q, wrongLanguage as R, notesOfSession as S, ClockError as T, readDocument as U, parsePlotsFile as V, Reader as W, copyWorldPrompts as X, PromptLibrary as Y, inheritPrompts as Z, readRunDetail as _, externalWithheld as a, InvalidWorldError as at, readWithdrawn as b, record as c, SessionNotFoundError as ct, toolEnabled as d, translator as dt, promptProblem as et, MAX_OOC_ANSWER as f, readActivity as g, readDecisionStats as h, externalTools as i, InvalidStartError as it, PLOTS_METADATA_KEY as j, RESULTS as k, AUTHORING_NEEDS as l, WorldNotFoundError as lt, readUsage as m, installHooks as n, shippedPromptsDirectory as nt, PREVIEW_TOOL as o, ReflectionRefusedError as ot, storesOf as p, LANGUAGE_FOLDER as q, externalGiven as r, AgentUnavailableError as rt, createTools$1 as s, SessionArchivedError as st, externalToolLimit as t, shippedLanguages as tt, characterRunner as u, languageOf$1 as ut, readVerdicts as v, observeAsPlayer as w, addToNote as x, writeVerdicts as y, PLOTS_FILE_NAME as z };
|
|
3693
3756
|
|
|
3694
|
-
//# sourceMappingURL=hooks-
|
|
3757
|
+
//# sourceMappingURL=hooks-BLperIIB.js.map
|
package/lib/images.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as withPngMetadata, a as inheritImages, c as referenceImagePath, g as readPngMetadata, i as entityImageDirectory, l as sceneImagePath, o as nextSceneSerial, s as readImageMetadata, t as addToLibrary } from "./library-DsDc6fQa.js";
|
|
2
2
|
import { i as transientPrompt, n as generateTransientImage, r as referencePrompt, t as generateReferenceImage } from "./generator-CO8usAjE.js";
|
|
3
3
|
import { i as updateImage, r as listGallery } from "./gallery-C7VOJ3xH.js";
|
|
4
|
-
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-
|
|
4
|
+
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-BHSbyWwZ.js";
|
|
5
5
|
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,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as loadItems, Bt as ImportCardError, C as populateLocations, D as populateVariables, E as populateTriggers, Et as writeLorebookEntry, F as loadCalendar, Ft as parseLoreEdit, Gt as LORE_SCOPES, Ht as pictureOf, I as parseCalendarFile, It as parsePlaceEdit, J as withPlayer, Jt as DICE_RESULTS, Kt as DICE_COMPARISONS, Lt as parseRelationEdit, M as loadDice, Mt as InvalidEditProblems, N as parseDiceFile, Nt as parseCharacterEdit, O as routineProblems, P as CALENDAR_FILE_NAME, Pt as parseFactionEdit, Q as variableProblems, R as loadLocations, Rt as parseThingEdit, S as populateKnowledge, St as lorebookDirectory, T as populateRoutines, Tt as updateLorebookInfo, U as CHARACTERS_DIR, Ut as readCard, Vt as isPng, W as loadCharacters, Wt as LORE_KINDS, X as loadVariables, Y as VARIABLES_FILE_NAME, Z as parseVariablesFile, _ as populateCharacters, _t as deleteLorebookEntry, at as CHARACTER_FILE_NAME, b as populateFactions, bt as listLorebooks, ct as ImportNotFoundError, d as markReady, dt as WORLD_FILE_NAME, f as guardedLookup, ft as parseWorldFile, g as populateCalendar, gt as deleteLorebook, h as knowsCharacter, ht as createLorebook, j as DICE_FILE_NAME, jt as subfolders, k as TRIGGERS_FILE_NAME, l as authoringChatSessionId, lt as ImportStore, m as loadValidatedWorld, mt as addLorebookEntries, ot as parseCharacterFile, p as vetUrl, pt as parseWorldInfoEdit, q as partsOf, qt as DICE_READINGS, st as IMPORT_FOLDER, t as AuthoringTools, ut as parseChoices, v as populateClock, vt as entriesOf, w as populateLore, wt as reserveLorebook, x as populateItems, xt as loadLorebook, y as populateDice, yt as isLorebookName, zt as IMPORT_COMMAND } from "./authoring-tools-
|
|
3
|
-
import { _ as readWorldPrompt, a as isPresetName, c as presetDirectory, d as savePresetFromWorld, g as listWorldPrompts, h as deleteWorldPrompt, i as deletePreset, o as listPresets, p as updatePresetInfo, r as createPresetFromShipped, s as loadPreset, t as PRESET_FILE, u as reservePreset, v as writeWorldPrompt } from "./presets-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { n as chatSessionId, r as roleplaySessionOf } from "./access-EbNdZFbk.js";
|
|
2
|
+
import { B as loadItems, Bt as ImportCardError, C as populateLocations, D as populateVariables, E as populateTriggers, Et as writeLorebookEntry, F as loadCalendar, Ft as parseLoreEdit, Gt as LORE_SCOPES, Ht as pictureOf, I as parseCalendarFile, It as parsePlaceEdit, J as withPlayer, Jt as DICE_RESULTS, Kt as DICE_COMPARISONS, Lt as parseRelationEdit, M as loadDice, Mt as InvalidEditProblems, N as parseDiceFile, Nt as parseCharacterEdit, O as routineProblems, P as CALENDAR_FILE_NAME, Pt as parseFactionEdit, Q as variableProblems, R as loadLocations, Rt as parseThingEdit, S as populateKnowledge, St as lorebookDirectory, T as populateRoutines, Tt as updateLorebookInfo, U as CHARACTERS_DIR, Ut as readCard, Vt as isPng, W as loadCharacters, Wt as LORE_KINDS, X as loadVariables, Y as VARIABLES_FILE_NAME, Z as parseVariablesFile, _ as populateCharacters, _t as deleteLorebookEntry, at as CHARACTER_FILE_NAME, b as populateFactions, bt as listLorebooks, ct as ImportNotFoundError, d as markReady, dt as WORLD_FILE_NAME, f as guardedLookup, ft as parseWorldFile, g as populateCalendar, gt as deleteLorebook, h as knowsCharacter, ht as createLorebook, j as DICE_FILE_NAME, jt as subfolders, k as TRIGGERS_FILE_NAME, l as authoringChatSessionId, lt as ImportStore, m as loadValidatedWorld, mt as addLorebookEntries, ot as parseCharacterFile, p as vetUrl, pt as parseWorldInfoEdit, q as partsOf, qt as DICE_READINGS, st as IMPORT_FOLDER, t as AuthoringTools, ut as parseChoices, v as populateClock, vt as entriesOf, w as populateLore, wt as reserveLorebook, x as populateItems, xt as loadLorebook, y as populateDice, yt as isLorebookName, zt as IMPORT_COMMAND } from "./authoring-tools-BGzzW6O5.js";
|
|
3
|
+
import { _ as readWorldPrompt, a as isPresetName, c as presetDirectory, d as savePresetFromWorld, g as listWorldPrompts, h as deleteWorldPrompt, i as deletePreset, o as listPresets, p as updatePresetInfo, r as createPresetFromShipped, s as loadPreset, t as PRESET_FILE, u as reservePreset, v as writeWorldPrompt } from "./presets-DcPCnn8O.js";
|
|
4
|
+
import { _ as readTimeline, d as TimelineError, g as switchPreset, h as recordPreset, i as reflectionStatus, m as presetStatus, p as copyPreset, v as pathTo, y as defaultBoundaries } from "./reflection-6qfOC5OT.js";
|
|
5
|
+
import { a as liveSettings, b as VARIABLE_VISIBILITIES, c as writeSettings, d as parseSettings, i as InvalidSettingsError, l as DEFAULT_SETTINGS, n as encodeOutput, o as readSettings, p as WORLD_RULES_KEY, s as useChildReasoning, u as SETTINGS_SPEC, v as VARIABLE_KINDS, y as VARIABLE_SUBJECTS } from "./narration-_dA9oIt2.js";
|
|
6
|
+
import { C as readNotes, G as formatIssue, H as plotReferenceProblems, K as errorMessage, M as plotProgressOf, N as populatePlots, O as zoneOf, Q as languageOf, S as notesOfSession, U as readDocument, V as parsePlotsFile, X as copyWorldPrompts, Y as PromptLibrary, _ as readRunDetail, at as InvalidWorldError, b as readWithdrawn, ct as SessionNotFoundError, g as readActivity, h as readDecisionStats, i as externalTools, it as InvalidStartError, j as PLOTS_METADATA_KEY, lt as WorldNotFoundError, m as readUsage, ot as ReflectionRefusedError, rt as AgentUnavailableError, st as SessionArchivedError, tt as shippedLanguages, w as observeAsPlayer, x as addToNote } from "./hooks-BLperIIB.js";
|
|
7
7
|
import { t as trimCharacters } from "./text-CT1re6XT.js";
|
|
8
|
+
import { c as parseSampling, l as sharedSamplingOf, r as childSamplingOf } from "./child-D5SVNk4O.js";
|
|
8
9
|
import { a as inheritImages, b as slug, c as referenceImagePath, l as sceneImagePath, t as addToLibrary, x as uniqueKey } from "./library-DsDc6fQa.js";
|
|
9
|
-
import { A as worldEntityImageFile, B as readWorldInfo, C as readWorldEditor, D as uploadWorldCharacterPortrait, E as replaceFile, F as loadWorldParts, I as PRESET_FILE$1, L as presetMessage, O as uploadWorldEntityImage, S as generateWorldEntityImage, T as removeWorldTrigger, U as languageOfDocuments, V as translateMessage, W as readWorldDocuments, _ as editWorldPlots$1, a as deleteWorldPackFile, b as entityFolder, c as createAuthoredEntity, f as editWorldCharacter$1, g as editWorldPlace$1, h as editWorldNarrationVoice, j as writeWorldTrigger, k as worldCharacterPortraitFile, l as deleteAuthoredEntity, m as editWorldLore$1, n as packFileProblem, p as editWorldFaction$1, t as MAX_PACK_TEXT, u as readAuthoredEntityDocument, v as editWorldRelation$1, w as readWorldTrigger, x as generateWorldCharacterPortrait, y as editWorldThing$1, z as editWorldInfo } from "./pack-jail-
|
|
10
|
-
import { n as readPreset, r as selectPrompts, t as previewPreset } from "./preset-
|
|
11
|
-
import { a as lorebookImportMessage, d as selectEntries, l as previewLorebook, s as lorebookChatSessionId, t as LOREBOOK_UPLOAD, u as readLorebook } from "./lorebook-author-tools-
|
|
12
|
-
import { a as presetChatSessionId, n as narrationImportMessage } from "./preset-author-tools-
|
|
10
|
+
import { A as worldEntityImageFile, B as readWorldInfo, C as readWorldEditor, D as uploadWorldCharacterPortrait, E as replaceFile, F as loadWorldParts, I as PRESET_FILE$1, L as presetMessage, O as uploadWorldEntityImage, S as generateWorldEntityImage, T as removeWorldTrigger, U as languageOfDocuments, V as translateMessage, W as readWorldDocuments, _ as editWorldPlots$1, a as deleteWorldPackFile, b as entityFolder, c as createAuthoredEntity, f as editWorldCharacter$1, g as editWorldPlace$1, h as editWorldNarrationVoice, j as writeWorldTrigger, k as worldCharacterPortraitFile, l as deleteAuthoredEntity, m as editWorldLore$1, n as packFileProblem, p as editWorldFaction$1, t as MAX_PACK_TEXT, u as readAuthoredEntityDocument, v as editWorldRelation$1, w as readWorldTrigger, x as generateWorldCharacterPortrait, y as editWorldThing$1, z as editWorldInfo } from "./pack-jail-BKFmbYP8.js";
|
|
11
|
+
import { n as readPreset, r as selectPrompts, t as previewPreset } from "./preset-CJLW8Mp0.js";
|
|
12
|
+
import { a as lorebookImportMessage, d as selectEntries, l as previewLorebook, s as lorebookChatSessionId, t as LOREBOOK_UPLOAD, u as readLorebook } from "./lorebook-author-tools-C-cFiE6E.js";
|
|
13
|
+
import { a as presetChatSessionId, n as narrationImportMessage } from "./preset-author-tools-1RstgEZs.js";
|
|
13
14
|
import { t as doctorChatSessionId } from "./doctor-chat-ByDfCMeo.js";
|
|
14
|
-
import { _ as API_PREFIX, a as packIds, c as describePack, d as packPath, f as readPack, l as isPackId, m as PACK_LIMITS, n as anyTab, o as syncWorldPacks, r as copyWorldPacks, s as worldPackStates, t as activePack, u as packFile } from "./packs-
|
|
15
|
+
import { _ as API_PREFIX, a as packIds, c as describePack, d as packPath, f as readPack, l as isPackId, m as PACK_LIMITS, n as anyTab, o as syncWorldPacks, r as copyWorldPacks, s as worldPackStates, t as activePack, u as packFile } from "./packs-ZTG7fWut.js";
|
|
15
16
|
import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-CO8usAjE.js";
|
|
16
17
|
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-C7VOJ3xH.js";
|
|
17
18
|
import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
|
|
@@ -3894,6 +3895,14 @@ function createApiHandler({ catalogue, worlds, createWorld, starter, authorWorld
|
|
|
3894
3895
|
throw error;
|
|
3895
3896
|
}
|
|
3896
3897
|
} },
|
|
3898
|
+
"/sessions/decisions": { GET: async (_req, res, url) => {
|
|
3899
|
+
try {
|
|
3900
|
+
sendJson(res, 200, sessions.decisions(url.searchParams.get("id") ?? ""));
|
|
3901
|
+
} catch (error) {
|
|
3902
|
+
if (error instanceof SessionNotFoundError) return sendError(res, 404, error.message);
|
|
3903
|
+
throw error;
|
|
3904
|
+
}
|
|
3905
|
+
} },
|
|
3897
3906
|
"/sessions/notes": { GET: async (_req, res, url) => {
|
|
3898
3907
|
try {
|
|
3899
3908
|
sendJson(res, 200, sessions.notes(url.searchParams.get("id") ?? ""));
|
|
@@ -5941,6 +5950,25 @@ function readInterventions(session) {
|
|
|
5941
5950
|
});
|
|
5942
5951
|
}
|
|
5943
5952
|
//#endregion
|
|
5953
|
+
//#region src/host/decisions/status.ts
|
|
5954
|
+
/**
|
|
5955
|
+
* Whether a decision service is there, which one, and what was kept about how the story's decisions went.
|
|
5956
|
+
* @throws {SessionNotFoundError} for an id that names no session.
|
|
5957
|
+
*/
|
|
5958
|
+
function decisionsOfSession(deps, id) {
|
|
5959
|
+
const sessions = deps.sessionsDir();
|
|
5960
|
+
if (!isSessionId(id) || !existsSync(sessionDatabase(sessions, id))) throw new SessionNotFoundError(`no session "${id}"`);
|
|
5961
|
+
const service = deps.service();
|
|
5962
|
+
return {
|
|
5963
|
+
available: service !== void 0,
|
|
5964
|
+
...service === void 0 ? {} : {
|
|
5965
|
+
provider: service.provider,
|
|
5966
|
+
model: service.model
|
|
5967
|
+
},
|
|
5968
|
+
stats: readDecisionStats(sessionFolder(sessions, id))
|
|
5969
|
+
};
|
|
5970
|
+
}
|
|
5971
|
+
//#endregion
|
|
5944
5972
|
//#region src/host/sessions/open-session.ts
|
|
5945
5973
|
/** Make sure a session has its DSH chat, so that it can be opened. */
|
|
5946
5974
|
async function openSession(deps, id) {
|
|
@@ -7802,6 +7830,10 @@ function apply(ctx, config) {
|
|
|
7802
7830
|
if (!isSessionId(id) || !existsSync(sessionDatabase(sessions, id))) throw new SessionNotFoundError(`no session "${id}"`);
|
|
7803
7831
|
resetVectors(ctx.roleplayState.openSession(sessions, id));
|
|
7804
7832
|
},
|
|
7833
|
+
decisions: (id) => decisionsOfSession({
|
|
7834
|
+
sessionsDir: deps.sessionsDir,
|
|
7835
|
+
service: () => ctx.get("decisions")
|
|
7836
|
+
}, id),
|
|
7805
7837
|
notes: (id) => notesOfSession({
|
|
7806
7838
|
sessionsDir: deps.sessionsDir,
|
|
7807
7839
|
open: (sessionId) => ctx.roleplayState.openSession(deps.sessionsDir(), sessionId)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Bt as ImportCardError, Ct as readLorebook$1, Et as writeLorebookEntry, Gt as LORE_SCOPES, J as withPlayer, K as cleanText, St as lorebookDirectory, Tt as updateLorebookInfo, Wt as LORE_KINDS, _t as deleteLorebookEntry, i as contextOf, q as partsOf, r as MAX_PREVIEW_TEXT, st as IMPORT_FOLDER, vt as entriesOf, xt as loadLorebook } from "./authoring-tools-
|
|
2
|
-
import { n as createPresetFromGuidance } from "./presets-
|
|
3
|
-
import "./narration-
|
|
4
|
-
import {
|
|
1
|
+
import { Bt as ImportCardError, Ct as readLorebook$1, Et as writeLorebookEntry, Gt as LORE_SCOPES, J as withPlayer, K as cleanText, St as lorebookDirectory, Tt as updateLorebookInfo, Wt as LORE_KINDS, _t as deleteLorebookEntry, i as contextOf, q as partsOf, r as MAX_PREVIEW_TEXT, st as IMPORT_FOLDER, vt as entriesOf, xt as loadLorebook } from "./authoring-tools-BGzzW6O5.js";
|
|
2
|
+
import { n as createPresetFromGuidance } from "./presets-DcPCnn8O.js";
|
|
3
|
+
import "./narration-_dA9oIt2.js";
|
|
4
|
+
import { nt as shippedPromptsDirectory } from "./hooks-BLperIIB.js";
|
|
5
5
|
import { b as slug, v as mapLimit, x as uniqueKey } from "./library-DsDc6fQa.js";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -691,4 +691,4 @@ async function lorebookApproval(exec, next, state) {
|
|
|
691
691
|
//#endregion
|
|
692
692
|
export { lorebookImportMessage as a, lorebookOfChat as c, selectEntries as d, lorebookAuthorTools as i, previewLorebook as l, LorebookReader as n, pendingTargets as o, lorebookApproval as r, lorebookChatSessionId as s, LOREBOOK_UPLOAD as t, readLorebook as u };
|
|
693
693
|
|
|
694
|
-
//# sourceMappingURL=lorebook-author-tools-
|
|
694
|
+
//# sourceMappingURL=lorebook-author-tools-C-cFiE6E.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { St as lorebookDirectory, n as limitAuthoringAgents } from "./authoring-tools-
|
|
2
|
-
import "./hooks-
|
|
3
|
-
import { c as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-
|
|
1
|
+
import { St as lorebookDirectory, n as limitAuthoringAgents } from "./authoring-tools-BGzzW6O5.js";
|
|
2
|
+
import "./hooks-BLperIIB.js";
|
|
3
|
+
import { c as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-C-cFiE6E.js";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { existsSync, readdirSync } from "node:fs";
|
|
6
6
|
//#region src/lorebook-authoring.ts
|
|
@@ -132,6 +132,51 @@ const VARIABLE_VISIBILITIES = [
|
|
|
132
132
|
builtin: true
|
|
133
133
|
}));
|
|
134
134
|
//#endregion
|
|
135
|
+
//#region src/shared/decisions.ts
|
|
136
|
+
/** The places where a language model's closed-choice judgement can be given to a decision model instead, or, for the gates, a check can be made at all. */
|
|
137
|
+
const DECISION_SITES = [
|
|
138
|
+
"triggers",
|
|
139
|
+
"reflection",
|
|
140
|
+
"agency",
|
|
141
|
+
"refusal",
|
|
142
|
+
"rules",
|
|
143
|
+
"secrets"
|
|
144
|
+
];
|
|
145
|
+
/** The sites that check what the game master delivers to the player. They are off unless a chat turns one on: a check costs a request, or at least a call, in every turn. */
|
|
146
|
+
const GATE_SITES = ["agency", "refusal"];
|
|
147
|
+
const EXTRA_MODES = ["off", "on"];
|
|
148
|
+
/**
|
|
149
|
+
* Who makes a site's judgements.
|
|
150
|
+
* - `llm`: the language model, as before.
|
|
151
|
+
* - `decision`: the decision model alone; a judgement it is not confident of counts as "no".
|
|
152
|
+
* - `hybrid`: the decision model where it is confident, the language model for the rest.
|
|
153
|
+
* - `shadow`: both, acting on the language model's answer and recording whether the decision model agreed.
|
|
154
|
+
*/
|
|
155
|
+
const DECISION_MODES = [
|
|
156
|
+
"llm",
|
|
157
|
+
"decision",
|
|
158
|
+
"hybrid",
|
|
159
|
+
"shadow"
|
|
160
|
+
];
|
|
161
|
+
/** What a gate can be set to: the modes of any site, or off. */
|
|
162
|
+
const GATE_MODES = ["off", ...DECISION_MODES];
|
|
163
|
+
const emptySiteStats = () => ({
|
|
164
|
+
runs: 0,
|
|
165
|
+
items: 0,
|
|
166
|
+
decided: 0,
|
|
167
|
+
escalated: 0,
|
|
168
|
+
fallbacks: 0,
|
|
169
|
+
agreed: 0,
|
|
170
|
+
disagreed: 0,
|
|
171
|
+
decisionMs: 0,
|
|
172
|
+
llmMs: 0,
|
|
173
|
+
samples: []
|
|
174
|
+
});
|
|
175
|
+
const emptyStats = (since) => ({
|
|
176
|
+
since,
|
|
177
|
+
sites: Object.fromEntries(DECISION_SITES.map((site) => [site, emptySiteStats()]))
|
|
178
|
+
});
|
|
179
|
+
//#endregion
|
|
135
180
|
//#region src/shared/rules.ts
|
|
136
181
|
/** The key under which a session keeps the rules of its world, which it copies at the start so that it stays whole without the world's files. */
|
|
137
182
|
const WORLD_RULES_KEY = "rules";
|
|
@@ -262,6 +307,16 @@ const SETTINGS_SPEC = {
|
|
|
262
307
|
cueTurns: integer(1, 20, 2),
|
|
263
308
|
judgedPerTurn: integer(0, 5, 2)
|
|
264
309
|
},
|
|
310
|
+
decisions: {
|
|
311
|
+
triggers: choice(DECISION_MODES, "llm"),
|
|
312
|
+
reflection: choice(DECISION_MODES, "llm"),
|
|
313
|
+
agency: choice(GATE_MODES, "off"),
|
|
314
|
+
refusal: choice(GATE_MODES, "off"),
|
|
315
|
+
rules: choice(EXTRA_MODES, "off"),
|
|
316
|
+
secrets: choice(EXTRA_MODES, "off"),
|
|
317
|
+
gateThreshold: ratio(.1, .95, .5),
|
|
318
|
+
confidence: ratio(0, 1, .7)
|
|
319
|
+
},
|
|
265
320
|
interface: { pack: text(60, "") },
|
|
266
321
|
rewind: { keepSnapshots: integer(0, 500, 30) },
|
|
267
322
|
rules: { own: text(MAX_OWN_RULES, "") },
|
|
@@ -524,6 +579,6 @@ function decodeOutput(text) {
|
|
|
524
579
|
}
|
|
525
580
|
}
|
|
526
581
|
//#endregion
|
|
527
|
-
export {
|
|
582
|
+
export { emptyStats as _, liveSettings as a, VARIABLE_VISIBILITIES as b, writeSettings as c, parseSettings as d, parseSwitchboard as f, GATE_SITES as g, DECISION_SITES as h, InvalidSettingsError as i, DEFAULT_SETTINGS as l, rulesOf as m, encodeOutput as n, readSettings as o, WORLD_RULES_KEY as p, encodePreview as r, useChildReasoning as s, decodeOutput as t, SETTINGS_SPEC as u, VARIABLE_KINDS as v, VARIABLE_SUBJECTS as y };
|
|
528
583
|
|
|
529
|
-
//# sourceMappingURL=narration-
|
|
584
|
+
//# sourceMappingURL=narration-_dA9oIt2.js.map
|