@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,4 +1,4 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import "./settings-CA6icLL_.js";
|
|
2
2
|
import { dirname, extname, join, posix, sep } from "node:path";
|
|
3
3
|
import { copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync } from "node:fs";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
@@ -365,7 +365,7 @@ var Reader = class Reader {
|
|
|
365
365
|
});
|
|
366
366
|
}
|
|
367
367
|
child(key) {
|
|
368
|
-
return this.path === "" ? key : `${this.path}.${key}`;
|
|
368
|
+
return this.path === "" ? key : key === "" ? this.path : `${this.path}.${key}`;
|
|
369
369
|
}
|
|
370
370
|
};
|
|
371
371
|
//#endregion
|
|
@@ -1377,4 +1377,4 @@ function anyTab(bases) {
|
|
|
1377
1377
|
//#endregion
|
|
1378
1378
|
export { formatIssue as A, shippedText as B, PLOTS_FILE_NAME as C, readDocument as D, plotReferenceProblems as E, languageOf as F, SessionArchivedError as G, InvalidStartError as H, listFiles as I, INTENT_HORIZONS as J, SessionNotFoundError as K, promptProblem as L, PromptLibrary as M, copyWorldPrompts as N, errorMessage as O, inheritPrompts as P, shippedLanguages as R, wrongLanguage as S, parsePlotsFile as T, InvalidWorldError as U, AgentUnavailableError as V, ReflectionRefusedError as W, INTENT_TYPES as X, INTENT_STATUSES as Y, API_PREFIX as _, packIds as a, isStoryLanguage as b, describePack as c, packPath as d, readPack as f, SURFACE_NAMES as g, PACK_MEDIA_TYPES as h, inheritPacks as i, PROMPTS_FOLDER as j, Reader as k, isPackId as l, PACK_LIMITS as m, anyTab as n, syncWorldPacks as o, PACK_ACTIONS as p, WorldNotFoundError as q, copyWorldPacks as r, worldPackStates as s, activePack as t, packFile as u, LANGUAGE_NAMES as v, loadPlots as w, textLanguage as x, STORY_LANGUAGES as y, shippedPromptsDirectory as z };
|
|
1379
1379
|
|
|
1380
|
-
//# sourceMappingURL=packs-
|
|
1380
|
+
//# sourceMappingURL=packs-BCGK9KZV.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as promptFor } from "./access-EbNdZFbk.js";
|
|
2
|
-
import { A as runChild, d as nextSceneSerial, n as generateTransientImage, p as referenceImagePath, t as generateReferenceImage } from "./generator-
|
|
3
|
-
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-
|
|
2
|
+
import { A as runChild, d as nextSceneSerial, n as generateTransientImage, p as referenceImagePath, t as generateReferenceImage } from "./generator-BzeepLd2.js";
|
|
3
|
+
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-DS5-qH9F.js";
|
|
4
4
|
import { dirname, join, relative } from "node:path";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -850,4 +850,4 @@ async function runImagePresenter(job) {
|
|
|
850
850
|
//#endregion
|
|
851
851
|
export { tokensOf as a, searchImages as i, interpretImage as n, present as o, imageTools as r, presentedFor as s, runImagePresenter as t };
|
|
852
852
|
|
|
853
|
-
//# sourceMappingURL=presenter-agent-
|
|
853
|
+
//# sourceMappingURL=presenter-agent-Cp-J0onD.js.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import "./src-CWTNeL6Y.js";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { existsSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
4
1
|
//#region ../dsh-roleplay-model/src/clock.ts
|
|
5
2
|
/**
|
|
6
3
|
* How the story's time passes: `simulated` moves only when the story does (the game master says how
|
|
@@ -8,6 +5,131 @@ import { existsSync, readFileSync, renameSync, statSync, writeFileSync } from "n
|
|
|
8
5
|
*/
|
|
9
6
|
const CLOCK_MODES = ["simulated", "real"];
|
|
10
7
|
//#endregion
|
|
8
|
+
//#region ../dsh-roleplay-model/src/variable.ts
|
|
9
|
+
/** What a variable holds: a number within bounds, a yes or no, or one of a list of words. */
|
|
10
|
+
const VARIABLE_KINDS = [
|
|
11
|
+
"number",
|
|
12
|
+
"flag",
|
|
13
|
+
"choice"
|
|
14
|
+
];
|
|
15
|
+
/** What a variable is about: each character, item or place has its own value; `world` has one value for the whole story. */
|
|
16
|
+
const VARIABLE_SUBJECTS = [
|
|
17
|
+
"character",
|
|
18
|
+
"item",
|
|
19
|
+
"location",
|
|
20
|
+
"world"
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* Who can tell what the value is. `public`: anyone present (what shows). `private`: the character it belongs to, and the
|
|
24
|
+
* game master (what it feels or knows of itself). `hidden`: only the game master and the record keeper.
|
|
25
|
+
*/
|
|
26
|
+
const VARIABLE_VISIBILITIES = [
|
|
27
|
+
"public",
|
|
28
|
+
"private",
|
|
29
|
+
"hidden"
|
|
30
|
+
];
|
|
31
|
+
[
|
|
32
|
+
{
|
|
33
|
+
key: "valence",
|
|
34
|
+
name: "Valence",
|
|
35
|
+
description: "How pleasant its mood is: -1 very unpleasant, 0 neutral, 1 very pleasant.",
|
|
36
|
+
labels: [
|
|
37
|
+
{
|
|
38
|
+
upTo: -.6,
|
|
39
|
+
label: "miserable"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
upTo: -.25,
|
|
43
|
+
label: "unhappy"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
upTo: .25,
|
|
47
|
+
label: "even"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
upTo: .6,
|
|
51
|
+
label: "pleased"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
upTo: 1,
|
|
55
|
+
label: "delighted"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
key: "arousal",
|
|
61
|
+
name: "Arousal",
|
|
62
|
+
description: "How worked up it is: -1 drowsy, 0 ordinary, 1 frantic.",
|
|
63
|
+
labels: [
|
|
64
|
+
{
|
|
65
|
+
upTo: -.6,
|
|
66
|
+
label: "drowsy"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
upTo: -.25,
|
|
70
|
+
label: "calm"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
upTo: .25,
|
|
74
|
+
label: "alert"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
upTo: .6,
|
|
78
|
+
label: "keyed up"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
upTo: 1,
|
|
82
|
+
label: "frantic"
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
key: "dominance",
|
|
88
|
+
name: "Dominance",
|
|
89
|
+
description: "How much in control it feels: -1 helpless, 0 even, 1 commanding.",
|
|
90
|
+
labels: [
|
|
91
|
+
{
|
|
92
|
+
upTo: -.6,
|
|
93
|
+
label: "helpless"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
upTo: -.25,
|
|
97
|
+
label: "uneasy"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
upTo: .25,
|
|
101
|
+
label: "steady"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
upTo: .6,
|
|
105
|
+
label: "confident"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
upTo: 1,
|
|
109
|
+
label: "commanding"
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
].map(({ labels, ...rest }) => ({
|
|
114
|
+
...rest,
|
|
115
|
+
kind: "number",
|
|
116
|
+
subject: "character",
|
|
117
|
+
only: [],
|
|
118
|
+
min: -1,
|
|
119
|
+
max: 1,
|
|
120
|
+
integer: false,
|
|
121
|
+
options: [],
|
|
122
|
+
default: 0,
|
|
123
|
+
baseline: true,
|
|
124
|
+
visibility: "private",
|
|
125
|
+
bands: labels.map((band) => ({
|
|
126
|
+
upTo: band.upTo,
|
|
127
|
+
label: band.label
|
|
128
|
+
})),
|
|
129
|
+
always: false,
|
|
130
|
+
builtin: true
|
|
131
|
+
}));
|
|
132
|
+
//#endregion
|
|
11
133
|
//#region src/shared/rules.ts
|
|
12
134
|
/** 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. */
|
|
13
135
|
const WORLD_RULES_KEY = "rules";
|
|
@@ -37,6 +159,7 @@ const record = () => ({
|
|
|
37
159
|
kind: "record",
|
|
38
160
|
fallback: {}
|
|
39
161
|
});
|
|
162
|
+
const switchboard = () => ({ kind: "switchboard" });
|
|
40
163
|
const choice = (options, fallback) => ({
|
|
41
164
|
kind: "choice",
|
|
42
165
|
options,
|
|
@@ -150,11 +273,13 @@ const SETTINGS_SPEC = {
|
|
|
150
273
|
interpreterModel: text(200, ""),
|
|
151
274
|
captioner: text(200, "")
|
|
152
275
|
},
|
|
276
|
+
dice: { visibility: choice(["hidden", "card"], "card") },
|
|
277
|
+
tools: switchboard(),
|
|
153
278
|
embedding: { options: record() }
|
|
154
279
|
};
|
|
155
280
|
const isField = (spec) => "kind" in spec && typeof spec["kind"] === "string";
|
|
156
281
|
function defaultsOf(spec) {
|
|
157
|
-
return Object.fromEntries(Object.entries(spec).map(([key, entry]) => [key, isField(entry) ? entry.kind === "record" ? { ...entry.fallback } : entry.fallback : defaultsOf(entry)]));
|
|
282
|
+
return Object.fromEntries(Object.entries(spec).map(([key, entry]) => [key, isField(entry) ? entry.kind === "record" ? { ...entry.fallback } : entry.kind === "switchboard" ? {} : entry.fallback : defaultsOf(entry)]));
|
|
158
283
|
}
|
|
159
284
|
const DEFAULT_SETTINGS = defaultsOf(SETTINGS_SPEC);
|
|
160
285
|
/** Whether a name is a time zone the runtime knows. */
|
|
@@ -170,6 +295,8 @@ function isTimeZone(zone) {
|
|
|
170
295
|
/** A model as `provider/model`: both parts present, no spaces. */
|
|
171
296
|
const MODEL_NAME = /^[^\s/]+\/\S+$/;
|
|
172
297
|
const OPTION_NAME = /^[A-Za-z][A-Za-z0-9_]{0,39}$/;
|
|
298
|
+
/** What tools registered by other plugins are named: letters, digits and `_ . : -`, as MCP servers and others name theirs. */
|
|
299
|
+
const TOOL_NAME = /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,79}$/;
|
|
173
300
|
/** The options, or what is wrong with them. */
|
|
174
301
|
function parseOptions(value, name) {
|
|
175
302
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return `"${name}" must be an object`;
|
|
@@ -179,6 +306,23 @@ function parseOptions(value, name) {
|
|
|
179
306
|
if (bad !== void 0) return `"${name}.${bad[0]}" must be a number, text or true/false, under a name of letters, digits and underscores`;
|
|
180
307
|
return Object.fromEntries(entries);
|
|
181
308
|
}
|
|
309
|
+
/** The switches, or what is wrong with them. Names are not checked against any list: what this version does not know is kept for the version that does. */
|
|
310
|
+
function parseSwitchboard(value, name) {
|
|
311
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return `"${name}" must be an object`;
|
|
312
|
+
const agents = Object.entries(value);
|
|
313
|
+
if (agents.length > 20) return `"${name}" may name at most 20 kinds of agent`;
|
|
314
|
+
const result = {};
|
|
315
|
+
for (const [agent, switches] of agents) {
|
|
316
|
+
if (!OPTION_NAME.test(agent)) return `"${name}.${agent}" is not a name of letters, digits and underscores`;
|
|
317
|
+
if (typeof switches !== "object" || switches === null || Array.isArray(switches)) return `"${name}.${agent}" must be an object`;
|
|
318
|
+
const entries = Object.entries(switches);
|
|
319
|
+
if (entries.length > 300) return `"${name}.${agent}" may name at most 300 tools`;
|
|
320
|
+
const bad = entries.find(([tool, on]) => !TOOL_NAME.test(tool) || typeof on !== "boolean");
|
|
321
|
+
if (bad !== void 0) return `"${name}.${agent}.${bad[0]}" must be true or false, under a tool's name (letters, digits and _ . : -)`;
|
|
322
|
+
result[agent] = Object.fromEntries(entries);
|
|
323
|
+
}
|
|
324
|
+
return result;
|
|
325
|
+
}
|
|
182
326
|
function describe(spec) {
|
|
183
327
|
return spec.kind === "integer" ? `a whole number from ${spec.min} to ${spec.max}` : `a number from ${spec.min} to ${spec.max}`;
|
|
184
328
|
}
|
|
@@ -195,8 +339,12 @@ function parseLevel(spec, input, path, problems) {
|
|
|
195
339
|
const name = path === "" ? key : `${path}.${key}`;
|
|
196
340
|
const given = key in record ? record[key] : void 0;
|
|
197
341
|
if (!isField(entry)) result[key] = parseLevel(entry, given === void 0 ? {} : given, name, problems);
|
|
198
|
-
else if (given === void 0) result[key] = entry.kind === "record" ? { ...entry.fallback } : entry.fallback;
|
|
199
|
-
else if (entry.kind === "
|
|
342
|
+
else if (given === void 0) result[key] = entry.kind === "record" ? { ...entry.fallback } : entry.kind === "switchboard" ? {} : entry.fallback;
|
|
343
|
+
else if (entry.kind === "switchboard") {
|
|
344
|
+
const board = parseSwitchboard(given, name);
|
|
345
|
+
if (typeof board === "string") problems.push(board);
|
|
346
|
+
else result[key] = board;
|
|
347
|
+
} else if (entry.kind === "record") {
|
|
200
348
|
const options = parseOptions(given, name);
|
|
201
349
|
if (typeof options === "string") problems.push(options);
|
|
202
350
|
else result[key] = options;
|
|
@@ -230,139 +378,6 @@ function parseSettings(value) {
|
|
|
230
378
|
};
|
|
231
379
|
}
|
|
232
380
|
//#endregion
|
|
233
|
-
|
|
234
|
-
const SETTINGS_FILE = "settings.json";
|
|
235
|
-
const known = /* @__PURE__ */ new Map();
|
|
236
|
-
let childReasoning = "";
|
|
237
|
-
/** The thinking level helpers get when a chat's own setting is empty (the profile's choice); returns the function that takes it back. */
|
|
238
|
-
function useChildReasoning(level) {
|
|
239
|
-
childReasoning = level;
|
|
240
|
-
return () => {
|
|
241
|
-
childReasoning = "";
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
/** The settings are not acceptable; `problems` say what to fix. */
|
|
245
|
-
var InvalidSettingsError = class extends Error {
|
|
246
|
-
problems;
|
|
247
|
-
constructor(problems) {
|
|
248
|
-
super(`the settings are not acceptable: ${problems.join("; ")}`);
|
|
249
|
-
this.problems = problems;
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
/**
|
|
253
|
-
* The settings of the session in `folder`; a session that has none yet has the defaults.
|
|
254
|
-
* @throws {InvalidSettingsError} when the file exists and is not valid.
|
|
255
|
-
*/
|
|
256
|
-
function readSettings(folder) {
|
|
257
|
-
const file = join(folder, SETTINGS_FILE);
|
|
258
|
-
if (!existsSync(file)) return { ...DEFAULT_SETTINGS };
|
|
259
|
-
let value;
|
|
260
|
-
try {
|
|
261
|
-
value = JSON.parse(readFileSync(file, "utf8"));
|
|
262
|
-
} catch (error) {
|
|
263
|
-
throw new InvalidSettingsError([`${SETTINGS_FILE} is not valid JSON (${error instanceof Error ? error.message : String(error)})`]);
|
|
264
|
-
}
|
|
265
|
-
const parsed = parseSettings(value);
|
|
266
|
-
if (!parsed.ok) throw new InvalidSettingsError(parsed.problems);
|
|
267
|
-
return parsed.value;
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Store the settings of the session in `folder`, replacing what was there.
|
|
271
|
-
* @throws {InvalidSettingsError} when the value is not acceptable; nothing is written then.
|
|
272
|
-
*/
|
|
273
|
-
function writeSettings(folder, value) {
|
|
274
|
-
const parsed = parseSettings(value);
|
|
275
|
-
if (!parsed.ok) throw new InvalidSettingsError(parsed.problems);
|
|
276
|
-
const file = join(folder, SETTINGS_FILE);
|
|
277
|
-
const temporary = `${file}.${process.pid}.tmp`;
|
|
278
|
-
writeFileSync(temporary, `${JSON.stringify(parsed.value, null, 2)}\n`);
|
|
279
|
-
renameSync(temporary, file);
|
|
280
|
-
known.delete(folder);
|
|
281
|
-
return parsed.value;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* The settings to use right now. Called before each use, so an edit to the file applies at the
|
|
285
|
-
* next round, step or run without a restart; the file is parsed again only when it changed.
|
|
286
|
-
* A file that is not valid is reported once through `problem` and the last good settings
|
|
287
|
-
* (the defaults when there were none) stay in force, so a typo cannot stop a story in the middle.
|
|
288
|
-
*/
|
|
289
|
-
function liveSettings(folder, problem = () => void 0) {
|
|
290
|
-
const value = loadedSettings(folder, problem);
|
|
291
|
-
return value.reasoning.children === "" && childReasoning !== "" ? {
|
|
292
|
-
...value,
|
|
293
|
-
reasoning: {
|
|
294
|
-
...value.reasoning,
|
|
295
|
-
children: childReasoning
|
|
296
|
-
}
|
|
297
|
-
} : value;
|
|
298
|
-
}
|
|
299
|
-
function loadedSettings(folder, problem) {
|
|
300
|
-
let modified = -1;
|
|
301
|
-
try {
|
|
302
|
-
modified = statSync(join(folder, SETTINGS_FILE)).mtimeMs;
|
|
303
|
-
} catch {}
|
|
304
|
-
const last = known.get(folder);
|
|
305
|
-
if (last?.modified === modified) return last.value;
|
|
306
|
-
try {
|
|
307
|
-
const value = readSettings(folder);
|
|
308
|
-
known.set(folder, {
|
|
309
|
-
modified,
|
|
310
|
-
value
|
|
311
|
-
});
|
|
312
|
-
return value;
|
|
313
|
-
} catch (error) {
|
|
314
|
-
if (!(error instanceof InvalidSettingsError)) throw error;
|
|
315
|
-
problem(`${error.message} (the last good settings stay in force)`);
|
|
316
|
-
const value = last?.value ?? { ...DEFAULT_SETTINGS };
|
|
317
|
-
known.set(folder, {
|
|
318
|
-
modified,
|
|
319
|
-
value
|
|
320
|
-
});
|
|
321
|
-
return value;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
//#endregion
|
|
325
|
-
//#region src/shared/narration.ts
|
|
326
|
-
const OPEN = "<roleplay-output>";
|
|
327
|
-
const CLOSE = "</roleplay-output>";
|
|
328
|
-
const PREVIEW_OPEN = "<roleplay-preview>";
|
|
329
|
-
const PREVIEW_CLOSE = "</roleplay-preview>";
|
|
330
|
-
/** What the game master shows the player while the characters are still being asked: a scene-setting opening that the delivered output replaces in the view. */
|
|
331
|
-
function encodePreview(text) {
|
|
332
|
-
return `${PREVIEW_OPEN}${JSON.stringify({ text })}${PREVIEW_CLOSE}`;
|
|
333
|
-
}
|
|
334
|
-
function encodeOutput(output) {
|
|
335
|
-
return `${OPEN}${JSON.stringify(output)}${CLOSE}`;
|
|
336
|
-
}
|
|
337
|
-
function isSegment(value) {
|
|
338
|
-
if (typeof value !== "object" || value === null) return false;
|
|
339
|
-
const segment = value;
|
|
340
|
-
if (segment["type"] === "narration") return typeof segment["text"] === "string";
|
|
341
|
-
return segment["type"] === "utterance" && typeof segment["character"] === "string" && typeof segment["name"] === "string" && typeof segment["text"] === "string";
|
|
342
|
-
}
|
|
343
|
-
/** The output encoded in a tool result's text, or nothing when the text carries none. */
|
|
344
|
-
function decodeOutput(text) {
|
|
345
|
-
const start = text.indexOf(OPEN);
|
|
346
|
-
const end = text.indexOf(CLOSE, start + 17);
|
|
347
|
-
if (start < 0 || end < 0) return void 0;
|
|
348
|
-
try {
|
|
349
|
-
const value = JSON.parse(text.slice(start + 17, end));
|
|
350
|
-
const segments = value["segments"];
|
|
351
|
-
if (!Array.isArray(segments) || !segments.every(isSegment) || typeof value["repaired"] !== "boolean") return void 0;
|
|
352
|
-
const ooc = value["ooc"];
|
|
353
|
-
const ruled = typeof ooc === "object" && ooc !== null && typeof ooc["legal"] === "boolean" && typeof ooc["note"] === "string" ? ooc : void 0;
|
|
354
|
-
const timelineNode = typeof value["timelineNode"] === "string" ? value["timelineNode"] : void 0;
|
|
355
|
-
return {
|
|
356
|
-
segments,
|
|
357
|
-
repaired: value["repaired"],
|
|
358
|
-
...ruled === void 0 ? {} : { ooc: ruled },
|
|
359
|
-
...timelineNode === void 0 ? {} : { timelineNode }
|
|
360
|
-
};
|
|
361
|
-
} catch {
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
//#endregion
|
|
366
|
-
export { liveSettings as a, writeSettings as c, parseSettings as d, WORLD_RULES_KEY as f, InvalidSettingsError as i, DEFAULT_SETTINGS as l, encodeOutput as n, readSettings as o, rulesOf as p, encodePreview as r, useChildReasoning as s, decodeOutput as t, SETTINGS_SPEC as u };
|
|
381
|
+
export { WORLD_RULES_KEY as a, VARIABLE_SUBJECTS as c, parseSwitchboard as i, VARIABLE_VISIBILITIES as l, SETTINGS_SPEC as n, rulesOf as o, parseSettings as r, VARIABLE_KINDS as s, DEFAULT_SETTINGS as t };
|
|
367
382
|
|
|
368
|
-
//# sourceMappingURL=
|
|
383
|
+
//# sourceMappingURL=settings-CA6icLL_.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-agentic-roleplay/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
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",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@deepseek-ai/schemastery": "^3.18.4"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@dsh-agentic-roleplay/state": "0.3.
|
|
77
|
+
"@dsh-agentic-roleplay/state": "0.3.2",
|
|
78
78
|
"@dsh-ai-providers/core": "^0.1.2"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Dice. When an attempt can plainly go either way and what happens next depends on it, roll for it instead of deciding it yourself: your dice tools are ${tools}, and every number comes from them, never from you.
|
|
2
|
+
- Roll only when the outcome is uncertain and matters to the story. Do not roll for what the character can plainly do, for what the rules forbid (judge_action has already refused it), or for what a character merely says. Roll once for an attempt.
|
|
3
|
+
- Say it when you judge: judge_action's uncertain is true for such an attempt, and then nobody is asked to act until you have rolled. Roll after judge_action and before resolve_round, so that the dice are settled before you decide what happens. Name the character the attempt is for (the player's character too).
|
|
4
|
+
- Use the check whose use fits; each tells you what its dice are read against. A check's own result says what the roll was (a label such as a critical failure) and what it comes to (succeeded, partial or failed). Use roll_dice only for what has no check (damage, a random choice, who goes first) and read its number by the rules of the world, or plainly when there are none.
|
|
5
|
+
- The result stands. In resolve_round give the outcome for the character the attempt was for the result its roll gave, and cite the roll with roll: the id the tool gave; a different result is refused. A critical result has more to it: let it show in what happens. Never roll again to get a better result and never change what the dice said.
|
|
6
|
+
- A character that is not the player's is never asked to roll: you roll for it. When the player rolled, the scene tells you what came up; it is a fact like any other.
|
|
7
|
+
${checks}
|
|
@@ -28,6 +28,8 @@ ${preview}
|
|
|
28
28
|
|
|
29
29
|
You may not end a turn before its output is delivered.
|
|
30
30
|
|
|
31
|
+
${dice}
|
|
32
|
+
|
|
31
33
|
Out-of-character commands. When the scene says the turn is an out-of-character command, the player is speaking to you as the author of the story, not through their character. It is a turn of its own and works differently: nobody is asked to act and there is no preview. Only the rules of the world and of the player (the scene lists them) bind it; nothing else does, so what the player's character could not do, the command may: bring things into being, make characters act, go somewhere or stop, change what the story tracks, move time.
|
|
32
34
|
A. Call ooc_ruling first: check the command against each listed rule literally (a command that needs magic breaks a rule against magic, however it is worded); legal is false when it breaks one, and the reason is what the player is told, in plain words. When it is illegal nothing changes: call narrate with no segments.
|
|
33
35
|
B. When it is legal, do what the command says and no more, with the tools you have: resolve_round with one outcome for each character it concerns, whether or not that character was asked (summary is what is decreed to happen to it; moves_to with ignore_exits when the story must carry it somewhere; item_changes for existing things; variable_changes), introduce_thing for a thing that does not exist yet (a thing that merely appears needs only this, resolve_round is for characters), expand_world for a person, advance_time for time. Each is checked like in any turn and you are told when it cannot be done. What the command changed is worth remembering: call record_memory afterwards.
|
|
@@ -4,6 +4,8 @@ A belief is what the character holds to be true, suspects, or has been told; it
|
|
|
4
4
|
|
|
5
5
|
A belief is a conclusion, not a copy of a report. It is about the world, a place or other people: what the character now thinks of someone, what they suspect is going on, what they have worked out. Never restate what the character itself did or said, and never write about the character in the third person as if from outside; do not repeat a sentence of what they took in, and do not merge unrelated things into one belief.
|
|
6
6
|
|
|
7
|
-
Prefer fewer, firmer beliefs. Digest more than you add: merge beliefs that say the same thing into one and drop the rest, let go of a belief that later events settled or overturned, and doubt one that later events contradict instead of stating it more strongly. Add a belief only when a pattern runs through things from different times, or one event plainly changed how the character sees something or someone; a single passing moment is not yet a belief. Every belief has a confidence: doubtful, likely (when you leave it out) or sure; sure needs things from at least two different turns. When something the character took in since speaks against a belief, do not state the belief more strongly and do not simply let it go:
|
|
7
|
+
Prefer fewer, firmer beliefs. Digest more than you add: merge beliefs that say the same thing into one and drop the rest, let go of a belief that later events settled or overturned, and doubt one that later events contradict instead of stating it more strongly. Add a belief only when a pattern runs through things from different times, or one event plainly changed how the character sees something or someone; a single passing moment is not yet a belief. Every belief has a confidence: doubtful, likely (when you leave it out) or sure; sure needs things from at least two different turns. When something the character took in since speaks against a belief, do not state the belief more strongly and do not simply let it go: put it in doubt: list it under doubt with the numbers of what speaks against it (its confidence is lowered for you, and what speaks against it is kept with it); let a belief go only when later events settled or overturned it for good. Every change names the numbers of the things it took in that it rests on, and they are checked. When nothing is firm enough, change nothing: empty lists are a good answer.
|
|
8
|
+
|
|
9
|
+
A belief's confidence, importance and the numbers it rests on are fields of their own; the text holds nothing but the belief.
|
|
8
10
|
|
|
9
11
|
Write in ${language}, in one or two sentences a belief, the way the character would put it to themselves.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
骰子。当一次尝试明显可能成也可能败、而接下来发生什么取决于它时,用掷骰来决定,而不是你自己决定:你的骰子工具是 ${tools},每一个数字都来自它们,绝不来自你。
|
|
2
|
+
- 只有当结果不确定、且对故事有影响时才掷骰。角色明显做得到的事、规则禁止的事(judge_action 已经拒绝了它)、角色只是说说而已的事,都不要掷骰。一次尝试只掷一次。
|
|
3
|
+
- 在判断时就说明:对这样的尝试,judge_action 的 uncertain 为 true,此后在你掷骰之前不会有任何人被要求行动。在 judge_action 之后、resolve_round 之前掷骰,这样在你决定发生什么之前骰子就已经定了。写明这次尝试是为哪个角色而做的(玩家的角色也一样)。
|
|
4
|
+
- 用用途合适的检定;每个检定都会告诉你它的骰子要对照什么。检定自己的结果会说明这次掷骰是什么(例如“大失败”这样的标签)以及结果如何(succeeded、partial 或 failed)。只有没有对应检定的事(伤害、随机选择、谁先行动)才用 roll_dice,并按世界的规则来理解它的数字,没有规则时就按常理。
|
|
5
|
+
- 结果不可更改。在 resolve_round 里,为这次尝试所属的角色给出它的掷骰所给出的结果,并用 roll 引用这次掷骰:工具给出的 id;给出不同的结果会被拒绝。大成功或大失败意味着还有更多:让它体现在发生的事里。绝不为了更好的结果再掷一次,也绝不改动骰子所说的。
|
|
6
|
+
- 不是玩家的角色绝不会被要求掷骰:由你替它掷。当玩家自己掷了骰,场景会告诉你掷出了什么;它和别的事实一样是事实。
|
|
7
|
+
${checks}
|
|
@@ -28,6 +28,8 @@ ${preview}
|
|
|
28
28
|
|
|
29
29
|
在输出交付之前,你不得结束回合。
|
|
30
30
|
|
|
31
|
+
${dice}
|
|
32
|
+
|
|
31
33
|
戏外指令。当场景说明这一回合是一条戏外指令时,是玩家在以故事作者的身份对你说话,而不是通过他们的角色。它自成一回合,运作方式不同:没有人被要求行动,也没有预览。只有世界的规则和玩家自己的规则(场景会列出)约束它;其他任何东西都不约束它,所以玩家的角色做不到的事,这条指令可以做到:让东西出现、让角色行动、去某个地方或停下、改变故事所追踪的东西、推进时间。
|
|
32
34
|
A. 先调用 ooc_ruling:逐字对照每一条所列规则检查这条指令(需要魔法的指令违反了禁止魔法的规则,无论怎么措辞);当它违反其中一条时,legal 为 false,并且用平实的话写出理由,玩家会看到这个理由。当它不合法时,什么也不会改变:调用 narrate,不带任何片段。
|
|
33
35
|
B. 当它合法时,按指令说的去做,不多做,用你有的工具:用 resolve_round 为它涉及的每个角色给一个结果,不论该角色之前有没有被询问(summary 是被判定发生在它身上的事;当故事必须把它带到某处时,用 moves_to 加 ignore_exits;用 item_changes 处理已有的物品;用 variable_changes);用 introduce_thing 处理尚不存在的物品(单纯冒出来的物品只需要它,resolve_round 是给角色用的),用 expand_world 处理尚不存在的人;用 advance_time 处理时间。每一项都像在任何一回合中一样被检查,做不到时会告诉你。指令改变的内容值得记住:之后调用 record_memory。
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
信念是结论,而不是对见闻的复制。它关于世界、某个地方或其他人:角色现在如何看待某人、怀疑发生了什么、推断出了什么。不要复述角色自己做过或说过的事,也不要以旁观者的口吻用第三人称写这个角色;不要照抄见闻中的句子,也不要把不相关的事合并成一条信念。
|
|
6
6
|
|
|
7
|
-
宁可少而稳。归纳多于添加:把说同一件事的信念合并成一条,其余的放下;对已被后来的事件定论或推翻的信念予以放下;对被后来的事件反驳的信念,应表达为怀疑,而不是说得更肯定。只有当某种规律贯穿于不同时间的见闻,或某个事件明确改变了角色对某事或某人的看法时才新增信念;单个转瞬即逝的时刻还不算信念。每条信念都有把握程度:存疑(doubtful)、较有把握(likely,不写时即为此项)或确信(sure
|
|
7
|
+
宁可少而稳。归纳多于添加:把说同一件事的信念合并成一条,其余的放下;对已被后来的事件定论或推翻的信念予以放下;对被后来的事件反驳的信念,应表达为怀疑,而不是说得更肯定。只有当某种规律贯穿于不同时间的见闻,或某个事件明确改变了角色对某事或某人的看法时才新增信念;单个转瞬即逝的时刻还不算信念。每条信念都有把握程度:存疑(doubtful)、较有把握(likely,不写时即为此项)或确信(sure);确信需要来自至少两个不同回合的见闻。如果角色此后的见闻与某条信念相悖,不要把它说得更肯定,也不要直接放下:把它列在 doubt 下,并写明相悖的见闻编号(它的把握程度会替你降低,相悖的见闻也会和它一起保存);只有当后来的事件已经彻底定论或推翻它时才放下它。每一项改动都要写明所依据的见闻编号,这些编号会被核对。如果没有足够确定的内容,就什么都不改:空列表是个好答案。
|
|
8
|
+
|
|
9
|
+
信念的把握程度、重要性和它所依据的编号都是各自独立的字段;文字里只写信念本身,不要写别的。
|
|
8
10
|
|
|
9
11
|
用${language}书写,每条信念一两句话,像角色对自己说的那样。
|
package/lib/src-CWTNeL6Y.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
//#region ../dsh-roleplay-model/src/variable.ts
|
|
2
|
-
/** What a variable holds: a number within bounds, a yes or no, or one of a list of words. */
|
|
3
|
-
const VARIABLE_KINDS = [
|
|
4
|
-
"number",
|
|
5
|
-
"flag",
|
|
6
|
-
"choice"
|
|
7
|
-
];
|
|
8
|
-
/** What a variable is about: each character, item or place has its own value; `world` has one value for the whole story. */
|
|
9
|
-
const VARIABLE_SUBJECTS = [
|
|
10
|
-
"character",
|
|
11
|
-
"item",
|
|
12
|
-
"location",
|
|
13
|
-
"world"
|
|
14
|
-
];
|
|
15
|
-
/**
|
|
16
|
-
* Who can tell what the value is. `public`: anyone present (what shows). `private`: the character it belongs to, and the
|
|
17
|
-
* game master (what it feels or knows of itself). `hidden`: only the game master and the record keeper.
|
|
18
|
-
*/
|
|
19
|
-
const VARIABLE_VISIBILITIES = [
|
|
20
|
-
"public",
|
|
21
|
-
"private",
|
|
22
|
-
"hidden"
|
|
23
|
-
];
|
|
24
|
-
[
|
|
25
|
-
{
|
|
26
|
-
key: "valence",
|
|
27
|
-
name: "Valence",
|
|
28
|
-
description: "How pleasant its mood is: -1 very unpleasant, 0 neutral, 1 very pleasant.",
|
|
29
|
-
labels: [
|
|
30
|
-
{
|
|
31
|
-
upTo: -.6,
|
|
32
|
-
label: "miserable"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
upTo: -.25,
|
|
36
|
-
label: "unhappy"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
upTo: .25,
|
|
40
|
-
label: "even"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
upTo: .6,
|
|
44
|
-
label: "pleased"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
upTo: 1,
|
|
48
|
-
label: "delighted"
|
|
49
|
-
}
|
|
50
|
-
]
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
key: "arousal",
|
|
54
|
-
name: "Arousal",
|
|
55
|
-
description: "How worked up it is: -1 drowsy, 0 ordinary, 1 frantic.",
|
|
56
|
-
labels: [
|
|
57
|
-
{
|
|
58
|
-
upTo: -.6,
|
|
59
|
-
label: "drowsy"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
upTo: -.25,
|
|
63
|
-
label: "calm"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
upTo: .25,
|
|
67
|
-
label: "alert"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
upTo: .6,
|
|
71
|
-
label: "keyed up"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
upTo: 1,
|
|
75
|
-
label: "frantic"
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
key: "dominance",
|
|
81
|
-
name: "Dominance",
|
|
82
|
-
description: "How much in control it feels: -1 helpless, 0 even, 1 commanding.",
|
|
83
|
-
labels: [
|
|
84
|
-
{
|
|
85
|
-
upTo: -.6,
|
|
86
|
-
label: "helpless"
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
upTo: -.25,
|
|
90
|
-
label: "uneasy"
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
upTo: .25,
|
|
94
|
-
label: "steady"
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
upTo: .6,
|
|
98
|
-
label: "confident"
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
upTo: 1,
|
|
102
|
-
label: "commanding"
|
|
103
|
-
}
|
|
104
|
-
]
|
|
105
|
-
}
|
|
106
|
-
].map(({ labels, ...rest }) => ({
|
|
107
|
-
...rest,
|
|
108
|
-
kind: "number",
|
|
109
|
-
subject: "character",
|
|
110
|
-
only: [],
|
|
111
|
-
min: -1,
|
|
112
|
-
max: 1,
|
|
113
|
-
integer: false,
|
|
114
|
-
options: [],
|
|
115
|
-
default: 0,
|
|
116
|
-
baseline: true,
|
|
117
|
-
visibility: "private",
|
|
118
|
-
bands: labels.map((band) => ({
|
|
119
|
-
upTo: band.upTo,
|
|
120
|
-
label: band.label
|
|
121
|
-
})),
|
|
122
|
-
always: false,
|
|
123
|
-
builtin: true
|
|
124
|
-
}));
|
|
125
|
-
//#endregion
|
|
126
|
-
export { VARIABLE_SUBJECTS as n, VARIABLE_VISIBILITIES as r, VARIABLE_KINDS as t };
|
|
127
|
-
|
|
128
|
-
//# sourceMappingURL=src-CWTNeL6Y.js.map
|