@dsh-agentic-roleplay/core 0.12.2 → 0.12.4

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 (31) hide show
  1. package/lib/{authoring-tools-BZr4bgBy.js → authoring-tools-B_qYKK8c.js} +2135 -1863
  2. package/lib/authoring.js +208 -35
  3. package/lib/client.js +850 -491
  4. package/lib/client.js.map +1 -1
  5. package/lib/doctor.js +1 -1
  6. package/lib/{gallery-BNg0rPTp.js → gallery-Bu6eZMKk.js} +2 -2
  7. package/lib/{generator-9-5at9cZ.js → generator-CTWQWbSW.js} +2 -2
  8. package/lib/{hooks-Dtq5KZQX.js → hooks-YXQZ9G2d.js} +200 -41
  9. package/lib/images.js +4 -4
  10. package/lib/index.js +62 -42
  11. package/lib/{library-DTxakw0z.js → library-BmlHNCah.js} +2 -2
  12. package/lib/{lorebook-author-tools-BjcEUo22.js → lorebook-author-tools-C3rRpMt7.js} +6 -6
  13. package/lib/lorebook-authoring.js +5 -5
  14. package/lib/orchestration.js +8 -8
  15. package/lib/{pack-jail-Dt0VTsu0.js → pack-jail-VbcXiukr.js} +42 -14
  16. package/lib/{packs-DWfR2Ted.js → packs-CzVh2ZNe.js} +2 -2
  17. package/lib/{presenter-agent-vFOxIuWv.js → presenter-agent-CF3fneuJ.js} +4 -4
  18. package/lib/{preset-Dv5YF2qj.js → preset-C595KRUM.js} +3 -3
  19. package/lib/{preset-author-tools-BUzO9mTW.js → preset-author-tools-CF_JKKTE.js} +6 -6
  20. package/lib/preset-authoring.js +5 -5
  21. package/lib/{reflection-Dd3pEiZB.js → reflection-ByIQSOKC.js} +6 -6
  22. package/lib/{serial-BUaJGwVy.js → serial-ULGUKWsu.js} +1136 -1056
  23. package/lib/{text-Dfv8S8eq.js → text-hiKTooVb.js} +3 -1
  24. package/lib/{turn-guard-87NE-Cnp.js → turn-guard-DXMeAJdv.js} +2 -2
  25. package/package.json +3 -2
  26. package/prompts/en/import/opening.md +17 -0
  27. package/prompts/en/roleplay/decide-opening.md +1 -0
  28. package/prompts/en/world/procedure.md +1 -1
  29. package/prompts/zh/import/opening.md +17 -0
  30. package/prompts/zh/roleplay/decide-opening.md +1 -0
  31. package/prompts/zh/world/procedure.md +1 -1
package/lib/authoring.js CHANGED
@@ -1,11 +1,11 @@
1
- import { $ as readSource, A as editsSince, C as worldFieldChanges, D as loadCardEvidence, E as loadWorldParts, J as UPDATE_FOLDER, Kt as authoredWorldOf, Mt as CALENDAR_FILE_NAME, O as CHECK_COMMANDS, Ot as COMMANDS_FILE_NAME, Q as entitiesByPiece, S as pictureChange, T as readWorldInfo, Tt as DICE_FILE_NAME, Z as cardTools, _ as runChecks, a as importHooks, b as diffText, et as checkWorld, g as CHECKS, h as presentReport, i as contextOf, l as isReviewing, m as checkImported, n as limitAuthoringAgents, o as importTools, v as addressChanges, w as editWorldInfo, x as matchPieces, y as cardChanges } from "./authoring-tools-BZr4bgBy.js";
2
- import { t as guardAuthoringTurns } from "./turn-guard-87NE-Cnp.js";
1
+ import { $ as checkWorld, A as loadWorldParts, At as lettersOf, C as cardChanges, D as worldFieldChanges, E as pictureChange, F as editsSince, Ft as cardTools, It as entitiesByPiece, Lt as readSource, M as CHECK_COMMANDS, Mt as UPDATE_FOLDER, N as CHECK_COMMAND_DESCRIPTIONS, O as editWorldInfo, Qt as authoredWorldOf, Rt as COMMANDS_FILE_NAME, S as addressChanges, St as DICE_FILE_NAME, T as matchPieces, Tt as CALENDAR_FILE_NAME, b as CHECKS, j as loadCardEvidence, jt as shapeOpening, k as readWorldInfo, kt as loadCharacters, l as importTools, n as limitAuthoringAgents, o as contextOf, p as isReviewing, s as importHooks, u as worldOf, v as checkImported, w as diffText, x as runChecks, y as presentReport } from "./authoring-tools-B_qYKK8c.js";
2
+ import { t as guardAuthoringTurns } from "./turn-guard-DXMeAJdv.js";
3
3
  import { n as silenceRuntimeContext, t as silenceHarnessDevContext } from "./dev-context-Cgv_wZbG.js";
