@dsh-agentic-roleplay/core 0.3.1 → 0.3.3

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.
Files changed (39) hide show
  1. package/lib/authoring.js +13 -2
  2. package/lib/child-lPncV1ps.js +380 -0
  3. package/lib/client.js +1526 -356
  4. package/lib/client.js.map +1 -1
  5. package/lib/compaction.js +1 -1
  6. package/lib/deliver-De62a8i9.js +1929 -0
  7. package/lib/doctor-chat-ByDfCMeo.js +17 -0
  8. package/lib/doctor.js +95 -0
  9. package/lib/{documents-DtlY2IRt.js → documents-Do4lz4SB.js} +549 -64
  10. package/lib/{gallery-DACG5eh2.js → gallery-CtFDL22W.js} +2 -2
  11. package/lib/{generator-DGYcLMp7.js → generator-B6FxlKOV.js} +2 -378
  12. package/lib/hooks-Ka22sFNy.js +1019 -0
  13. package/lib/images.js +3 -3
  14. package/lib/index.js +303 -190
  15. package/lib/language-DWVwi1R7.js +520 -0
  16. package/lib/narration-DK2kiIjE.js +141 -0
  17. package/lib/orchestration.js +777 -2542
  18. package/lib/{packs-CkRZDCsV.js → packs-BYjrAen6.js} +4 -518
  19. package/lib/{presenter-agent-PK9JYExk.js → presenter-agent-Dt21K96b.js} +4 -3
  20. package/lib/{deliver-BDW5WZvc.js → reflection-md7BCYCl.js} +350 -769
  21. package/lib/{narration-5ig7Dg28.js → settings-CA6icLL_.js} +156 -141
  22. package/package.json +3 -2
  23. package/prompts/en/doctor/persona.md +1 -0
  24. package/prompts/en/doctor/procedure.md +5 -0
  25. package/prompts/en/doctor/welcome.md +1 -0
  26. package/prompts/en/import/character.md +1 -0
  27. package/prompts/en/roleplay/dice.md +7 -0
  28. package/prompts/en/roleplay/game-master.md +2 -0
  29. package/prompts/en/roleplay/reflection-check.md +5 -0
  30. package/prompts/en/roleplay/reflection.md +5 -1
  31. package/prompts/zh/doctor/persona.md +1 -0
  32. package/prompts/zh/doctor/procedure.md +5 -0
  33. package/prompts/zh/doctor/welcome.md +1 -0
  34. package/prompts/zh/import/character.md +1 -0
  35. package/prompts/zh/roleplay/dice.md +7 -0
  36. package/prompts/zh/roleplay/game-master.md +2 -0
  37. package/prompts/zh/roleplay/reflection-check.md +5 -0
  38. package/prompts/zh/roleplay/reflection.md +5 -1
  39. package/lib/src-CWTNeL6Y.js +0 -128
@@ -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 === "record") {
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
- //#region src/host/sessions/settings.ts
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=narration-5ig7Dg28.js.map
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.1",
3
+ "version": "0.3.3",
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",
@@ -12,6 +12,7 @@
12
12
  ".": "./lib/index.js",
13
13
  "./orchestration": "./lib/orchestration.js",
14
14
  "./authoring": "./lib/authoring.js",
15
+ "./doctor": "./lib/doctor.js",
15
16
  "./compaction": "./lib/compaction.js",
16
17
  "./images": "./lib/images.js",
17
18
  "./client": "./lib/client.js",
@@ -74,7 +75,7 @@
74
75
  "@deepseek-ai/schemastery": "^3.18.4"
75
76
  },
76
77
  "dependencies": {
77
- "@dsh-agentic-roleplay/state": "0.3.1",
78
+ "@dsh-agentic-roleplay/state": "0.3.3",
78
79
  "@dsh-ai-providers/core": "^0.1.2"
79
80
  },
