@dsh-agentic-roleplay/core 0.8.1 → 0.9.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 (51) hide show
  1. package/lib/{access-DtOxFKBK.js → access-CfQWbNZP.js} +4 -7
  2. package/lib/{authoring-tools-DNnx0Nts.js → authoring-tools-CdHlvx32.js} +2125 -152
  3. package/lib/authoring.js +143 -47
  4. package/lib/{child-D6mpkkCE.js → child-lYYeOwl2.js} +28 -51
  5. package/lib/client.js +611 -774
  6. package/lib/client.js.map +1 -1
  7. package/lib/compaction.js +8 -13
  8. package/lib/{doctor-chat-ByDfCMeo.js → doctor-chat-hL1a61hp.js} +2 -3
  9. package/lib/doctor.js +6 -8
  10. package/lib/{gallery-D9nG3C78.js → gallery-BKh7eu80.js} +3 -4
  11. package/lib/{generator-r1Czm7oi.js → generator-DdZ1-sgv.js} +3 -4
  12. package/lib/helper.js +2 -3
  13. package/lib/{hooks-BQCzgggH.js → hooks-CcQj_dJo.js} +69 -97
  14. package/lib/images.js +4 -4
  15. package/lib/index.js +195 -265
  16. package/lib/{library-zI-2tG7h.js → library-QFL6Z_Nr.js} +9 -15
  17. package/lib/{lorebook-author-tools-ywaYicwd.js → lorebook-author-tools-DWBnYo1E.js} +10 -13
  18. package/lib/lorebook-authoring.js +5 -6
  19. package/lib/{narration-CnBlVure.js → narration-CjB_KwwY.js} +9 -15
  20. package/lib/orchestration.js +53 -64
  21. package/lib/{pack-jail-5EJ-WYyW.js → pack-jail-BMy6NcCY.js} +81 -788
  22. package/lib/{packs-Cv8hanXJ.js → packs-BREPSfHy.js} +6 -10
  23. package/lib/{presenter-agent-BSaMSd3G.js → presenter-agent-B49-_iUm.js} +12 -18
  24. package/lib/{preset-CWI3-0r1.js → preset-BqgY1Tz4.js} +5 -6
  25. package/lib/{preset-author-tools-BrJYa2cr.js → preset-author-tools-BB_Dcv2o.js} +12 -14
  26. package/lib/preset-authoring.js +6 -7
  27. package/lib/{presets-MwOSMMyu.js → presets-Bwnrx7p0.js} +69 -63
  28. package/lib/{reflection-zSaMsjKj.js → reflection-CUWG-6Qg.js} +19 -30
  29. package/lib/{text-BzudpQLS.js → text-CbGQhK1-.js} +9 -10
  30. package/lib/{turn-guard-Cv8pfHEA.js → turn-guard-Bb8Ew-1z.js} +6 -11
  31. package/package.json +29 -29
  32. package/prompts/en/checks/decide-sheet.md +1 -0
  33. package/prompts/en/checks/fidelity.md +7 -0
  34. package/prompts/en/checks/gaps.md +4 -0
  35. package/prompts/en/checks/notice.md +3 -0
  36. package/prompts/en/import/casting.md +1 -1
  37. package/prompts/en/import/character.md +1 -0
  38. package/prompts/en/import/finish-draft.md +1 -1
  39. package/prompts/en/import/finish-ok.md +3 -1
  40. package/prompts/en/import/notice-repair.md +2 -2
  41. package/prompts/en/import/repair-again.md +2 -2
  42. package/prompts/zh/checks/decide-sheet.md +1 -0
  43. package/prompts/zh/checks/fidelity.md +7 -0
  44. package/prompts/zh/checks/gaps.md +4 -0
  45. package/prompts/zh/checks/notice.md +3 -0
  46. package/prompts/zh/import/casting.md +1 -1
  47. package/prompts/zh/import/character.md +1 -0
  48. package/prompts/zh/import/finish-draft.md +1 -1
  49. package/prompts/zh/import/finish-ok.md +3 -1
  50. package/prompts/zh/import/notice-repair.md +2 -2
  51. package/prompts/zh/import/repair-again.md +2 -2
@@ -1,12 +1,11 @@
1
- import { q as Reader } from "./hooks-BQCzgggH.js";
1
+ import { q as Reader } from "./hooks-CcQj_dJo.js";
2
2
  import { dirname, extname, join, posix, sep } from "node:path";
3
3
  import { copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync } from "node:fs";
4
4
  import { createHash } from "node:crypto";
5
- //#region src/shared/worlds.ts
5
+ // src/shared/worlds.ts
6
6
  /** Path prefix of the plugin's HTTP API. Relative, so a mounted deployment resolves it against the page. */
7
7
  const API_PREFIX = "roleplay-api";
8
- //#endregion
9
- //#region src/shared/interface-pack.ts
8
+ // src/shared/interface-pack.ts
10
9
  /** What a surface may do for the player; a pack lists the ones it uses. */