4
- import { B as deleteTriggerDocument, D as editWorldPlots, G as parseVariablesEdit, H as writeTriggerDocument, K as parseDiceEdit, M as readWorldEditor, O as editWorldRelation, Q as translateTools, U as parseCalendarEdit, V as readTriggerDocuments, X as presetTools, a as deleteWorldPackFile, c as createAuthoredEntity, d as replaceAuthoredEntity, f as editCalendar, g as editVariables, i as checkWorldPack, l as deleteAuthoredEntity, m as editDice, nt as finishUpdate, o as listWorldPacks, p as editCommands, q as parseCommandsEdit, r as registerPackJail, rt as pendingUpdate, s as AUTHORED_ENTITY_KINDS, u as readAuthoredEntityDocument } from "./pack-jail-Dt0VTsu0.js";
5
- import { i as translator, r as languageOf } from "./text-Dfv8S8eq.js";
6
- import { $ as deleteWorldPrompt, At as parseAuthoringCommand, Ct as PICTURE_FILE, F as parseWorldInfoEdit, Ft as VARIABLES_FILE_NAME, Q as PROSE_PROMPTS, an as parseRelationEdit, bt as IMPORT_FOLDER, en as InvalidEditProblems, et as listWorldPrompts, nt as writeWorldPrompt, tt as readWorldPrompt } from "./serial-BUaJGwVy.js";
7
- import { B as parsePlotsFile, at as shippedPromptsDirectory, q as formatIssue } from "./hooks-Dtq5KZQX.js";
8
- import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-DWfR2Ted.js";
4
+ import { B as deleteTriggerDocument, D as editWorldPlots, G as parseVariablesEdit, H as writeTriggerDocument, K as parseDiceEdit, M as readWorldEditor, O as editWorldRelation, Q as translateTools, U as parseCalendarEdit, V as readTriggerDocuments, X as presetTools, a as deleteWorldPackFile, c as createAuthoredEntity, d as replaceAuthoredEntity, f as editCalendar, g as editVariables, i as checkWorldPack, l as deleteAuthoredEntity, m as editDice, nt as finishUpdate, o as listWorldPacks, p as editCommands, q as parseCommandsEdit, r as registerPackJail, rt as pendingUpdate, s as AUTHORED_ENTITY_KINDS, u as readAuthoredEntityDocument } from "./pack-jail-VbcXiukr.js";
5
+ import { i as translator, r as languageOf } from "./text-hiKTooVb.js";
6
+ import { Et as IMPORT_FOLDER, F as parseWorldInfoEdit, I as hasSpeech, Pt as InvalidEditProblems, R as partsText, at as writeWorldPrompt, it as readWorldPrompt, kt as PICTURE_FILE, nt as deleteWorldPrompt, qt as VARIABLES_FILE_NAME, rt as listWorldPrompts, tt as PROSE_PROMPTS, zt as parseRelationEdit } from "./serial-ULGUKWsu.js";
7
+ import { B as parsePlotsFile, at as shippedPromptsDirectory, ht as registerCommands, q as formatIssue } from "./hooks-YXQZ9G2d.js";
8
+ import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-CzVh2ZNe.js";
9
9
  import "./access-Csp80TFX.js";
