@dsh-agentic-roleplay/core 0.10.0 → 0.10.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/README.md +1 -1
- package/lib/{authoring-tools-B4mEdKp_.js → authoring-tools-C6Hzy8jU.js} +1425 -1241
- package/lib/authoring.js +18 -7
- package/lib/{child-Dtv76jNx.js → child-C8r8AFpm.js} +36 -5
- package/lib/client.js +1780 -829
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +2 -2
- package/lib/doctor.js +2 -2
- package/lib/{gallery-BZJleAeH.js → gallery-CtG-bDzz.js} +2 -2
- package/lib/{generator-Cg6CQc5S.js → generator-nLoPM5MF.js} +2 -2
- package/lib/helper.js +1 -1
- package/lib/{hooks-DTjHWTfx.js → hooks-BuQ61nvQ.js} +105 -61
- package/lib/images.js +4 -4
- package/lib/index.js +964 -106
- package/lib/{library-GIlrkOim.js → library-CH-ahlm0.js} +2 -2
- package/lib/{lorebook-author-tools-BCFFJSle.js → lorebook-author-tools-B6_Jj8oe.js} +6 -6
- package/lib/lorebook-authoring.js +4 -4
- package/lib/{narration-BVzew4-K.js → narration-B0hConSw.js} +5 -2
- package/lib/orchestration.js +50 -13
- package/lib/{pack-jail-hsNQNTOf.js → pack-jail-OZSgU85i.js} +10 -10
- package/lib/{packs-UpK_cvI4.js → packs-B88bxt8E.js} +2 -2
- package/lib/{presenter-agent-DZOgBOR9.js → presenter-agent-D-WNs626.js} +5 -5
- package/lib/{preset-Cyoj1ZWa.js → preset-DNuqvMan.js} +4 -4
- package/lib/{preset-author-tools-RSta6pHK.js → preset-author-tools-CDwavcTb.js} +6 -6
- package/lib/preset-authoring.js +5 -5
- package/lib/{presets-CvpsW_10.js → presets-9_MNxwaw.js} +103 -7
- package/lib/{reflection-0qTvw2It.js → reflection-BvM0w1R4.js} +132 -92
- package/lib/{text-CbGQhK1-.js → text-CzqhC8sT.js} +11 -1
- package/lib/{turn-guard-BzNeGNnc.js → turn-guard-Ygdww1Wt.js} +3 -3
- package/package.json +2 -2
- package/prompts/en/checks/decide-stated.md +1 -0
- package/prompts/zh/checks/decide-stated.md +1 -0
package/lib/authoring.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { t as guardAuthoringTurns } from "./turn-guard-
|
|
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-
|
|
4
|
-
import {
|
|
5
|
-
import { i as translator, r as languageOf } from "./text-
|
|
6
|
-
import { H as parsePlotsFile, Y as formatIssue, ot as shippedPromptsDirectory } from "./hooks-
|
|
7
|
-
import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-
|
|
1
|
+
import { $ as readSource, A as editsSince, C as worldFieldChanges, D as loadCardEvidence, E as loadWorldParts, J as UPDATE_FOLDER, O as CHECK_COMMANDS, Q as entitiesByPiece, S as pictureChange, T as readWorldInfo, Z as cardTools, _ as runChecks, a as importHooks, b as diffText, g as CHECKS, gt as checkWorld, h as presentReport, i as contextOf, l as isReviewing, m as checkImported, n as limitAuthoringAgents, nt as parseWorldInfoEdit, o as importTools, on as authoredWorldOf, v as addressChanges, w as editWorldInfo, x as matchPieces, y as cardChanges } from "./authoring-tools-C6Hzy8jU.js";
|
|
2
|
+
import { t as guardAuthoringTurns } from "./turn-guard-Ygdww1Wt.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-OZSgU85i.js";
|
|
4
|
+
import { $ as IMPORT_FOLDER, At as InvalidEditProblems, Ft as parseRelationEdit, G as deleteWorldPrompt, J as writeWorldPrompt, K as listWorldPrompts, W as PROSE_PROMPTS, dt as parseAuthoringCommand, nt as PICTURE_FILE, q as readWorldPrompt } from "./presets-9_MNxwaw.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-CzqhC8sT.js";
|
|
6
|
+
import { H as parsePlotsFile, Y as formatIssue, ot as shippedPromptsDirectory } from "./hooks-BuQ61nvQ.js";
|
|
7
|
+
import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-B88bxt8E.js";
|
|
8
8
|
import "./access-CXtaZNbx.js";
|
|
9
9
|
import { join, relative } from "node:path";
|
|
10
|
+
import { createHash } from "node:crypto";
|
|
10
11
|
import { readFile, readdir } from "node:fs/promises";
|
|
11
12
|
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
12
13
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
@@ -921,6 +922,10 @@ async function loreTitles(directory) {
|
|
|
921
922
|
}
|
|
922
923
|
return titles;
|
|
923
924
|
}
|
|
925
|
+
const hashOf = async (file) => await readFile(file).then((bytes) => createHash("sha256").update(bytes).digest("hex"), (error) => {
|
|
926
|
+
if (error.code === "ENOENT") return void 0;
|
|
927
|
+
throw error;
|
|
928
|
+
});
|
|
924
929
|
const output$1 = {
|
|
925
930
|
schema: { type: "json" },
|
|
926
931
|
render: (_args, value) => [{
|
|
@@ -985,8 +990,14 @@ function updateTools(worlds) {
|
|
|
985
990
|
}];
|
|
986
991
|
});
|
|
987
992
|
const edits = await editsSince(directory);
|
|
993
|
+
const picture = pictureChange(await hashOf(join(directory, IMPORT_FOLDER, PICTURE_FILE)), await hashOf(join(directory, IMPORT_FOLDER, UPDATE_FOLDER, PICTURE_FILE)));
|
|
988
994
|
return json({
|
|
989
995
|
card: cardChanges(before.card, after.card),
|
|
996
|
+
images: {
|
|
997
|
+
cardPicture: picture,
|
|
998
|
+
...addressChanges(before.card, after.card),
|
|
999
|
+
effect: "A changed card picture replaces the portrait that is still the card's picture when the update is finished; a portrait the person changed is kept. Pictures the card no longer points to stay in the image library."
|
|
1000
|
+
},
|
|
990
1001
|
changed: changed.slice(0, MAX_PIECES),
|
|
991
1002
|
...changed.length > MAX_PIECES ? { moreChanged: changed.length - MAX_PIECES } : {},
|
|
992
1003
|
added: match.added.slice(0, MAX_PIECES).map((piece) => ({
|
|
@@ -52,6 +52,7 @@ const addTokens = (a, b) => {
|
|
|
52
52
|
...unreported > 0 ? { unreported } : {}
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
|
+
const totalTokens = (count) => count.input + count.cached + count.output;
|
|
55
56
|
// src/host/agents/usage.ts
|
|
56
57
|
/** The tokens the model service reported for the requests it answered in a session's events; a request it reported nothing for adds nothing. */
|
|
57
58
|
function tokensOf(events) {
|
|
@@ -92,6 +93,29 @@ function messageTokens(message) {
|
|
|
92
93
|
if (typeof content === "string") return estimateTokens(content);
|
|
93
94
|
return Array.isArray(content) ? content.reduce((sum, block) => sum + estimateTokens(blockText(block)), 0) : 0;
|
|
94
95
|
}
|
|
96
|
+
const MAX_SECTIONS = 24;
|
|
97
|
+
const MAX_TITLE = 80;
|
|
98
|
+
const HEADING = /^(.{1,200}?)[::]\s*$/u;
|
|
99
|
+
/**
|
|
100
|
+
* The parts of a helper's brief, as the brief itself divides them: it is written in paragraphs, and a paragraph whose first line ends in a colon opens a new part with that line as its
|
|
101
|
+
* title. Text before the first heading is the part called with an empty title. Sizes are estimated.
|
|
102
|
+
*/
|
|
103
|
+
function briefSections(prompt) {
|
|
104
|
+
const parts = [];
|
|
105
|
+
for (const block of prompt.split(/\n{2,}/)) {
|
|
106
|
+
if (block.trim() === "") continue;
|
|
107
|
+
const heading = HEADING.exec(block.split("\n")[0]);
|
|
108
|
+
if (heading !== null || parts.length === 0) parts.push({
|
|
109
|
+
title: heading === null ? "" : heading[1].trim().slice(0, MAX_TITLE),
|
|
110
|
+
text: [block]
|
|
111
|
+
});
|
|
112
|
+
else parts[parts.length - 1].text.push(block);
|
|
113
|
+
}
|
|
114
|
+
return parts.slice(0, MAX_SECTIONS).map((part) => ({
|
|
115
|
+
title: part.title,
|
|
116
|
+
tokens: estimateTokens(part.text.join("\n\n"))
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
95
119
|
// src/host/agents/requests.ts
|
|
96
120
|
/** What a request's prompt was made of: the parts the log shows, and whatever else the service counted (the earlier turns of the conversation). */
|
|
97
121
|
function parts(held, prompt) {
|
|
@@ -272,8 +296,12 @@ function childSampling(settings, kind, estimate) {
|
|
|
272
296
|
priority: kind === "characters" || kind === "authoring" ? "foreground" : "background"
|
|
273
297
|
};
|
|
274
298
|
}
|
|
299
|
+
const briefOf = (prompt) => {
|
|
300
|
+
const brief = briefSections(prompt);
|
|
301
|
+
return brief.length > 1 ? { brief } : {};
|
|
302
|
+
};
|
|
275
303
|
/** What a caller passes as `trace`: files each run of a kind of helper under a label in the store's record of activity, with its detail when the chat keeps it. */
|
|
276
|
-
function childTrace(store, kind, label, extra = {}, named) {
|
|
304
|
+
function childTrace(store, kind, label, extra = {}, named, cause) {
|
|
277
305
|
const model = (named ?? store.settings().models[kind]).trim();
|
|
278
306
|
return (run) => {
|
|
279
307
|
const keep = store.settings().diagnostics.keepRuns;
|
|
@@ -284,6 +312,8 @@ function childTrace(store, kind, label, extra = {}, named) {
|
|
|
284
312
|
model,
|
|
285
313
|
ms: run.ms,
|
|
286
314
|
calls: run.calls,
|
|
315
|
+
...cause === void 0 ? {} : { cause },
|
|
316
|
+
...briefOf(run.detail.prompt),
|
|
287
317
|
...run.detail.calls.some((call) => call.failed) ? { refused: run.detail.calls.filter((call) => call.failed).length } : {},
|
|
288
318
|
turn: run.turn,
|
|
289
319
|
tokens: run.tokens,
|
|
@@ -346,6 +376,7 @@ const isUnfinishedCall = (error) => error instanceof Error && /parse tool call a
|
|
|
346
376
|
async function runChild(task) {
|
|
347
377
|
for (let attempt = 1;; attempt += 1) {
|
|
348
378
|
const began = Date.now();
|
|
379
|
+
const turnAtStart = currentTurn(task.parent);
|
|
349
380
|
const stats = {
|
|
350
381
|
calls: 0,
|
|
351
382
|
record: []
|
|
@@ -371,7 +402,7 @@ async function runChild(task) {
|
|
|
371
402
|
ms: Date.now() - began,
|
|
372
403
|
calls: stats.calls,
|
|
373
404
|
detail: detail(),
|
|
374
|
-
turn:
|
|
405
|
+
turn: turnAtStart,
|
|
375
406
|
tokens: stats.tokens ?? NO_TOKENS,
|
|
376
407
|
requests: stats.requests ?? []
|
|
377
408
|
});
|
|
@@ -383,7 +414,7 @@ async function runChild(task) {
|
|
|
383
414
|
calls: stats.calls,
|
|
384
415
|
error: error instanceof Error ? error.message : String(error),
|
|
385
416
|
detail: detail(),
|
|
386
|
-
turn:
|
|
417
|
+
turn: turnAtStart,
|
|
387
418
|
tokens: stats.tokens ?? NO_TOKENS,
|
|
388
419
|
requests: stats.requests ?? []
|
|
389
420
|
});
|
|
@@ -756,6 +787,6 @@ async function execute(task, stats) {
|
|
|
756
787
|
}
|
|
757
788
|
return submitted.value;
|
|
758
789
|
}
|
|
759
|
-
export { tokensOf$1 as S, addTokens as _, childTrace as a,
|
|
790
|
+
export { tokensOf$1 as C, estimateAnswer as S, addTokens as _, childTrace as a, cutOff as b, runChild as c, sharedSamplingOf as d, requestsOf as f, NO_TOKENS as g, tokensOf as h, childSamplingOf as i, SAMPLING_RANGES as l, estimateTokens as m, childModel as n, helpers as o, blockText as p, childSampling as r, namedModel as s, ChildTimeoutError as t, parseSampling as u, totalTokens as v, finishOf as x, currentTurn as y };
|
|
760
791
|
|
|
761
|
-
//# sourceMappingURL=child-
|
|
792
|
+
//# sourceMappingURL=child-C8r8AFpm.js.map
|