@dsh-agentic-roleplay/core 0.3.5 → 0.4.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 (52) hide show
  1. package/lib/{preset-ClQm7KPQ.js → authoring-tools-C_8ClUkP.js} +542 -261
  2. package/lib/authoring.js +7 -5
  3. package/lib/{child-CFjnaTZt.js → child-DsixtqTw.js} +94 -2
  4. package/lib/client.js +16938 -14212
  5. package/lib/client.js.map +1 -1
  6. package/lib/compaction.js +1 -1
  7. package/lib/doctor.js +2 -4
  8. package/lib/{gallery-DIEgETzU.js → gallery-CDYKJf_O.js} +2 -2
  9. package/lib/{generator-DJ48HxPI.js → generator-BR1ugzln.js} +2 -2
  10. package/lib/{deliver-Cl6bjp7g.js → hooks-B2EhBS_-.js} +1884 -236
  11. package/lib/images.js +4 -4
  12. package/lib/index.js +1200 -242
  13. package/lib/{library-9JB9zw5a.js → library-COIktKBa.js} +4 -3
  14. package/lib/lorebook-author-tools-C-o0t4dL.js +694 -0
  15. package/lib/lorebook-authoring.js +69 -0
  16. package/lib/{settings-CA6icLL_.js → narration-BT9uvQry.js} +145 -2
  17. package/lib/orchestration.js +34 -21
  18. package/lib/{pack-jail-ClMpVc__.js → pack-jail-soI-In96.js} +170 -12
  19. package/lib/{packs-BC2A3geF.js → packs-CJPSe5LI.js} +7 -4
  20. package/lib/{presenter-agent-DnNEG_Mn.js → presenter-agent-Gu34bZwd.js} +6 -6
  21. package/lib/preset-3zn8xme7.js +242 -0
  22. package/lib/{preset-author-tools-Dibp-LY9.js → preset-author-tools-C-X8G40s.js} +24 -18
  23. package/lib/preset-authoring.js +6 -3
  24. package/lib/{presets-DNjNxQL5.js → presets-C3mhqqfz.js} +50 -28
  25. package/lib/{reflection-Bju_LPFn.js → reflection-Btsj0ZLh.js} +51 -17
  26. package/package.json +3 -2
  27. package/packs/scene/map.html +1 -0
  28. package/packs/scene/strip.html +1 -0
  29. package/prompts/en/import/lorebook.md +8 -0
  30. package/prompts/en/import/style.md +1 -0
  31. package/prompts/en/lorebook/persona.md +1 -0
  32. package/prompts/en/lorebook/procedure.md +1 -0
  33. package/prompts/en/lorebook/welcome.md +1 -0
  34. package/prompts/en/preset/persona.md +1 -1
  35. package/prompts/en/preset/procedure.md +1 -1
  36. package/prompts/en/roleplay/character-lookup.md +1 -0
  37. package/prompts/en/roleplay/game-master.md +1 -1
  38. package/prompts/en/world/procedure.md +1 -1
  39. package/prompts/zh/import/lorebook.md +8 -0
  40. package/prompts/zh/import/style.md +1 -0
  41. package/prompts/zh/lorebook/persona.md +1 -0
  42. package/prompts/zh/lorebook/procedure.md +1 -0
  43. package/prompts/zh/lorebook/welcome.md +1 -0
  44. package/prompts/zh/preset/persona.md +1 -1
  45. package/prompts/zh/preset/procedure.md +1 -1
  46. package/prompts/zh/roleplay/character-lookup.md +1 -0
  47. package/prompts/zh/roleplay/game-master.md +1 -1
  48. package/prompts/zh/world/procedure.md +1 -1
  49. package/lib/hooks-DdO_tNhu.js +0 -1060
  50. package/lib/language-BgyxtB2h.js +0 -38
  51. package/lib/load-Clkl0T7C.js +0 -486
  52. package/lib/narration-DK2kiIjE.js +0 -141
