@dsh-agentic-roleplay/core 0.4.1 → 0.6.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/{authoring-tools-C2BHkEFP.js → authoring-tools-BGzzW6O5.js} +7 -6
- package/lib/authoring.js +5 -5
- package/lib/{child-DsixtqTw.js → child-D5SVNk4O.js} +58 -71
- package/lib/client.js +747 -316
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +18 -23
- package/lib/doctor.js +2 -2
- package/lib/{gallery-CDYKJf_O.js → gallery-C7VOJ3xH.js} +2 -2
- package/lib/{generator-BR1ugzln.js → generator-CO8usAjE.js} +2 -2
- package/lib/helper.js +26 -0
- package/lib/{hooks-CHmUksFS.js → hooks-BLperIIB.js} +70 -7
- package/lib/images.js +4 -4
- package/lib/index.js +64 -22
- package/lib/{library-COIktKBa.js → library-DsDc6fQa.js} +2 -2
- package/lib/{lorebook-author-tools-CaT74Q7v.js → lorebook-author-tools-C-cFiE6E.js} +6 -6
- package/lib/lorebook-authoring.js +3 -3
- package/lib/{narration-DstnwrvX.js → narration-_dA9oIt2.js} +57 -2
- package/lib/orchestration.js +372 -48
- package/lib/{pack-jail-CEDDI4Xw.js → pack-jail-BKFmbYP8.js} +10 -10
- package/lib/{packs-DB_9xiCp.js → packs-ZTG7fWut.js} +2 -2
- package/lib/{presenter-agent-Gu34bZwd.js → presenter-agent-BHSbyWwZ.js} +5 -5
- package/lib/{preset-BL1d40oG.js → preset-CJLW8Mp0.js} +3 -3
- package/lib/{preset-author-tools-B2wZXKZo.js → preset-author-tools-1RstgEZs.js} +5 -5
- package/lib/preset-authoring.js +4 -4
- package/lib/{presets-Dc15L6OU.js → presets-DcPCnn8O.js} +3 -3
- package/lib/{reflection-BWMVdHhR.js → reflection-6qfOC5OT.js} +236 -32
- package/lib/text-CT1re6XT.js +18 -0
- package/package.json +38 -41
- 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/preset-authoring.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as limitAuthoringAgents } from "./authoring-tools-
|
|
2
|
-
import { c as presetDirectory } from "./presets-
|
|
3
|
-
import "./hooks-
|
|
4
|
-
import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-
|
|
1
|
+
import { n as limitAuthoringAgents } from "./authoring-tools-BGzzW6O5.js";
|
|
2
|
+
import { c as presetDirectory } from "./presets-DcPCnn8O.js";
|
|
3
|
+
import "./hooks-BLperIIB.js";
|
|
4
|
+
import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-1RstgEZs.js";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
//#region src/preset-authoring.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import {
|
|
1
|
+
import { $ as listFiles, J as PROMPTS_FOLDER, Q as languageOf, et as promptProblem, nt as shippedPromptsDirectory, q as LANGUAGE_FOLDER, tt as shippedLanguages } from "./hooks-BLperIIB.js";
|
|
2
|
+
import { c as parseSampling } from "./child-D5SVNk4O.js";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
@@ -354,4 +354,4 @@ async function createPresetFromGuidance(root, request, guidance, shipped = shipp
|
|
|
354
354
|
//#endregion
|
|
355
355
|
export { readWorldPrompt as _, isPresetName as a, INTENT_STATUSES as b, presetDirectory as c, savePresetFromWorld as d, sha as f, listWorldPrompts as g, deleteWorldPrompt as h, deletePreset as i, readPreset as l, PROSE_PROMPTS as m, createPresetFromGuidance as n, listPresets as o, updatePresetInfo as p, createPresetFromShipped as r, loadPreset as s, PRESET_FILE as t, reservePreset as u, writeWorldPrompt as v, INTENT_TYPES as x, INTENT_HORIZONS as y };
|
|
356
356
|
|
|
357
|
-
//# sourceMappingURL=presets-
|
|
357
|
+
//# sourceMappingURL=presets-DcPCnn8O.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { r as roleplaySessionOf, t as promptFor } from "./access-EbNdZFbk.js";
|
|
2
|
-
import { f as sha, o as listPresets, s as loadPreset } from "./presets-
|
|
3
|
-
import "./narration-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { f as sha, o as listPresets, s as loadPreset } from "./presets-DcPCnn8O.js";
|
|
3
|
+
import "./narration-_dA9oIt2.js";
|
|
4
|
+
import { A as answerLimits, D as describeWhen, E as describeTime, J as PROMPTS_FOLDER, R as wrongLanguage, Z as inheritPrompts, dt as translator, ut as languageOf } from "./hooks-BLperIIB.js";
|
|
5
|
+
import { t as trimCharacters } from "./text-CT1re6XT.js";
|
|
6
|
+
import { i as childTrace, m as estimateAnswer, n as childSampling, o as runChild, t as childModel } from "./child-D5SVNk4O.js";
|
|
7
|
+
import { a as inheritImages } from "./library-DsDc6fQa.js";
|
|
8
|
+
import { i as inheritPacks } from "./packs-ZTG7fWut.js";
|
|
8
9
|
import { dirname, join } from "node:path";
|
|
9
10
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
10
11
|
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
@@ -566,6 +567,10 @@ const declinesToAuthor = {
|
|
|
566
567
|
const factionsStayPut = { strategize: () => Promise.resolve({ acted: [] }) };
|
|
567
568
|
/** Reflects on nothing: without a reflector what characters believe changes only through what the story records. */
|
|
568
569
|
const reflectsOnNothing = { reflect: () => Promise.resolve({ characters: [] }) };
|
|
570
|
+
/** Finds no fault: without a gate the output is delivered as the game master wrote it. */
|
|
571
|
+
const passesEverything = { check: () => Promise.resolve([]) };
|
|
572
|
+
/** Finds no broken rule: without a check the game master's judgement of an action stands as it is. */
|
|
573
|
+
const breaksNoRule = { check: () => Promise.resolve([]) };
|
|
569
574
|
/** Judges nothing: without a judge a trigger that waits on a statement never sees it hold. */
|
|
570
575
|
const judgesNothing = { judge: () => Promise.resolve({ judged: 0 }) };
|
|
571
576
|
/** Offers nothing: without a suggester the player writes their own move. */
|
|
@@ -584,6 +589,8 @@ function defaultBoundaries() {
|
|
|
584
589
|
strategist: factionsStayPut,
|
|
585
590
|
reflector: reflectsOnNothing,
|
|
586
591
|
judge: judgesNothing,
|
|
592
|
+
outputGate: passesEverything,
|
|
593
|
+
ruleCheck: breaksNoRule,
|
|
587
594
|
suggester: offersNothing,
|
|
588
595
|
recaller: recordsRecall,
|
|
589
596
|
sceneContext: castSummary
|
|
@@ -1122,6 +1129,166 @@ var Timelines = class {
|
|
|
1122
1129
|
}
|
|
1123
1130
|
};
|
|
1124
1131
|
//#endregion
|
|
1132
|
+
//#region src/host/decisions/route.ts
|
|
1133
|
+
/** The probability from which a yes is taken as a yes, for the confidence a chat asks. */
|
|
1134
|
+
const yesAt = (confidence) => (1 + confidence) / 2;
|
|
1135
|
+
/** The probability up to which a no is taken as a no. */
|
|
1136
|
+
const noAt = (confidence) => (1 - confidence) / 2;
|
|
1137
|
+
const clip = (text) => text.length > 120 ? `${text.slice(0, 119)}…` : text;
|
|
1138
|
+
const reportOf = (mode, items) => ({
|
|
1139
|
+
mode,
|
|
1140
|
+
items,
|
|
1141
|
+
decided: 0,
|
|
1142
|
+
escalated: 0,
|
|
1143
|
+
fallbacks: 0,
|
|
1144
|
+
agreed: 0,
|
|
1145
|
+
disagreed: 0,
|
|
1146
|
+
decisionMs: 0,
|
|
1147
|
+
llmMs: 0,
|
|
1148
|
+
samples: []
|
|
1149
|
+
});
|
|
1150
|
+
async function timed(run) {
|
|
1151
|
+
const started = performance.now();
|
|
1152
|
+
return {
|
|
1153
|
+
value: await run(),
|
|
1154
|
+
ms: Math.round(performance.now() - started)
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Gives each key a verdict the way its site is set to: from the language model, from the decision model, from the decision model where it
|
|
1159
|
+
* is confident and the language model elsewhere, or from the language model while comparing it with the decision model. A decision model
|
|
1160
|
+
* that cannot be used never stops a story: its keys go to the language model and the report says why.
|
|
1161
|
+
*/
|
|
1162
|
+
async function routeVerdicts(route, signal) {
|
|
1163
|
+
const { mode, keys } = route;
|
|
1164
|
+
const report = reportOf(mode, keys.length);
|
|
1165
|
+
const verdicts = /* @__PURE__ */ new Map();
|
|
1166
|
+
if (keys.length === 0) return {
|
|
1167
|
+
verdicts,
|
|
1168
|
+
report
|
|
1169
|
+
};
|
|
1170
|
+
const viaLlm = async (subset) => {
|
|
1171
|
+
const { value, ms } = await timed(() => route.llm(subset));
|
|
1172
|
+
report.llmMs += ms;
|
|
1173
|
+
for (const [key, verdict] of value) verdicts.set(key, verdict);
|
|
1174
|
+
};
|
|
1175
|
+
const viaDecision = async () => {
|
|
1176
|
+
try {
|
|
1177
|
+
const { value, ms } = await timed(() => route.probabilities(keys));
|
|
1178
|
+
report.decisionMs += ms;
|
|
1179
|
+
return value;
|
|
1180
|
+
} catch (error) {
|
|
1181
|
+
if (signal.aborted) throw error;
|
|
1182
|
+
report.problem = error instanceof Error ? error.message : String(error);
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
if (mode === "llm") {
|
|
1187
|
+
await viaLlm(keys);
|
|
1188
|
+
return {
|
|
1189
|
+
verdicts,
|
|
1190
|
+
report
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
if (mode === "shadow") {
|
|
1194
|
+
const [decided] = await Promise.all([viaDecision(), viaLlm(keys)]);
|
|
1195
|
+
if (decided === void 0) return {
|
|
1196
|
+
verdicts,
|
|
1197
|
+
report
|
|
1198
|
+
};
|
|
1199
|
+
for (const key of keys) {
|
|
1200
|
+
const probability = decided.get(key);
|
|
1201
|
+
const llm = verdicts.get(key);
|
|
1202
|
+
if (probability === void 0 || llm === void 0) continue;
|
|
1203
|
+
const decision = probability >= route.yesAt;
|
|
1204
|
+
if (decision === llm) report.agreed += 1;
|
|
1205
|
+
else {
|
|
1206
|
+
report.disagreed += 1;
|
|
1207
|
+
if (report.samples.length < 20) report.samples.push({
|
|
1208
|
+
turn: route.turn,
|
|
1209
|
+
what: clip(route.what(key)),
|
|
1210
|
+
probability: Math.round(probability * 1e3) / 1e3,
|
|
1211
|
+
decision,
|
|
1212
|
+
llm
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
return {
|
|
1217
|
+
verdicts,
|
|
1218
|
+
report
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
const decided = await viaDecision();
|
|
1222
|
+
if (decided === void 0) {
|
|
1223
|
+
report.fallbacks = keys.length;
|
|
1224
|
+
await viaLlm(keys);
|
|
1225
|
+
return {
|
|
1226
|
+
verdicts,
|
|
1227
|
+
report
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
const unsure = [];
|
|
1231
|
+
for (const key of keys) {
|
|
1232
|
+
const probability = decided.get(key);
|
|
1233
|
+
if (probability === void 0) {
|
|
1234
|
+
unsure.push(key);
|
|
1235
|
+
continue;
|
|
1236
|
+
}
|
|
1237
|
+
if (mode === "hybrid" && probability > route.noAt && probability < route.yesAt) unsure.push(key);
|
|
1238
|
+
else verdicts.set(key, probability >= route.yesAt);
|
|
1239
|
+
}
|
|
1240
|
+
report.decided = keys.length - unsure.length;
|
|
1241
|
+
report.escalated = unsure.length;
|
|
1242
|
+
if (unsure.length > 0) await viaLlm(unsure);
|
|
1243
|
+
return {
|
|
1244
|
+
verdicts,
|
|
1245
|
+
report
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
/** Asks the decision model one yes-or-no question for each key about one state, in a single request; the answers are probabilities of yes. */
|
|
1249
|
+
async function askYesNo(service, state, asks, signal) {
|
|
1250
|
+
const questions = Object.fromEntries(asks.map(({ key, instructions }) => [key, {
|
|
1251
|
+
type: "noul",
|
|
1252
|
+
instructions
|
|
1253
|
+
}]));
|
|
1254
|
+
const { answers } = await service.decide(state, questions, {
|
|
1255
|
+
priority: "background",
|
|
1256
|
+
signal
|
|
1257
|
+
});
|
|
1258
|
+
return new Map(asks.map(({ key }) => [key, answers[key].probability]));
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Says once, through `say`, why a site's decision model could not be used, and again only when the reason changes, so that a story
|
|
1262
|
+
* played on without the service does not fill the log.
|
|
1263
|
+
*/
|
|
1264
|
+
function announceProblem(seen, key, report, say) {
|
|
1265
|
+
if (report.problem === void 0) {
|
|
1266
|
+
seen.delete(key);
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
if (seen.get(key) === report.problem) return;
|
|
1270
|
+
seen.set(key, report.problem);
|
|
1271
|
+
say?.(`the decision model could not be used for ${key}, the language model judged instead: ${report.problem}`);
|
|
1272
|
+
}
|
|
1273
|
+
/** The reports of several routed runs of one site as one: counts and times added, the disagreements kept up to the limit, the latest problem. */
|
|
1274
|
+
function mergeReports(mode, reports) {
|
|
1275
|
+
const merged = reportOf(mode, 0);
|
|
1276
|
+
for (const report of reports) {
|
|
1277
|
+
merged.items += report.items;
|
|
1278
|
+
merged.decided += report.decided;
|
|
1279
|
+
merged.escalated += report.escalated;
|
|
1280
|
+
merged.fallbacks += report.fallbacks;
|
|
1281
|
+
merged.agreed += report.agreed;
|
|
1282
|
+
merged.disagreed += report.disagreed;
|
|
1283
|
+
merged.decisionMs += report.decisionMs;
|
|
1284
|
+
merged.llmMs += report.llmMs;
|
|
1285
|
+
merged.samples.push(...report.samples);
|
|
1286
|
+
if (report.problem !== void 0) merged.problem = report.problem;
|
|
1287
|
+
}
|
|
1288
|
+
merged.samples = merged.samples.slice(-20);
|
|
1289
|
+
return merged;
|
|
1290
|
+
}
|
|
1291
|
+
//#endregion
|
|
1125
1292
|
//#region src/host/orchestration/whereabouts.ts
|
|
1126
1293
|
const within = (inner, outer, places) => {
|
|
1127
1294
|
const byId = new Map(places.map((place) => [place.id, place]));
|
|
@@ -1872,6 +2039,7 @@ function brief(session, material, doubted, now, zone, time, tr) {
|
|
|
1872
2039
|
* and leaves the characters not yet done as they were.
|
|
1873
2040
|
*/
|
|
1874
2041
|
function memoryReflector(deps) {
|
|
2042
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1875
2043
|
return { async reflect(job, signal) {
|
|
1876
2044
|
const parent = deps.agentOf(job.chat);
|
|
1877
2045
|
if (parent === void 0) throw new Error(`no agent for chat ${job.chat}`);
|
|
@@ -1892,37 +2060,73 @@ function memoryReflector(deps) {
|
|
|
1892
2060
|
const shown = shownOf(session, material);
|
|
1893
2061
|
const found = [];
|
|
1894
2062
|
let checked = 0;
|
|
2063
|
+
const reports = [];
|
|
1895
2064
|
for (const belief of material.beliefs) {
|
|
1896
2065
|
const near = bearingOn(belief, material.fresh);
|
|
1897
2066
|
if (near.length === 0 || checked >= MAX_CHECKS) continue;
|
|
1898
2067
|
checked += 1;
|
|
1899
|
-
const
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
2068
|
+
const askLanguageModel = async (ids) => {
|
|
2069
|
+
const things = ids.flatMap((id) => shown.perceptions.get(id) ?? []);
|
|
2070
|
+
let verdict;
|
|
2071
|
+
try {
|
|
2072
|
+
verdict = await runChild({
|
|
2073
|
+
parent,
|
|
2074
|
+
signal,
|
|
2075
|
+
reasoningEffort: settings.reasoning.children,
|
|
2076
|
+
sampling: childSampling(settings, "records", estimateAnswer([MAX_TEXT * 2, 100], settings.prompts.language)),
|
|
2077
|
+
...childModel(settings, "records"),
|
|
2078
|
+
trace: childTrace(store, "records", `reflection check ${material.character.name} b${belief.id}`),
|
|
2079
|
+
persona: promptFor(parent, "roleplay/reflection-check", settings.prompts.language),
|
|
2080
|
+
prompt: checkBrief(material.character, belief, things, now, zone, (turn, round) => session.clock.at(turn, round), tr),
|
|
2081
|
+
result: CHECK_RESULT,
|
|
2082
|
+
beforeSubmit: (value) => {
|
|
2083
|
+
const problem = checkProblem(value, belief, shown, new Set(ids), tr);
|
|
2084
|
+
return problem === void 0 ? void 0 : tr("not acceptable: {problems}", { problems: problem });
|
|
2085
|
+
},
|
|
2086
|
+
maxCalls: 2
|
|
2087
|
+
});
|
|
2088
|
+
} catch (error) {
|
|
2089
|
+
if (signal.aborted) throw error;
|
|
2090
|
+
}
|
|
2091
|
+
const named = new Set(verdict?.verdict === "contradicted" ? verdict.things : []);
|
|
2092
|
+
return new Map(ids.map((id) => [id, named.has(id)]));
|
|
2093
|
+
};
|
|
2094
|
+
const askDecisionModel = async (ids) => {
|
|
2095
|
+
const service = deps.decisions?.();
|
|
2096
|
+
if (service === void 0) throw new Error("no decision service is selected, or the selected one is not loaded");
|
|
2097
|
+
const askable = ids.filter((id) => (shown.perceptions.get(id)?.event.turn ?? -1) >= belief.turn);
|
|
2098
|
+
const answers = askable.length === 0 ? /* @__PURE__ */ new Map() : await askYesNo(service, {
|
|
2099
|
+
held_by: referent(material.character),
|
|
2100
|
+
belief: belief.text,
|
|
2101
|
+
things: Object.fromEntries(askable.map((id) => [`p${id}`, shown.perceptions.get(id).perception.content]))
|
|
2102
|
+
}, askable.map((id) => ({
|
|
2103
|
+
key: `p${id}`,
|
|
2104
|
+
instructions: store.text("roleplay/decide-reflection", { thing: `p${id}` })
|
|
2105
|
+
})), signal);
|
|
2106
|
+
return new Map(ids.map((id) => [id, answers.get(`p${id}`) ?? 0]));
|
|
2107
|
+
};
|
|
2108
|
+
const routed = await routeVerdicts({
|
|
2109
|
+
mode: settings.decisions.reflection,
|
|
2110
|
+
yesAt: yesAt(settings.decisions.confidence),
|
|
2111
|
+
noAt: noAt(settings.decisions.confidence),
|
|
2112
|
+
turn: job.turn,
|
|
2113
|
+
keys: near,
|
|
2114
|
+
what: (id) => `${belief.text} / ${shown.perceptions.get(id)?.perception.content ?? ""}`,
|
|
2115
|
+
probabilities: askDecisionModel,
|
|
2116
|
+
llm: askLanguageModel
|
|
2117
|
+
}, signal);
|
|
2118
|
+
reports.push(routed.report);
|
|
2119
|
+
const contradicted = [...routed.verdicts].filter(([, yes]) => yes).map(([id]) => id);
|
|
2120
|
+
if (contradicted.length > 0) found.push({
|
|
1922
2121
|
belief: belief.id,
|
|
1923
|
-
things:
|
|
2122
|
+
things: contradicted
|
|
1924
2123
|
});
|
|
1925
2124
|
}
|
|
2125
|
+
if (reports.length > 0) {
|
|
2126
|
+
const merged = mergeReports(settings.decisions.reflection, reports);
|
|
2127
|
+
announceProblem(seen, `${job.chat}:reflection`, merged, deps.problem);
|
|
2128
|
+
store.recordDecisions?.("reflection", merged);
|
|
2129
|
+
}
|
|
1926
2130
|
const doubted = new Set(found.map((entry) => entry.belief));
|
|
1927
2131
|
const proposal = withDoubts(settleProposal(await runChild({
|
|
1928
2132
|
parent,
|
|
@@ -1994,6 +2198,6 @@ function memoryReflector(deps) {
|
|
|
1994
2198
|
} };
|
|
1995
2199
|
}
|
|
1996
2200
|
//#endregion
|
|
1997
|
-
export { whereabouts as a,
|
|
2201
|
+
export { readTimeline as _, whereabouts as a, sameWords as b, noAt as c, TimelineError as d, Timelines as f, switchPreset as g, recordPreset as h, reflectionStatus as i, routeVerdicts as l, presetStatus as m, memoryReflector as n, announceProblem as o, copyPreset as p, recordFailure as r, askYesNo as s, dueReflection as t, yesAt as u, pathTo as v, referent as x, defaultBoundaries as y };
|
|
1998
2202
|
|
|
1999
|
-
//# sourceMappingURL=reflection-
|
|
2203
|
+
//# sourceMappingURL=reflection-6qfOC5OT.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/shared/text.ts
|
|
2
|
+
/** Remove characters from either end without a backtracking regular expression. */
|
|
3
|
+
function trimCharacters(value, characters, edge = "both") {
|
|
4
|
+
let start = 0;
|
|
5
|
+
let end = value.length;
|
|
6
|
+
if (edge !== "end") while (start < end && characters.includes(value[start])) start += 1;
|
|
7
|
+
if (edge !== "start") while (end > start && characters.includes(value[end - 1])) end -= 1;
|
|
8
|
+
return value.slice(start, end);
|
|
9
|
+
}
|
|
10
|
+
/** A path-like name without its last extension. */
|
|
11
|
+
function withoutExtension(value) {
|
|
12
|
+
const dot = value.lastIndexOf(".");
|
|
13
|
+
return dot < 0 ? value : value.slice(0, dot);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { withoutExtension as n, trimCharacters as t };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=text-CT1re6XT.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-agentic-roleplay/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Core plugin of the agentic roleplay bundle for DeepSeek Harness: roleplay UI, orchestration and storage.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Firefox2100",
|
|
@@ -16,14 +16,12 @@
|
|
|
16
16
|
"./lorebook-authoring": "./lib/lorebook-authoring.js",
|
|
17
17
|
"./doctor": "./lib/doctor.js",
|
|
18
18
|
"./compaction": "./lib/compaction.js",
|
|
19
|
+
"./helper": "./lib/helper.js",
|
|
19
20
|
"./images": "./lib/images.js",
|
|
20
21
|
"./client": "./lib/client.js",
|
|
21
22
|
"./package.json": "./package.json"
|
|
22
23
|
},
|
|
23
24
|
"dsh": {
|
|
24
|
-
"engines": {
|
|
25
|
-
"dsh": ">=0.2.0-rc.2 <0.2.1"
|
|
26
|
-
},
|
|
27
25
|
"bundle": {
|
|
28
26
|
"patch": "./cordis.patch.yml"
|
|
29
27
|
},
|
|
@@ -38,7 +36,8 @@
|
|
|
38
36
|
}
|
|
39
37
|
},
|
|
40
38
|
"engines": {
|
|
41
|
-
"node": ">=22"
|
|
39
|
+
"node": ">=22",
|
|
40
|
+
"dsh": ">=0.2.1-rc.2 <0.2.2"
|
|
42
41
|
},
|
|
43
42
|
"repository": {
|
|
44
43
|
"type": "git",
|
|
@@ -73,46 +72,44 @@
|
|
|
73
72
|
],
|
|
74
73
|
"license": "GPL-3.0-only",
|
|
75
74
|
"peerDependencies": {
|
|
76
|
-
"@deepseek-ai/dsh": ">=0.2.
|
|
77
|
-
"@deepseek-ai/schemastery": "^3.18.
|
|
75
|
+
"@deepseek-ai/dsh": ">=0.2.1-rc.2 <0.2.2",
|
|
76
|
+
"@deepseek-ai/schemastery": "^3.18.5"
|
|
78
77
|
},
|
|
79
78
|
"dependencies": {
|
|
80
|
-
"@dsh-agentic-roleplay/state": "0.
|
|
81
|
-
"@dsh-ai-providers/core": "^0.
|
|
79
|
+
"@dsh-agentic-roleplay/state": "0.6.0",
|
|
80
|
+
"@dsh-ai-providers/core": "^0.5.0"
|
|
82
81
|
},
|
|
83
82
|
"devDependencies": {
|
|
84
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
85
|
-
"@deepseek-ai/cordis-plugin-loader": "^1.0.
|
|
86
|
-
"@deepseek-ai/dsh-agent": "0.2.
|
|
87
|
-
"@deepseek-ai/dsh-agent-loop": "0.2.
|
|
88
|
-
"@deepseek-ai/dsh-api-remotes": "0.2.
|
|
89
|
-
"@deepseek-ai/dsh-client-locale": "0.2.
|
|
90
|
-
"@deepseek-ai/dsh-client-store": "0.2.
|
|
91
|
-
"@deepseek-ai/dsh-client-ui-chat": "0.2.
|
|
92
|
-
"@deepseek-ai/dsh-client-ui-conversation": "0.2.
|
|
93
|
-
"@deepseek-ai/dsh-client-ui-layout": "0.2.
|
|
94
|
-
"@deepseek-ai/dsh-client-ui-primitives": "0.2.
|
|
95
|
-
"@deepseek-ai/dsh-client-ui-renderer": "0.2.
|
|
96
|
-
"@deepseek-ai/dsh-client-ui-session": "0.2.
|
|
97
|
-
"@deepseek-ai/dsh-client-ui-settings": "0.2.
|
|
98
|
-
"@deepseek-ai/dsh-client-ui-sidebar": "0.2.
|
|
99
|
-
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.
|
|
100
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.2.
|
|
101
|
-
"@deepseek-ai/dsh-compaction": "0.2.
|
|
102
|
-
"@deepseek-ai/dsh-compaction-basic": "0.2.
|
|
103
|
-
"@deepseek-ai/dsh-host-webserver": "0.2.
|
|
104
|
-
"@deepseek-ai/dsh-
|
|
105
|
-
"@deepseek-ai/dsh-
|
|
106
|
-
"@deepseek-ai/dsh-session": "0.2.
|
|
107
|
-
"@deepseek-ai/dsh-
|
|
108
|
-
"@deepseek-ai/dsh-subagent": "0.2.
|
|
109
|
-
"@deepseek-ai/dsh-
|
|
110
|
-
"@deepseek-ai/dsh-
|
|
111
|
-
"@deepseek-ai/dsh-
|
|
112
|
-
"@deepseek-ai/dsh-
|
|
113
|
-
"@deepseek-ai/
|
|
114
|
-
"@deepseek-ai/dsh-user-approval": "0.2.0-rc.2",
|
|
115
|
-
"@deepseek-ai/schemastery": "^3.18.4",
|
|
83
|
+
"@deepseek-ai/cordis": "^4.0.5",
|
|
84
|
+
"@deepseek-ai/cordis-plugin-loader": "^1.0.6",
|
|
85
|
+
"@deepseek-ai/dsh-agent": "0.2.1-rc.2",
|
|
86
|
+
"@deepseek-ai/dsh-agent-loop": "0.2.1-rc.2",
|
|
87
|
+
"@deepseek-ai/dsh-api-remotes": "0.2.1-rc.2",
|
|
88
|
+
"@deepseek-ai/dsh-client-locale": "0.2.1-rc.2",
|
|
89
|
+
"@deepseek-ai/dsh-client-store": "0.2.1-rc.2",
|
|
90
|
+
"@deepseek-ai/dsh-client-ui-chat": "0.2.1-rc.2",
|
|
91
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.2.1-rc.2",
|
|
92
|
+
"@deepseek-ai/dsh-client-ui-layout": "0.2.1-rc.2",
|
|
93
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.1-rc.2",
|
|
94
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.1-rc.2",
|
|
95
|
+
"@deepseek-ai/dsh-client-ui-session": "0.2.1-rc.2",
|
|
96
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.1-rc.2",
|
|
97
|
+
"@deepseek-ai/dsh-client-ui-sidebar": "0.2.1-rc.2",
|
|
98
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.1-rc.2",
|
|
99
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.2",
|
|
100
|
+
"@deepseek-ai/dsh-compaction": "0.2.1-rc.2",
|
|
101
|
+
"@deepseek-ai/dsh-compaction-basic": "0.2.1-rc.2",
|
|
102
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.1-rc.2",
|
|
103
|
+
"@deepseek-ai/dsh-llm": "0.2.1-rc.2",
|
|
104
|
+
"@deepseek-ai/dsh-session": "0.2.1-rc.2",
|
|
105
|
+
"@deepseek-ai/dsh-session-projection": "0.2.1-rc.2",
|
|
106
|
+
"@deepseek-ai/dsh-subagent": "0.2.1-rc.2",
|
|
107
|
+
"@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.1-rc.2",
|
|
108
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
|
|
109
|
+
"@deepseek-ai/dsh-token-meter": "0.2.1-rc.2",
|
|
110
|
+
"@deepseek-ai/dsh-tools": "0.2.1-rc.2",
|
|
111
|
+
"@deepseek-ai/dsh-user-approval": "0.2.1-rc.2",
|
|
112
|
+
"@deepseek-ai/schemastery": "^3.18.5",
|
|
116
113
|
"@types/node": "^22.20.0",
|
|
117
114
|
"@types/react": "~18.3.1",
|
|
118
115
|
"dsh-roleplay-model": "0.0.0",
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
You check one action of an interactive story against one rule of the world. The rule is: ${rule}
|
|
2
|
+
|
|
3
|
+
The action is what the player's character tries to do, as the player wrote it. You work only from the action and the rule: never add a fact that is not in them. The action breaks the rule when carrying it out would need what the rule excludes, or would do what the rule forbids. It does not break the rule when it only comes near it, or is about something else. Read the rule literally. When in doubt, it does not break the rule.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
You compare one belief of a character in an interactive story with one thing the character took in after they formed it. You work only from what you are shown: never add a fact that is not in it. The belief is what the character holds to be true; it may be wrong. The thing contradicts the belief when, if the thing is true, the belief cannot be: the two cannot both be true, even when it was not meant as a contradiction (a boat that was never untied cannot have been taken). A thing that adds to the belief, repeats it, is about something else, shows a different side of the same people, or is merely surprising or in tension with the belief does not contradict it. Example of a contradiction: the belief "the mayor never visits the observatory" and "the mayor admits she visits it every night". Examples of no contradiction: the belief "she trusts him with the watch" and "she goes up to the observatory at night" (both can be true); the belief "he is honest" and "he kept a secret" (a secret is not a lie). When in doubt, the belief and the thing agree.
|
|
2
|
+
|
|
3
|
+
The thing to compare with the belief is the one numbered ${thing}.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
You judge one statement about an interactive story: does the statement hold in the story right now? You work only from the recorded events and from where each character is and what they are doing, which you are shown: never add a fact that is not in it. A statement holds only when what you are shown establishes it. When it is not established, or only hinted at, it does not hold; when it was established and has since stopped being true, it does not hold either. Do not guess what may happen next, and do not judge what the characters ought to do.
|
|
2
|
+
|
|
3
|
+
The statement: ${statement}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
You check one passage of narration from an interactive story for one fault: it speaks, acts, thinks or feels for the player's character beyond what the player wrote. You work only from the player's message and the passage you are shown: never add a fact that is not in it. The player decides what their own character does, says, thinks and feels. The passage is at fault when it gives the player's character new words, actions, decisions, thoughts or feelings that the player's message does not state. It is not at fault when it describes the world, the other characters and what they do and say, the results of what the player's character did, what the player's character sees or hears, or a bodily sensation that follows directly from what happened, or when it only restates what the player's message already says. When in doubt, it is not at fault.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
You check one passage of an interactive story for one fault: it steps out of the story. You work only from the passage you are shown: never add a fact that is not in it. The passage is at fault when it refuses to continue, apologises for what comes next, adds a content warning, a disclaimer or a moral comment, speaks as an AI model or an assistant, mentions its instructions, or addresses the player outside the story. It is not at fault when a character inside the story refuses, warns or objects, or when violent, dark or uncomfortable events are simply told as part of the story. When in doubt, it is not at fault.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
You check one passage of an interactive story for one fault: it gives away a hidden fact that the player's character does not know yet. The hidden fact is: ${secret}
|
|
2
|
+
|
|
3
|
+
You work only from the passage you are shown: never add a fact that is not in it. The passage is at fault when it states this fact, or something that plainly amounts to it, as true or as certain, in the narration or in what a character says. It is not at fault when it only touches the same people or places, hints, raises a suspicion or a rumour, or has a character guess without being sure. When in doubt, it is not at fault.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
你要把互动故事中一个角色的一个信念,与角色在形成这个信念之后了解到的一件事进行比较。你只依据所给的内容:绝不添加其中没有的事实。信念是角色认为真实的事,它可能是错的。如果这件事为真,信念就不可能为真,那么这件事就与信念矛盾:两者不可能同时成立,即使并非有意为之也一样(一条从未解开缆绳的船不可能被开走)。如果这件事是对信念的补充、重复,讲的是别的事,展示了同一些人的另一面,或者只是令人意外、与信念有些冲突,那就不算矛盾。矛盾的例子:信念“市长从不去天文台”与“市长承认她每天晚上都去那里”。不矛盾的例子:信念“她信任他,让他值夜班”与“她夜里上了天文台”(两者可以同时为真);信念“他是个诚实的人”与“他隐瞒了一个秘密”(保守秘密不等于撒谎)。拿不准时,视为信念与这件事一致。
|
|
2
|
+
|
|
3
|
+
要与信念比较的事,是编号为 ${thing} 的那一件。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
你要检查互动故事中的一段叙述有没有一个毛病:它超出了玩家所写的内容,替玩家的角色说话、行动、思考或感受。你只依据玩家的消息和所给的这段叙述:绝不添加其中没有的事实。玩家的角色做什么、说什么、想什么、感受什么,由玩家决定。如果这段叙述给了玩家的角色玩家消息中没有写到的新话语、新动作、新决定、新想法或新感受,就是有毛病。如果它描写的是世界、其他角色及其言行、玩家角色所做之事的结果、玩家角色看到或听到的东西,或由所发生的事直接引起的身体感觉,或者只是复述玩家消息已经写到的内容,就没有毛病。拿不准时,视为没有毛病。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
你要检查互动故事中的一段文字有没有一个毛病:它跳出了故事。你只依据所给的这段文字:绝不添加其中没有的事实。如果这段文字拒绝继续、为接下来的内容道歉、加上内容警告、免责声明或道德评论、以 AI 模型或助手的身份说话、提到自己的指令,或在故事之外对玩家说话,就是有毛病。如果只是故事里的角色拒绝、警告或反对,或者暴力、阴暗、令人不适的情节只是作为故事的一部分被讲述,就没有毛病。拿不准时,视为没有毛病。
|