@dsh-agentic-roleplay/core 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{access-CfQWbNZP.js → access-CXtaZNbx.js} +50 -2
- package/lib/{authoring-tools-C_l07RYn.js → authoring-tools-B4mEdKp_.js} +144 -58
- package/lib/authoring.js +7 -7
- package/lib/{child-lYYeOwl2.js → child-Dtv76jNx.js} +116 -11
- package/lib/client.js +2805 -790
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +3 -3
- package/lib/doctor.js +3 -3
- package/lib/{gallery-q7niLtWn.js → gallery-BZJleAeH.js} +5 -9
- package/lib/{generator-BpjPrvHe.js → generator-Cg6CQc5S.js} +2 -2
- package/lib/helper.js +1 -1
- package/lib/{hooks-DNaDzMjW.js → hooks-DTjHWTfx.js} +132 -25
- package/lib/images.js +4 -4
- package/lib/index.js +362 -33
- package/lib/{library-CIkxhf_R.js → library-GIlrkOim.js} +6 -13
- package/lib/{lorebook-author-tools-BiMDmdFi.js → lorebook-author-tools-BCFFJSle.js} +6 -6
- package/lib/lorebook-authoring.js +4 -4
- package/lib/{narration-CjB_KwwY.js → narration-BVzew4-K.js} +7 -52
- package/lib/orchestration.js +155 -10
- package/lib/{pack-jail-B35Vx3hT.js → pack-jail-hsNQNTOf.js} +10 -10
- package/lib/{packs-BajKw7S9.js → packs-UpK_cvI4.js} +2 -2
- package/lib/{presenter-agent-jgtuTwZr.js → presenter-agent-DZOgBOR9.js} +12 -17
- package/lib/{preset-DWgkcPau.js → preset-Cyoj1ZWa.js} +4 -4
- package/lib/{preset-author-tools-BhuYIKms.js → preset-author-tools-RSta6pHK.js} +6 -6
- package/lib/preset-authoring.js +5 -5
- package/lib/{presets-9GzaSELc.js → presets-CvpsW_10.js} +7 -8
- package/lib/{reflection-4L0Plvct.js → reflection-0qTvw2It.js} +53 -26
- package/lib/{turn-guard-sCUXmp-5.js → turn-guard-BzNeGNnc.js} +3 -3
- package/package.json +2 -2
- package/prompts/en/checks/conflict.md +1 -1
- package/prompts/en/checks/decide-conflict.md +1 -1
- package/prompts/en/checks/decide-opening.md +1 -1
- package/prompts/en/checks/decide-same-value.md +1 -1
- package/prompts/en/checks/decide-sheet.md +1 -1
- package/prompts/en/checks/fidelity.md +1 -0
- package/prompts/zh/checks/conflict.md +1 -1
- package/prompts/zh/checks/decide-conflict.md +1 -1
- package/prompts/zh/checks/decide-opening.md +1 -1
- package/prompts/zh/checks/decide-same-value.md +1 -1
- package/prompts/zh/checks/decide-sheet.md +1 -1
- package/prompts/zh/checks/fidelity.md +1 -0
package/lib/compaction.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as liveSettings, t as decodeOutput } from "./narration-
|
|
2
|
-
import {
|
|
3
|
-
import { c as runChild, n as childModel, r as childSampling
|
|
1
|
+
import { a as liveSettings, t as decodeOutput } from "./narration-BVzew4-K.js";
|
|
2
|
+
import { l as roleplaySessionOf, t as promptFor } from "./access-CXtaZNbx.js";
|
|
3
|
+
import { S as tokensOf, c as runChild, n as childModel, r as childSampling } from "./child-Dtv76jNx.js";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { sessionFolder } from "@dsh-agentic-roleplay/state";
|
|
6
6
|
import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
|
package/lib/doctor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as chatSessionId } from "./access-CXtaZNbx.js";
|
|
2
2
|
import { n as doctorSessionOf } from "./doctor-chat-hL1a61hp.js";
|
|
3
|
-
import { i as externalTools, t as externalToolLimit } from "./hooks-
|
|
4
|
-
import { a as liveSettings } from "./narration-
|
|
3
|
+
import { i as externalTools, t as externalToolLimit } from "./hooks-DTjHWTfx.js";
|
|
4
|
+
import { a as liveSettings } from "./narration-BVzew4-K.js";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as atomicWrite } from "./access-CXtaZNbx.js";
|
|
2
|
+
import { _ as writeImageFileMetadata, a as LIBRARY_FOLDER, g as sidecarOf, h as readImageFileMetadata, m as mediaTypeOf, x as mapLimit } from "./library-GIlrkOim.js";
|
|
2
3
|
import { join, sep } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import { lstat, mkdir, readFile, readdir, realpath, rename, stat, writeFile } from "node:fs/promises";
|
|
4
|
+
import { lstat, readFile, readdir, realpath, stat } from "node:fs/promises";
|
|
5
5
|
// src/host/images/gallery.ts
|
|
6
6
|
const READ_AT_ONCE = 8;
|
|
7
7
|
const SEGMENT = /^[\p{L}\p{N}][\p{L}\p{N}\p{M}._-]{0,199}$/u;
|
|
@@ -95,11 +95,7 @@ async function readCache(images) {
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
async function writeCache(images, cache) {
|
|
98
|
-
await
|
|
99
|
-
const file = join(images, CACHE_FILE);
|
|
100
|
-
const temporary = `${file}.${process.pid}.${randomUUID()}.writing`;
|
|
101
|
-
await writeFile(temporary, JSON.stringify(cache));
|
|
102
|
-
await rename(temporary, file);
|
|
98
|
+
await atomicWrite(join(images, CACHE_FILE), JSON.stringify(cache), { createDirectory: true });
|
|
103
99
|
}
|
|
104
100
|
/**
|
|
105
101
|
* Every image of a session folder with what its file says, newest first. The files are the truth; `images/.index.json` only remembers what
|
|
@@ -191,4 +187,4 @@ async function updateImage(sessionFolder, path, update) {
|
|
|
191
187
|
}
|
|
192
188
|
export { updateImage as i, galleryFile as n, listGallery as r, describeGalleryImage as t };
|
|
193
189
|
|
|
194
|
-
//# sourceMappingURL=gallery-
|
|
190
|
+
//# sourceMappingURL=gallery-BZJleAeH.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as sceneImagePath, f as writeImage, u as referenceImagePath } from "./library-
|
|
1
|
+
import { d as sceneImagePath, f as writeImage, u as referenceImagePath } from "./library-GIlrkOim.js";
|
|
2
2
|
// src/host/images/generator.ts
|
|
3
3
|
const unique = (values) => [...new Set(values.map((value) => value.trim()).filter((value) => value !== ""))];
|
|
4
4
|
/** What a reference image shows: the subject and its stable look. */
|
|
@@ -141,4 +141,4 @@ async function generateTransientImage(service, request) {
|
|
|
141
141
|
}
|
|
142
142
|
export { uploadReferenceImage as a, transientPrompt as i, generateTransientImage as n, referencePrompt as r, generateReferenceImage as t };
|
|
143
143
|
|
|
144
|
-
//# sourceMappingURL=generator-
|
|
144
|
+
//# sourceMappingURL=generator-Cg6CQc5S.js.map
|
package/lib/helper.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as
|
|
1
|
+
import { l as roleplaySessionOf, t as promptFor } from "./access-CXtaZNbx.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-BVzew4-K.js";
|
|
3
3
|
import { i as translator, r as languageOf$1, t as trimCharacters } from "./text-CbGQhK1-.js";
|
|
4
|
-
import { a as childTrace, c as runChild, f as tokensOf, m as
|
|
4
|
+
import { _ as addTokens, a as childTrace, c as runChild, f as requestsOf, g as NO_TOKENS, h as tokensOf, m as estimateTokens, n as childModel, p as blockText, r as childSampling, x as estimateAnswer } from "./child-Dtv76jNx.js";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
import { copyFileSync, cpSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { readFile, stat } from "node:fs/promises";
|
|
@@ -1024,7 +1024,7 @@ const NOTE_KINDS = [
|
|
|
1024
1024
|
"world"
|
|
1025
1025
|
];
|
|
1026
1026
|
// src/host/sessions/notes.ts
|
|
1027
|
-
const KEY$
|
|
1027
|
+
const KEY$5 = "notes";
|
|
1028
1028
|
const isNote = (value) => {
|
|
1029
1029
|
if (typeof value !== "object" || value === null) return false;
|
|
1030
1030
|
const note = value;
|
|
@@ -1032,12 +1032,12 @@ const isNote = (value) => {
|
|
|
1032
1032
|
};
|
|
1033
1033
|
/** The notes of a session, at most one per kind. */
|
|
1034
1034
|
function readNotes(session) {
|
|
1035
|
-
const stored = session.metadata.getValue(KEY$
|
|
1035
|
+
const stored = session.metadata.getValue(KEY$5);
|
|
1036
1036
|
return Array.isArray(stored) ? stored.filter(isNote) : [];
|
|
1037
1037
|
}
|
|
1038
1038
|
/** Replaces the note of the same kind. */
|
|
1039
1039
|
function putNote(session, note) {
|
|
1040
|
-
session.metadata.setValue(KEY$
|
|
1040
|
+
session.metadata.setValue(KEY$5, [...readNotes(session).filter((existing) => existing.kind !== note.kind), note]);
|
|
1041
1041
|
}
|
|
1042
1042
|
/** The most lines one note keeps: what is past it is not told. */
|
|
1043
1043
|
const MAX_NOTE_LINES = 8;
|
|
@@ -1052,7 +1052,7 @@ function addToNote(session, kind, turn, lines) {
|
|
|
1052
1052
|
}
|
|
1053
1053
|
/** Removes every note: they belong to the turn that made them. */
|
|
1054
1054
|
function clearNotes(session) {
|
|
1055
|
-
if (readNotes(session).length > 0) session.metadata.setValue(KEY$
|
|
1055
|
+
if (readNotes(session).length > 0) session.metadata.setValue(KEY$5, []);
|
|
1056
1056
|
}
|
|
1057
1057
|
/**
|
|
1058
1058
|
* The notes of a session, for the player's screen.
|
|
@@ -1069,11 +1069,54 @@ function notesOfSession(deps, id) {
|
|
|
1069
1069
|
count: waiting
|
|
1070
1070
|
}];
|
|
1071
1071
|
}
|
|
1072
|
+
// src/host/diagnostics/master-trace.ts
|
|
1073
|
+
const cut = (text) => text.length > 240 ? `${text.slice(0, 240)}…` : text;
|
|
1074
|
+
const textOf = (message) => Array.isArray(message?.content) ? message.content.map(blockText).join("") : typeof message?.content === "string" ? message.content : "";
|
|
1075
|
+
/**
|
|
1076
|
+
* What the chat's log says of one turn of the game master: how long it waited before its first request, each request with the parts of its prompt, each tool call with its time and the
|
|
1077
|
+
* reason when it was refused, and what the harness said to it to keep the turn going. `events` are those from the turn's start to its end.
|
|
1078
|
+
*/
|
|
1079
|
+
function masterTrace(events) {
|
|
1080
|
+
const start = events.find((event) => event.type === "turn/start");
|
|
1081
|
+
const end = events.findLast((event) => event.type === "turn/end");
|
|
1082
|
+
const first = events.find((event) => event.type === "step/start");
|
|
1083
|
+
const pending = /* @__PURE__ */ new Map();
|
|
1084
|
+
const calls = [];
|
|
1085
|
+
const steered = [];
|
|
1086
|
+
let answered = false;
|
|
1087
|
+
for (const event of events) {
|
|
1088
|
+
const data = event.data;
|
|
1089
|
+
if (event.type === "assistant/message") answered = true;
|
|
1090
|
+
else if (event.type === "tool/call" && data?.callId !== void 0 && data.name !== void 0) pending.set(data.callId, {
|
|
1091
|
+
tool: data.name,
|
|
1092
|
+
at: event.time ?? 0
|
|
1093
|
+
});
|
|
1094
|
+
else if (event.type === "tool/result") {
|
|
1095
|
+
const message = data?.message;
|
|
1096
|
+
const call = message?.toolCallId === void 0 ? void 0 : pending.get(message.toolCallId);
|
|
1097
|
+
if (call !== void 0 && calls.length < 60) calls.push({
|
|
1098
|
+
tool: call.tool,
|
|
1099
|
+
...event.time === void 0 ? {} : { ms: Math.max(0, event.time - call.at) },
|
|
1100
|
+
failed: message?.isError === true,
|
|
1101
|
+
note: cut(textOf(message))
|
|
1102
|
+
});
|
|
1103
|
+
} else if (event.type === "user/message" && answered && data?.source?.kind === "roleplay" && steered.length < 20) steered.push(cut(textOf(data)));
|
|
1104
|
+
}
|
|
1105
|
+
const requests = requestsOf(events);
|
|
1106
|
+
return {
|
|
1107
|
+
startedAt: start?.time ?? 0,
|
|
1108
|
+
...end?.time === void 0 ? {} : { endedAt: end.time },
|
|
1109
|
+
...start?.time === void 0 || first?.time === void 0 ? {} : { beforeMs: Math.max(0, first.time - start.time) },
|
|
1110
|
+
...requests.length === 0 ? {} : { requests },
|
|
1111
|
+
...calls.length === 0 ? {} : { calls },
|
|
1112
|
+
...steered.length === 0 ? {} : { steered }
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1072
1115
|
// src/host/triggers/deliver.ts
|
|
1073
|
-
const KEY$
|
|
1116
|
+
const KEY$4 = "triggers.withdrawn";
|
|
1074
1117
|
/** Why a note was withdrawn instead of told, by the number of the note. */
|
|
1075
1118
|
function readWithdrawn(session) {
|
|
1076
|
-
const stored = session.metadata.getValue(KEY$
|
|
1119
|
+
const stored = session.metadata.getValue(KEY$4);
|
|
1077
1120
|
if (!Array.isArray(stored)) return {};
|
|
1078
1121
|
return Object.fromEntries(stored.flatMap((entry) => {
|
|
1079
1122
|
const { note, reason } = entry ?? {};
|
|
@@ -1092,7 +1135,7 @@ function deliverNow(session, notes, clock) {
|
|
|
1092
1135
|
note: Number(note),
|
|
1093
1136
|
reason
|
|
1094
1137
|
}));
|
|
1095
|
-
session.metadata.setValue(KEY$
|
|
1138
|
+
session.metadata.setValue(KEY$4, [...before, ...withdrawn.map(({ note, reason }) => ({
|
|
1096
1139
|
note: note.id,
|
|
1097
1140
|
reason
|
|
1098
1141
|
}))].slice(-100));
|
|
@@ -1103,9 +1146,9 @@ function deliverNow(session, notes, clock) {
|
|
|
1103
1146
|
}));
|
|
1104
1147
|
}
|
|
1105
1148
|
// src/host/triggers/judged.ts
|
|
1106
|
-
const KEY$
|
|
1149
|
+
const KEY$3 = "triggers.judged";
|
|
1107
1150
|
function readVerdicts(session) {
|
|
1108
|
-
const stored = session.metadata.getValue(KEY$
|
|
1151
|
+
const stored = session.metadata.getValue(KEY$3);
|
|
1109
1152
|
if (typeof stored !== "object" || stored === null || Array.isArray(stored)) return {};
|
|
1110
1153
|
const verdicts = {};
|
|
1111
1154
|
for (const [statement, value] of Object.entries(stored)) {
|
|
@@ -1119,7 +1162,7 @@ function readVerdicts(session) {
|
|
|
1119
1162
|
}
|
|
1120
1163
|
/** Keeps the verdicts of the given statements as they stand and drops every other: a statement no trigger waits on is no longer judged. */
|
|
1121
1164
|
function writeVerdicts(session, verdicts, keep) {
|
|
1122
|
-
session.metadata.setValue(KEY$
|
|
1165
|
+
session.metadata.setValue(KEY$3, Object.fromEntries(Object.entries(verdicts).filter(([statement]) => keep.has(statement))));
|
|
1123
1166
|
}
|
|
1124
1167
|
/** For `runTriggers`: a statement is true when its last verdict says so, and false when nobody judged it. */
|
|
1125
1168
|
const verdictReader = (session) => {
|
|
@@ -1252,6 +1295,32 @@ function noteStore(session, settings, clock) {
|
|
|
1252
1295
|
}
|
|
1253
1296
|
};
|
|
1254
1297
|
}
|
|
1298
|
+
// src/host/sessions/trace.ts
|
|
1299
|
+
const KEY$2 = "trace";
|
|
1300
|
+
const isTrace = (value) => typeof value === "object" && value !== null && typeof value.turn === "number" && typeof value.startedAt === "number";
|
|
1301
|
+
/** What the story kept of each turn's work, oldest first. It belongs to the story's state, so taking the story back takes the turns that no longer count with it. */
|
|
1302
|
+
function readTraces(session) {
|
|
1303
|
+
const stored = session.metadata.getValue(KEY$2);
|
|
1304
|
+
return Array.isArray(stored) ? stored.filter(isTrace) : [];
|
|
1305
|
+
}
|
|
1306
|
+
/** Adds to a turn's trace what one source of it knows; the sources (the characters' briefs, the scene, the log at the end of the turn) arrive at different times. */
|
|
1307
|
+
function updateTrace(session, turn, patch, merge) {
|
|
1308
|
+
const all = readTraces(session);
|
|
1309
|
+
const at = all.findIndex((entry) => entry.turn === turn);
|
|
1310
|
+
const current = at === -1 ? {
|
|
1311
|
+
turn,
|
|
1312
|
+
startedAt: 0
|
|
1313
|
+
} : all[at];
|
|
1314
|
+
const next = {
|
|
1315
|
+
...current,
|
|
1316
|
+
...patch,
|
|
1317
|
+
...merge?.(current)
|
|
1318
|
+
};
|
|
1319
|
+
if (at === -1) all.push(next);
|
|
1320
|
+
else all[at] = next;
|
|
1321
|
+
all.sort((a, b) => a.turn - b.turn);
|
|
1322
|
+
session.metadata.setValue(KEY$2, all.slice(-30));
|
|
1323
|
+
}
|
|
1255
1324
|
// src/host/sessions/activity.ts
|
|
1256
1325
|
const KEY$1 = "activity";
|
|
1257
1326
|
const isEntry = (value) => {
|
|
@@ -1363,7 +1432,7 @@ function readUsage(session) {
|
|
|
1363
1432
|
return Array.isArray(stored) ? stored.filter(isUsage) : [];
|
|
1364
1433
|
}
|
|
1365
1434
|
/** Adds tokens to a turn's record: the game master's own, or a helper's run. */
|
|
1366
|
-
function addUsage(session, turn, who, tokens) {
|
|
1435
|
+
function addUsage(session, turn, who, tokens, masterMs) {
|
|
1367
1436
|
const all = readUsage(session);
|
|
1368
1437
|
const at = all.findIndex((entry) => entry.turn === turn);
|
|
1369
1438
|
const entry = at === -1 ? {
|
|
@@ -1374,7 +1443,8 @@ function addUsage(session, turn, who, tokens) {
|
|
|
1374
1443
|
} : all[at];
|
|
1375
1444
|
const next = who === "master" ? {
|
|
1376
1445
|
...entry,
|
|
1377
|
-
master: addTokens(entry.master, tokens)
|
|
1446
|
+
master: addTokens(entry.master, tokens),
|
|
1447
|
+
...masterMs === void 0 ? {} : { masterMs: (entry.masterMs ?? 0) + masterMs }
|
|
1378
1448
|
} : {
|
|
1379
1449
|
...entry,
|
|
1380
1450
|
helpers: addTokens(entry.helpers, tokens),
|
|
@@ -2089,8 +2159,11 @@ function storeOf(session, folder, problem, queryVector, wall, prompt) {
|
|
|
2089
2159
|
});
|
|
2090
2160
|
return used;
|
|
2091
2161
|
},
|
|
2092
|
-
recordUsage: (turn, tokens) => {
|
|
2093
|
-
addUsage(session, turn, "master", tokens);
|
|
2162
|
+
recordUsage: (turn, tokens, ms) => {
|
|
2163
|
+
addUsage(session, turn, "master", tokens, ms);
|
|
2164
|
+
},
|
|
2165
|
+
recordTrace: (turn, patch, merge) => {
|
|
2166
|
+
updateTrace(session, turn, patch, merge);
|
|
2094
2167
|
},
|
|
2095
2168
|
notes: () => readNotes(session),
|
|
2096
2169
|
clearNotes: () => {
|
|
@@ -3478,7 +3551,17 @@ function installHooks(ctx, deps) {
|
|
|
3478
3551
|
const events = session.snapshotEvents();
|
|
3479
3552
|
const began = events.findLastIndex((entry) => entry.type === "turn/start");
|
|
3480
3553
|
const start = began === -1 ? void 0 : events[began];
|
|
3481
|
-
if (start?.type
|
|
3554
|
+
if (start?.type !== "turn/start") return;
|
|
3555
|
+
const store = stores(session.id);
|
|
3556
|
+
store?.recordUsage?.(start.data.turn, tokensOf(events.slice(began)), Math.max(0, event.time - start.time));
|
|
3557
|
+
try {
|
|
3558
|
+
store?.recordTrace?.(start.data.turn, {
|
|
3559
|
+
...masterTrace(events.slice(began)),
|
|
3560
|
+
endedAt: event.time
|
|
3561
|
+
});
|
|
3562
|
+
} catch (error) {
|
|
3563
|
+
ctx.logger.warn(`roleplay: the trace of turn ${start.data.turn} could not be kept: ${error instanceof Error ? error.message : String(error)}`);
|
|
3564
|
+
}
|
|
3482
3565
|
});
|
|
3483
3566
|
ctx.on("agent/created", async ({ agent }) => {
|
|
3484
3567
|
const { header } = agent.session;
|
|
@@ -3543,7 +3626,20 @@ function installHooks(ctx, deps) {
|
|
|
3543
3626
|
upcoming: store.upcoming(payload.turn)
|
|
3544
3627
|
};
|
|
3545
3628
|
const tracked = store.tracked();
|
|
3629
|
+
const sections = [];
|
|
3630
|
+
let selection;
|
|
3546
3631
|
const lines = [boundaries().sceneContext.scene({
|
|
3632
|
+
report: {
|
|
3633
|
+
section: (id, text) => {
|
|
3634
|
+
sections.push({
|
|
3635
|
+
id,
|
|
3636
|
+
tokens: estimateTokens(text)
|
|
3637
|
+
});
|
|
3638
|
+
},
|
|
3639
|
+
selected: (found) => {
|
|
3640
|
+
selection = found;
|
|
3641
|
+
}
|
|
3642
|
+
},
|
|
3547
3643
|
...tracked.length === 0 ? {} : { tracked },
|
|
3548
3644
|
time: {
|
|
3549
3645
|
now: time,
|
|
@@ -3563,14 +3659,21 @@ function installHooks(ctx, deps) {
|
|
|
3563
3659
|
...queryVector === void 0 ? {} : { queryVector }
|
|
3564
3660
|
})];
|
|
3565
3661
|
const pacing = ooc === void 0 ? pacingAdvice(store, payload.turn) : void 0;
|
|
3566
|
-
|
|
3662
|
+
const addLine = (id, text) => {
|
|
3663
|
+
lines.push(text);
|
|
3664
|
+
sections.push({
|
|
3665
|
+
id,
|
|
3666
|
+
tokens: estimateTokens(text)
|
|
3667
|
+
});
|
|
3668
|
+
};
|
|
3669
|
+
if (used !== void 0) addLine("command", [tr("The player used the world's command /{word}: {description} It is part of the story, not an out-of-character command: play it in the story. The world raises and lowers the command's own flag itself: never change it.", {
|
|
3567
3670
|
word: used.word,
|
|
3568
3671
|
description: used.description
|
|
3569
3672
|
}), ...commandBringsPeopleIn(store, used) ? [tr("The world itself brings in anyone this command calls for, after this turn: do not make them up yourself with expand_world.")] : []].join(" "));
|
|
3570
|
-
if (pacing !== void 0)
|
|
3571
|
-
else if (ooc === void 0 && plotAuthorNeeded(store, payload.turn))
|
|
3673
|
+
if (pacing !== void 0) addLine("pacing", describePacingAdvice(pacing));
|
|
3674
|
+
else if (ooc === void 0 && plotAuthorNeeded(store, payload.turn)) addLine("pacing", store.text("roleplay/plot-hint"));
|
|
3572
3675
|
const rules = store.rules();
|
|
3573
|
-
if (rules.length > 0)
|
|
3676
|
+
if (rules.length > 0) addLine("rules", store.text("roleplay/rules", { rules: rules.map((rule) => `- ${rule}`).join("\n") }));
|
|
3574
3677
|
const wanted = ooc === void 0 ? parseRoll(text) : void 0;
|
|
3575
3678
|
if (wanted !== void 0) try {
|
|
3576
3679
|
const made = rollPlain(wanted.expression);
|
|
@@ -3585,7 +3688,7 @@ function installHooks(ctx, deps) {
|
|
|
3585
3688
|
reason: wanted.reason === "" ? tr("the player's roll") : wanted.reason,
|
|
3586
3689
|
by: "player"
|
|
3587
3690
|
});
|
|
3588
|
-
|
|
3691
|
+
addLine("roll", tr("The player rolled {dice} ({reason}) and got {total}: dice {faces}. This is a fact, decided by the dice: take it into account when you judge the attempt and decide what happens.", {
|
|
3589
3692
|
dice: roll.expression,
|
|
3590
3693
|
reason: roll.reason,
|
|
3591
3694
|
total: roll.total,
|
|
@@ -3604,12 +3707,16 @@ function installHooks(ctx, deps) {
|
|
|
3604
3707
|
engine.skip(owner);
|
|
3605
3708
|
lines.push(store.text("roleplay/input-refused", { reason: verdict.reason }));
|
|
3606
3709
|
}
|
|
3710
|
+
store.recordTrace?.(payload.turn, {
|
|
3711
|
+
scene: sections,
|
|
3712
|
+
...selection === void 0 ? {} : { selected: selection }
|
|
3713
|
+
});
|
|
3607
3714
|
return {
|
|
3608
3715
|
...decision,
|
|
3609
3716
|
messages: [...decision.messages, notice(lines.join("\n\n"))]
|
|
3610
3717
|
};
|
|
3611
3718
|
});
|
|
3612
3719
|
}
|
|
3613
|
-
export {
|
|
3720
|
+
export { PromptLibrary as $, RESULTS as A, PLOTS_FILE_NAME as B, notesOfSession as C, describeTime as D, ClockError as E, LANGUAGE_NAMES as F, commandFlagKey as G, parsePlotsFile as H, STORY_LANGUAGES as I, Reader as J, commandsOf as K, isStoryLanguage as L, PLOTS_METADATA_KEY as M, plotProgressOf as N, describeWhen as O, populatePlots as P, PROMPTS_FOLDER as Q, textLanguage as R, addToNote as S, observeAsPlayer as T, plotReferenceProblems as U, loadPlots as V, COMMANDS_KEY as W, errorMessage as X, formatIssue as Y, LANGUAGE_FOLDER as Z, readRunDetail as _, externalWithheld as a, shippedLanguages as at, writeVerdicts as b, record as c, AgentUnavailableError as ct, guardRepeatedCalls as d, ReflectionRefusedError as dt, copyWorldPrompts as et, MAX_OOC_ANSWER as f, SessionArchivedError as ft, readActivity as g, COMPARISONS as gt, readDecisionStats as h, AUTHORING_NEEDS as ht, externalTools as i, promptProblem as it, answerLimits as j, zoneOf as k, characterRunner as l, InvalidStartError as lt, readUsage as m, WorldNotFoundError as mt, installHooks as n, languageOf as nt, PREVIEW_TOOL as o, shippedPromptsDirectory as ot, storesOf as p, SessionNotFoundError as pt, readDocument as q, externalGiven as r, listFiles as rt, createTools$1 as s, shippedText as st, externalToolLimit as t, inheritPrompts as tt, toolEnabled as u, InvalidWorldError as ut, readTraces as v, readNotes as w, readWithdrawn as x, readVerdicts as y, wrongLanguage as z };
|
|
3614
3721
|
|
|
3615
|
-
//# sourceMappingURL=hooks-
|
|
3722
|
+
//# sourceMappingURL=hooks-DTjHWTfx.js.map
|
package/lib/images.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
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-
|
|
2
|
-
import { i as updateImage, r as listGallery } from "./gallery-
|
|
3
|
-
import { c as nextSceneSerial, d as sceneImagePath, l as readImageMetadata, o as entityImageDirectory, s as inheritImages, t as addToLibrary, u as referenceImagePath, v as readPngMetadata, y as withPngMetadata } from "./library-
|
|
4
|
-
import { i as transientPrompt, n as generateTransientImage, r as referencePrompt, t as generateReferenceImage } from "./generator-
|
|
1
|
+
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-DZOgBOR9.js";
|
|
2
|
+
import { i as updateImage, r as listGallery } from "./gallery-BZJleAeH.js";
|
|
3
|
+
import { c as nextSceneSerial, d as sceneImagePath, l as readImageMetadata, o as entityImageDirectory, s as inheritImages, t as addToLibrary, u as referenceImagePath, v as readPngMetadata, y as withPngMetadata } from "./library-GIlrkOim.js";
|
|
4
|
+
import { i as transientPrompt, n as generateTransientImage, r as referencePrompt, t as generateReferenceImage } from "./generator-Cg6CQc5S.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 };
|