package/lib/authoring.js CHANGED
@@ -1,8 +1,8 @@
1
- import { c as isReviewing, i as importTools, mt as InvalidEditProblems, o as authoredWorldOf, r as importHooks, yt as parseRelationEdit } from "./preset-ClQm7KPQ.js";
2
- import { _ as writeWorldPrompt, g as readWorldPrompt, h as listWorldPrompts, m as deleteWorldPrompt, p as PROSE_PROMPTS } from "./presets-DNjNxQL5.js";
3
- import { c as formatIssue, r as parsePlotsFile, v as shippedPromptsDirectory } from "./load-Clkl0T7C.js";
4
- import { B as translateTools, C as readWorldEditor, F as loadWorldParts, M as deleteTriggerDocument, N as readTriggerDocuments, P as writeTriggerDocument, R as presetTools, _ as editWorldPlots, a as deleteWorldPackFile, c as createAuthoredEntity, d as replaceAuthoredEntity, i as checkWorldPack, l as deleteAuthoredEntity, o as listWorldPacks, r as registerPackJail, s as AUTHORED_ENTITY_KINDS, u as readAuthoredEntityDocument, v as editWorldRelation } from "./pack-jail-ClMpVc__.js";
5
- import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-BC2A3geF.js";
1
+ import { Lt as parseRelationEdit, Mt as InvalidEditProblems, a as importHooks, c as authoredWorldOf, n as limitAuthoringAgents, o as importTools, u as isReviewing } from "./authoring-tools-C_8ClUkP.js";
2
+ import { _ as readWorldPrompt, g as listWorldPrompts, h as deleteWorldPrompt, m as PROSE_PROMPTS, v as writeWorldPrompt } from "./presets-C3mhqqfz.js";
3
+ import { $ as shippedPromptsDirectory, H as formatIssue, R as parsePlotsFile } from "./hooks-B2EhBS_-.js";
4
+ import { C as readWorldEditor, F as loadWorldParts, H as translateTools, M as deleteTriggerDocument, N as readTriggerDocuments, P as writeTriggerDocument, R as presetTools, _ as editWorldPlots, a as deleteWorldPackFile, c as createAuthoredEntity, d as replaceAuthoredEntity, i as checkWorldPack, l as deleteAuthoredEntity, o as listWorldPacks, r as registerPackJail, s as AUTHORED_ENTITY_KINDS, u as readAuthoredEntityDocument, v as editWorldRelation } from "./pack-jail-soI-In96.js";
5
+ import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-CJPSe5LI.js";
6
6
  import { join, relative } from "node:path";
7
7
  import { defineTool } from "@deepseek-ai/dsh-tools";
8
8
  import { readFile } from "node:fs/promises";
@@ -710,6 +710,7 @@ const inject = [
710
710
  "roleplayImport",
711
711
  "roleplayPrompts",
712
712
  "roleplayAuthoringLanguages",
713
+ "roleplayAuthoringTools",
713
714
  "tools",
714
715
  "systemPrompt"
715
716
  ];
@@ -745,6 +746,7 @@ function apply(ctx) {
745
746
  worldDirectory,
746
747
  reviewing
747
748
  });
749
+ limitAuthoringAgents(ctx, (chat) => authoredWorldOf(chat) === void 0 ? void 0 : "worldAuthoring");
748
750
  ctx.on("tools/pre-execute", (exec, next) => authoringApproval(exec, next, reviewing));