11
10
  const PACK_ACTIONS = [
12
11
  "say",
@@ -75,8 +74,7 @@ const PACK_MEDIA_TYPES = {
75
74
  ogg: "audio/ogg",
76
75
  wav: "audio/wav"
77
76
  };
78
- //#endregion
79
- //#region src/host/interface/skin.ts
77
+ // src/host/interface/skin.ts
80
78
  const NESTABLE = /* @__PURE__ */ new Set(["media", "supports"]);
81
79
  const FORBIDDEN_TEXT = [
82
80
  "expression(",
@@ -382,8 +380,7 @@ function checkSkin(css, url) {
382
380
  problems: context.problems
383
381
  };
384
382
  }
385
- //#endregion
386
- //#region src/host/interface/pack.ts
383
+ // src/host/interface/pack.ts
387
384
  const ID = /^[\p{L}\p{N}][\p{L}\p{N}_-]{0,59}$/u;
388
385
  const SEGMENT = /^[\p{L}\p{N}_.-]+$/u;
389
386
  const TOKEN_NAME = /^--dsw-alias-[a-z0-9-]+$/;
@@ -837,7 +834,6 @@ function anyTab(bases) {
837
834
  }
838
835
  }));
839
836
  }
840
- //#endregion
841
837
  export { API_PREFIX as _, packIds as a, describePack as c, packPath as d, readPack as f, SURFACE_NAMES as g, PACK_MEDIA_TYPES as h, inheritPacks as i, isPackId as l, PACK_LIMITS as m, anyTab as n, syncWorldPacks as o, PACK_ACTIONS as p, copyWorldPacks as r, worldPackStates as s, activePack as t, packFile as u };
842
838
 
843
- //# sourceMappingURL=packs-Cv8hanXJ.js.map
839
+ //# sourceMappingURL=packs-BREPSfHy.js.map
@@ -1,15 +1,15 @@
1
- import { t as promptFor } from "./access-DtOxFKBK.js";
2
- import { c as runChild } from "./child-D6mpkkCE.js";
3
- import { c as nextSceneSerial, u as referenceImagePath } from "./library-zI-2tG7h.js";
4
- import { n as generateTransientImage, t as generateReferenceImage } from "./generator-r1Czm7oi.js";
5
- import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-D9nG3C78.js";
1
+ import { t as promptFor } from "./access-CfQWbNZP.js";
2
+ import { c as runChild } from "./child-lYYeOwl2.js";
3
+ import { n as generateTransientImage, t as generateReferenceImage } from "./generator-DdZ1-sgv.js";
4
+ import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-BKh7eu80.js";
5
+ import { c as nextSceneSerial, u as referenceImagePath } from "./library-QFL6Z_Nr.js";
6
6
  import { dirname, join, relative } from "node:path";
7
7
  import { existsSync } from "node:fs";
8
8
  import { createHash, randomUUID } from "node:crypto";
9
9
  import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
10
10
  import { defineTool } from "@deepseek-ai/dsh-tools";
11
11
  import { characterKey, itemKey, locationKey } from "@dsh-agentic-roleplay/state";
12
- //#region src/host/images/presented.ts
12
+ // src/host/images/presented.ts
13
13
  const PRESENTED_FOLDER = "presented";
14
14
  const fileOf = (folder, node) => join(folder, "images", PRESENTED_FOLDER, `${node}.json`);
15
15
  /** The images shown for a timeline node that were not made for it. */
@@ -34,8 +34,7 @@ async function present(sessionFolder, node, image) {
34
34
  }] }, null, 2));
35
35
  await rename(temporary, file);
36
36
  }
37
- //#endregion
38
- //#region src/host/images/image-search.ts
37
+ // src/host/images/image-search.ts
39
38
  const WORD = /[\p{L}\p{N}]+/gu;
40
39
  const CJK = /[㐀-鿿぀-ヿ가-힯]/u;
41
40
  /** Function words that say nothing about a picture, so that "a boat at anchor" does not find a wood because both have an "a". */
@@ -118,8 +117,7 @@ function searchImages(images, query) {
118
117
  };
119
118
  }).filter((match) => match.score > 0).sort((a, b) => b.score - a.score || b.image.createdAt.localeCompare(a.image.createdAt)).slice(0, query.limit ?? 5);
120
119
  }
121
- //#endregion
122
- //#region src/host/images/image-vectors.ts
120
+ // src/host/images/image-vectors.ts
123
121
  const VECTORS_FILE = ".vectors.json";
124
122
  /** Images closer than this to the query by meaning are candidates even when they share no word with it. */
125
123
  const MIN_SIMILARITY = .35;
@@ -251,8 +249,7 @@ async function findImages(sessionFolder, images, query, embedder, signal) {
251
249
  };
252
250
  }
253
251
  }
