@dsh-agentic-roleplay/core 0.11.1 → 0.12.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/{access-Md1YTSX1.js → access-DifaiHrI.js} +3 -15
- package/lib/{authoring-tools-BFdw7ahj.js → authoring-tools-VOaXzr_R.js} +58 -766
- package/lib/authoring.js +136 -13
- package/lib/{child-C9nPIy9j.js → child-DzZ-aI6k.js} +130 -2
- package/lib/client.js +17093 -2269
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +3 -3
- package/lib/dev-context-Bdm-eVer.js +40 -0
- package/lib/doctor.js +5 -3
- package/lib/{gallery-BWHmjogd.js → gallery-Ctz-UoFk.js} +3 -3
- package/lib/{generator-QCdm8nUh.js → generator-Cv6WWmZT.js} +2 -2
- package/lib/helper.js +15 -1
- package/lib/{hooks-C2U1-8ur.js → hooks-BdR3mBeM.js} +751 -344
- package/lib/images.js +4 -4
- package/lib/index.js +342 -463
- package/lib/jail-Cp4zEfip.js +107 -0
- package/lib/{library-4zmCAshR.js → library-BU2A_Dx8.js} +3 -3
- package/lib/{lorebook-author-tools-Bjfjt3bg.js → lorebook-author-tools-DUKcQu8P.js} +20 -7
- package/lib/lorebook-authoring.js +12 -5
- package/lib/{narration-b_VBEUWn.js → narration-CDsJ5wxH.js} +29 -2
- package/lib/orchestration.js +615 -48
- package/lib/{pack-jail-Ci9bIeDI.js → pack-jail-CzHQu0n3.js} +559 -23
- package/lib/{packs-CYkozh8Q.js → packs-BZ-45J4-.js} +2 -2
- package/lib/{presenter-agent-CqkAL03Q.js → presenter-agent-C2ZkoxZu.js} +9 -9
- package/lib/{preset-B-35yUmt.js → preset-BPnRPW-1.js} +4 -4
- package/lib/{preset-author-tools-BUymqZM5.js → preset-author-tools-DBqPwn-o.js} +9 -8
- package/lib/preset-authoring.js +11 -6
- package/lib/{reflection-B9N0z3KY.js → reflection-Cuy0YLv0.js} +22 -16
- package/lib/{presets-_U-xroo0.js → serial-BZNeK57v.js} +1305 -331
- package/lib/service-mRKwpWjX.js +140 -0
- package/lib/{text-C2AGl7Je.js → text-Dfv8S8eq.js} +27 -2
- package/lib/{turn-guard-C0M3rXEN.js → turn-guard-xaFxYc1T.js} +3 -3
- package/locale/de.json +6 -0
- package/locale/en.json +6 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +34 -34
- package/prompts/en/import/finish-ok.md +1 -1
- package/prompts/en/import/generator.md +1 -1
- package/prompts/en/import/style.md +2 -1
- package/prompts/en/import/variables.md +2 -1
- package/prompts/en/roleplay/character-lookup.md +1 -1
- package/prompts/en/roleplay/decide-errand.md +1 -0
- package/prompts/en/roleplay/decide-message.md +1 -0
- package/prompts/en/roleplay/dream.md +1 -0
- package/prompts/en/roleplay/gate-repeat.md +1 -0
- package/prompts/en/world/procedure.md +1 -1
- package/prompts/zh/import/finish-ok.md +1 -1
- package/prompts/zh/import/generator.md +1 -1
- package/prompts/zh/import/style.md +2 -1
- package/prompts/zh/import/variables.md +2 -1
- package/prompts/zh/roleplay/character-lookup.md +1 -1
- package/prompts/zh/roleplay/decide-errand.md +1 -0
- package/prompts/zh/roleplay/decide-message.md +1 -0
- package/prompts/zh/roleplay/dream.md +1 -0
- package/prompts/zh/roleplay/gate-repeat.md +1 -0
- package/prompts/zh/world/procedure.md +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as Reader } from "./hooks-
|
|
1
|
+
import { K as Reader } from "./hooks-BdR3mBeM.js";
|
|
2
2
|
import { dirname, extname, join, posix, sep } from "node:path";
|
|
3
3
|
import { copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync } from "node:fs";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
@@ -836,4 +836,4 @@ function anyTab(bases) {
|
|
|
836
836
|
}
|
|
837
837
|
export { API_PREFIX as _, packIds as a, describePack as c, packPath as d, readPack as f, SURFACE_NAMES as g, PACK_MEDIA_TYPES as h, inheritPacks as i, isPackId as l, PACK_LIMITS as m, anyTab as n, syncWorldPacks as o, PACK_ACTIONS as p, copyWorldPacks as r, worldPackStates as s, activePack as t, packFile as u };
|
|
838
838
|
|
|
839
|
-
//# sourceMappingURL=packs-
|
|
839
|
+
//# sourceMappingURL=packs-BZ-45J4-.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as atomicWrite, t as promptFor } from "./access-
|
|
2
|
-
import { l as runChild } from "./child-
|
|
3
|
-
import { n as generateTransientImage, t as generateReferenceImage } from "./generator-
|
|
4
|
-
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-
|
|
5
|
-
import { c as nextSceneSerial, u as referenceImagePath } from "./library-
|
|
6
|
-
import { join, relative } from "node:path";
|
|
1
|
+
import { n as atomicWrite, t as promptFor } from "./access-DifaiHrI.js";
|
|
2
|
+
import { l as runChild } from "./child-DzZ-aI6k.js";
|
|
3
|
+
import { n as generateTransientImage, t as generateReferenceImage } from "./generator-Cv6WWmZT.js";
|
|
4
|
+
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-Ctz-UoFk.js";
|
|
5
|
+
import { c as nextSceneSerial, u as referenceImagePath } from "./library-BU2A_Dx8.js";
|
|
6
|
+
import { join, relative, sep } from "node:path";
|
|
7
7
|
import { characterKey, itemKey, locationKey } from "@dsh-agentic-roleplay/state";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
@@ -450,7 +450,7 @@ function imageTools(deps) {
|
|
|
450
450
|
...args.art_direction === void 0 ? {} : { artDirection: args.art_direction },
|
|
451
451
|
...deps.signal === void 0 ? {} : { signal: deps.signal }
|
|
452
452
|
});
|
|
453
|
-
const local = relative(deps.root, path);
|
|
453
|
+
const local = relative(deps.root, path).split(sep).join("/");
|
|
454
454
|
recorded.push(local);
|
|
455
455
|
return { path: local };
|
|
456
456
|
}
|
|
@@ -543,7 +543,7 @@ function imageTools(deps) {
|
|
|
543
543
|
...references.length === 0 ? {} : { references },
|
|
544
544
|
...deps.signal === void 0 ? {} : { signal: deps.signal }
|
|
545
545
|
});
|
|
546
|
-
const local = relative(deps.root, path);
|
|
546
|
+
const local = relative(deps.root, path).split(sep).join("/");
|
|
547
547
|
recorded.push(local);
|
|
548
548
|
return {
|
|
549
549
|
path: local,
|
|
@@ -844,4 +844,4 @@ async function runImagePresenter(job) {
|
|
|
844
844
|
}
|
|
845
845
|
export { searchImages as a, presentedFor as c, findImages as i, interpretImage as n, tokensOf as o, imageTools as r, present as s, runImagePresenter as t };
|
|
846
846
|
|
|
847
|
-
//# sourceMappingURL=presenter-agent-
|
|
847
|
+
//# sourceMappingURL=presenter-agent-C2ZkoxZu.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Rt as ImportCardError, r as MAX_PREVIEW_TEXT } from "./authoring-tools-VOaXzr_R.js";
|
|
2
|
+
import { p as SAMPLING_RANGES } from "./child-DzZ-aI6k.js";
|
|
3
|
+
import { gt as cleanText } from "./serial-BZNeK57v.js";
|
|
4
4
|
// src/host/import/preset.ts
|
|
5
5
|
/** The older preset layout keeps its texts under fixed keys. */
|
|
6
6
|
const LEGACY_KEYS = [
|
|
@@ -239,4 +239,4 @@ function selectPrompts(file, enabled, keepSampling) {
|
|
|
239
239
|
}
|
|
240
240
|
export { readPreset as n, selectPrompts as r, previewPreset as t };
|
|
241
241
|
|
|
242
|
-
//# sourceMappingURL=preset-
|
|
242
|
+
//# sourceMappingURL=preset-BPnRPW-1.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./access-
|
|
2
|
-
import { $ as
|
|
3
|
-
import { n as readPreset$1 } from "./preset-
|
|
4
|
-
import { i as contextOf } from "./authoring-tools-
|
|
5
|
-
import { i as translator, r as languageOf } from "./text-
|
|
6
|
-
import { et as languageOf$1, it as shippedPromptsDirectory, rt as shippedLanguages } from "./hooks-
|
|
1
|
+
import "./access-DifaiHrI.js";
|
|
2
|
+
import { $ as deleteWorldPrompt, K as presetDirectory, Q as PROSE_PROMPTS, Z as updatePresetInfo, bt as IMPORT_FOLDER, et as listWorldPrompts, l as extractStyleFrom, nt as writeWorldPrompt, q as readPreset, tt as readWorldPrompt, yt as withPlayer, z as PRESET_FILE } from "./serial-BZNeK57v.js";
|
|
3
|
+
import { n as readPreset$1 } from "./preset-BPnRPW-1.js";
|
|
4
|
+
import { i as contextOf } from "./authoring-tools-VOaXzr_R.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-Dfv8S8eq.js";
|
|
6
|
+
import { et as languageOf$1, it as shippedPromptsDirectory, rt as shippedLanguages } from "./hooks-BdR3mBeM.js";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { readFile, rm } from "node:fs/promises";
|
|
@@ -234,10 +234,11 @@ function presetAuthorTools(reader, settings, prompting, shipped = shippedPrompts
|
|
|
234
234
|
];
|
|
235
235
|
}
|
|
236
236
|
/** Every change to a preset is put to the person; the first import into an empty preset only fills it, so it is not. */
|
|
237
|
-
async function presetApproval(exec, next, carries) {
|
|
237
|
+
async function presetApproval(exec, next, carries, auto = () => false) {
|
|
238
238
|
if (!PRESET_MUTATION_TOOLS.includes(exec.name) || exec.agent === void 0 || presetOfChat(exec.agent.session.id) === void 0) return await next();
|
|
239
239
|
const args = exec.arguments;
|
|
240
240
|
const chat = exec.agent.session.id;
|
|
241
|
+
if (auto() && !isRulesPrompt(args["id"])) return await next();
|
|
241
242
|
if (exec.name === "import_narration_preset") {
|
|
242
243
|
if (!carries(chat)) return await next();
|
|
243
244
|
return {
|
|
@@ -278,4 +279,4 @@ async function presetApproval(exec, next, carries) {
|
|
|
278
279
|
}
|
|
279
280
|
export { presetChatSessionId as a, presetAuthorTools as i, narrationImportMessage as n, presetOfChat as o, presetApproval as r, PresetReader as t };
|
|
280
281
|
|
|
281
|
-
//# sourceMappingURL=preset-author-tools-
|
|
282
|
+
//# sourceMappingURL=preset-author-tools-DBqPwn-o.js.map
|
package/lib/preset-authoring.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { n as limitAuthoringAgents } from "./authoring-tools-
|
|
2
|
-
import { t as guardAuthoringTurns } from "./turn-guard-
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
5
|
-
import
|
|
1
|
+
import { n as limitAuthoringAgents } from "./authoring-tools-VOaXzr_R.js";
|
|
2
|
+
import { t as guardAuthoringTurns } from "./turn-guard-xaFxYc1T.js";
|
|
3
|
+
import { t as silenceHarnessDevContext } from "./dev-context-Bdm-eVer.js";
|
|
4
|
+
import { i as presetAuthorTools, o as presetOfChat, r as presetApproval, t as PresetReader } from "./preset-author-tools-DBqPwn-o.js";
|
|
5
|
+
import "./hooks-BdR3mBeM.js";
|
|
6
|
+
import { K as presetDirectory } from "./serial-BZNeK57v.js";
|
|
6
7
|
import { join } from "node:path";
|
|
7
8
|
import { existsSync } from "node:fs";
|
|
8
9
|
// src/preset-authoring.ts
|
|
@@ -18,6 +19,7 @@ const inject = [
|
|
|
18
19
|
];
|
|
19
20
|
/** The preset authoring chat: reads and writes the prose prompts of one library preset, each write approved by the person. */
|
|
20
21
|
function apply(ctx) {
|
|
22
|
+
silenceHarnessDevContext(ctx);
|
|
21
23
|
const library = () => ctx.roleplayRoot.path;
|
|
22
24
|
const reader = new PresetReader(library);
|
|
23
25
|
const prompting = {
|
|
@@ -34,7 +36,10 @@ function apply(ctx) {
|
|
|
34
36
|
const preset = presetOfChat(chat);
|
|
35
37
|
return preset === void 0 ? void 0 : ctx.roleplayAuthoringLanguages.get(`preset:${preset}`);
|
|
36
38
|
}, () => ctx.roleplayImport.settings.reasoning);
|
|
37
|
-
ctx.on("
|
|
39
|
+
ctx.on("session/event", (session, event) => {
|
|
40
|
+
if (event.type === "turn/end" && session.header.origin !== "subagent" && presetOfChat(session.id) !== void 0) ctx.roleplayImport.turnEnded(session.id);
|
|
41
|
+
});
|
|
42
|
+
ctx.on("tools/pre-execute", (exec, next) => presetApproval(exec, next, carries, () => ctx.roleplayImport.settings.approval === "auto"));
|
|
38
43
|
const languageOf = (context) => {
|
|
39
44
|
const chat = context.agent?.session.id;
|
|
40
45
|
const preset = chat === void 0 ? void 0 : presetOfChat(chat);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { s as inheritImages } from "./library-
|
|
7
|
-
import { i as inheritPacks } from "./packs-
|
|
1
|
+
import { O as estimateAnswer, a as childTrace, j as roleplaySessionOf, l as runChild, n as childModel, r as childSampling } from "./child-DzZ-aI6k.js";
|
|
2
|
+
import { A as routeVerdicts, D as mergeReports, E as askYesNo, G as loadPreset, T as announceProblem, W as listPresets, X as sha, j as yesAt, k as noAt, t as SerialQueue } from "./serial-BZNeK57v.js";
|
|
3
|
+
import { t as promptFor } from "./access-DifaiHrI.js";
|
|
4
|
+
import { $ as inheritPrompts, D as referent, I as wrongLanguage, X as PROMPTS_FOLDER, mt as describeWhen } from "./hooks-BdR3mBeM.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-Dfv8S8eq.js";
|
|
6
|
+
import { s as inheritImages } from "./library-BU2A_Dx8.js";
|
|
7
|
+
import { i as inheritPacks } from "./packs-BZ-45J4-.js";
|
|
8
8
|
import { dirname, join } from "node:path";
|
|
9
9
|
import { characterKey, locationKey, sessionDatabase, sessionFolder, tokens } from "@dsh-agentic-roleplay/state";
|
|
10
10
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -342,14 +342,12 @@ var TimelineError = class extends Error {};
|
|
|
342
342
|
*/
|
|
343
343
|
var Timelines = class {
|
|
344
344
|
deps;
|
|
345
|
-
|
|
345
|
+
queue = new SerialQueue();
|
|
346
346
|
constructor(deps) {
|
|
347
347
|
this.deps = deps;
|
|
348
348
|
}
|
|
349
349
|
serial(chat, job) {
|
|
350
|
-
|
|
351
|
-
this.queues.set(chat, run.catch(() => void 0));
|
|
352
|
-
return run;
|
|
350
|
+
return this.queue.run(chat, job);
|
|
353
351
|
}
|
|
354
352
|
idOf(chat) {
|
|
355
353
|
const id = roleplaySessionOf(chat);
|
|
@@ -365,6 +363,13 @@ var Timelines = class {
|
|
|
365
363
|
view(id) {
|
|
366
364
|
return viewOf(this.read(id));
|
|
367
365
|
}
|
|
366
|
+
/** What the narration of the last `count` turns before the one being played told, oldest first, on the path the story has taken; never what an alternative or a withdrawn turn said. */
|
|
367
|
+
narrationBefore(chat, count) {
|
|
368
|
+
const id = roleplaySessionOf(chat);
|
|
369
|
+
if (id === void 0) return [];
|
|
370
|
+
const { path, head } = this.view(id);
|
|
371
|
+
return path.filter((turn) => turn.id !== head).slice(-count).flatMap((turn) => turn.output === void 0 ? [] : [turn.output.segments.flatMap((segment) => segment.type === "narration" ? [segment.text] : []).join("\n")]);
|
|
372
|
+
}
|
|
368
373
|
/**
|
|
369
374
|
* The player has said something and a turn begins: the turn is added to the timeline after the head, and the state the earlier one left is kept at once,
|
|
370
375
|
* with the records still waiting for the keeper in it (they are in the database, so a restored state carries them).
|
|
@@ -409,19 +414,20 @@ var Timelines = class {
|
|
|
409
414
|
/**
|
|
410
415
|
* The turn ended in the log. Its own message is found now: it is the first message of the player after the last turn that ended
|
|
411
416
|
* (it is not in the log yet when the turn begins).
|
|
417
|
+
* @param beganSeq - where that turn's own `turn/start` sits, so the log is not searched for it.
|
|
412
418
|
*/
|
|
413
|
-
ended(chat, session, seq) {
|
|
419
|
+
ended(chat, session, seq, beganSeq) {
|
|
414
420
|
const id = this.idOf(chat);
|
|
415
421
|
const timeline = this.read(id);
|
|
416
422
|
const node = timeline.nodes.find((candidate) => candidate.id === timeline.head);
|
|
417
423
|
if (node === void 0 || node.endSeq !== void 0) return;
|
|
418
424
|
const after = Math.max(-1, ...timeline.nodes.filter((other) => other.id !== node.id).map((other) => other.endSeq ?? other.userSeq));
|
|
419
|
-
const human = session.snapshotEvents().find((event) => event.seq > after && event.type === "user/message" && event.data.source.kind === "user");
|
|
425
|
+
const human = session.snapshotEvents(after + 1).find((event) => event.seq > after && event.type === "user/message" && event.data.source.kind === "user");
|
|
420
426
|
if (human === void 0) throw new TimelineError(`turn ${node.turn} has no message of the player in the log`);
|
|
421
427
|
node.userSeq = human.seq;
|
|
422
428
|
node.endSeq = seq;
|
|
423
|
-
const began = session.snapshotEvents().find((event) => event.type === "turn/start" && event.data.turn === node.turn);
|
|
424
|
-
node.startSeq = Math.min(began
|
|
429
|
+
const began = beganSeq ?? session.snapshotEvents(0).find((event) => event.type === "turn/start" && event.data.turn === node.turn)?.seq;
|
|
430
|
+
node.startSeq = Math.min(began ?? human.seq, human.seq);
|
|
425
431
|
writeTimeline(this.folder(id), timeline);
|
|
426
432
|
}
|
|
427
433
|
/** Keeps the state as it is under the name of the turn it follows from, when that is not done yet. */
|
|
@@ -1498,4 +1504,4 @@ function memoryReflector(deps) {
|
|
|
1498
1504
|
}
|
|
1499
1505
|
export { snapshotOf as _, whereabouts as a, copyPreset as c, switchPreset as d, readTimeline as f, pathTo as g, childrenOf as h, reflectionStatus as i, presetStatus as l, START_SNAPSHOT as m, memoryReflector as n, TimelineError as o, writeTimeline as p, recordFailure as r, Timelines as s, dueReflection as t, recordPreset as u };
|
|
1500
1506
|
|
|
1501
|
-
//# sourceMappingURL=reflection-
|
|
1507
|
+
//# sourceMappingURL=reflection-Cuy0YLv0.js.map
|