10
10
  import { join, relative } from "node:path";
11
11
  import { createHash } from "node:crypto";
@@ -321,6 +321,26 @@ function authoredWorldReadTools(reader) {
321
321
  })
322
322
  ];
323
323
  }
324
+ // src/host/authoring/opening-speakers.ts
325
+ /**
326
+ * Refuses an opening whose lines are spoken by someone the world does not have, and lists the ids it does have: a model asked to change who speaks writes a name's initials or an
327
+ * invented id unless it is told the real ones (found live: "hale" and "oldge" for a character whose id was "miller").
328
+ * @throws {InvalidEditProblems}
329
+ */
330
+ async function checkOpeningSpeakers(directory, edit) {
331
+ const spoken = [...(edit.openingParts ?? []).map((part) => ({
332
+ where: "openingParts",
333
+ part
334
+ })), ...(edit.alternateOpenings ?? []).flatMap((entry, index) => (entry.parts ?? []).map((part) => ({
335
+ where: `alternateOpenings[${index}].parts`,
336
+ part
337
+ })))].filter((entry) => entry.part.type === "utterance");
338
+ if (spoken.length === 0) return;
339
+ const { characters } = await loadCharacters(directory);
340
+ const ids = new Set(characters.map((character) => character.id));
341
+ const problems = spoken.flatMap(({ where, part }) => part.type === "utterance" && !ids.has(part.character) ? [`${where}: "${part.character}" is not a character of this world; the characters are ${characters.map((character) => `${character.id} (${character.name})`).join(", ")}`] : []);
342
+ if (problems.length > 0) throw new InvalidEditProblems(problems);
343
+ }
324
344
  // src/host/authoring/pack-tools.ts
325
345
  const PACK_MUTATION_TOOLS = ["delete_world_pack_file"];