254
- //#endregion
255
- //#region src/host/images/tools.ts
252
+ // src/host/images/tools.ts
256
253
  const kindSchema = {
257
254
  type: "string",
258
255
  enum: [
@@ -664,8 +661,7 @@ function imageTools(deps) {
664
661
  transient
665
662
  ];
666
663
  }
667
- //#endregion
668
- //#region src/host/images/interpreter.ts
664
+ // src/host/images/interpreter.ts
669
665
  const RESULT$1 = {
670
666
  type: "object",
671
667
  properties: {
@@ -796,8 +792,7 @@ async function interpretImage(job) {
796
792
  subjects: answer.subjects
797
793
  });
798
794
  }
799
- //#endregion
800
- //#region src/host/images/presenter-agent.ts
795
+ // src/host/images/presenter-agent.ts
801
796
  const RESULT = {
802
797
  type: "object",
803
798
  properties: { summary: {
@@ -849,7 +844,6 @@ async function runImagePresenter(job) {
849
844
  images: [...generated]
850
845
  };
851
846
  }
852
- //#endregion
853
847
  export { tokensOf as a, searchImages as i, interpretImage as n, present as o, imageTools as r, presentedFor as s, runImagePresenter as t };
854
848
 
855
- //# sourceMappingURL=presenter-agent-BSaMSd3G.js.map
849
+ //# sourceMappingURL=presenter-agent-B49-_iUm.js.map
@@ -1,7 +1,7 @@
1
- import { Nt as ImportCardError, r as MAX_PREVIEW_TEXT } from "./authoring-tools-DNnx0Nts.js";
2
- import { H as cleanText } from "./presets-MwOSMMyu.js";
3
- import { l as SAMPLING_RANGES } from "./child-D6mpkkCE.js";
4
- //#region src/host/import/preset.ts
1
+ import { Zt as ImportCardError, r as MAX_PREVIEW_TEXT } from "./authoring-tools-CdHlvx32.js";
2
+ import { l as SAMPLING_RANGES } from "./child-lYYeOwl2.js";
3
+ import { J as cleanText } from "./presets-Bwnrx7p0.js";
4
+ // src/host/import/preset.ts
5
5
  /** The older preset layout keeps its texts under fixed keys. */
6
6
  const LEGACY_KEYS = [
7
7
  "main_prompt",
@@ -237,7 +237,6 @@ function selectPrompts(file, enabled, keepSampling) {
237
237
  }];
238
238
  return Buffer.from(JSON.stringify(kept));
239
239
  }
240
- //#endregion
241
240
  export { readPreset as n, selectPrompts as r, previewPreset as t };
242
241
 
243
- //# sourceMappingURL=preset-CWI3-0r1.js.map
242
+ //# sourceMappingURL=preset-BqgY1Tz4.js.map
@@ -1,14 +1,14 @@
1
- import "./access-DtOxFKBK.js";
2
- import { i as contextOf } from "./authoring-tools-DNnx0Nts.js";
3
- import { B as readWorldPrompt, G as withPlayer, K as IMPORT_FOLDER, L as PROSE_PROMPTS, R as deleteWorldPrompt, V as writeWorldPrompt, c as presetDirectory, l as readPreset, p as updatePresetInfo, t as PRESET_FILE, v as extractStyleFrom, z as listWorldPrompts } from "./presets-MwOSMMyu.js";
4
- import { at as shippedPromptsDirectory, it as shippedLanguages, tt as languageOf } from "./hooks-BQCzgggH.js";
5
- import { i as translator, r as languageOf$1 } from "./text-BzudpQLS.js";
6
- import { n as readPreset$1 } from "./preset-CWI3-0r1.js";
1
+ import "./access-CfQWbNZP.js";
2
+ import { G as listWorldPrompts, K as readWorldPrompt, Q as IMPORT_FOLDER, U as PROSE_PROMPTS, W as deleteWorldPrompt, Z as withPlayer, c as presetDirectory, l as readPreset, p as updatePresetInfo, q as writeWorldPrompt, t as PRESET_FILE, x as extractStyleFrom } from "./presets-Bwnrx7p0.js";
3
+ import { n as readPreset$1 } from "./preset-BqgY1Tz4.js";
4
+ import { i as contextOf } from "./authoring-tools-CdHlvx32.js";
5
+ import { i as translator, r as languageOf } from "./text-CbGQhK1-.js";
6
+ import { at as shippedPromptsDirectory, it as shippedLanguages, tt as languageOf$1 } from "./hooks-CcQj_dJo.js";
7
7
  import { join } from "node:path";
8
8
  import { existsSync } from "node:fs";
9
9
  import { readFile, rm } from "node:fs/promises";
10
10
  import { defineTool } from "@deepseek-ai/dsh-tools";
11
- //#region src/shared/preset-chat.ts
11
+ // src/shared/preset-chat.ts
12
12
  const PREFIX = "preset-author-";
13
13
  /** Stable DSH chat identity for the authoring conversation of one library preset. */
14
14
  function presetChatSessionId(name) {
@@ -25,8 +25,7 @@ function presetOfChat(chatSessionId) {
25
25
  return;
26
26
  }
27
27
  }
28
- //#endregion
29
- //#region src/host/authoring/preset-author-tools.ts
28
+ // src/host/authoring/preset-author-tools.ts
30
29
  const PRESET_MUTATION_TOOLS = [
31
30
  "write_preset_prompt",
32
31
  "delete_preset_prompt",
@@ -37,7 +36,7 @@ const NARRATION_IMPORT_TOOL = "import_narration_preset";
37
36
  const UPLOAD_PATH = `${IMPORT_FOLDER}/${PRESET_FILE}`;
38
37
  /** The command that has a preset's authoring chat turn an uploaded SillyTavern preset into prompts. */
39
38
  function narrationImportMessage(language) {
40
- return translator(languageOf$1(language))("Turn the SillyTavern preset I uploaded into this preset's prompts: call {tool} with file {file}.", {
39
+ return translator(languageOf(language))("Turn the SillyTavern preset I uploaded into this preset's prompts: call {tool} with file {file}.", {
41
40
  tool: NARRATION_IMPORT_TOOL,
42
41
  file: UPLOAD_PATH
43
42
  });
@@ -143,7 +142,7 @@ function presetAuthorTools(reader, settings, prompting, shipped = shippedPrompts
143
142
  return json({
144
143
  action: "written",
145
144
  id: args.id,
146
- language: languageOf(args.language)
145
+ language: languageOf$1(args.language)
147
146
  });
148
147
  }
149
148
  }),
@@ -161,7 +160,7 @@ function presetAuthorTools(reader, settings, prompting, shipped = shippedPrompts
161
160
  return json({
162
161
  action: "deleted",
163
162
  id: args.id,
164
- language: languageOf(args.language),
163
+ language: languageOf$1(args.language),
165
164
  trashPath
166
165
  });
167
166
  }
@@ -277,7 +276,6 @@ async function presetApproval(exec, next, carries) {
277
276
  }
278
277
  };
279
278
  }
280
- //#endregion
281
279
  export { presetChatSessionId as a, presetAuthorTools as i, narrationImportMessage as n, presetOfChat as o, presetApproval as r, PresetReader as t };
282
280
 
283
- //# sourceMappingURL=preset-author-tools-BrJYa2cr.js.map
281
+ //# sourceMappingURL=preset-author-tools-BB_Dcv2o.js.map
@@ -1,11 +1,11 @@
1
- import { n as limitAuthoringAgents } from "./authoring-tools-DNnx0Nts.js";
2
- import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-BrJYa2cr.js";
3
- import { c as presetDirectory } from "./presets-MwOSMMyu.js";
4
- import "./hooks-BQCzgggH.js";
5
- import { t as guardAuthoringTurns } from "./turn-guard-Cv8pfHEA.js";
1
+ import { n as limitAuthoringAgents } from "./authoring-tools-CdHlvx32.js";
2
+ import { t as guardAuthoringTurns } from "./turn-guard-Bb8Ew-1z.js";
3
+ import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-BB_Dcv2o.js";
4
+ import "./hooks-CcQj_dJo.js";
5
+ import { c as presetDirectory } from "./presets-Bwnrx7p0.js";
6
6
  import { join } from "node:path";
7
7
  import { existsSync } from "node:fs";
8
- //#region src/preset-authoring.ts
8
+ // src/preset-authoring.ts
9
9
  const name = "@dsh-agentic-roleplay/core/preset-authoring";
10
10
  const inject = [
11
11
  "roleplayRoot",
@@ -55,7 +55,6 @@ function apply(ctx) {
55
55
  text: (context) => ctx.roleplayPrompts.text(id, languageOf(context))
56
56
  });
57
57
  }
58
- //#endregion
59
58
  export { apply, inject, name };
60
59
 
61
60
  //# sourceMappingURL=preset-authoring.js.map
@@ -1,14 +1,14 @@
1
- import { i as VARIABLE_VISIBILITIES, n as VARIABLE_KINDS, r as VARIABLE_SUBJECTS } from "./access-DtOxFKBK.js";
2
- import "./narration-CnBlVure.js";
3
- import { J as formatIssue, K as readDocument, X as LANGUAGE_FOLDER, Y as errorMessage, Z as PROMPTS_FOLDER, at as shippedPromptsDirectory, it as shippedLanguages, nt as listFiles, q as Reader, rt as promptProblem, tt as languageOf } from "./hooks-BQCzgggH.js";
4
- import { u as parseSampling } from "./child-D6mpkkCE.js";
5
- import { C as trOf, S as slug, b as mapLimit, w as uniqueKey, x as norm } from "./library-zI-2tG7h.js";
1
+ import { i as VARIABLE_VISIBILITIES, n as VARIABLE_KINDS, r as VARIABLE_SUBJECTS } from "./access-CfQWbNZP.js";
2
+ import "./narration-CjB_KwwY.js";
3
+ import { J as formatIssue, K as readDocument, X as LANGUAGE_FOLDER, Y as errorMessage, Z as PROMPTS_FOLDER, at as shippedPromptsDirectory, it as shippedLanguages, nt as listFiles, q as Reader, rt as promptProblem, tt as languageOf } from "./hooks-CcQj_dJo.js";
4
+ import { u as parseSampling } from "./child-lYYeOwl2.js";
5
+ import { C as trOf, S as slug, b as mapLimit, w as uniqueKey, x as norm } from "./library-QFL6Z_Nr.js";
6
6
  import { dirname, join } from "node:path";
7
7
  import { existsSync, readFileSync, readdirSync } from "node:fs";
8
8
  import { createHash, randomUUID } from "node:crypto";
9
9
  import { cp, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
10
10
  import { MAX_ROUTINE_WINDOWS, createSessionStore, dayTokenProblems, valueIssue } from "@dsh-agentic-roleplay/state";
11
- //#region ../dsh-roleplay-model/src/character.ts
11
+ // ../dsh-roleplay-model/src/character.ts
12
12
  const CHARACTER_ROLES = ["playable", "npc"];
13
13
  const CHARACTER_TIERS = [
14
14
  "principal",
@@ -16,8 +16,7 @@ const CHARACTER_TIERS = [
16
16
  "background"
17
17
  ];
18
18
  const CHARACTER_KINDS = ["person", "group"];
19
- //#endregion
20
- //#region ../dsh-roleplay-model/src/intent.ts
19
+ // ../dsh-roleplay-model/src/intent.ts
21
20
  const INTENT_TYPES = [
22
21
  "need",
23
22
  "obligation",
@@ -42,8 +41,7 @@ const INTENT_HORIZONS = [
42
41
  "long",
43
42
  "open_ended"
44
43
  ];
45
- //#endregion
46
- //#region ../dsh-roleplay-model/src/item.ts
44
+ // ../dsh-roleplay-model/src/item.ts
47
45
  /** Whether a container can be got into. */
48
46
  const CONTAINER_STATES = [
49
47
  "open",
@@ -108,23 +106,20 @@ const DEFAULT_SLOTS = [
108
106
  capacity: 1
109
107
  }
110
108
  ];
111
- //#endregion
112
- //#region ../dsh-roleplay-model/src/location.ts
109
+ // ../dsh-roleplay-model/src/location.ts
113
110
  /** Whether people can go through an exit now. */
114
111
  const EXIT_STATES = [
115
112
  "open",
116
113
  "locked",
117
114
  "blocked"
118
115
  ];
119
- //#endregion
120
- //#region ../dsh-roleplay-model/src/faction.ts
116
+ // ../dsh-roleplay-model/src/faction.ts
121
117
  const MEMBERSHIP_STATUSES = [
122
118
  "active",
123
119
  "inactive",
124
120
  "former"
125
121
  ];
126
- //#endregion
127
- //#region ../dsh-roleplay-model/src/agenda.ts
122
+ // ../dsh-roleplay-model/src/agenda.ts
128
123
  const WEEKDAY_NAMES = [
129
124
  "sun",
130
125
  "mon",
@@ -134,8 +129,7 @@ const WEEKDAY_NAMES = [
134
129
  "fri",
135
130
  "sat"
136
131
  ];
137
- //#endregion
138
- //#region ../dsh-roleplay-model/src/lore.ts
132
+ // ../dsh-roleplay-model/src/lore.ts
139
133
  const LORE_KINDS = [
140
134
  "history",
141
135
  "culture",
@@ -156,8 +150,7 @@ const LORE_SUBJECT_KINDS = [
156
150
  "item",
157
151
  "lore"
158
152
  ];
159
- //#endregion
160
- //#region src/shared/world-state.ts
153
+ // src/shared/world-state.ts
161
154
  /** The problems with an edit, for the person who made it; nothing was changed. */
162
155
  var InvalidEditProblems = class extends Error {
163
156
  problems;
@@ -706,8 +699,7 @@ function readIdentifier(reader, fallback) {
706
699
  if (id !== void 0 && id.length > 100) reader.fail("id", `must be at most 100 characters`);
707
700
  return id;
708
701
  }
709
- //#endregion
710
- //#region src/host/variables/values.ts
702
+ // src/host/variables/values.ts
711
703
  /** At most this many initial values in one file. */
712
704
  const MAX_VALUES = 40;
713
705
  /** The `variables` of a world file: what a character, item, place or the world starts with, by the key of each variable. */
@@ -745,8 +737,7 @@ function readVisualIdentity(reader) {
745
737
  ...globalId === void 0 ? {} : { globalId }
746
738
  };
747
739
  }
748
- //#endregion
749
- //#region src/host/characters/character-file.ts
740
+ // src/host/characters/character-file.ts
750
741
  const CHARACTER_FILE_NAME = "character.json";
751
742
  const ISO_DATE = /^\d{4}-\d{2}-\d{2}/;
752
743
  function readAge(reader) {
@@ -977,8 +968,7 @@ function parseCharacterFile(text, fallbackId) {
977
968
  value: character
978
969
  };
979
970
  }
980
- //#endregion
981
- //#region src/host/factions/faction-file.ts
971
+ // src/host/factions/faction-file.ts
982
972
  const FACTION_FILE_NAME = "faction.json";
983
973
  function readMembers(reader) {
984
974
  const seen = /* @__PURE__ */ new Set();
@@ -1078,8 +1068,7 @@ function parseFactionFile(text, fallbackId) {
1078
1068
  issues
1079
1069
  };
1080
1070
  }
1081
- //#endregion
1082
- //#region src/host/items/item-file.ts
1071
+ // src/host/items/item-file.ts
1083
1072
  const ITEM_FILE_NAME = "item.json";
1084
1073
  const SLOTS_FILE_NAME = "slots.json";
1085
1074
  /** Read an `item.json`; `fallbackId` (the folder name) is its id when the file sets none. */
@@ -1227,8 +1216,7 @@ function parseSlotsFile(text) {
1227
1216
  value: slots
1228
1217
  };
1229
1218
  }
1230
- //#endregion
1231
- //#region src/host/locations/location-file.ts
1219
+ // src/host/locations/location-file.ts
1232
1220
  const LOCATION_FILE_NAME = "location.json";
1233
1221
  const FEATURE_KEY = /^[\p{L}\p{N}][\p{L}\p{N}\p{M}_-]{0,59}$/u;
1234
1222
  function readFeatures(reader) {
@@ -1306,8 +1294,7 @@ function parseLocationFile(text, fallbackId) {
1306
1294
  value: location
1307
1295
  };
1308
1296
  }
1309
- //#endregion
1310
- //#region src/host/lore/lore-file.ts
1297
+ // src/host/lore/lore-file.ts
1311
1298
  const LORE_FILE_NAME = "lore.json";
1312
1299
  function instant(reader, key) {
1313
1300
  const value = reader.string(key);
@@ -1364,8 +1351,7 @@ function parseLoreFile(text, fallbackId) {
1364
1351
  issues
1365
1352
  };
1366
1353
  }
1367
- //#endregion
1368
- //#region src/host/variables/load.ts
1354
+ // src/host/variables/load.ts
1369
1355
  const VARIABLES_FILE_NAME = "variables.json";
1370
1356
  function readDefinition(reader) {
1371
1357
  const key = reader.string("key", { required: true });
@@ -1527,26 +1513,35 @@ function variableProblems(world) {
1527
1513
  }
1528
1514
  return problems;
1529
1515
  }
1530
- //#endregion
1531
- //#region src/shared/import-card.ts
1516
+ // src/shared/authoring-commands.ts
1517
+ /** The command a message starts with, when its name is one of `names` (not a longer word that starts with it). */
1518
+ function parseAuthoringCommand(text, names) {
1519
+ const value = text.trimStart();
1520
+ if (!value.startsWith("/")) return void 0;
1521
+ const end = value.search(/\s/u);
1522
+ const word = (end < 0 ? value : value.slice(0, end)).slice(1).toLowerCase();
1523
+ return names.includes(word) ? {
1524
+ name: word,
1525
+ rest: end < 0 ? "" : value.slice(end).trim()
1526
+ } : void 0;
1527
+ }
1528
+ // src/shared/import-card.ts
1532
1529
  /** The message the plugin sends on the player's behalf to start the import in the new world's authoring chat. */
1533
1530
  const IMPORT_COMMAND = "/import-st";
1534
1531
  /** The command in a message, with the card it names, or nothing when the message is not the command. */
1535
1532
  function parseImportCommand(text) {
1536
- const value = text.trimStart();
1537
- if (value.slice(0, 10).toLowerCase() !== "/import-st" || value.length > 10 && !/\s/u.test(value[10])) return void 0;
1538
- const body = value.slice(10).trimStart();
1539
- const boundary = body.search(/\s/u);
1533
+ const command = parseAuthoringCommand(text, [IMPORT_COMMAND.slice(1)]);
1534
+ if (command === void 0) return void 0;
1535
+ const boundary = command.rest.search(/\s/u);
1540
1536
  return boundary < 0 ? {
1541
- card: body,
1537
+ card: command.rest,
1542
1538
  request: ""
1543
1539
  } : {
1544
- card: body.slice(0, boundary),
1545
- request: body.slice(boundary).trim()
1540
+ card: command.rest.slice(0, boundary),
1541
+ request: command.rest.slice(boundary).trim()
1546
1542
  };
1547
1543
  }
1548
- //#endregion
1549
- //#region src/host/import/store.ts
1544
+ // src/host/import/store.ts
1550
1545
  const IMPORT_FOLDER = ".import";
1551
1546
  const CARD_FILE = "card.json";
1552
1547
  const CHOICES_FILE = "choices.json";
@@ -1732,8 +1727,7 @@ var ImportStore = class {
1732
1727
  }
1733
1728
  }
1734
1729
  };
1735
- //#endregion
1736
- //#region src/host/import/items.ts
1730
+ // src/host/import/items.ts
1737
1731
  /** The longest a piece goes into one call. Longer entries are cut into parts at the end of a paragraph. */
1738
1732
  const MAX_ITEM_CHARS = 5e3;
1739
1733
  /** What stands for the player in the text a model reads. The card's own `{{user}}` cannot: the system prompt of an agent reads double braces as a variable of its own. */
@@ -1795,8 +1789,7 @@ function playerWord(text, name) {
1795
1789
  function withPlayer(text, name) {
1796
1790
  return text.replace(/\[PLAYER\]|\{\{\s*user\s*\}\}/g, playerWord(text, name));
1797
1791
  }
1798
- //#endregion
1799
- //#region src/host/prompts/world-prompts.ts
1792
+ // src/host/prompts/world-prompts.ts
1800
1793
  /** The prompts that decide how the story is written and who the models are (prose and persona); every other prompt holds rules of the game. */
1801
1794
  const PROSE_PROMPTS = [
1802
1795
  "roleplay/persona",
@@ -1861,8 +1854,7 @@ async function deleteWorldPrompt(directory, language, id, shipped = shippedPromp
1861
1854
  await rm(dirname(file), { recursive: false }).catch(() => void 0);
1862
1855
  return aside;
1863
1856
  }
1864
- //#endregion
1865
- //#region src/host/decisions/route.ts
1857
+ // src/host/decisions/route.ts
1866
1858
  /** The probability from which a yes is taken as a yes, for the confidence a chat asks. */
1867
1859
  const yesAt = (confidence) => (1 + confidence) / 2;
1868
1860
  /** The probability up to which a no is taken as a no. */
@@ -1978,6 +1970,8 @@ async function routeVerdicts(route, signal) {
1978
1970
  report
1979
1971
  };
1980
1972
  }
1973
+ /** `hybrid` is a default that only does something where a decision model is set up: with none it is the language model alone, and nothing is said, because nothing is wrong. */
1974
+ const modeFor = (mode, service) => mode === "hybrid" && service === void 0 ? "llm" : mode;
1981
1975
  /** Asks the decision model one yes-or-no question for each key about one state, in a single request; the answers are probabilities of yes. */
1982
1976
  async function askYesNo(service, state, asks, signal) {
1983
1977
  const questions = Object.fromEntries(asks.map(({ key, instructions }) => [key, {
@@ -2021,8 +2015,7 @@ function mergeReports(mode, reports) {
2021
2015
  merged.samples = merged.samples.slice(-20);
2022
2016
  return merged;
2023
2017
  }
2024
- //#endregion
2025
- //#region src/host/import/roles.ts
2018
+ // src/host/import/roles.ts
2026
2019
  const ROLES = [
2027
2020
  "character",
2028
2021
  "player",
@@ -2104,8 +2097,7 @@ const isGeneratorOnly = (piece) => playsRole(piece, "generator") && piece.roles.
2104
2097
  const statesWorldFacts = (piece) => playsRole(piece, "world") && !playsRole(piece, "instruction") && !playsRole(piece, "generator");
2105
2098
  /** A piece that may hold guidance on making things up or a standing rule (the generator pieces are read whole by their own step). */
2106
2099
  const mayHoldGuidance = (piece) => !playsRole(piece, "generator") && piece.roles.some((role) => ROLE_TABLE[role].guidance);
2107
- //#endregion
2108
- //#region src/host/import/survey.ts
2100
+ // src/host/import/survey.ts
2109
2101
  const MAX_TARGETS = 10;
2110
2102
  const MAX_NAME = 100;
2111
2103
  /** What a name is when it only stands for the person using the card: not a character of the card. */
@@ -2478,8 +2470,7 @@ function findEntity(roster, name, kind) {
2478
2470
  }));
2479
2471
  return near.length === 1 ? near[0] : void 0;
2480
2472
  }
2481
- //#endregion
2482
- //#region src/host/import/extract.ts
2473
+ // src/host/import/extract.ts
2483
2474
  const emptyExtracted = () => ({
2484
2475
  characters: [],
2485
2476
  locations: [],
@@ -2620,6 +2611,7 @@ const CHARACTER_SCHEMA = {
2620
2611
  additionalProperties: false
2621
2612
  }
2622
2613
  },
2614
+ carries: strs("Things they have on them at the start (a weapon, a tool, a document, a keepsake), by the name the text gives them. Not things they only know of."),
2623
2615
  knows: {
2624
2616
  type: "object",
2625
2617
  properties: {
@@ -2653,6 +2645,8 @@ const CHARACTER_SCHEMA = {
2653
2645
  ],
2654
2646
  additionalProperties: false
2655
2647
  };
2648
+ /** The most things one character is given from what the text says it carries. */
2649
+ const MAX_CARRIED = 12;
2656
2650
  /** The document of a character file from what the call answered; names of places and characters become the keys they have in the roster. */
2657
2651
  function characterDocument(entity, answer, roster) {
2658
2652
  const notes = [];
@@ -2747,9 +2741,11 @@ function characterDocument(entity, answer, roster) {
2747
2741
  }
2748
2742
  put(knowledge, "exits", exits);
2749
2743
  put(document, "knowledge", Object.keys(knowledge).length === 0 ? void 0 : knowledge);
2744
+ const carried = [...new Set(list(answer["carries"]))].slice(0, MAX_CARRIED);
2750
2745
  return {
2751
2746
  document,
2752
- notes
2747
+ notes,
2748
+ ...carried.length === 0 ? {} : { carried }
2753
2749
  };
2754
2750
  }
2755
2751
  const PLACE_SCHEMA = {
@@ -3318,6 +3314,18 @@ async function extractEntities(ctx, card, items, classified, roster) {
3318
3314
  thing: "items"
3319
3315
  }[entity.kind]].push(built.document);
3320
3316
  }
3317
+ const itemIds = new Set(result.items.map((entry) => String(entry["id"])));
3318
+ for (const { entity, built } of entityResults) {
3319
+ if (entity.kind !== "character") continue;
3320
+ for (const name of built?.carried ?? []) {
3321
+ if (findEntity(roster, name, "thing") !== void 0 || result.items.some((entry) => norm(String(entry["name"])) === norm(name) && entry["held_by"] === entity.key)) continue;
3322
+ result.items.push({
3323
+ id: uniqueKey(slug(name, "thing"), itemIds),
3324
+ name,
3325
+ held_by: entity.key
3326
+ });
3327
+ }
3328
+ }
3321
3329
  const worldItems = items.filter((item) => statesWorldFacts(classified[item.id] ?? { roles: [] }));
3322
3330
  const taken = /* @__PURE__ */ new Set();
3323
3331
  const loreResults = await mapLimit(worldItems, ctx.concurrency, async (item, index) => {
@@ -3736,8 +3744,7 @@ async function extractVariables(ctx, card, items, classified, roster) {
3736
3744
  notes: found.flatMap((entry) => entry.notes)
3737
3745
  };
3738
3746
  }
3739
- //#endregion
3740
- //#region src/host/presets/presets.ts
3747
+ // src/host/presets/presets.ts
3741
3748
  const PRESETS_FOLDER = "presets";
3742
3749
  const PRESET_FILE = "preset.json";
3743
3750
  const NAME = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
@@ -3992,7 +3999,6 @@ async function createPresetFromGuidance(root, request, guidance, shipped = shipp
3992
3999
  });
3993
4000
  }
3994
4001
  }
3995
- //#endregion
3996
- export { writeChoices as $, isLeftOut as A, DEFAULT_SLOTS as At, readWorldPrompt as B, pruneMembers as C, parseLoreEdit as Ct, classifyItems as D, LORE_KINDS as Dt, buildRoster as E, parseThingEdit as Et, routeVerdicts as F, withPlayer as G, cleanText as H, yesAt as I, ImportStore as J, IMPORT_FOLDER as K, PROSE_PROMPTS as L, askYesNo as M, mergeReports as N, findEntity as O, LORE_SCOPES as Ot, noAt as P, readImportFolder as Q, deleteWorldPrompt as R, pruneLoreSubjects as S, parseFactionEdit as St, sourcesFor as T, parseRelationEdit as Tt, itemise as U, writeWorldPrompt as V, partsOf as W, openingText as X, PICTURE_FILE as Y, parseChoices as Z, extractStyle as _, parseCharacterFile as _t, isPresetName as a, variableProblems as at, pruneKnowledge as b, InvalidEditProblems as bt, presetDirectory as c, LOCATION_FILE_NAME as ct, savePresetFromWorld as d, SLOTS_FILE_NAME as dt, IMPORT_COMMAND as et, sha as f, parseItemFile as ft, extractEntities as g, CHARACTER_FILE_NAME as gt, emptyExtracted as h, parseFactionFile as ht, deletePreset as i, parseVariablesFile as it, announceProblem as j, INTENT_STATUSES as jt, ROLES as k, WEEKDAY_NAMES as kt, readPreset as l, parseLocationFile as lt, STANDING_PROMPT as m, FACTION_FILE_NAME as mt, createPresetFromGuidance as n, VARIABLES_FILE_NAME as nt, listPresets as o, LORE_FILE_NAME as ot, updatePresetInfo as p, parseSlotsFile as pt, ImportNotFoundError as q, createPresetFromShipped as r, loadVariables as rt, loadPreset as s, parseLoreFile as st, PRESET_FILE as t, parseImportCommand as tt, reservePreset as u, ITEM_FILE_NAME as ut, extractStyleFrom as v, readVariableValues as vt, pruneRelationships as w, parsePlaceEdit as wt, pruneLinks as x, parseCharacterEdit as xt, extractVariables as y, readIdentifier as yt, listWorldPrompts as z };
4002
+ export { ImportNotFoundError as $, sourcesFor as A, parseLoreEdit as At, noAt as B, inert as C, CHARACTER_FILE_NAME as Ct, pruneLoreSubjects as D, InvalidEditProblems as Dt, pruneLinks as E, readIdentifier as Et, isLeftOut as F, LORE_SCOPES as Ft, listWorldPrompts as G, yesAt as H, announceProblem as I, WEEKDAY_NAMES as It, cleanText as J, readWorldPrompt as K, askYesNo as L, DEFAULT_SLOTS as Lt, classifyItems as M, parseRelationEdit as Mt, findEntity as N, parseThingEdit as Nt, pruneMembers as O, parseCharacterEdit as Ot, ROLES as P, LORE_KINDS as Pt, IMPORT_FOLDER as Q, mergeReports as R, INTENT_STATUSES as Rt, extractVariables as S, parseFactionFile as St, pruneKnowledge as T, readVariableValues as Tt, PROSE_PROMPTS as U, routeVerdicts as V, deleteWorldPrompt as W, partsOf as X, itemise as Y, withPlayer as Z, characterDocument as _, ITEM_FILE_NAME as _t, isPresetName as a, writeChoices as at, extractStyle as b, parseSlotsFile as bt, presetDirectory as c, parseAuthoringCommand as ct, savePresetFromWorld as d, parseVariablesFile as dt, ImportStore as et, sha as f, variableProblems as ft, asWritten as g, parseLocationFile as gt, addLore as h, LOCATION_FILE_NAME as ht, deletePreset as i, readImportFolder as it, buildRoster as j, parsePlaceEdit as jt, pruneRelationships as k, parseFactionEdit as kt, readPreset as l, VARIABLES_FILE_NAME as lt, STANDING_PROMPT as m, parseLoreFile as mt, createPresetFromGuidance as n, openingText as nt, listPresets as o, IMPORT_COMMAND as ot, updatePresetInfo as p, LORE_FILE_NAME as pt, writeWorldPrompt as q, createPresetFromShipped as r, parseChoices as rt, loadPreset as s, parseImportCommand as st, PRESET_FILE as t, PICTURE_FILE as tt, reservePreset as u, loadVariables as ut, emptyExtracted as v, SLOTS_FILE_NAME as vt, loreDocuments as w, parseCharacterFile as wt, extractStyleFrom as x, FACTION_FILE_NAME as xt, extractEntities as y, parseItemFile as yt, modeFor as z };
3997
4003
 
3998
- //# sourceMappingURL=presets-MwOSMMyu.js.map
4004
+ //# sourceMappingURL=presets-Bwnrx7p0.js.map