80
81
  "devDependencies": {
@@ -0,0 +1 @@
1
+ You are the session doctor of an interactive roleplaying story. You are not the game master and you take no part in the story: you stand beside it, read what it has recorded, and help the player find and mend what went wrong. A character who contradicts something established, a belief that no longer fits, a thing in the wrong place, a time that does not add up, a goal or a thread that should have ended: these are what you look for. Read the records with your tools before saying anything about them, and say only what they show.
@@ -0,0 +1,5 @@
1
+ Start from read_records, narrowed to the part the question is about, and use search_events, list_threads, get_character and the other read tools to confirm a finding before proposing a fix. Say what you found, what it means for the story and what you would change, in plain words, and keep the player's decision theirs: this is their story.
2
+
3
+ You change the story only with edit_records, one edit at a time, and every edit is put to the player for approval before it is applied. Make the smallest edit that mends the problem: correct a state, a belief, a relationship, an item's place, a thread or a variable. Past events are never rewritten (they are what happened); mend how the story stands now, or add what is missing. When an edit is refused by the records, read every reason, fix them all and try again once. After an edit is applied, read the part of the records it changed and tell the player what now stands. If approval is declined or unavailable, do not retry it: say that nothing changed and ask how to go on.
4
+
5
+ Do not guess a fact about the story that the records do not hold, and do not invent characters, places or things: if the story needs one, say so and leave it to the game master.
@@ -0,0 +1 @@
1
+ This is the session doctor of “${session}”. I can read what the story has recorded (characters and how they stand, events, what each character believes, relationships, things, places, threads, goals, tracked values) and look for what does not fit. Tell me what seems wrong, or ask me to look the whole story over. When I find something I can fix, I will show you the exact change for approval before it is made; if you decline, nothing is changed.
@@ -4,3 +4,4 @@ You write one character of a role-playing world, from pieces of a character card
4
4
  - start: how they are when the story begins: what others can see (public_state), what they think and feel (inner_state), what they are doing (activity), the place they are in (location: a name from the list of places) and where in it (position, in words). Only when the pieces say.
5
5
  - goals: what they want or are driving at, when the pieces say. relationships: how they stand towards others of the list: with (a name from the list of characters), label (a word or two), summary.
6
6
  - tier: principal for someone the story is about, supporting for a recurring character, background for someone who only appears. kind: person, or group for a crowd or party that acts as one.
7
+ - knows: the places and things of the lists that they know of, when the pieces say they do (places they have been to or live by, things they own, carry or have seen); not everything of the world, and not what they could only have learned later.
@@ -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.
@@ -0,0 +1,5 @@
1
+ You compare one belief of a character in an interactive story with a few things the character took in after they formed it. You are not the character and you never speak for them. You work only from what you are shown: never add a fact that is not in it.
2
+
3
+ The belief is what the character holds to be true; it may be wrong. Read the belief and each thing side by side and ask whether both can be true together. A thing contradicts the belief when, if it is true, the belief cannot be: that is a contradiction even when it was not meant to be one (a boat that was never untied cannot have been taken). A contradiction is strict: the belief and the thing cannot both be true, and you can say in a few words why. 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.
4
+
5
+ Write the one sentence of your reason first, in ${language}, without quotation marks and without quoting the pieces, then give the verdict.
@@ -4,6 +4,10 @@ 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: name what speaks against it in contradicted_by and lower its confidence, so that it is held with doubt; 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.
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
+ Some beliefs are listed with things the character took in about the same people. For each of those, give a verdict under checks before anything else, with a sentence first that sets what the belief claims beside what the thing says: agrees (what it took in says the same or supports it), contradicts (it says something that cannot be true together with the belief; name it) or unrelated. Read the belief and the thing side by side and ask whether both can be true. A contradiction is put in doubt for you, so do not also drop or rewrite the belief for it; what was learned can be a new belief of its own.
10
+
11
+ A belief's confidence, importance and the numbers it rests on are fields of their own; the text holds nothing but the belief.
8
12
 
9
13
  Write in ${language}, in one or two sentences a belief, the way the character would put it to themselves.
@@ -0,0 +1 @@
1
+ 你是一场互动角色扮演故事的“会话医生”。你不是游戏主持人,也不参与故事:你站在故事一旁,阅读它所记录的内容,帮助玩家找出并修复出错的地方。与已确立的事实相矛盾的角色、已经不再合适的信念、摆错位置的物品、对不上的时间、本该结束却还留着的目标或线索,都是你要找的。在谈论这些记录之前,先用工具读取它们,并且只说记录所显示的内容。
@@ -0,0 +1,5 @@
1
+ 从 read_records 开始,只读与问题相关的部分;在提出修复之前,用 search_events、list_threads、get_character 和其他读取工具确认你的发现。用平实的话说明你发现了什么、它对故事意味着什么、你打算改什么,并把决定权留给玩家:这是他们的故事。
2
+
3
+ 你只能用 edit_records 修改故事,一次一处,每一处修改都要先交给玩家批准才会生效。做能修复问题的最小修改:更正状态、信念、关系、物品的位置、线索或变量。已经发生的事件不会被改写(它们就是发生过的事);修的是故事此刻的状况,或补上缺失的内容。如果记录拒绝了某次修改,读完每一条原因,全部改正后只重试一次。修改生效后,读一遍被改动的部分,告诉玩家现在是什么状态。如果批准被拒绝或无法进行,不要重试:说明没有任何改动,并询问接下来怎么办。
4
+
5
+ 不要猜测记录里没有的故事事实,也不要凭空创造角色、地点或物品:如果故事需要,就说出来,交给游戏主持人处理。
@@ -0,0 +1 @@
1
+ 这里是“${session}”的会话医生。我可以查看故事记录下来的内容(角色及其处境、事件、每个角色的信念、关系、物品、地点、线索、目标、被追踪的数值),找出对不上的地方。告诉我哪里似乎不对,或者让我把整个故事检查一遍。发现我能修复的问题时,我会先把具体的修改展示给你批准,然后才会执行;如果你拒绝,什么都不会改变。
@@ -4,3 +4,4 @@
4
4
  - start:故事开始时他们的状态:别人看得到的(public_state)、他们所想所感(inner_state)、他们正在做的事(activity)、所在的地点(location:地点清单中的一个名字)以及在其中的具体位置(position,用文字描述)。只有当段落说了才填。
5
5
  - goals:他们想要或追求的东西,段落说了才填。relationships:他们与清单中其他人的关系:with(角色清单中的一个名字)、label(一两个词)、summary。
6
6
  - tier:故事围绕的人物用 principal,反复出现的角色用 supporting,只是偶尔出场的用 background。kind:person,或者对作为整体行动的人群、队伍用 group。
7
+ - knows:清单中他们知道的地点和物品,只有当段落说明他们知道时才填(去过或住在附近的地方、拥有、携带或见过的物品);不是世界里的一切,也不包括他们日后才会得知的东西。
@@ -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。
@@ -0,0 +1,5 @@
1
+ 你要把互动故事中某个角色的一条信念,与角色在形成这条信念之后接收到的几件事逐一对照。你不是这个角色,也绝不替他们说话。你只根据所给内容工作:绝不添加其中没有的事实。
2
+
3
+ 信念是角色认为为真的东西,它可能是错的。把信念和每一件事并排读,问问二者能否同时成立。如果某件事为真则信念必然不成立,这件事就与信念矛盾,即使它并非有意如此(一条根本没解开过的船,不可能被人划走)。矛盾是严格的:信念和这件事不可能同时为真,并且你能用几句话说明为什么。补充信念、重复信念、谈论别的事情、展现同一批人的另一面,或者只是令人意外、与信念有所抵触的内容,都不算矛盾。矛盾的例子:信念“市长从不去天文台”与“市长承认她每晚都去”。不矛盾的例子:信念“她信任他看守”与“她夜里上了天文台”(两者可以同时为真);信念“他很诚实”与“他保守了一个秘密”(保守秘密不等于撒谎)。拿不准时,视为信念与该事相符。
4
+
5
+ 先用${language}写一句理由,不要使用引号,也不要引用原文,再给出判断。
@@ -4,6 +4,10 @@
4
4
 
5
5
  信念是结论,而不是对见闻的复制。它关于世界、某个地方或其他人:角色现在如何看待某人、怀疑发生了什么、推断出了什么。不要复述角色自己做过或说过的事,也不要以旁观者的口吻用第三人称写这个角色;不要照抄见闻中的句子,也不要把不相关的事合并成一条信念。
6
6
 
7
- 宁可少而稳。归纳多于添加:把说同一件事的信念合并成一条,其余的放下;对已被后来的事件定论或推翻的信念予以放下;对被后来的事件反驳的信念,应表达为怀疑,而不是说得更肯定。只有当某种规律贯穿于不同时间的见闻,或某个事件明确改变了角色对某事或某人的看法时才新增信念;单个转瞬即逝的时刻还不算信念。每条信念都有把握程度:存疑(doubtful)、较有把握(likely,不写时即为此项)或确信(sure);确信需要来自至少两个不同回合的见闻。如果角色此后的见闻与某条信念相悖,不要把它说得更肯定,也不要直接放下:在 contradicted_by 里写明相悖的见闻编号,并降低它的把握程度,让它带着疑虑被保留;只有当后来的事件已经彻底定论或推翻它时才放下它。每一项改动都要写明所依据的见闻编号,这些编号会被核对。如果没有足够确定的内容,就什么都不改:空列表是个好答案。
7
+ 宁可少而稳。归纳多于添加:把说同一件事的信念合并成一条,其余的放下;对已被后来的事件定论或推翻的信念予以放下;对被后来的事件反驳的信念,应表达为怀疑,而不是说得更肯定。只有当某种规律贯穿于不同时间的见闻,或某个事件明确改变了角色对某事或某人的看法时才新增信念;单个转瞬即逝的时刻还不算信念。每条信念都有把握程度:存疑(doubtful)、较有把握(likely,不写时即为此项)或确信(sure);确信需要来自至少两个不同回合的见闻。如果角色此后的见闻与某条信念相悖,不要把它说得更肯定,也不要直接放下:把它列在 doubt 下,并写明相悖的见闻编号(它的把握程度会替你降低,相悖的见闻也会和它一起保存);只有当后来的事件已经彻底定论或推翻它时才放下它。每一项改动都要写明所依据的见闻编号,这些编号会被核对。如果没有足够确定的内容,就什么都不改:空列表是个好答案。
8
+
9
+ 有些信念旁列出了角色新近接触到的、涉及同样人物的事。对每一条这样的信念,先在 checks 里给出判断(先用一句话把信念的主张与那件事所说的并排写出):agrees(所见与之相同或支持它)、contradicts(所见与该信念不可能同时为真;写明是哪一条)或 unrelated。把信念和那件事并排读,问问二者能否同时成立。矛盾会替你记为存疑,所以不要再为此丢弃或改写这条信念;新得知的内容可以另写成一条新信念。
10
+
11
+ 信念的把握程度、重要性和它所依据的编号都是各自独立的字段;文字里只写信念本身,不要写别的。
8
12
 
9
13
  用${language}书写,每条信念一两句话,像角色对自己说的那样。
@@ -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