326
346
  const output$4 = (value) => [{
@@ -616,6 +636,7 @@ const WORLD_INFO_FIELDS = [
616
636
  "tags",
617
637
  "rules",
618
638
  "opening",
639
+ "openingParts",
619
640
  "alternateOpenings",
620
641
  "startQuestions",
621
642
  "startingTime",
@@ -626,6 +647,7 @@ const WORLD_INFO_FIELDS = [
626
647
  ];
627
648
  const AUTHORING_MUTATION_TOOLS = /* @__PURE__ */ new Set([
628
649
  "import_preset",
650
+ "reshape_opening",
629
651
  "edit_world_info",
630
652
  "create_world_element",
631
653
  "replace_world_element",
@@ -667,6 +689,11 @@ function plotDocument(value) {
667
689
  /** Checks a write the way its tool will, and writes nothing: a change the tool would refuse is not put to the person. @throws {InvalidEditProblems} */
668
690
  async function validateMutation(reader, exec) {
669
691
  const args = exec.arguments;
692
+ if (exec.name === "edit_world_info") {
693
+ const { record } = await reader.read(exec);
694
+ await checkOpeningSpeakers(record.directory, parseWorldInfoEdit(args["changes"]));
695
+ return;
696
+ }
670
697
  if (exec.name !== "create_world_element" && exec.name !== "replace_world_element" && exec.name !== "write_world_trigger" && exec.name !== "write_world_file") return;
671
698
  const { record } = await reader.read(exec);
672
699
  if (exec.name === "write_world_file") {
@@ -690,6 +717,16 @@ async function validateMutation(reader, exec) {
690
717
  dryRun: true
691
718
  });
692
719
  }
720
+ /** Which openings (the world's own, or an alternate by position) hold other words than before, ignoring quotation marks and spacing: a change of form alone must not change them. */
721
+ function openingWordsChanged(before, after) {
722
+ const changed = [];
723
+ if (lettersOf(before.opening) !== lettersOf(after.opening)) changed.push("opening");
724
+ after.alternateOpenings.forEach((entry, index) => {
725
+ const was = before.alternateOpenings[index];
726
+ if (was !== void 0 && lettersOf(was.text) !== lettersOf(entry.text)) changed.push(`alternate:${index}`);
727
+ });
728
+ return changed;
729
+ }
693
730
  /** The most problems a write reports back; `check_world` lists the rest. */
694
731
  const REPORTED_PROBLEMS = 8;
695
732
  /**
@@ -793,7 +830,7 @@ function authoredWorldWriteTools(reader) {
793
830
  }),
794
831
  defineTool({
795
832
  name: "edit_world_info",
796
- description: `Change what the world says about itself in world.json: ${WORLD_INFO_FIELDS.join(", ")}. Give only the fields to change, as {"description": "...", "tags": ["..."], "opening": "...", "alternateOpenings": [{"title": "...", "text": "..."}]}: a list replaces the whole list, so read get_world_info first. The description is a short summary (a few sentences). An opening with lines spoken by characters cannot be edited as text. startQuestions is a list of {"id", "text", "options": [{"id", "label", "effect": {...}}]} with two to eight options each; an effect may hold rules (a list of text), opening (the position of an alternate opening), startingTime, clockMode (simulated or real), tools and plots, and {} changes nothing. The name, preset, lorebooks, sampling and tool switches are the person's and cannot be changed here. Requires user approval.`,
833
+ description: `Change what the world says about itself in world.json: ${WORLD_INFO_FIELDS.join(", ")}. Give only the fields to change, as {"description": "...", "tags": ["..."], "opening": "...", "alternateOpenings": [{"title": "...", "text": "..."}]}: a list replaces the whole list, so read get_world_info first. The description is a short summary (a few sentences). An opening is either plain text, which is narration only (opening, and text in an alternate opening), or an ordered list of parts, [{"type": "narration", "text": "..."}, {"type": "utterance", "character": "<character id>", "text": "..."}] (openingParts, and parts in an alternate opening); give one form, not both. Use parts whenever a character speaks, with the speaker's id from list_characters, and plain text only for pure narration; the words must stay exactly as they are when you only change the form, and a speaker you are not sure of stays narration. To only change the form of an opening, or to split it, use reshape_opening: it keeps every word, while retyping the opening here can lose some. Giving opening replaces parts with plain text; giving openingParts replaces plain text with parts. startQuestions is a list of {"id", "text", "options": [{"id", "label", "effect": {...}}]} with two to eight options each; an effect may hold rules (a list of text), opening (the position of an alternate opening), startingTime, clockMode (simulated or real), tools and plots, and {} changes nothing. The name, preset, lorebooks, sampling and tool switches are the person's and cannot be changed here. Requires user approval.`,
797
834
  parameters: { changes: {
798
835
  type: "json",
799
836
  required: true,
@@ -805,13 +842,20 @@ function authoredWorldWriteTools(reader) {
805
842
  const edit = parseWorldInfoEdit(args.changes);
806
843
  const refused = Object.keys(edit).filter((key) => !WORLD_INFO_FIELDS.includes(key));
807
844
  if (refused.length > 0) throw new InvalidEditProblems([`${refused.join(", ")} cannot be changed here: ${WORLD_INFO_FIELDS.join(", ")} can`]);
845
+ await checkOpeningSpeakers(record.directory, edit);
846
+ const before = await readWorldInfo(record.directory);
808
847
  const info = await editWorldInfo(record.directory, edit);
809
848
  await reader.refresh();
849
+ const reworded = openingWordsChanged(before, info);
810
850
  return {
811
851
  action: "edited",
812
852
  kind: "world info",
813
853
  changed: Object.keys(edit),
814
- info
854
+ info,
855
+ ...reworded.length === 0 ? {} : {
856
+ opening_words_changed: reworded,
857
+ note: "The words of these openings are not what they were. If you only meant to change their form (plain text or parts), put the original words back or use reshape_opening, which keeps every word."
858
+ }
815
859
  };
816
860
  }
817
861
  }),
@@ -984,6 +1028,17 @@ async function authoringApproval(exec, next, reviewing = () => Promise.resolve(f
984
1028
  }, remove ? void 0 : sizeOf(args["text"]))
985
1029
  };
986
1030
  }
1031
+ if (exec.name === "reshape_opening") {
1032
+ const target = String(args["target"]);
1033
+ return {
1034
+ kind: "ask",
1035
+ reason: `change the form of the authored world's ${target}`,
1036
+ displayReason: {
1037
+ en: `Change the opening “${target}” to ${String(args["form"]) === "parts" ? "parts (narration and spoken lines)" : "plain text"}? Its words stay the same.`,
1038
+ zh: `把开场“${target}”改为${String(args["form"]) === "parts" ? "分段形式(叙述与台词)" : "纯文本"}?文字内容不变。`
1039
+ }
1040
+ };
1041
+ }
987
1042
  if (exec.name === "edit_world_info") return {
988
1043
  kind: "ask",
989
1044
  reason: "edit the authored world's description, tags, opening or other world.json fields",
@@ -1250,6 +1305,116 @@ function updateHooks(ctx, worlds, languageOf$1) {
1250
1305
  }));
1251
1306
  });
1252
1307
  }
1308
+ // src/host/import/opening-tools.ts
1309
+ const OPENING_TOOL = "reshape_opening";
1310
+ /**
1311
+ * The tool that turns an opening of the world into parts (narration and lines of characters) or back into plain text, for a world imported before openings could have parts
1312
+ * or whose split was wrong. It keeps every word: a split that changes the text is refused. Every call asks the person first.
1313
+ */
1314
+ function openingTools(worlds, settings, prompting) {
1315
+ return [defineTool({
1316
+ name: OPENING_TOOL,
1317
+ description: "Change the form of an opening without changing its words. form \"parts\" splits plain text into narration and the lines that characters of this world speak (a speaker you are not sure of stays narration; an opening with no spoken line stays plain text); form \"plain\" joins parts that are only narration back into plain text and is refused when a character speaks. target is \"opening\" (the world's opening message) or \"alternate:<position>\" (an alternate opening, counting from 0). To correct who speaks a line, or to change words, use edit_world_info with openingParts instead. When the person asks to change the form of an opening, call this at once: the person approves the call itself, so do not ask first, and never retype the opening with edit_world_info to do it. Requires user approval.",
1318
+ parameters: {
1319
+ target: {
1320
+ type: "string",
1321
+ required: true,
1322
+ description: "\"opening\" or \"alternate:<position>\"."
1323
+ },
1324
+ form: {
1325
+ type: "string",
1326
+ required: true,
1327
+ enum: ["parts", "plain"],
1328
+ description: "The form to give it."
1329
+ }
1330
+ },
1331
+ output: {
1332
+ schema: { type: "json" },
1333
+ render: (_args, value) => [{
1334
+ type: "text",
1335
+ text: JSON.stringify(value, null, 1)
1336
+ }]
1337
+ },
1338
+ isConcurrencySafe: () => false,
1339
+ async execute(args, exec) {
1340
+ const world = await worldOf(worlds, exec);
1341
+ const info = await readWorldInfo(world.directory);
1342
+ const match = /^alternate:(\d+)$/.exec(args.target.trim());
1343
+ const position = match === null ? void 0 : Number(match[1]);
1344
+ if (args.target.trim() !== "opening" && position === void 0) throw new Error("target is \"opening\" or \"alternate:<position>\"");
1345
+ const alternate = position === void 0 ? void 0 : info.alternateOpenings[position];
1346
+ if (position !== void 0 && alternate === void 0) throw new Error(`the world has no alternate opening ${position}`);
1347
+ const current = alternate === void 0 ? {
1348
+ text: info.opening,
1349
+ parts: info.openingParts
1350
+ } : {
1351
+ text: alternate.text,
1352
+ parts: alternate.parts
1353
+ };
1354
+ if (current.text.trim() === "") throw new Error("that opening is empty");
1355
+ const write = async (form) => {
1356
+ if (alternate === void 0 || position === void 0) {
1357
+ await editWorldInfo(world.directory, form);
1358
+ return;
1359
+ }
1360
+ const { text: _text, parts: _parts, ...rest } = alternate;
1361
+ const entry = "opening" in form ? {
1362
+ ...rest,
1363
+ text: form.opening
1364
+ } : {
1365
+ ...rest,
1366
+ text: partsText(form.openingParts),
1367
+ parts: form.openingParts
1368
+ };
1369
+ await editWorldInfo(world.directory, { alternateOpenings: info.alternateOpenings.map((item, index) => index === position ? entry : item) });
1370
+ };
1371
+ if (args.form === "plain") {
1372
+ if (current.parts === void 0) return {
1373
+ target: args.target,
1374
+ form: "plain",
1375
+ changed: false,
1376
+ note: "it is already plain text"
1377
+ };
1378
+ if (hasSpeech(current.parts)) throw new Error("characters speak in this opening, so it cannot be plain text; remove their lines first");
1379
+ await write({ opening: partsText(current.parts) });
1380
+ await worlds.list({ refresh: true });
1381
+ return {
1382
+ target: args.target,
1383
+ form: "plain",
1384
+ changed: true
1385
+ };
1386
+ }
1387
+ if (current.parts !== void 0) return {
1388
+ target: args.target,
1389
+ form: "parts",
1390
+ changed: false,
1391
+ note: "it is already in parts"
1392
+ };
1393
+ const language = prompting.languages().get(world.id);
1394
+ const ctx = contextOf(exec, settings(), (id, variables) => prompting.prompts().text(id, language, variables), language);
1395
+ const cast = (await loadCharacters(world.directory)).characters.map((character) => ({
1396
+ id: character.id,
1397
+ name: character.name,
1398
+ aliases: character.aliases ?? []
1399
+ }));
1400
+ const shaped = await shapeOpening(ctx, current.text, cast);
1401
+ if (shaped.parts === void 0) return {
1402
+ target: args.target,
1403
+ form: "parts",
1404
+ changed: false,
1405
+ note: shaped.note ?? "no character speaks in it, so it stays plain text"
1406
+ };
1407
+ await write({ openingParts: shaped.parts });
1408
+ await worlds.list({ refresh: true });
1409
+ return {
1410
+ target: args.target,
1411
+ form: "parts",
1412
+ changed: true,
1413
+ parts: shaped.parts
1414
+ };
1415
+ }
1416
+ })];
1417
+ }
1253
1418
  // src/host/checks/tools.ts
1254
1419
  const output = {
1255
1420
  schema: { type: "json" },
@@ -1323,7 +1488,7 @@ function checkTools(reader, judging) {
1323
1488
  })
1324
1489
  ];
1325
1490
  }
1326
- // src/host/checks/hooks.ts
1491
+ // src/host/checks/commands.ts
1327
1492
  /** The tool each kit is run with, for the notice of a check command. */
1328
1493
  const KIT_TOOLS = {
1329
1494
  consistency: "check_world",
@@ -1331,34 +1496,41 @@ const KIT_TOOLS = {
1331
1496
  quality: "check_quality",
1332
1497
  playability: "check_play"
1333
1498
  };
1334
- /** Hears the check commands (`/check`, `/check-world`) in an authoring chat and tells the assistant to run those kits and what to do with what they find. */
1335
- function checkHooks(ctx, prompting) {
1336
- const authoring = (agent) => agent.session.header.origin === "subagent" || authoredWorldOf(agent.session.id) === void 0 ? void 0 : agent.session.id;
1337
- ctx.on("agent/pre-step", async (payload, next) => {
1338
- const decision = await next();
1339
- const chat = authoring(payload.agent);
1340
- if (decision.kind !== "enter" || payload.step !== 1 || chat === void 0) return decision;
1341
- const text = payload.messages.filter((message) => message.source.kind === "user").flatMap((message) => message.content.flatMap((block) => block.type === "text" ? [block.text] : [])).join("\n");
1342
- const command = parseAuthoringCommand(text, Object.keys(CHECK_COMMANDS));
1343
- if (command === void 0) return decision;
1344
- const world = authoredWorldOf(chat);
1345
- const tools = CHECK_COMMANDS[command.name].map((kit) => KIT_TOOLS[kit]).join(", ");
1346
- const notice = prompting.prompts().text("checks/notice", world === void 0 ? void 0 : prompting.languages().get(world), {
1347
- command: `/${command.name}`,
1348
- tools,
1349
- request: command.rest === "" ? "-" : command.rest
1350
- });
1351
- return {
1352
- ...decision,
1353
- messages: [...decision.messages, createUserMessage({
1499
+ /**
1500
+ * The check commands (`/check`, `/check-world`, ...) of a world authoring chat. Running one tells the assistant which kits to run and what to do with what they find, and what the person
1501
+ * added after the name (`deep` lets a model judge too) is passed on as it was typed.
1502
+ */
1503
+ function checkCommands(ctx, prompting) {
1504
+ registerCommands(ctx, Object.entries(CHECK_COMMANDS).map(([name, kits]) => ({
1505
+ name,
1506
+ description: CHECK_COMMAND_DESCRIPTIONS[name] ?? name,
1507
+ hint: "[deep] [what to look at]",
1508
+ recordInput: false,
1509
+ handler: ({ agent, rawInput }) => {
1510
+ const world = authoredWorldOf(agent.session.id);
1511
+ if (world === void 0 || agent.session.header.origin === "subagent") return {
1512
+ kind: "error",
1513
+ text: `/${name} runs in the authoring chat of a world`
1514
+ };
1515
+ const request = rawInput.trim();
1516
+ const notice = prompting.prompts().text("checks/notice", prompting.languages().get(world), {
1517
+ command: `/${name}`,
1518
+ tools: kits.map((kit) => KIT_TOOLS[kit]).join(", "),
1519
+ request: request === "" ? "-" : request
1520
+ });
1521
+ agent.followup(createUserMessage({
1354
1522
  content: [{
1355
1523
  type: "text",
1356
1524
  text: notice
1357
1525
  }],
1358
1526
  source: { kind: "roleplay" }
1359
- })]
1360
- };
1361
- });
1527
+ }));
1528
+ return {
1529
+ kind: "success",
1530
+ text: `Running ${kits.length === 1 ? "the check" : "the checks"}…`
1531
+ };
1532
+ }
1533
+ })));
1362
1534
  }
1363
1535
  // src/authoring.ts
1364
1536
  const name = "@dsh-agentic-roleplay/core/authoring";
@@ -1392,13 +1564,14 @@ function apply(ctx) {
1392
1564
  for (const tool of cardTools(ctx.roleplayWorlds)) ctx.tools.register(tool);
1393
1565
  for (const tool of updateTools(ctx.roleplayWorlds)) ctx.tools.register(tool);
1394
1566
  for (const tool of presetTools(ctx.roleplayWorlds, () => ctx.roleplayImport.settings, prompting)) ctx.tools.register(tool);
1567
+ for (const tool of openingTools(ctx.roleplayWorlds, () => ctx.roleplayImport.settings, prompting)) ctx.tools.register(tool);
1395
1568
  for (const tool of translateTools(ctx.roleplayWorlds, () => ctx.roleplayImport.settings, prompting)) ctx.tools.register(tool);
1396
1569
  for (const tool of checkTools(reader, {
1397
1570
  settings: () => ctx.roleplayImport.settings,
1398
1571
  prompting
1399
1572
  })) ctx.tools.register(tool);
1400
- importHooks(ctx, ctx.roleplayWorlds, prompting);
1401
- checkHooks(ctx, prompting);
1573
+ importHooks(ctx, ctx.roleplayWorlds, prompting, ctx.roleplayImport.state);
1574
+ checkCommands(ctx, prompting);
1402
1575
  updateHooks(ctx, ctx.roleplayWorlds, (world) => ctx.roleplayAuthoringLanguages.get(world));
1403
1576
  const reviewing = async (chat) => {
1404
1577
  const id = authoredWorldOf(chat);