@dsh-agentic-roleplay/core 0.12.2 → 0.12.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.
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 UPDATE_FOLDER, C as cardChanges, D as worldFieldChanges, E as pictureChange, F as editsSince, Ft as readSource, It as COMMANDS_FILE_NAME, M as CHECK_COMMANDS, N as CHECK_COMMAND_DESCRIPTIONS, Nt as cardTools, O as editWorldInfo, Pt as entitiesByPiece, S as addressChanges, St as DICE_FILE_NAME, T as matchPieces, Tt as CALENDAR_FILE_NAME, Xt as authoredWorldOf, b as CHECKS, j as loadCardEvidence, k as readWorldInfo, l as importTools, n as limitAuthoringAgents, o as contextOf, p as isReviewing, s as importHooks, v as checkImported, w as diffText, x as runChecks, y as presentReport } from "./authoring-tools-hacA5fG-.js";
2
+ import { t as guardAuthoringTurns } from "./turn-guard-DDxikrq7.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";
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-Bq0fzKi4.js";
5
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";
6
+ import { $ as deleteWorldPrompt, Ct as IMPORT_FOLDER, Et as PICTURE_FILE, F as parseWorldInfoEdit, It as parseRelationEdit, Q as PROSE_PROMPTS, Wt as VARIABLES_FILE_NAME, et as listWorldPrompts, jt as InvalidEditProblems, nt as writeWorldPrompt, tt as readWorldPrompt } from "./serial-CDGoXYh-.js";
7
+ import { B as parsePlotsFile, at as shippedPromptsDirectory, ht as registerCommands, q as formatIssue } from "./hooks-DlrFO4aQ.js";
8
+ import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-D-7EU3yU.js";
9
9
  import "./access-Csp80TFX.js";
10
10
  import { join, relative } from "node:path";
11
11
  import { createHash } from "node:crypto";
@@ -1323,7 +1323,7 @@ function checkTools(reader, judging) {
1323
1323
  })
1324
1324
  ];
1325
1325
  }
1326
- // src/host/checks/hooks.ts
1326
+ // src/host/checks/commands.ts
1327
1327
  /** The tool each kit is run with, for the notice of a check command. */
1328
1328
  const KIT_TOOLS = {
1329
1329
  consistency: "check_world",
@@ -1331,34 +1331,41 @@ const KIT_TOOLS = {
1331
1331
  quality: "check_quality",
1332
1332
  playability: "check_play"
1333
1333
  };
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({
1334
+ /**
1335
+ * 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
1336
+ * added after the name (`deep` lets a model judge too) is passed on as it was typed.
1337
+ */
1338
+ function checkCommands(ctx, prompting) {
1339
+ registerCommands(ctx, Object.entries(CHECK_COMMANDS).map(([name, kits]) => ({
1340
+ name,
1341
+ description: CHECK_COMMAND_DESCRIPTIONS[name] ?? name,
1342
+ hint: "[deep] [what to look at]",
1343
+ recordInput: false,
1344
+ handler: ({ agent, rawInput }) => {
1345
+ const world = authoredWorldOf(agent.session.id);
1346
+ if (world === void 0 || agent.session.header.origin === "subagent") return {
1347
+ kind: "error",
1348
+ text: `/${name} runs in the authoring chat of a world`
1349
+ };
1350
+ const request = rawInput.trim();
1351
+ const notice = prompting.prompts().text("checks/notice", prompting.languages().get(world), {
1352
+ command: `/${name}`,
1353
+ tools: kits.map((kit) => KIT_TOOLS[kit]).join(", "),
1354
+ request: request === "" ? "-" : request
1355
+ });
1356
+ agent.followup(createUserMessage({
1354
1357
  content: [{
1355
1358
  type: "text",
1356
1359
  text: notice
1357
1360
  }],
1358
1361
  source: { kind: "roleplay" }
1359
- })]
1360
- };
1361
- });
1362
+ }));
1363
+ return {
1364
+ kind: "success",
1365
+ text: `Running ${kits.length === 1 ? "the check" : "the checks"}…`
1366
+ };
1367
+ }
1368
+ })));
1362
1369
  }
1363
1370
  // src/authoring.ts
1364
1371
  const name = "@dsh-agentic-roleplay/core/authoring";
@@ -1397,8 +1404,8 @@ function apply(ctx) {
1397
1404
  settings: () => ctx.roleplayImport.settings,
1398
1405
  prompting
1399
1406
  })) ctx.tools.register(tool);
1400
- importHooks(ctx, ctx.roleplayWorlds, prompting);
1401
- checkHooks(ctx, prompting);
1407
+ importHooks(ctx, ctx.roleplayWorlds, prompting, ctx.roleplayImport.state);
1408
+ checkCommands(ctx, prompting);
1402
1409
  updateHooks(ctx, ctx.roleplayWorlds, (world) => ctx.roleplayAuthoringLanguages.get(world));
1403
1410
  const reviewing = async (chat) => {
1404
1411
  const id = authoredWorldOf(chat);