@dsh-agentic-roleplay/core 0.4.0 → 0.5.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.
Files changed (30) hide show
  1. package/lib/{child-DsixtqTw.js → access-tN5D3WI8.js} +21 -14
  2. package/lib/{authoring-tools-C_8ClUkP.js → authoring-tools-Ch_3oIKC.js} +7 -6
  3. package/lib/authoring.js +5 -5
  4. package/lib/client.js +346 -314
  5. package/lib/client.js.map +1 -1
  6. package/lib/compaction.js +20 -25
  7. package/lib/doctor.js +3 -3
  8. package/lib/{gallery-CDYKJf_O.js → gallery-C7VOJ3xH.js} +2 -2
  9. package/lib/{generator-BR1ugzln.js → generator-CO8usAjE.js} +2 -2
  10. package/lib/{hooks-B2EhBS_-.js → hooks-C7gt2c01.js} +87 -8
  11. package/lib/images.js +4 -4
  12. package/lib/index.js +34 -23
  13. package/lib/{library-COIktKBa.js → library-DsDc6fQa.js} +2 -2
  14. package/lib/{lorebook-author-tools-C-o0t4dL.js → lorebook-author-tools-DII7Xt7Q.js} +6 -6
  15. package/lib/lorebook-authoring.js +3 -3
  16. package/lib/{narration-BT9uvQry.js → narration-DstnwrvX.js} +4 -1
  17. package/lib/orchestration.js +326 -26
  18. package/lib/{pack-jail-soI-In96.js → pack-jail-AzR6dCNm.js} +10 -10
  19. package/lib/{packs-CJPSe5LI.js → packs-C7g534Mi.js} +2 -2
  20. package/lib/{presenter-agent-Gu34bZwd.js → presenter-agent-BsC6Vftz.js} +5 -6
  21. package/lib/{preset-3zn8xme7.js → preset-Drfu_K-H.js} +3 -3
  22. package/lib/{preset-author-tools-C-X8G40s.js → preset-author-tools-CdIsFhQw.js} +5 -5
  23. package/lib/preset-authoring.js +4 -4
  24. package/lib/{presets-C3mhqqfz.js → presets-CADd77WB.js} +3 -3
  25. package/lib/{reflection-Btsj0ZLh.js → reflection-CUGuPAZR.js} +8 -8
  26. package/lib/text-CT1re6XT.js +18 -0
  27. package/package.json +37 -41
  28. package/prompts/en/roleplay/record-keeper.md +3 -3
  29. package/prompts/zh/roleplay/record-keeper.md +3 -3
  30. package/lib/access-EbNdZFbk.js +0 -25
@@ -1,10 +1,10 @@
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-C3mhqqfz.js";
3
- import "./narration-BT9uvQry.js";
4
- import { C as describeTime, D as answerLimits, F as wrongLanguage, G as PROMPTS_FOLDER, J as inheritPrompts, ct as translator, st as languageOf, w as describeWhen } from "./hooks-B2EhBS_-.js";
5
- import { a as runChild, h as trimCharacters, i as childTrace, n as childSampling, p as estimateAnswer, t as childModel } from "./child-DsixtqTw.js";
6
- import { a as inheritImages } from "./library-COIktKBa.js";
7
- import { i as inheritPacks } from "./packs-CJPSe5LI.js";
1
+ import { _ as roleplaySessionOf, a as childTrace, m as estimateAnswer, n as childModel, o as runChild, r as childSampling, t as promptFor } from "./access-tN5D3WI8.js";
2
+ import { f as sha, o as listPresets, s as loadPreset } from "./presets-CADd77WB.js";
3
+ import "./narration-DstnwrvX.js";
4
+ import { E as describeWhen, L as wrongLanguage, T as describeTime, X as inheritPrompts, k as answerLimits, lt as languageOf, q as PROMPTS_FOLDER, ut as translator } from "./hooks-C7gt2c01.js";
5
+ import { t as trimCharacters } from "./text-CT1re6XT.js";
6
+ import { a as inheritImages } from "./library-DsDc6fQa.js";
7
+ import { i as inheritPacks } from "./packs-C7g534Mi.js";
8
8
  import { dirname, join } from "node:path";
