@dsh-agentic-roleplay/core 0.8.2 → 0.9.1
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-tools-BgmC2oqU.js → authoring-tools-C_l07RYn.js} +2568 -53
- package/lib/authoring.js +145 -38
- package/lib/client.js +327 -327
- package/lib/doctor.js +1 -1
- package/lib/{gallery-D1V4h8vh.js → gallery-q7niLtWn.js} +2 -2
- package/lib/{generator-CLPosooC.js → generator-BpjPrvHe.js} +2 -2
- package/lib/{hooks-rQTTeOC4.js → hooks-DNaDzMjW.js} +38 -5
- package/lib/images.js +4 -4
- package/lib/index.js +14 -14
- package/lib/{library-Dfu0dgRj.js → library-CIkxhf_R.js} +5 -3
- package/lib/{lorebook-author-tools-BAaAqZZm.js → lorebook-author-tools-BiMDmdFi.js} +6 -6
- package/lib/lorebook-authoring.js +4 -4
- package/lib/orchestration.js +8 -8
- package/lib/{pack-jail-CN-314ln.js → pack-jail-B35Vx3hT.js} +36 -728
- package/lib/{packs-DIj5BEfq.js → packs-BajKw7S9.js} +2 -2
- package/lib/{presenter-agent-DR0KvLE0.js → presenter-agent-jgtuTwZr.js} +4 -4
- package/lib/{preset-CscHj1-Y.js → preset-DWgkcPau.js} +3 -3
- package/lib/{preset-author-tools-CxluF8qc.js → preset-author-tools-BhuYIKms.js} +6 -6
- package/lib/preset-authoring.js +5 -5
- package/lib/{presets-HB8kJTaE.js → presets-9GzaSELc.js} +32 -12
- package/lib/{reflection-Dg1xtOTW.js → reflection-4L0Plvct.js} +6 -6
- package/lib/{text-DyRN4nDP.js → text-CbGQhK1-.js} +4 -3
- package/lib/{turn-guard-g_hDn0jR.js → turn-guard-sCUXmp-5.js} +2 -2
- package/package.json +2 -2
- package/prompts/en/checks/conflict.md +1 -0
- package/prompts/en/checks/decide-conflict.md +1 -0
- package/prompts/en/checks/decide-covered.md +1 -0
- package/prompts/en/checks/decide-opening.md +1 -0
- package/prompts/en/checks/decide-same-thing.md +1 -0
- package/prompts/en/checks/decide-same-value.md +1 -0
- package/prompts/en/checks/decide-sheet.md +1 -0
- package/prompts/en/checks/fidelity.md +7 -0
- package/prompts/en/checks/gaps.md +4 -0
- package/prompts/en/checks/notice.md +3 -0
- package/prompts/en/import/finish-draft.md +1 -1
- package/prompts/en/import/finish-ok.md +3 -1
- package/prompts/en/import/notice-repair.md +2 -2
- package/prompts/en/import/repair-again.md +2 -2
- package/prompts/zh/checks/conflict.md +1 -0
- package/prompts/zh/checks/decide-conflict.md +1 -0
- package/prompts/zh/checks/decide-covered.md +1 -0
- package/prompts/zh/checks/decide-opening.md +1 -0
- package/prompts/zh/checks/decide-same-thing.md +1 -0
- package/prompts/zh/checks/decide-same-value.md +1 -0
- package/prompts/zh/checks/decide-sheet.md +1 -0
- package/prompts/zh/checks/fidelity.md +7 -0
- package/prompts/zh/checks/gaps.md +4 -0
- package/prompts/zh/checks/notice.md +3 -0
- package/prompts/zh/import/finish-draft.md +1 -1
- package/prompts/zh/import/finish-ok.md +3 -1
- package/prompts/zh/import/notice-repair.md +2 -2
- package/prompts/zh/import/repair-again.md +2 -2
package/lib/authoring.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as guardAuthoringTurns } from "./turn-guard-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { i as translator, r as languageOf } from "./text-
|
|
6
|
-
import { J as formatIssue, V as parsePlotsFile, at as shippedPromptsDirectory } from "./hooks-
|
|
7
|
-
import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-
|
|
1
|
+
import { A as cardTools, C as readWorldInfo, E as loadCardEvidence, F as editsSince, M as readSource, N as CHECK_COMMANDS, S as editWorldInfo, T as loadWorldParts, _ as runChecks, a as importHooks, b as matchPieces, g as CHECKS, h as presentReport, ht as checkWorld, i as contextOf, in as authoredWorldOf, j as entitiesByPiece, l as isReviewing, m as checkImported, n as limitAuthoringAgents, o as importTools, tt as parseWorldInfoEdit, v as cardChanges, x as worldFieldChanges, y as diffText } from "./authoring-tools-C_l07RYn.js";
|
|
2
|
+
import { t as guardAuthoringTurns } from "./turn-guard-sCUXmp-5.js";
|
|
3
|
+
import { C as readWorldEditor, L as presetTools, M as deleteTriggerDocument, N as readTriggerDocuments, P as writeTriggerDocument, U as finishUpdate, W as pendingUpdate, _ 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, z as translateTools } from "./pack-jail-B35Vx3hT.js";
|
|
4
|
+
import { Dt as InvalidEditProblems, G as listWorldPrompts, K as readWorldPrompt, Mt as parseRelationEdit, Q as IMPORT_FOLDER, U as PROSE_PROMPTS, W as deleteWorldPrompt, ct as parseAuthoringCommand, q as writeWorldPrompt } from "./presets-9GzaSELc.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-CbGQhK1-.js";
|
|
6
|
+
import { J as formatIssue, V as parsePlotsFile, at as shippedPromptsDirectory } from "./hooks-DNaDzMjW.js";
|
|
7
|
+
import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-BajKw7S9.js";
|
|
8
8
|
import "./access-CfQWbNZP.js";
|
|
9
9
|
import { join, relative } from "node:path";
|
|
10
10
|
import { readFile, readdir } from "node:fs/promises";
|
|
@@ -12,13 +12,13 @@ import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
|
12
12
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
13
13
|
import { isDeepStrictEqual } from "node:util";
|
|
14
14
|
// src/host/authoring/read-tools.ts
|
|
15
|
-
const output$
|
|
15
|
+
const output$5 = (value) => [{
|
|
16
16
|
type: "text",
|
|
17
17
|
text: JSON.stringify(value, null, 2)
|
|
18
18
|
}];
|
|
19
19
|
const jsonOutput$3 = {
|
|
20
20
|
schema: { type: "json" },
|
|
21
|
-
render: (_args, value) => output$
|
|
21
|
+
render: (_args, value) => output$5(value)
|
|
22
22
|
};
|
|
23
23
|
const keyParameter$1 = {
|
|
24
24
|
type: "string",
|
|
@@ -119,16 +119,6 @@ function authoredWorldReadTools(reader) {
|
|
|
119
119
|
return json$1(await readWorldInfo((await reader.read(exec)).record.directory));
|
|
120
120
|
}
|
|
121
121
|
}),
|
|
122
|
-
defineTool({
|
|
123
|
-
name: "world_check",
|
|
124
|
-
description: "Check the world as starting a story from it would: every file reads and everything that refers to something refers to something that is there. It names the problems of the first part of the world that has any (characters, factions, places, calendar, dice, items, lore, tracked values, triggers, plots), so run it again after fixing them to see whether another part has some. Run it before you say a world is done.",
|
|
125
|
-
parameters: {},
|
|
126
|
-
output: jsonOutput$3,
|
|
127
|
-
isConcurrencySafe: () => true,
|
|
128
|
-
async execute(_args, exec) {
|
|
129
|
-
return json$1(await checkWorld((await reader.read(exec)).record));
|
|
130
|
-
}
|
|
131
|
-
}),
|
|
132
122
|
listTool(reader, "list_characters", "List authored characters with stable keys and concise identifying information.", (world) => world.characters, (entry) => ({
|
|
133
123
|
key: entry.key,
|
|
134
124
|
name: entry.name,
|
|
@@ -263,13 +253,13 @@ function authoredWorldReadTools(reader) {
|
|
|
263
253
|
}
|
|
264
254
|
// src/host/authoring/pack-tools.ts
|
|
265
255
|
const PACK_MUTATION_TOOLS = ["delete_world_pack_file"];
|
|
266
|
-
const output$
|
|
256
|
+
const output$4 = (value) => [{
|
|
267
257
|
type: "text",
|
|
268
258
|
text: JSON.stringify(value, null, 2)
|
|
269
259
|
}];
|
|
270
260
|
const jsonOutput$2 = {
|
|
271
261
|
schema: { type: "json" },
|
|
272
|
-
render: (_args, value) => output$
|
|
262
|
+
render: (_args, value) => output$4(value)
|
|
273
263
|
};
|
|
274
264
|
/** A path as the file tools take it: relative to the chat's folder when it has one, which is short and hard to mistype. */
|
|
275
265
|
function relativeTo(exec, path) {
|
|
@@ -371,13 +361,13 @@ function worldPackTools(reader) {
|
|
|
371
361
|
}
|
|
372
362
|
// src/host/authoring/prompt-tools.ts
|
|
373
363
|
const PROMPT_MUTATION_TOOLS = ["write_world_prompt", "delete_world_prompt"];
|
|
374
|
-
const output$
|
|
364
|
+
const output$3 = (value) => [{
|
|
375
365
|
type: "text",
|
|
376
366
|
text: JSON.stringify(value, null, 2)
|
|
377
367
|
}];
|
|
378
368
|
const jsonOutput$1 = {
|
|
379
369
|
schema: { type: "json" },
|
|
380
|
-
render: (_args, value) => output$
|
|
370
|
+
render: (_args, value) => output$3(value)
|
|
381
371
|
};
|
|
382
372
|
const idParameter = {
|
|
383
373
|
type: "string",
|
|
@@ -524,7 +514,7 @@ function sizeOf(text) {
|
|
|
524
514
|
zh: `${text.length} 个字符,开头:${clip(text, 70)}`
|
|
525
515
|
};
|
|
526
516
|
}
|
|
527
|
-
function plain(value, max = 220) {
|
|
517
|
+
function plain$1(value, max = 220) {
|
|
528
518
|
const text = clip(value, max);
|
|
529
519
|
return {
|
|
530
520
|
en: text,
|
|
@@ -532,13 +522,13 @@ function plain(value, max = 220) {
|
|
|
532
522
|
};
|
|
533
523
|
}
|
|
534
524
|
// src/host/authoring/write-tools.ts
|
|
535
|
-
const output$
|
|
525
|
+
const output$2 = (value) => [{
|
|
536
526
|
type: "text",
|
|
537
527
|
text: JSON.stringify(value, null, 2)
|
|
538
528
|
}];
|
|
539
529
|
const jsonOutput = {
|
|
540
530
|
schema: { type: "json" },
|
|
541
|
-
render: (_args, value) => output$
|
|
531
|
+
render: (_args, value) => output$2(value)
|
|
542
532
|
};
|
|
543
533
|
const kindParameter = {
|
|
544
534
|
type: "string",
|
|
@@ -598,7 +588,7 @@ function plotDocument(value) {
|
|
|
598
588
|
if (!parsed.ok) throw new InvalidEditProblems(parsed.issues.map(formatIssue));
|
|
599
589
|
return parsed.value[0];
|
|
600
590
|
}
|
|
601
|
-
/** The most problems a write reports back; `
|
|
591
|
+
/** The most problems a write reports back; `check_world` lists the rest. */
|
|
602
592
|
const REPORTED_PROBLEMS = 8;
|
|
603
593
|
/**
|
|
604
594
|
* A write is allowed to leave the world unfinished (a character first, its place next), so the check is advice, not a refusal: the assistant sees at once what its edit
|
|
@@ -615,16 +605,16 @@ function withWorldCheck(reader, tool) {
|
|
|
615
605
|
const check = await checkWorld(record);
|
|
616
606
|
if (check.ok) return {
|
|
617
607
|
...done,
|
|
618
|
-
|
|
608
|
+
check_world: "ok: a story could start from this world"
|
|
619
609
|
};
|
|
620
610
|
const shown = check.problems.slice(0, REPORTED_PROBLEMS).map((problem) => `${problem.where}: ${problem.message}`);
|
|
621
611
|
return {
|
|
622
612
|
...done,
|
|
623
|
-
|
|
613
|
+
check_world: {
|
|
624
614
|
ok: false,
|
|
625
615
|
still_open: shown,
|
|
626
616
|
more: check.problems.length - shown.length + check.more,
|
|
627
|
-
note: "Not an error of this edit; fix what the world still needs before the end of the turn (
|
|
617
|
+
note: "Not an error of this edit; fix what the world still needs before the end of the turn (check_world lists all)."
|
|
628
618
|
}
|
|
629
619
|
};
|
|
630
620
|
}
|
|
@@ -651,7 +641,7 @@ function authoredWorldWriteTools(reader) {
|
|
|
651
641
|
id: record.summary.id,
|
|
652
642
|
directory: record.directory
|
|
653
643
|
};
|
|
654
|
-
await createAuthoredEntity(world, args.kind, args.key, args.document);
|
|
644
|
+
await createAuthoredEntity(world, args.kind, args.key, args.document, { refuseUnread: true });
|
|
655
645
|
return result("created", args.kind, args.key, await readWorldEditor(world));
|
|
656
646
|
}
|
|
657
647
|
}),
|
|
@@ -674,7 +664,7 @@ function authoredWorldWriteTools(reader) {
|
|
|
674
664
|
id: record.summary.id,
|
|
675
665
|
directory: record.directory
|
|
676
666
|
};
|
|
677
|
-
await replaceAuthoredEntity(world, args.kind, args.key, args.document);
|
|
667
|
+
await replaceAuthoredEntity(world, args.kind, args.key, args.document, { refuseUnread: true });
|
|
678
668
|
return result("replaced", args.kind, args.key, await readWorldEditor(world));
|
|
679
669
|
}
|
|
680
670
|
}),
|
|
@@ -882,9 +872,9 @@ async function infoDetail(changes, before) {
|
|
|
882
872
|
try {
|
|
883
873
|
edit = parseWorldInfoEdit(changes);
|
|
884
874
|
} catch {
|
|
885
|
-
return plain(changes);
|
|
875
|
+
return plain$1(changes);
|
|
886
876
|
}
|
|
887
|
-
return before === void 0 ? plain(edit) : changedFields(before, {
|
|
877
|
+
return before === void 0 ? plain$1(edit) : changedFields(before, {
|
|
888
878
|
...before,
|
|
889
879
|
...edit
|
|
890
880
|
});
|
|
@@ -907,7 +897,7 @@ async function detailOf(exec, kind, key, current) {
|
|
|
907
897
|
const before = exec.agent === void 0 ? void 0 : await current?.(exec.agent.session.id, kind, key);
|
|
908
898
|
return before === void 0 ? createdFields(args["document"]) : changedFields(before, args["document"]);
|
|
909
899
|
}
|
|
910
|
-
case "edit_world_relationship": return plain(args["change"]);
|
|
900
|
+
case "edit_world_relationship": return plain$1(args["change"]);
|
|
911
901
|
case "replace_world_plots": return Array.isArray(args["plots"]) ? {
|
|
912
902
|
en: `${args["plots"].length} plots`,
|
|
913
903
|
zh: `${args["plots"].length} 条剧情`
|
|
@@ -931,7 +921,7 @@ async function loreTitles(directory) {
|
|
|
931
921
|
}
|
|
932
922
|
return titles;
|
|
933
923
|
}
|
|
934
|
-
const output = {
|
|
924
|
+
const output$1 = {
|
|
935
925
|
schema: { type: "json" },
|
|
936
926
|
render: (_args, value) => [{
|
|
937
927
|
type: "text",
|
|
@@ -956,7 +946,7 @@ function updateTools(worlds) {
|
|
|
956
946
|
name: "card_diff",
|
|
957
947
|
description: "What a newer version of the card this world was imported from changes. For each piece (field, greeting, lorebook entry) that changed, was added or was dropped: the sentences that differ, and the characters, places and things the import made from it, which are what may need to change. Also the files of the world that were edited since the import, and what the newer version changes about the card itself. Start here when asked to update the world from its card; read whole pieces with card_read (version current or new).",
|
|
958
948
|
parameters: {},
|
|
959
|
-
output,
|
|
949
|
+
output: output$1,
|
|
960
950
|
isConcurrencySafe: () => true,
|
|
961
951
|
async execute(_args, exec) {
|
|
962
952
|
const directory = await worldOf(exec);
|
|
@@ -1026,12 +1016,14 @@ function updateTools(worlds) {
|
|
|
1026
1016
|
name: "card_update_finish",
|
|
1027
1017
|
description: `Makes the newer card the card this world was made from, once the world has been brought up to date with it: the old card is kept in ${IMPORT_FOLDER}/previous, and what the world holds now is what later edits are measured against. Run it after your edits, and only then.`,
|
|
1028
1018
|
parameters: {},
|
|
1029
|
-
output,
|
|
1019
|
+
output: output$1,
|
|
1030
1020
|
async execute(_args, exec) {
|
|
1031
1021
|
const directory = await worldOf(exec);
|
|
1032
1022
|
const outcome = await finishUpdate(directory, exec.signal === void 0 ? {} : { signal: exec.signal });
|
|
1023
|
+
const checks = await checkImported(directory, (await readWorldInfo(directory)).name);
|
|
1033
1024
|
return json({
|
|
1034
1025
|
done: true,
|
|
1026
|
+
checks,
|
|
1035
1027
|
card: `${IMPORT_FOLDER}/card.json`,
|
|
1036
1028
|
previous: join(IMPORT_FOLDER, "previous"),
|
|
1037
1029
|
forgottenRecords: outcome.forgotten,
|
|
@@ -1099,6 +1091,116 @@ function updateHooks(ctx, worlds, languageOf$1) {
|
|
|
1099
1091
|
}));
|
|
1100
1092
|
});
|
|
1101
1093
|
}
|
|
1094
|
+
// src/host/checks/tools.ts
|
|
1095
|
+
const output = {
|
|
1096
|
+
schema: { type: "json" },
|
|
1097
|
+
render: (_args, value) => [{
|
|
1098
|
+
type: "text",
|
|
1099
|
+
text: JSON.stringify(value, null, 2)
|
|
1100
|
+
}]
|
|
1101
|
+
};
|
|
1102
|
+
/** A value as the tool result carries it: plain data. */
|
|
1103
|
+
const plain = (value) => JSON.parse(JSON.stringify(value));
|
|
1104
|
+
const deepParameter = {
|
|
1105
|
+
type: "boolean",
|
|
1106
|
+
description: "Also run the checks a model judges (slower, one or more model requests each). Leave it off for a quick look; turn it on when the quick checks leave the world looking thin, when the person asks for a thorough check, or before you say an import is done."
|
|
1107
|
+
};
|
|
1108
|
+
function kitTool(reader, judging, name, kit, description, card = false) {
|
|
1109
|
+
return defineTool({
|
|
1110
|
+
name,
|
|
1111
|
+
description,
|
|
1112
|
+
parameters: {
|
|
1113
|
+
...card ? { version: {
|
|
1114
|
+
type: "string",
|
|
1115
|
+
enum: ["current", "new"],
|
|
1116
|
+
description: "current (the default) is the card the world was made from; new is the newer version waiting to update it."
|
|
1117
|
+
} } : {},
|
|
1118
|
+
deep: deepParameter
|
|
1119
|
+
},
|
|
1120
|
+
output,
|
|
1121
|
+
isConcurrencySafe: () => false,
|
|
1122
|
+
async execute(args, exec) {
|
|
1123
|
+
const { record } = await reader.read(exec);
|
|
1124
|
+
const version = args.version === "new" ? "new" : "current";
|
|
1125
|
+
const evidence = card ? await loadCardEvidence(record.directory, version) : void 0;
|
|
1126
|
+
if (card && evidence === void 0) throw new Error(version === "new" ? "no newer version of the card is waiting to update this world" : "this world has no source card: it was not imported from one, or its .import folder was removed");
|
|
1127
|
+
const language = judging.prompting.languages().get(record.summary.id);
|
|
1128
|
+
const text = (id, variables) => judging.prompting.prompts().text(id, language, variables);
|
|
1129
|
+
const model = args.deep === true ? contextOf(exec, judging.settings(), text, language) : void 0;
|
|
1130
|
+
const report = await runChecks({
|
|
1131
|
+
world: record,
|
|
1132
|
+
...evidence === void 0 ? {} : { card: evidence },
|
|
1133
|
+
...model === void 0 ? {} : { model }
|
|
1134
|
+
}, {
|
|
1135
|
+
kits: [kit],
|
|
1136
|
+
deep: args.deep === true
|
|
1137
|
+
});
|
|
1138
|
+
return plain(presentReport(report));
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
/** The checks of the suite as tools of a world authoring chat; each kit is one call, and what it finds is stored with the world for the next run to compare with. */
|
|
1143
|
+
function checkTools(reader, judging) {
|
|
1144
|
+
return [
|
|
1145
|
+
kitTool(reader, judging, "check_world", "consistency", "Check the world for inconsistencies: whether a story could start from it (every file reads and everything that refers to something refers to something that is there; it names the problems of the first part of the world that has any, so run it again after fixing them), places no one can reach, names that clash, tracked values that are the same thing twice, and prompts the story could not use. With deep, tracked values, characters, places and things that are the same under different words, and background entries that contradict each other, are found by meaning (with quoted passages for contradictions). Run it before you say a world is done. It reads only; each finding says where it is and, when clear, what would fix it."),
|
|
1146
|
+
kitTool(reader, judging, "check_card", "fidelity", "Compare the world with the card it was imported from, which is kept: whether every piece of the card the import read is in the world, whether every name in the world occurs in the card, whether the numbers the card gives were kept, and, with version new, what a newer card waiting to update the world changed that the world does not say yet. With deep, a model also compares each document with the pieces it was made from and quotes the facts that were lost or made up, and a piece that shares no words with the world (another language, a rewrite) is looked for by meaning before it is called lost. A finding is a pointer: read the piece with card_read before you change anything. It reads only.", true),
|
|
1147
|
+
kitTool(reader, judging, "check_quality", "quality", "Check the authoring quality of the world: whether someone can be played, whether the characters that matter have sheets to play from, places with nothing in them, what the world says about itself. With deep, a model also judges whether each sheet is enough to play and what the world is missing to play well. It reads only; a finding is a gap to fill from what the card or the person says, never from invention."),
|
|
1148
|
+
kitTool(reader, judging, "check_play", "playability", "Check whether a story can begin well from this world: for each character the player may play, whether the place they start in has ways out, people and things, and, with deep, whether a model reading the opening and that first scene finds something the player can do. It reads only; a finding is a gap in the first scene to fill from what the card or the person says, never from invention."),
|
|
1149
|
+
defineTool({
|
|
1150
|
+
name: "check_list",
|
|
1151
|
+
description: "List the checks of the suite: which kit each belongs to, whether the program or a model decides it, and what it needs.",
|
|
1152
|
+
parameters: {},
|
|
1153
|
+
output,
|
|
1154
|
+
isConcurrencySafe: () => true,
|
|
1155
|
+
async execute() {
|
|
1156
|
+
return plain(CHECKS.map((check) => ({
|
|
1157
|
+
id: check.id,
|
|
1158
|
+
kit: check.kit,
|
|
1159
|
+
mode: check.mode,
|
|
1160
|
+
needs: check.needs,
|
|
1161
|
+
description: check.description
|
|
1162
|
+
})));
|
|
1163
|
+
}
|
|
1164
|
+
})
|
|
1165
|
+
];
|
|
1166
|
+
}
|
|
1167
|
+
// src/host/checks/hooks.ts
|
|
1168
|
+
/** The tool each kit is run with, for the notice of a check command. */
|
|
1169
|
+
const KIT_TOOLS = {
|
|
1170
|
+
consistency: "check_world",
|
|
1171
|
+
fidelity: "check_card",
|
|
1172
|
+
quality: "check_quality",
|
|
1173
|
+
playability: "check_play"
|
|
1174
|
+
};
|
|
1175
|
+
/** 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. */
|
|
1176
|
+
function checkHooks(ctx, prompting) {
|
|
1177
|
+
const authoring = (agent) => agent.session.header.origin === "subagent" || authoredWorldOf(agent.session.id) === void 0 ? void 0 : agent.session.id;
|
|
1178
|
+
ctx.on("agent/pre-step", async (payload, next) => {
|
|
1179
|
+
const decision = await next();
|
|
1180
|
+
const chat = authoring(payload.agent);
|
|
1181
|
+
if (decision.kind !== "enter" || payload.step !== 1 || chat === void 0) return decision;
|
|
1182
|
+
const text = payload.messages.filter((message) => message.source.kind === "user").flatMap((message) => message.content.flatMap((block) => block.type === "text" ? [block.text] : [])).join("\n");
|
|
1183
|
+
const command = parseAuthoringCommand(text, Object.keys(CHECK_COMMANDS));
|
|
1184
|
+
if (command === void 0) return decision;
|
|
1185
|
+
const world = authoredWorldOf(chat);
|
|
1186
|
+
const tools = CHECK_COMMANDS[command.name].map((kit) => KIT_TOOLS[kit]).join(", ");
|
|
1187
|
+
const notice = prompting.prompts().text("checks/notice", world === void 0 ? void 0 : prompting.languages().get(world), {
|
|
1188
|
+
command: `/${command.name}`,
|
|
1189
|
+
tools,
|
|
1190
|
+
request: command.rest === "" ? "-" : command.rest
|
|
1191
|
+
});
|
|
1192
|
+
return {
|
|
1193
|
+
...decision,
|
|
1194
|
+
messages: [...decision.messages, createUserMessage({
|
|
1195
|
+
content: [{
|
|
1196
|
+
type: "text",
|
|
1197
|
+
text: notice
|
|
1198
|
+
}],
|
|
1199
|
+
source: { kind: "roleplay" }
|
|
1200
|
+
})]
|
|
1201
|
+
};
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1102
1204
|
// src/authoring.ts
|
|
1103
1205
|
const name = "@dsh-agentic-roleplay/core/authoring";
|
|
1104
1206
|
const inject = [
|
|
@@ -1130,7 +1232,12 @@ function apply(ctx) {
|
|
|
1130
1232
|
for (const tool of updateTools(ctx.roleplayWorlds)) ctx.tools.register(tool);
|
|
1131
1233
|
for (const tool of presetTools(ctx.roleplayWorlds, () => ctx.roleplayImport.settings, prompting)) ctx.tools.register(tool);
|
|
1132
1234
|
for (const tool of translateTools(ctx.roleplayWorlds, () => ctx.roleplayImport.settings, prompting)) ctx.tools.register(tool);
|
|
1235
|
+
for (const tool of checkTools(reader, {
|
|
1236
|
+
settings: () => ctx.roleplayImport.settings,
|
|
1237
|
+
prompting
|
|
1238
|
+
})) ctx.tools.register(tool);
|
|
1133
1239
|
importHooks(ctx, ctx.roleplayWorlds, prompting);
|
|
1240
|
+
checkHooks(ctx, prompting);
|
|
1134
1241
|
updateHooks(ctx, ctx.roleplayWorlds, (world) => ctx.roleplayAuthoringLanguages.get(world));
|
|
1135
1242
|
const reviewing = async (chat) => {
|
|
1136
1243
|
const id = authoredWorldOf(chat);
|