749
751
  for (const [name, order, id] of [[
750
752
  "WORLD_AUTHORING_PERSONA",
@@ -3,6 +3,21 @@ import { SessionId } from "@deepseek-ai/dsh-session";
3
3
  import { ReasoningEffortId, createUserMessage, lastAssistantStreamChunk } from "@deepseek-ai/dsh-llm";
4
4
  import { appendDelegatedPolicyOverrides, applyChildComposition, captureDelegatedPolicyOverrides, childSessionMeta, resolveChildAgentOptions, resolveChildDepth } from "@deepseek-ai/dsh-subagent";
5
5
  import { ToolArgsError, validateJsonSchemaValue } from "@deepseek-ai/dsh-tools";
6
+ //#region src/shared/text.ts
7
+ /** Remove characters from either end without a backtracking regular expression. */
8
+ function trimCharacters(value, characters, edge = "both") {
9
+ let start = 0;
10
+ let end = value.length;
11
+ if (edge !== "end") while (start < end && characters.includes(value[start])) start += 1;
12
+ if (edge !== "start") while (end > start && characters.includes(value[end - 1])) end -= 1;
13
+ return value.slice(start, end);
14
+ }
15
+ /** A path-like name without its last extension. */
16
+ function withoutExtension(value) {
17
+ const dot = value.lastIndexOf(".");
18
+ return dot < 0 ? value : value.slice(0, dot);
19
+ }
20
+ //#endregion
6
21
  //#region src/host/agents/budget.ts
7
22
  /** Tokens a text of a number of characters comes to: a character of a script written without spaces takes about one and a half, of the others about a third. */
8
23
  function tokensOf$1(characters, language) {
@@ -65,6 +80,82 @@ function tokensOf(events) {
65
80
  const MAX_RUN_TEXT = 4e3;
66
81
  const MAX_RUN_PROMPT = 24e3;
67
82
  //#endregion
83
+ //#region src/shared/sampling.ts
84
+ /** The controls beyond temperature, which apply to the game master and the characters (the helpers that must be exact are never asked more freely). */
85
+ const SHARED_SAMPLING = [
86
+ "topP",
87
+ "topK",
88
+ "minP",
89
+ "frequencyPenalty",
90
+ "presencePenalty",
91
+ "repetitionPenalty"
92
+ ];
93
+ /** Each control's range and the value that leaves the choice to the model's server (and so is never sent). */
94
+ const SAMPLING_RANGES = {
95
+ master: {
96
+ min: 0,
97
+ max: 2
98
+ },
99
+ characters: {
100
+ min: 0,
101
+ max: 2
102
+ },
103
+ topP: {
104
+ min: 0,
105
+ max: 1,
106
+ neutral: 1
107
+ },
108
+ topK: {
109
+ min: 0,
110
+ max: 1e3,
111
+ neutral: 0
112
+ },
113
+ minP: {
114
+ min: 0,
115
+ max: 1,
116
+ neutral: 0
117
+ },
118
+ frequencyPenalty: {
119
+ min: -2,
120
+ max: 2,
121
+ neutral: 0
122
+ },
123
+ presencePenalty: {
124
+ min: -2,
125
+ max: 2,
126
+ neutral: 0
127
+ },
128
+ repetitionPenalty: {
129
+ min: 0,
130
+ max: 2,
131
+ neutral: 1
132
+ }
133
+ };
134
+ const SAMPLING_KEYS = Object.keys(SAMPLING_RANGES);
135
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
136
+ /** Reads the `sampling` object of a file or a request: every unknown name or out-of-range value is a problem, named with `where`. */
137
+ function parseSampling(value, where, problems) {
138
+ const sampling = {};
139
+ if (value === void 0 || value === null) return sampling;
140
+ if (!isRecord(value)) {
141
+ problems.push(`${where} must be an object`);
142
+ return sampling;
143
+ }
144
+ for (const key of Object.keys(value)) if (!Object.hasOwn(SAMPLING_RANGES, key)) problems.push(`${where}.${key} is not something that can be set (${SAMPLING_KEYS.join(", ")})`);
145
+ for (const key of SAMPLING_KEYS) {
146
+ const number = value[key];
147
+ if (number === void 0) continue;
148
+ const { min, max } = SAMPLING_RANGES[key];
149
+ if (typeof number !== "number" || !Number.isFinite(number) || number < min || number > max) problems.push(`${where}.${key} must be a number from ${min} to ${max}`);
150
+ else sampling[key] = number;
151
+ }
152
+ return sampling;
153
+ }
154
+ /** The controls of a chat's settings that are not neutral, as a model request carries them. */
155
+ function sharedSamplingOf(settings) {
156
+ return Object.fromEntries(SHARED_SAMPLING.flatMap((key) => settings[key] === SAMPLING_RANGES[key].neutral ? [] : [[key, settings[key]]]));
157
+ }
158
+ //#endregion
68
159
  //#region src/host/agents/child.ts
69
160
  /** The tool every child ends with: its arguments are the child's result. */
70
161
  const SUBMIT_TOOL = "submit_result";
@@ -93,6 +184,7 @@ function childSampling(settings, kind, estimate) {
93
184
  const ceiling = kind === "characters" || kind === "suggestions" ? settings.sampling.shortMaxTokens : settings.sampling.maxTokens;
94
185
  return {
95
186
  temperature: settings.sampling[kind],
187
+ ...kind === "characters" ? sharedSamplingOf(settings.sampling) : {},
96
188
  toolChoice: settings.sampling.tools,
97
189
  maxTokens: estimate === void 0 ? ceiling : Math.min(ceiling, outputBudget(estimate, settings.sampling.headroom)),
98
190
  priority: kind === "characters" || kind === "authoring" ? "foreground" : "background"
@@ -430,6 +522,6 @@ async function execute(task, stats) {
430
522
  return submitted.value;
431
523
  }
432
524
  //#endregion
433
- export { runChild as a, addTokens as c, tokensOf$1 as d, childTrace as i, currentTurn as l, childSampling as n, tokensOf as o, childSamplingOf as r, NO_TOKENS as s, childModel as t, estimateAnswer as u };
525
+ export { runChild as a, sharedSamplingOf as c, addTokens as d, currentTurn as f, withoutExtension as g, trimCharacters as h, childTrace as i, tokensOf as l, tokensOf$1 as m, childSampling as n, SAMPLING_RANGES as o, estimateAnswer as p, childSamplingOf as r, parseSampling as s, childModel as t, NO_TOKENS as u };
434
526
 
435
- //# sourceMappingURL=child-CFjnaTZt.js.map
527
+ //# sourceMappingURL=child-DsixtqTw.js.map