9
9
  import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
10
10
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
@@ -1996,4 +1996,4 @@ function memoryReflector(deps) {
1996
1996
  //#endregion
1997
1997
  export { whereabouts as a, copyPreset as c, switchPreset as d, readTimeline as f, referent as g, sameWords as h, reflectionStatus as i, presetStatus as l, defaultBoundaries as m, memoryReflector as n, TimelineError as o, pathTo as p, recordFailure as r, Timelines as s, dueReflection as t, recordPreset as u };
1998
1998
 
1999
- //# sourceMappingURL=reflection-Btsj0ZLh.js.map
1999
+ //# sourceMappingURL=reflection-CUGuPAZR.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.4.0",
3
+ "version": "0.5.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",
@@ -21,9 +21,6 @@
21
21
  "./package.json": "./package.json"
22
22
  },
23
23
  "dsh": {
24
- "engines": {
25
- "dsh": ">=0.2.0-rc.2 <0.2.1"
26
- },
27
24
  "bundle": {
28
25
  "patch": "./cordis.patch.yml"
29
26
  },
@@ -38,7 +35,8 @@
38
35
  }
39
36
  },
40
37
  "engines": {
41
- "node": ">=22"
38
+ "node": ">=22",
39
+ "dsh": ">=0.2.1-rc.2 <0.2.2"
42
40
  },
43
41
  "repository": {
44
42
  "type": "git",
@@ -73,46 +71,44 @@
73
71
  ],
74
72
  "license": "GPL-3.0-only",
75
73
  "peerDependencies": {
76
- "@deepseek-ai/dsh": ">=0.2.0-rc.2 <0.2.1",
77
- "@deepseek-ai/schemastery": "^3.18.4"
74
+ "@deepseek-ai/dsh": ">=0.2.1-rc.2 <0.2.2",
75
+ "@deepseek-ai/schemastery": "^3.18.5"
78
76
  },
79
77
  "dependencies": {
80
- "@dsh-agentic-roleplay/state": "0.4.0",
81
- "@dsh-ai-providers/core": "^0.1.2"
78
+ "@dsh-agentic-roleplay/state": "0.5.0",
79
+ "@dsh-ai-providers/core": "^0.3.0"
82
80
  },
