@dsh-agentic-roleplay/core 0.10.0 → 0.10.2
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/icon.svg +13 -0
- package/lib/{authoring-tools-B4mEdKp_.js → authoring-tools-C9cmcUbD.js} +1820 -1243
- package/lib/authoring.js +18 -7
- package/lib/{child-Dtv76jNx.js → child-C9nPIy9j.js} +40 -5
- package/lib/client.js +4668 -2249
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +2 -2
- package/lib/doctor.js +3 -3
- 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 +8 -1
- package/lib/{hooks-DTjHWTfx.js → hooks-BpLN_hhT.js} +282 -211
- package/lib/images.js +4 -4
- package/lib/index.js +1399 -146
- package/lib/{library-GIlrkOim.js → library-CH-ahlm0.js} +2 -2
- package/lib/{lorebook-author-tools-BCFFJSle.js → lorebook-author-tools-Cg7QQemi.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 +108 -21
- package/lib/{pack-jail-hsNQNTOf.js → pack-jail-D5j5mIq6.js} +16 -12
- package/lib/{packs-UpK_cvI4.js → packs-Cc05FrId.js} +2 -2
- package/lib/{presenter-agent-DZOgBOR9.js → presenter-agent-UKbKYXMO.js} +6 -6
- package/lib/{preset-Cyoj1ZWa.js → preset-Be4lz6vB.js} +4 -4
- package/lib/{preset-author-tools-RSta6pHK.js → preset-author-tools-C3s0iSfv.js} +6 -6
- package/lib/preset-authoring.js +5 -5
- package/lib/{presets-CvpsW_10.js → presets-Cl9sU3Qs.js} +152 -14
- package/lib/{reflection-0qTvw2It.js → reflection-I9z-PvFK.js} +135 -93
- package/lib/{text-CbGQhK1-.js → text-CzqhC8sT.js} +11 -1
- package/lib/{turn-guard-BzNeGNnc.js → turn-guard-B9pGCeir.js} +3 -3
- package/package.json +4 -2
- package/prompts/en/checks/decide-opening.md +7 -1
- package/prompts/en/checks/decide-stated.md +1 -0
- package/prompts/en/roleplay/record-keeper.md +2 -1
- package/prompts/zh/checks/decide-opening.md +7 -1
- package/prompts/zh/checks/decide-stated.md +1 -0
- package/prompts/zh/roleplay/record-keeper.md +2 -1
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 {
|
|
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, h as presentReport, i as contextOf, l as isReviewing, ln as authoredWorldOf, m as checkImported, n as limitAuthoringAgents, nt as parseWorldInfoEdit, o as importTools, v as addressChanges, vt as checkWorld, w as editWorldInfo, x as matchPieces, y as cardChanges } from "./authoring-tools-C9cmcUbD.js";
|
|
2
|
+
import { t as guardAuthoringTurns } from "./turn-guard-B9pGCeir.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-D5j5mIq6.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-Cl9sU3Qs.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-CzqhC8sT.js";
|
|
6
|
+
import { G as formatIssue, R as parsePlotsFile, nt as shippedPromptsDirectory } from "./hooks-BpLN_hhT.js";
|
|
7
|
+
import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-Cc05FrId.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) {
|
|
@@ -171,6 +195,10 @@ const MAX_RUN_PROMPT = 24e3;
|
|
|
171
195
|
* minutes, a game master's turn never ended), so what the stop decided is not waited on past this.
|
|
172
196
|
*/
|
|
173
197
|
const STOP_GRACE_MS = 15e3;
|
|
198
|
+
/** The share of its output cap each recovery after the first leaves the game master: a call that runs on is cut sooner, so the next try has to be shorter. */
|
|
199
|
+
const RECOVERY_SHRINK = .5;
|
|
200
|
+
/** The least output a recovery leaves the game master. */
|
|
201
|
+
const RECOVERY_FLOOR = 2048;
|
|
174
202
|
// src/shared/sampling.ts
|
|
175
203
|
/** The controls beyond temperature, which apply to the game master and the characters (the helpers that must be exact are never asked more freely). */
|
|
176
204
|
const SHARED_SAMPLING = [
|
|
@@ -272,8 +300,12 @@ function childSampling(settings, kind, estimate) {
|
|
|
272
300
|
priority: kind === "characters" || kind === "authoring" ? "foreground" : "background"
|
|
273
301
|
};
|
|
274
302
|
}
|
|
303
|
+
const briefOf = (prompt) => {
|
|
304
|
+
const brief = briefSections(prompt);
|
|
305
|
+
return brief.length > 1 ? { brief } : {};
|
|
306
|
+
};
|
|
275
307
|
/** 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) {
|
|
308
|
+
function childTrace(store, kind, label, extra = {}, named, cause) {
|
|
277
309
|
const model = (named ?? store.settings().models[kind]).trim();
|
|
278
310
|
return (run) => {
|
|
279
311
|
const keep = store.settings().diagnostics.keepRuns;
|
|
@@ -284,6 +316,8 @@ function childTrace(store, kind, label, extra = {}, named) {
|
|
|
284
316
|
model,
|
|
285
317
|
ms: run.ms,
|
|
286
318
|
calls: run.calls,
|
|
319
|
+
...cause === void 0 ? {} : { cause },
|
|
320
|
+
...briefOf(run.detail.prompt),
|
|
287
321
|
...run.detail.calls.some((call) => call.failed) ? { refused: run.detail.calls.filter((call) => call.failed).length } : {},
|
|
288
322
|
turn: run.turn,
|
|
289
323
|
tokens: run.tokens,
|
|
@@ -346,6 +380,7 @@ const isUnfinishedCall = (error) => error instanceof Error && /parse tool call a
|
|
|
346
380
|
async function runChild(task) {
|
|
347
381
|
for (let attempt = 1;; attempt += 1) {
|
|
348
382
|
const began = Date.now();
|
|
383
|
+
const turnAtStart = task.turn ?? currentTurn(task.parent);
|
|
349
384
|
const stats = {
|
|
350
385
|
calls: 0,
|
|
351
386
|
record: []
|
|
@@ -371,7 +406,7 @@ async function runChild(task) {
|
|
|
371
406
|
ms: Date.now() - began,
|
|
372
407
|
calls: stats.calls,
|
|
373
408
|
detail: detail(),
|
|
374
|
-
turn:
|
|
409
|
+
turn: turnAtStart,
|
|
375
410
|
tokens: stats.tokens ?? NO_TOKENS,
|
|
376
411
|
requests: stats.requests ?? []
|
|
377
412
|
});
|
|
@@ -383,7 +418,7 @@ async function runChild(task) {
|
|
|
383
418
|
calls: stats.calls,
|
|
384
419
|
error: error instanceof Error ? error.message : String(error),
|
|
385
420
|
detail: detail(),
|
|
386
|
-
turn:
|
|
421
|
+
turn: turnAtStart,
|
|
387
422
|
tokens: stats.tokens ?? NO_TOKENS,
|
|
388
423
|
requests: stats.requests ?? []
|
|
389
424
|
});
|
|
@@ -756,6 +791,6 @@ async function execute(task, stats) {
|
|
|
756
791
|
}
|
|
757
792
|
return submitted.value;
|
|
758
793
|
}
|
|
759
|
-
export { tokensOf$1 as S,
|
|
794
|
+
export { cutOff as C, tokensOf$1 as E, currentTurn as S, estimateAnswer as T, estimateTokens as _, childTrace as a, addTokens as b, namedModel as c, parseSampling as d, sharedSamplingOf as f, blockText as g, requestsOf as h, childSamplingOf as i, runChild as l, RECOVERY_SHRINK as m, childModel as n, helpers as o, RECOVERY_FLOOR as p, childSampling as r, isUnfinishedCall as s, ChildTimeoutError as t, SAMPLING_RANGES as u, tokensOf as v, finishOf as w, totalTokens as x, NO_TOKENS as y };
|
|
760
795
|
|
|
761
|
-
//# sourceMappingURL=child-
|
|
796
|
+
//# sourceMappingURL=child-C9nPIy9j.js.map
|