83
81
  "devDependencies": {
84
- "@deepseek-ai/cordis": "^4.0.4",
85
- "@deepseek-ai/cordis-plugin-loader": "^1.0.5",
86
- "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
87
- "@deepseek-ai/dsh-agent-loop": "0.2.0-rc.2",
88
- "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.2",
89
- "@deepseek-ai/dsh-client-locale": "0.2.0-rc.2",
90
- "@deepseek-ai/dsh-client-store": "0.2.0-rc.2",
91
- "@deepseek-ai/dsh-client-ui-chat": "0.2.0-rc.2",
92
- "@deepseek-ai/dsh-client-ui-conversation": "0.2.0-rc.2",
93
- "@deepseek-ai/dsh-client-ui-layout": "0.2.0-rc.2",
94
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.2",
95
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
96
- "@deepseek-ai/dsh-client-ui-session": "0.2.0-rc.2",
97
- "@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.2",
98
- "@deepseek-ai/dsh-client-ui-sidebar": "0.2.0-rc.2",
99
- "@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.0-rc.2",
100
- "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
101
- "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
102
- "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.2",
103
- "@deepseek-ai/dsh-host-webserver": "0.2.0-rc.2",
104
- "@deepseek-ai/dsh-invariants": "0.2.0-rc.2",
105
- "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
106
- "@deepseek-ai/dsh-session": "0.2.0-rc.2",
107
- "@deepseek-ai/dsh-session-projection": "0.2.0-rc.2",
108
- "@deepseek-ai/dsh-subagent": "0.2.0-rc.2",
109
- "@deepseek-ai/dsh-subagent-in-process-driver": "0.2.0-rc.2",
110
- "@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.0-rc.2",
111
- "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
112
- "@deepseek-ai/dsh-token-meter": "0.2.0-rc.2",
113
- "@deepseek-ai/dsh-tools": "0.2.0-rc.2",
114
- "@deepseek-ai/dsh-user-approval": "0.2.0-rc.2",
115
- "@deepseek-ai/schemastery": "^3.18.4",
82
+ "@deepseek-ai/cordis": "^4.0.5",
83
+ "@deepseek-ai/cordis-plugin-loader": "^1.0.6",
84
+ "@deepseek-ai/dsh-agent": "0.2.1-rc.2",
85
+ "@deepseek-ai/dsh-agent-loop": "0.2.1-rc.2",
86
+ "@deepseek-ai/dsh-api-remotes": "0.2.1-rc.2",
87
+ "@deepseek-ai/dsh-client-locale": "0.2.1-rc.2",
88
+ "@deepseek-ai/dsh-client-store": "0.2.1-rc.2",
89
+ "@deepseek-ai/dsh-client-ui-chat": "0.2.1-rc.2",
90
+ "@deepseek-ai/dsh-client-ui-conversation": "0.2.1-rc.2",
91
+ "@deepseek-ai/dsh-client-ui-layout": "0.2.1-rc.2",
92
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.1-rc.2",
93
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.1-rc.2",
94
+ "@deepseek-ai/dsh-client-ui-session": "0.2.1-rc.2",
95
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.1-rc.2",
96
+ "@deepseek-ai/dsh-client-ui-sidebar": "0.2.1-rc.2",
97
+ "@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.1-rc.2",
98
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.2",
99
+ "@deepseek-ai/dsh-compaction": "0.2.1-rc.2",
100
+ "@deepseek-ai/dsh-compaction-basic": "0.2.1-rc.2",
101
+ "@deepseek-ai/dsh-host-webserver": "0.2.1-rc.2",
102
+ "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
103
+ "@deepseek-ai/dsh-session": "0.2.1-rc.2",
104
+ "@deepseek-ai/dsh-session-projection": "0.2.1-rc.2",
105
+ "@deepseek-ai/dsh-subagent": "0.2.1-rc.2",
106
+ "@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.1-rc.2",
107
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
108
+ "@deepseek-ai/dsh-token-meter": "0.2.1-rc.2",
109
+ "@deepseek-ai/dsh-tools": "0.2.1-rc.2",
110
+ "@deepseek-ai/dsh-user-approval": "0.2.1-rc.2",
111
+ "@deepseek-ai/schemastery": "^3.18.5",
116
112
  "@types/node": "^22.20.0",
117
113
  "@types/react": "~18.3.1",
118
114
  "dsh-roleplay-model": "0.0.0",
@@ -3,12 +3,12 @@ You are the record keeper of an interactive story. You turn what was decided in
3
3
  You work only from the material you are given and from what your tools show. You never infer, guess, embellish or add anything that is not stated there; when something is not stated, you leave it out. You write no story text and decide nothing: what happened has already been decided. Write the text of every event, perception, belief and thread in ${language}, whatever language the material or the character sheets are in; keep names as they are written.
4
4
 
5
5
  You work in a loop with your tools:
6
- 1. Write the records for the rounds due with edit_records. One call may hold state changes, events, beliefs and threads together; it is applied entirely or not at all. If it is refused, the reasons come back: correct them and call again.
7
- 2. Check your work when the prompt says verification is on: read the records back with read_records for those rounds and compare them with the rounds, item by item: an event the rounds do not support (correct or retract it: only events you wrote in this run can be corrected); something clearly stated and missing (add it); two events saying the same thing (retract the later); a perception by someone who could not have perceived the event, or missing for the character who did or said it; a character state that is a log of events or leaks a private thought into public_state; a belief the rounds do not support (retract it); an importance clearly out of proportion. Fix what you find with edit_records (event_edits, event_retractions, belief_edits, belief_retractions, new events) and read again. Do not change wording for style.
6
+ 1. What each character did and said in the rounds due is already written as plain events, listed with their ids under "Already recorded for these rounds"; an utterance is one of them, word for word. Never write those again and never change the words of a quoted utterance. Make them better with edit_records: event_edits to set the importance, the tags and who is involved, and to correct who perceived them and how (a bystander who only glimpsed it, or took it in wrongly); new events only for what the rounds establish that no listed event covers (a revelation, a consequence, a change); and the rest below. One call may hold state changes, events, beliefs and threads together; it is applied entirely or not at all. If it is refused, the reasons come back: correct them and call again.
7
+ 2. Check your work when the prompt says verification is on: read the records back with read_records for those rounds and compare them with the rounds, item by item: an event the rounds do not support (correct or retract it: only events that are still drafts, which are the ones written for these rounds, can be corrected); something clearly stated and missing (add it); two events saying the same thing (retract the later); a perception by someone who could not have perceived the event, or missing for the character who did or said it; a character state that is a log of events or leaks a private thought into public_state; a belief the rounds do not support (retract it); an importance clearly out of proportion. Fix what you find with edit_records (event_edits, event_retractions, belief_edits, belief_retractions, new events) and read again. Do not change wording for style.
8
8
  3. Finish with submit_result.
9
9
 
10
10
  What to write:
11
- - events: one for each distinct thing that happened (an action, a statement that matters, a revelation, a change), in the past tense ("Bob took the key."), one sentence, no interpretation, no narration. Never repeat an event that is already recorded. Usually one to four per round. Give each its turn and round, its tags (lowercase words: objects, places, topics) and the characters it involves.
11
+ - events: one for each distinct thing that happened (an action, a statement that matters, a revelation, a change), in the past tense ("Bob took the key."), one sentence, no interpretation, no narration. Never repeat an event that is already recorded. Usually none to three new ones per round, since the actions and the words are already there. Give each its turn and round, its tags and the characters it involves. Tags are lowercase words (objects, places, topics): choose from the tags listed under "Tags already in use", and make a new tag only when none of them fits.
12
12
  - importance: 1 a passing detail, 2 minor, 3 notable, 4 important, 5 turns the story. Most events are 2 or 3.
13
13
  - perceived_by: only characters who could actually perceive the event, each once, with how (witnessed, heard, told, inferred). The character who does or says something always perceives it. A character who was not there does not.
14
14
  - The rounds you are given may be several, from this turn and earlier ones, because the game master records only when the story moves on. Write each event at the turn and round it belongs to. Routine rounds (small talk, movement) do not each need an event: fold them into the event that matters, or leave them out. If the game master named what is worth keeping, write that first.
@@ -3,12 +3,12 @@
3
3
  你只根据所给的材料和你的工具所显示的内容工作。绝不推断、猜测、渲染,也不添加其中没有写明的任何东西;没有写明的,就不写。你不写故事文字,也不做任何决定:发生了什么,已经决定好了。无论材料或角色卡是什么语言,每个事件、感知、信念和线索的文字都用${language}书写;名字保持原样。
4
4
 
5
5
  你用工具循环工作:
6
- 1. 用 edit_records 为到期的各轮写下记录。一次调用可以同时包含状态变化、事件、信念和线索;它要么全部生效,要么全部不生效。如果被拒绝,会返回理由:改正后再调用。
7
- 2. 当提示说明开启了核查时,检查你的工作:用 read_records 读回这些轮次的记录,并与各轮逐项比对:有一个各轮并不支持的事件(改正它或撤回它:只有你在这次运行中写的事件才能改正);明确写明了却漏掉的内容(补上);两个说同一件事的事件(撤回后一个);一个不可能感知到该事件的人所做的感知,或者做了或说了这件事的角色反而缺少感知;一个把事件当成流水账、或者把私下想法泄漏进 public_state 的角色状态;一个各轮并不支持的信念(撤回它);重要性明显不成比例。用 edit_records 改正你发现的问题(event_edits、event_retractions、belief_edits、belief_retractions、新事件),然后再读一遍。不要为了文风而改措辞。
6
+ 1. 到期各轮里每个角色做了什么、说了什么,已经写成了朴素的事件,列在“Already recorded for these rounds”下并带有 id;角色说的话就是其中一条,一字不差。绝不要再写一遍,也绝不要改动被引用的话的措辞。用 edit_records 把它们做得更好:用 event_edits 设定重要性、标签和涉及的角色,并改正谁感知到了它、怎样感知(只是瞥见的旁观者,或者理解错了的人);只有当各轮确立了某件没有任何已列事件涵盖的事(一次揭示、一个后果、一个变化)时才写新事件;其余见下。一次调用可以同时包含状态变化、事件、信念和线索;它要么全部生效,要么全部不生效。如果被拒绝,会返回理由:改正后再调用。
7
+ 2. 当提示说明开启了核查时,检查你的工作:用 read_records 读回这些轮次的记录,并与各轮逐项比对:有一个各轮并不支持的事件(改正它或撤回它:只有仍是草稿的事件,也就是为这几轮写的事件,才能改正);明确写明了却漏掉的内容(补上);两个说同一件事的事件(撤回后一个);一个不可能感知到该事件的人所做的感知,或者做了或说了这件事的角色反而缺少感知;一个把事件当成流水账、或者把私下想法泄漏进 public_state 的角色状态;一个各轮并不支持的信念(撤回它);重要性明显不成比例。用 edit_records 改正你发现的问题(event_edits、event_retractions、belief_edits、belief_retractions、新事件),然后再读一遍。不要为了文风而改措辞。
8
8
  3. 用 submit_result 结束。
9
9
 
10
10
  要写什么:
11
- - events:对每一件不同的事(一个行动、一句重要的话、一次揭示、一个变化)各写一条,叙述已发生的事实(“鲍勃拿走了钥匙。”),一句话,不加解释,不加叙述。绝不重复已经记录过的事件。通常每轮一到四条。给每条标上它所在的回合(turn)和轮次(round)、标签(tags,小写词:物品、地点、话题)以及它涉及的角色。
11
+ - events:对每一件不同的事(一个行动、一句重要的话、一次揭示、一个变化)各写一条,叙述已发生的事实(“鲍勃拿走了钥匙。”),一句话,不加解释,不加叙述。绝不重复已经记录过的事件。行动和话语已经写好,所以通常每轮新写零到三条。给每条标上它所在的回合(turn)和轮次(round)、标签(tags)以及它涉及的角色。标签是小写词(物品、地点、话题):从“Tags already in use”下列出的标签中选;只有其中没有合适的,才新建标签。
12
12
  - importance:1 是一闪而过的细节,2 是次要的,3 是值得注意的,4 是重要的,5 是扭转故事的。大多数事件是 2 或 3。
13
13
  - perceived_by:只写确实能感知到该事件的角色,每个只写一次,并说明方式(witnessed 目睹、heard 听到、told 被告知、inferred 推断)。做了或说了某事的角色总是能感知到它。不在场的角色则不能。
14
14
  - 你拿到的轮次可能有好几个,来自这一回合和更早的回合,因为游戏主持人只有在故事向前推进时才会记录。把每个事件写在它所属的回合和轮次。例行的轮次(闲聊、移动)不必每个都写事件:把它们并入重要的事件,或者略去。如果游戏主持人点明了值得保留的内容,先写那个。
@@ -1,25 +0,0 @@
1
- //#region src/shared/chat.ts
2
- const CHAT_PREFIX = "session-";
3
- const UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
4
- /** The DSH chat of a roleplay session is named after the session's id. */
5
- function chatSessionId(sessionId) {
6
- return `${CHAT_PREFIX}${sessionId}`;
7
- }
8
- /** The roleplay session a DSH chat id could belong to; ordinary DSH chats have ids of the same shape. */
9
- function roleplaySessionOf(chat) {
10
- if (!chat.startsWith(CHAT_PREFIX)) return void 0;
11
- const id = chat.slice(8);
12
- return UUID_V4.test(id) ? id : void 0;
13
- }
14
- //#endregion
15
- //#region src/host/prompts/access.ts
16
- /** The prompt `id` in `language`, from the library of the agent's own context. */
17
- function promptFor(agent, id, language, variables) {
18
- const library = agent.ctx.get("roleplayPrompts");
19
- if (library === void 0) throw new Error("the prompt library is not running");
20
- return library.text(id, language, variables, roleplaySessionOf(agent.session.id));
21
- }
22
- //#endregion
23
- export { chatSessionId as n, roleplaySessionOf as r, promptFor as t };
24
-
25
- //# sourceMappingURL=access-EbNdZFbk.js.map