@dsh-agentic-roleplay/core 0.11.1 → 0.12.0
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-DAw54-NI.js} +3 -15
- package/lib/{authoring-tools-BFdw7ahj.js → authoring-tools-4NgDhIJV.js} +51 -11
- package/lib/authoring.js +8 -8
- package/lib/{child-C9nPIy9j.js → child-D3QUNb3m.js} +121 -2
- package/lib/client.js +1013 -449
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +3 -3
- package/lib/doctor.js +3 -3
- package/lib/{gallery-BWHmjogd.js → gallery-Ct6nm4UQ.js} +3 -3
- package/lib/{generator-QCdm8nUh.js → generator-CI8fOnXy.js} +2 -2
- package/lib/helper.js +13 -1
- package/lib/{hooks-C2U1-8ur.js → hooks-BNeoGMHZ.js} +722 -334
- package/lib/images.js +4 -4
- package/lib/index.js +234 -20
- package/lib/jail-BIF79PJO.js +107 -0
- package/lib/{library-4zmCAshR.js → library-BF9ZMSFz.js} +3 -3
- package/lib/{lorebook-author-tools-Bjfjt3bg.js → lorebook-author-tools-DBk-V0hp.js} +7 -7
- package/lib/lorebook-authoring.js +4 -4
- package/lib/{narration-b_VBEUWn.js → narration-xvErE2yp.js} +29 -2
- package/lib/orchestration.js +593 -47
- package/lib/{pack-jail-Ci9bIeDI.js → pack-jail-C8EyX9Ix.js} +12 -11
- package/lib/{packs-CYkozh8Q.js → packs-S0SzrVv-.js} +2 -2
- package/lib/{presenter-agent-CqkAL03Q.js → presenter-agent-Bc478nTA.js} +6 -6
- package/lib/{preset-B-35yUmt.js → preset-SJZyw0kt.js} +4 -4
- package/lib/{preset-author-tools-BUymqZM5.js → preset-author-tools-CzogjK42.js} +7 -7
- package/lib/preset-authoring.js +5 -5
- package/lib/{presets-_U-xroo0.js → presets-DQ5rioMh.js} +231 -48
- package/lib/{reflection-B9N0z3KY.js → reflection-buQiSdvq.js} +15 -8
- 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-BSAba8sp.js} +3 -3
- package/package.json +3 -3
- package/prompts/en/import/finish-ok.md +1 -1
- package/prompts/en/import/generator.md +1 -1
- package/prompts/en/import/style.md +1 -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/zh/import/finish-ok.md +1 -1
- package/prompts/zh/import/generator.md +1 -1
- package/prompts/zh/import/style.md +1 -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/lib/images.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as searchImages, c as presentedFor, n as interpretImage, o as tokensOf, r as imageTools, s as present, t as runImagePresenter } from "./presenter-agent-
|
|
2
|
-
import { i as updateImage, r as listGallery } from "./gallery-
|
|
3
|
-
import { c as nextSceneSerial, d as sceneImagePath, l as readImageMetadata, o as entityImageDirectory, s as inheritImages, t as addToLibrary, u as referenceImagePath, v as readPngMetadata, y as withPngMetadata } from "./library-
|
|
4
|
-
import { i as transientPrompt, n as generateTransientImage, r as referencePrompt, t as generateReferenceImage } from "./generator-
|
|
1
|
+
import { a as searchImages, c as presentedFor, n as interpretImage, o as tokensOf, r as imageTools, s as present, t as runImagePresenter } from "./presenter-agent-Bc478nTA.js";
|
|
2
|
+
import { i as updateImage, r as listGallery } from "./gallery-Ct6nm4UQ.js";
|
|
3
|
+
import { c as nextSceneSerial, d as sceneImagePath, l as readImageMetadata, o as entityImageDirectory, s as inheritImages, t as addToLibrary, u as referenceImagePath, v as readPngMetadata, y as withPngMetadata } from "./library-BF9ZMSFz.js";
|
|
4
|
+
import { i as transientPrompt, n as generateTransientImage, r as referencePrompt, t as generateReferenceImage } from "./generator-CI8fOnXy.js";
|
|
5
5
|
export { addToLibrary, entityImageDirectory, generateReferenceImage, generateTransientImage, imageTools, inheritImages, interpretImage, listGallery, nextSceneSerial, present, presentedFor, readImageMetadata, readPngMetadata, referenceImagePath, referencePrompt, runImagePresenter, sceneImagePath, searchImages, tokensOf, transientPrompt, updateImage, withPngMetadata };
|
package/lib/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $t as subfolders, At as populateLore, Bt as loadLocations, Ct as populateCharacters, Dt as populateItems, E as loadWorldParts, Et as populateFactions, F as localChanges, Ft as TRIGGERS_FILE_NAME, G as vetUrl, Gt as DICE_FILE_NAME, Ht as loadItems, I as readOrigin, Jt as CALENDAR_FILE_NAME, Kt as loadDice, L as writeOrigin, M as describeChanges, Mt as populateTriggers, N as hashWorld, Nt as populateVariables, Ot as populateKnowledge, P as isUnchanged, Pt as routineProblems, Qt as loadCharacters, R as CatalogueError, St as populateCalendar, T as readWorldInfo, Tt as populateDice, U as guardedLookup, Xt as parseCalendarFile, Yt as loadCalendar, Zt as CHARACTERS_DIR, _ as runChecks, _t as writeLorebookEntry, an as readCard, at as addLorebookEntries, c as importPhase, cn as DICE_RESULTS, ct as deleteLorebookEntry, d as markReady, dt as listLorebooks, en as knownOutputCeiling, et as WORLD_FILE_NAME, f as settleDraft, ft as loadLorebook, gt as updateLorebookInfo, ht as reserveLorebook, in as pictureOf, it as questionView, jt as populateRoutines, kt as populateLocations, ln as authoredWorldOf, lt as entriesOf, nn as cardFormat, nt as parseWorldInfoEdit, on as DICE_COMPARISONS, ot as createLorebook, p as structureImport, pt as lorebookDirectory, qt as parseDiceFile, rn as isPng, rt as combineAnswers, sn as DICE_READINGS, st as deleteLorebook, t as AuthoringTools, tn as ImportCardError, tt as parseWorldFile, u as keepDraft, ut as isLorebookName, vt as checkWorld, w as editWorldInfo, wt as populateClock, xt as knowsCharacter, yt as loadValidatedWorld } from "./authoring-tools-
|
|
3
|
-
import { a as lorebookImportMessage, c as readLorebook, d as lorebookOfChat, l as selectEntries, s as previewLorebook, t as LOREBOOK_UPLOAD, u as lorebookChatSessionId } from "./lorebook-author-tools-
|
|
4
|
-
import { a as presetChatSessionId, n as narrationImportMessage, o as presetOfChat } from "./preset-author-tools-
|
|
5
|
-
import { A as plotProgressOf, B as parsePlotsFile, C as readNotes, G as readDocument, H as COMMANDS_KEY, J as errorMessage, L as readUsage, Q as copyWorldPrompts, S as notesOfSession, T as defaultBoundaries, V as plotReferenceProblems, X as PROMPTS_FOLDER, Y as LANGUAGE_FOLDER, Z as PromptLibrary, _ as readTraces, b as readWithdrawn, ct as InvalidWorldError, dt as SessionNotFoundError, et as languageOf, ft as WorldNotFoundError, g as readRunDetail, h as readActivity, ht as zoneOf,
|
|
6
|
-
import { a as liveSettings, c as writeSettings, d as parseSettings, i as InvalidSettingsError, l as DEFAULT_SETTINGS, o as readSettings, p as WORLD_RULES_KEY, s as useChildReasoning, u as SETTINGS_SPEC } from "./narration-
|
|
7
|
-
import { $ as IMPORT_FOLDER,
|
|
8
|
-
import { $ as DOCTOR_OPENING_SOURCE, A as worldEntityImageFile, B as languageOfDocuments, C as readWorldEditor, D as uploadWorldCharacterPortrait, E as replaceFile, F as PRESET_FILE$1, G as revertUpdate, H as findTargets, I as presetMessage, J as AuthoringSessions, K as startUpdate, O as uploadWorldEntityImage, Q as agentServicesOf, R as translateMessage, S as generateWorldEntityImage, T as removeWorldTrigger, V as readWorldDocuments, X as ensureAuthoringChat, Y as authoringTitle, Z as AgentSessions, _ as editWorldPlots$1, a as deleteWorldPackFile, b as entityFolder, c as createAuthoredEntity, et as appendEmptyTurn, f as editWorldCharacter$1, g as editWorldPlace$1, h as editWorldNarrationVoice, j as writeWorldTrigger, k as worldCharacterPortraitFile, l as deleteAuthoredEntity, m as editWorldLore$1, n as packFileProblem, p as editWorldFaction$1, q as updateStatus, t as MAX_PACK_TEXT, tt as appendNarratedTurn, u as readAuthoredEntityDocument, v as editWorldRelation$1, w as readWorldTrigger, x as generateWorldCharacterPortrait, y as editWorldThing$1 } from "./pack-jail-
|
|
9
|
-
import {
|
|
10
|
-
import { i as translator, r as languageOf$1, t as trimCharacters } from "./text-
|
|
11
|
-
import { _ as snapshotOf, c as copyPreset, d as switchPreset, f as readTimeline, g as pathTo, h as childrenOf, i as reflectionStatus, l as presetStatus, m as START_SNAPSHOT, o as TimelineError, p as writeTimeline, u as recordPreset } from "./reflection-
|
|
12
|
-
import { n as readPreset, r as selectPrompts, t as previewPreset } from "./preset-
|
|
13
|
-
import { C as slug, T as uniqueKey, d as sceneImagePath, s as inheritImages, t as addToLibrary, u as referenceImagePath } from "./library-
|
|
1
|
+
import { A as chatSessionId, _ as RECOVERY_SHRINK, g as RECOVERY_FLOOR, h as sharedSamplingOf, i as childSamplingOf, j as roleplaySessionOf, m as parseSampling, s as isUnfinishedCall, w as totalTokens } from "./child-D3QUNb3m.js";
|
|
2
|
+
import { $t as subfolders, At as populateLore, Bt as loadLocations, Ct as populateCharacters, Dt as populateItems, E as loadWorldParts, Et as populateFactions, F as localChanges, Ft as TRIGGERS_FILE_NAME, G as vetUrl, Gt as DICE_FILE_NAME, Ht as loadItems, I as readOrigin, Jt as CALENDAR_FILE_NAME, Kt as loadDice, L as writeOrigin, M as describeChanges, Mt as populateTriggers, N as hashWorld, Nt as populateVariables, Ot as populateKnowledge, P as isUnchanged, Pt as routineProblems, Qt as loadCharacters, R as CatalogueError, St as populateCalendar, T as readWorldInfo, Tt as populateDice, U as guardedLookup, Xt as parseCalendarFile, Yt as loadCalendar, Zt as CHARACTERS_DIR, _ as runChecks, _t as writeLorebookEntry, an as readCard, at as addLorebookEntries, c as importPhase, cn as DICE_RESULTS, ct as deleteLorebookEntry, d as markReady, dt as listLorebooks, en as knownOutputCeiling, et as WORLD_FILE_NAME, f as settleDraft, ft as loadLorebook, gt as updateLorebookInfo, ht as reserveLorebook, in as pictureOf, it as questionView, jt as populateRoutines, kt as populateLocations, ln as authoredWorldOf, lt as entriesOf, nn as cardFormat, nt as parseWorldInfoEdit, on as DICE_COMPARISONS, ot as createLorebook, p as structureImport, pt as lorebookDirectory, qt as parseDiceFile, rn as isPng, rt as combineAnswers, sn as DICE_READINGS, st as deleteLorebook, t as AuthoringTools, tn as ImportCardError, tt as parseWorldFile, u as keepDraft, ut as isLorebookName, vt as checkWorld, w as editWorldInfo, wt as populateClock, xt as knowsCharacter, yt as loadValidatedWorld } from "./authoring-tools-4NgDhIJV.js";
|
|
3
|
+
import { a as lorebookImportMessage, c as readLorebook, d as lorebookOfChat, l as selectEntries, s as previewLorebook, t as LOREBOOK_UPLOAD, u as lorebookChatSessionId } from "./lorebook-author-tools-DBk-V0hp.js";
|
|
4
|
+
import { a as presetChatSessionId, n as narrationImportMessage, o as presetOfChat } from "./preset-author-tools-CzogjK42.js";
|
|
5
|
+
import { A as plotProgressOf, B as parsePlotsFile, C as readNotes, G as readDocument, H as COMMANDS_KEY, J as errorMessage, L as readUsage, Q as copyWorldPrompts, S as notesOfSession, T as defaultBoundaries, V as plotReferenceProblems, X as PROMPTS_FOLDER, Y as LANGUAGE_FOLDER, Z as PromptLibrary, _ as readTraces, b as readWithdrawn, ct as InvalidWorldError, dt as SessionNotFoundError, et as languageOf, ft as WorldNotFoundError, g as readRunDetail, h as readActivity, ht as zoneOf, j as populatePlots, k as PLOTS_METADATA_KEY, lt as ReflectionRefusedError, m as readDecisionStats, nt as promptProblem, o as externalTools, ot as AgentUnavailableError, q as formatIssue, rt as shippedLanguages, st as InvalidStartError, tt as listFiles, ut as SessionArchivedError, w as observeAsPlayer, x as addToNote } from "./hooks-BNeoGMHZ.js";
|
|
6
|
+
import { a as liveSettings, c as writeSettings, d as parseSettings, i as InvalidSettingsError, l as DEFAULT_SETTINGS, o as readSettings, p as WORLD_RULES_KEY, s as useChildReasoning, u as SETTINGS_SPEC } from "./narration-xvErE2yp.js";
|
|
7
|
+
import { $ as IMPORT_FOLDER, Bt as LORE_KINDS, Ft as parseLoreEdit, G as deleteWorldPrompt, It as parsePlaceEdit, J as writeWorldPrompt, K as listWorldPrompts, Lt as parseRelationEdit, Mt as InvalidEditProblems, Nt as parseCharacterEdit, Ot as CHARACTER_FILE_NAME, Pt as parseFactionEdit, Q as withPlayer, Rt as parseThingEdit, Vt as LORE_SCOPES, Z as partsOf, _t as variableProblems, a as isPresetName, at as readImportFolder, c as presetDirectory, d as savePresetFromWorld, et as ImportNotFoundError, gt as parseVariablesFile, ht as loadVariables, i as deletePreset, it as parseChoices, kt as parseCharacterFile, mt as VARIABLES_FILE_NAME, o as listPresets, p as updatePresetInfo, pt as sourceSummary, q as readWorldPrompt, r as createPresetFromShipped, s as loadPreset, st as IMPORT_COMMAND, t as PRESET_FILE, tt as ImportStore, u as reservePreset, zt as guarded } from "./presets-DQ5rioMh.js";
|
|
8
|
+
import { $ as DOCTOR_OPENING_SOURCE, A as worldEntityImageFile, B as languageOfDocuments, C as readWorldEditor, D as uploadWorldCharacterPortrait, E as replaceFile, F as PRESET_FILE$1, G as revertUpdate, H as findTargets, I as presetMessage, J as AuthoringSessions, K as startUpdate, O as uploadWorldEntityImage, Q as agentServicesOf, R as translateMessage, S as generateWorldEntityImage, T as removeWorldTrigger, V as readWorldDocuments, X as ensureAuthoringChat, Y as authoringTitle, Z as AgentSessions, _ as editWorldPlots$1, a as deleteWorldPackFile, b as entityFolder, c as createAuthoredEntity, et as appendEmptyTurn, f as editWorldCharacter$1, g as editWorldPlace$1, h as editWorldNarrationVoice, j as writeWorldTrigger, k as worldCharacterPortraitFile, l as deleteAuthoredEntity, m as editWorldLore$1, n as packFileProblem, p as editWorldFaction$1, q as updateStatus, t as MAX_PACK_TEXT, tt as appendNarratedTurn, u as readAuthoredEntityDocument, v as editWorldRelation$1, w as readWorldTrigger, x as generateWorldCharacterPortrait, y as editWorldThing$1 } from "./pack-jail-C8EyX9Ix.js";
|
|
9
|
+
import { a as VARIABLE_KINDS, i as atomicWriteSync, n as atomicWrite, o as VARIABLE_SUBJECTS, r as atomicWriteJson, s as VARIABLE_VISIBILITIES } from "./access-DAw54-NI.js";
|
|
10
|
+
import { i as translator, r as languageOf$1, t as trimCharacters } from "./text-Dfv8S8eq.js";
|
|
11
|
+
import { _ as snapshotOf, c as copyPreset, d as switchPreset, f as readTimeline, g as pathTo, h as childrenOf, i as reflectionStatus, l as presetStatus, m as START_SNAPSHOT, o as TimelineError, p as writeTimeline, u as recordPreset } from "./reflection-buQiSdvq.js";
|
|
12
|
+
import { n as readPreset, r as selectPrompts, t as previewPreset } from "./preset-SJZyw0kt.js";
|
|
13
|
+
import { C as slug, T as uniqueKey, d as sceneImagePath, s as inheritImages, t as addToLibrary, u as referenceImagePath } from "./library-BF9ZMSFz.js";
|
|
14
|
+
import { o as FOLDER_ACCESS, r as InvalidFoldersError, t as StoryFoldersService } from "./service-mRKwpWjX.js";
|
|
14
15
|
import { t as doctorChatSessionId } from "./doctor-chat-hL1a61hp.js";
|
|
15
|
-
import { _ as API_PREFIX, a as packIds, c as describePack, d as packPath, f as readPack, l as isPackId, m as PACK_LIMITS, n as anyTab, o as syncWorldPacks, r as copyWorldPacks, s as worldPackStates, t as activePack, u as packFile } from "./packs-
|
|
16
|
-
import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-
|
|
17
|
-
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-
|
|
16
|
+
import { _ as API_PREFIX, a as packIds, c as describePack, d as packPath, f as readPack, l as isPackId, m as PACK_LIMITS, n as anyTab, o as syncWorldPacks, r as copyWorldPacks, s as worldPackStates, t as activePack, u as packFile } from "./packs-S0SzrVv-.js";
|
|
17
|
+
import { a as uploadReferenceImage, t as generateReferenceImage } from "./generator-CI8fOnXy.js";
|
|
18
|
+
import { i as updateImage, n as galleryFile, r as listGallery } from "./gallery-Ct6nm4UQ.js";
|
|
18
19
|
import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
|
|
19
20
|
import { SESSION_DATABASE_FILE, addLocalDays, createSessionStore, describeInstant, describeValue, holidaysOn, isSessionId, itemKey, lintWorld, locationKey, openSessionStore, parseInstant, readCalendar, seasonOf, sessionDatabase, sessionFolder, shownVariables, systemTimeZone } from "@dsh-agentic-roleplay/state";
|
|
20
21
|
import { copyFileSync, cpSync, createReadStream, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -1464,6 +1465,49 @@ var Lorebooks = class {
|
|
|
1464
1465
|
};
|
|
1465
1466
|
}
|
|
1466
1467
|
};
|
|
1468
|
+
// src/host/autonomy/ticker.ts
|
|
1469
|
+
/**
|
|
1470
|
+
* Looks at the stories that switched on going on while their player is away, one after the other and one at a time: a story that did not is never touched, and
|
|
1471
|
+
* a story that cannot be looked at is reported and left for the next time.
|
|
1472
|
+
*/
|
|
1473
|
+
var AutonomyTicker = class {
|
|
1474
|
+
deps;
|
|
1475
|
+
running = false;
|
|
1476
|
+
constructor(deps) {
|
|
1477
|
+
this.deps = deps;
|
|
1478
|
+
}
|
|
1479
|
+
/** @returns how many stories were looked at. */
|
|
1480
|
+
async run(signal) {
|
|
1481
|
+
if (this.running) return 0;
|
|
1482
|
+
this.running = true;
|
|
1483
|
+
let looked = 0;
|
|
1484
|
+
try {
|
|
1485
|
+
for (const session of this.deps.sessions()) {
|
|
1486
|
+
if (signal.aborted) break;
|
|
1487
|
+
if (session.archived) continue;
|
|
1488
|
+
let on;
|
|
1489
|
+
try {
|
|
1490
|
+
const { autonomy, clock } = this.deps.settings(session.id);
|
|
1491
|
+
on = autonomy.enabled && clock.mode === "real";
|
|
1492
|
+
} catch (error) {
|
|
1493
|
+
this.deps.problem(`the settings of "${session.name}" could not be read: ${error instanceof Error ? error.message : String(error)}`);
|
|
1494
|
+
continue;
|
|
1495
|
+
}
|
|
1496
|
+
if (!on) continue;
|
|
1497
|
+
try {
|
|
1498
|
+
await this.deps.ensure(session.id, session.name);
|
|
1499
|
+
await this.deps.tick(`session-${session.id}`, signal);
|
|
1500
|
+
looked += 1;
|
|
1501
|
+
} catch (error) {
|
|
1502
|
+
if (!signal.aborted) this.deps.problem(`"${session.name}" could not be looked at while its player is away: ${error instanceof Error ? error.message : String(error)}`);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
} finally {
|
|
1506
|
+
this.running = false;
|
|
1507
|
+
}
|
|
1508
|
+
return looked;
|
|
1509
|
+
}
|
|
1510
|
+
};
|
|
1467
1511
|
const KIND = {
|
|
1468
1512
|
folder: "sessions",
|
|
1469
1513
|
projectTitle: "Session Doctor",
|
|
@@ -1543,6 +1587,11 @@ var RoleplayOrchestration = class extends Service {
|
|
|
1543
1587
|
recallPreview = () => Promise.reject(/* @__PURE__ */ new Error("the orchestration is not running"));
|
|
1544
1588
|
/** Whether a turn of the chat is being played; there while the orchestration is. */
|
|
1545
1589
|
playing = () => false;
|
|
1590
|
+
/** One look at a story that goes on while its player is away (the characters' days, and perhaps a message); there while the orchestration is. */
|
|
1591
|
+
autonomy = () => Promise.resolve({
|
|
1592
|
+
outcome: "off",
|
|
1593
|
+
moved: 0
|
|
1594
|
+
});
|
|
1546
1595
|
/** Whether a reflection of the chat is running; there while the orchestration is. */
|
|
1547
1596
|
reflecting = () => false;
|
|
1548
1597
|
/** What the story's turns are and taking the story back to one; there while the orchestration is. */
|
|
@@ -2140,6 +2189,48 @@ function lorebookRoutes(api) {
|
|
|
2140
2189
|
} }
|
|
2141
2190
|
};
|
|
2142
2191
|
}
|
|
2192
|
+
// src/host/workspace/routes.ts
|
|
2193
|
+
function parseFolders(body) {
|
|
2194
|
+
if (!Array.isArray(body["folders"])) return "\"folders\" must be a list";
|
|
2195
|
+
const folders = [];
|
|
2196
|
+
for (const entry of body["folders"]) {
|
|
2197
|
+
const folder = entry;
|
|
2198
|
+
if (typeof folder !== "object" || folder === null || typeof folder["path"] !== "string" || !FOLDER_ACCESS.includes(folder["access"])) return "each folder needs a \"path\" and an \"access\" of read or write";
|
|
2199
|
+
folders.push({
|
|
2200
|
+
path: folder["path"],
|
|
2201
|
+
access: folder["access"]
|
|
2202
|
+
});
|
|
2203
|
+
}
|
|
2204
|
+
return folders;
|
|
2205
|
+
}
|
|
2206
|
+
function folderRoutes(api) {
|
|
2207
|
+
const failed = (res, error) => {
|
|
2208
|
+
if (error instanceof SessionNotFoundError) return sendError(res, 404, error.message);
|
|
2209
|
+
if (error instanceof InvalidFoldersError) return sendJson(res, 422, {
|
|
2210
|
+
message: error.message,
|
|
2211
|
+
problems: error.problems
|
|
2212
|
+
});
|
|
2213
|
+
throw error;
|
|
2214
|
+
};
|
|
2215
|
+
return { "/sessions/folders": {
|
|
2216
|
+
GET: async (_req, res, url) => {
|
|
2217
|
+
try {
|
|
2218
|
+
sendJson(res, 200, await api.status(url.searchParams.get("id") ?? ""));
|
|
2219
|
+
} catch (error) {
|
|
2220
|
+
failed(res, error);
|
|
2221
|
+
}
|
|
2222
|
+
},
|
|
2223
|
+
PUT: async (req, res, url) => {
|
|
2224
|
+
const folders = parseFolders(await readJsonBody(req));
|
|
2225
|
+
if (typeof folders === "string") return sendError(res, 400, folders);
|
|
2226
|
+
try {
|
|
2227
|
+
sendJson(res, 200, await api.set(url.searchParams.get("id") ?? "", folders));
|
|
2228
|
+
} catch (error) {
|
|
2229
|
+
failed(res, error);
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
} };
|
|
2233
|
+
}
|
|
2143
2234
|
// src/host/prompts/routes.ts
|
|
2144
2235
|
function promptRoutes(api) {
|
|
2145
2236
|
const fail = (res, error) => {
|
|
@@ -2449,7 +2540,7 @@ function playerViewOf(session, options) {
|
|
|
2449
2540
|
summary: player.summary,
|
|
2450
2541
|
publicState: playerState?.publicState ?? ""
|
|
2451
2542
|
};
|
|
2452
|
-
view.variables.push(...shown(player.name, shownVariables(session, "character", player.id, keyOf$3(player), "
|
|
2543
|
+
view.variables.push(...shown(player.name, shownVariables(session, "character", player.id, keyOf$3(player), "self")));
|
|
2453
2544
|
const placement = session.placements.get("character", player.id);
|
|
2454
2545
|
const here = placement === void 0 ? void 0 : session.locations.get(placement.locationId);
|
|
2455
2546
|
const known = new Set(session.knowledge.list(player.id, "location").map((entry) => entry.subjectId));
|
|
@@ -3805,7 +3896,8 @@ const ROUTINE_FIELDS = [
|
|
|
3805
3896
|
"location",
|
|
3806
3897
|
"feature",
|
|
3807
3898
|
"position",
|
|
3808
|
-
"interruptible"
|
|
3899
|
+
"interruptible",
|
|
3900
|
+
"sleep"
|
|
3809
3901
|
];
|
|
3810
3902
|
/**
|
|
3811
3903
|
* The windows of a day as the browser sends them.
|
|
@@ -3840,6 +3932,7 @@ function parseRoutineEdit(value) {
|
|
|
3840
3932
|
]) if (entry[key] !== void 0 && typeof entry[key] !== "string") problems.push(`${at}.${key} must be text`);
|
|
3841
3933
|
if (entry["days"] !== void 0 && !(Array.isArray(entry["days"]) && entry["days"].every((day) => typeof day === "string"))) problems.push(`${at}.days must be a list of days`);
|
|
3842
3934
|
if (entry["interruptible"] !== void 0 && typeof entry["interruptible"] !== "boolean") problems.push(`${at}.interruptible must be true or false`);
|
|
3935
|
+
if (entry["sleep"] !== void 0 && typeof entry["sleep"] !== "boolean") problems.push(`${at}.sleep must be true or false`);
|
|
3843
3936
|
const text = (key) => typeof entry[key] === "string" ? entry[key].trim() : "";
|
|
3844
3937
|
return {
|
|
3845
3938
|
days: Array.isArray(entry["days"]) ? entry["days"].map((day) => day.trim().toLowerCase()).filter((day) => day !== "") : [],
|
|
@@ -3850,7 +3943,8 @@ function parseRoutineEdit(value) {
|
|
|
3850
3943
|
...text("location") === "" ? {} : { location: text("location") },
|
|
3851
3944
|
...text("feature") === "" ? {} : { feature: text("feature") },
|
|
3852
3945
|
...text("position") === "" ? {} : { position: text("position") },
|
|
3853
|
-
interruptible: entry["interruptible"] !== false
|
|
3946
|
+
interruptible: entry["interruptible"] !== false,
|
|
3947
|
+
...entry["sleep"] === true ? { sleep: true } : {}
|
|
3854
3948
|
};
|
|
3855
3949
|
});
|
|
3856
3950
|
if (problems.length > 0) throw new InvalidEditProblems(problems);
|
|
@@ -4848,6 +4942,7 @@ async function writeJournal(sessionsDir, id, body, now = () => /* @__PURE__ */ n
|
|
|
4848
4942
|
// src/shared/reference.ts
|
|
4849
4943
|
/** The pages of the reference: what the player may look up about the story, never what only the story knows. */
|
|
4850
4944
|
const REFERENCE_SECTIONS = [
|
|
4945
|
+
"status",
|
|
4851
4946
|
"profile",
|
|
4852
4947
|
"people",
|
|
4853
4948
|
"places",
|
|
@@ -5085,8 +5180,71 @@ function quests(session, options) {
|
|
|
5085
5180
|
...threads.filter((thread) => thread.status === "resolved").reverse()
|
|
5086
5181
|
];
|
|
5087
5182
|
}
|
|
5183
|
+
/**
|
|
5184
|
+
* Every tracked value the player may read, by subject: the world's, their own (private ones too), the place's, those of the people they have met or are with, and of the things they carry
|
|
5185
|
+
* or see lying about, without the feelings every story has (the profile tells those in words). What is hidden, and what is private to someone else, is not read.
|
|
5186
|
+
*/
|
|
5187
|
+
function status(session) {
|
|
5188
|
+
const stand = standpoint(session);
|
|
5189
|
+
if (stand === void 0) return [];
|
|
5190
|
+
const values = (kind, id, key, audience) => shownVariables(session, kind, id, key, audience, { all: true }).filter(({ variable }) => variable.builtin !== true).map(({ variable, value }) => ({
|
|
5191
|
+
name: variable.name,
|
|
5192
|
+
value: describeValue(variable, value)
|
|
5193
|
+
}));
|
|
5194
|
+
const groups = [
|
|
5195
|
+
{
|
|
5196
|
+
subject: "world",
|
|
5197
|
+
values: values("world", 0, "world", "others")
|
|
5198
|
+
},
|
|
5199
|
+
{
|
|
5200
|
+
subject: "player",
|
|
5201
|
+
key: keyOf$1(stand.player),
|
|
5202
|
+
name: stand.player.name,
|
|
5203
|
+
values: values("character", stand.player.id, keyOf$1(stand.player), "self")
|
|
5204
|
+
},
|
|
5205
|
+
...stand.here === void 0 ? [] : [{
|
|
5206
|
+
subject: "place",
|
|
5207
|
+
key: locationKey(stand.here),
|
|
5208
|
+
name: stand.here.name,
|
|
5209
|
+
here: true,
|
|
5210
|
+
values: values("location", stand.here.id, locationKey(stand.here), "others")
|
|
5211
|
+
}],
|
|
5212
|
+
...people(session).flatMap((person) => {
|
|
5213
|
+
const character = session.characters.list().find((candidate) => keyOf$1(candidate) === person.key);
|
|
5214
|
+
return character === void 0 ? [] : [{
|
|
5215
|
+
subject: "person",
|
|
5216
|
+
key: person.key,
|
|
5217
|
+
name: person.name,
|
|
5218
|
+
here: person.here,
|
|
5219
|
+
values: values("character", character.id, person.key, "others")
|
|
5220
|
+
}];
|
|
5221
|
+
})
|
|
5222
|
+
];
|
|
5223
|
+
const things = [...session.items.contents({
|
|
5224
|
+
kind: "character",
|
|
5225
|
+
id: stand.player.id
|
|
5226
|
+
}).map((entry) => ({
|
|
5227
|
+
entry,
|
|
5228
|
+
here: false
|
|
5229
|
+
})), ...stand.here === void 0 ? [] : session.items.contents({
|
|
5230
|
+
kind: "location",
|
|
5231
|
+
id: stand.here.id
|
|
5232
|
+
}).map((entry) => ({
|
|
5233
|
+
entry,
|
|
5234
|
+
here: true
|
|
5235
|
+
}))].filter(({ entry }) => !entry.item.hidden);
|
|
5236
|
+
for (const { entry, here } of things) groups.push({
|
|
5237
|
+
subject: "thing",
|
|
5238
|
+
key: itemKey(entry.item),
|
|
5239
|
+
name: entry.item.name,
|
|
5240
|
+
here,
|
|
5241
|
+
values: values("item", entry.item.id, itemKey(entry.item), "others")
|
|
5242
|
+
});
|
|
5243
|
+
return groups.filter((group) => group.values.length > 0);
|
|
5244
|
+
}
|
|
5088
5245
|
/** One page per section; a new page is a new entry here and in `REFERENCE_SECTIONS`. */
|
|
5089
5246
|
const PAGES = {
|
|
5247
|
+
status,
|
|
5090
5248
|
profile,
|
|
5091
5249
|
people,
|
|
5092
5250
|
places,
|
|
@@ -5681,6 +5839,7 @@ function createApiHandler(deps) {
|
|
|
5681
5839
|
...interfaceRoutes(packs),
|
|
5682
5840
|
...presetRoutes(presets),
|
|
5683
5841
|
...lorebookRoutes(lorebooks),
|
|
5842
|
+
...folderRoutes(deps.folders),
|
|
5684
5843
|
...promptRoutes(deps.prompts),
|
|
5685
5844
|
...syncRoutes(sync)
|
|
5686
5845
|
};
|
|
@@ -5758,7 +5917,8 @@ async function deleteSession(deps, id) {
|
|
|
5758
5917
|
const ROOT_LAYOUT = [
|
|
5759
5918
|
"characters",
|
|
5760
5919
|
"sessions",
|
|
5761
|
-
"worlds"
|
|
5920
|
+
"worlds",
|
|
5921
|
+
"workspace"
|
|
5762
5922
|
];
|
|
5763
5923
|
/**
|
|
5764
5924
|
* Resolve the configured root to an absolute, normalized path.
|
|
@@ -7092,6 +7252,18 @@ async function startSession(deps, request) {
|
|
|
7092
7252
|
mode: answers.clockMode
|
|
7093
7253
|
}
|
|
7094
7254
|
};
|
|
7255
|
+
const givenAutonomy = (request.settings?.autonomy)?.enabled;
|
|
7256
|
+
if (world.autonomy === true && givenAutonomy === void 0) settings = {
|
|
7257
|
+
...settings,
|
|
7258
|
+
autonomy: {
|
|
7259
|
+
...settings.autonomy,
|
|
7260
|
+
enabled: true
|
|
7261
|
+
},
|
|
7262
|
+
...givenClock === void 0 && answers.clockMode === void 0 ? { clock: {
|
|
7263
|
+
...settings.clock,
|
|
7264
|
+
mode: "real"
|
|
7265
|
+
} } : {}
|
|
7266
|
+
};
|
|
7095
7267
|
const timeZone = settings.clock.timeZone !== "" ? settings.clock.timeZone : settings.clock.mode === "real" ? systemTimeZone() : world.clock?.timeZone ?? "UTC";
|
|
7096
7268
|
const tools = Object.fromEntries([.../* @__PURE__ */ new Set([
|
|
7097
7269
|
...Object.keys(world.tools ?? {}),
|
|
@@ -7872,6 +8044,7 @@ async function loadWorld(folder, dir, file, problems) {
|
|
|
7872
8044
|
...world.startQuestions === void 0 ? {} : { startQuestions: world.startQuestions },
|
|
7873
8045
|
...world.rules === void 0 ? {} : { rules: world.rules },
|
|
7874
8046
|
...world.tools === void 0 ? {} : { tools: world.tools },
|
|
8047
|
+
...world.autonomy === void 0 ? {} : { autonomy: world.autonomy },
|
|
7875
8048
|
...world.narrationVoice === void 0 ? {} : { narrationVoice: world.narrationVoice },
|
|
7876
8049
|
...world.sampling === void 0 ? {} : { sampling: world.sampling },
|
|
7877
8050
|
...world.preset === void 0 ? {} : { preset: world.preset },
|
|
@@ -9914,6 +10087,7 @@ const Config = z.object({
|
|
|
9914
10087
|
}).default({ ...DEFAULT_OFFLOAD }).volatile(),
|
|
9915
10088
|
catalogueMaxBytes: z.number().min(1024).default(268435456).volatile(),
|
|
9916
10089
|
catalogueTrashDays: z.number().min(0).default(30).volatile(),
|
|
10090
|
+
autonomyTickSeconds: z.number().min(0).max(3600).default(30).volatile(),
|
|
9917
10091
|
importMaxUploadBytes: z.number().min(1024).default(104857600).volatile(),
|
|
9918
10092
|
importConcurrency: z.number().min(1).max(16).default(4).volatile(),
|
|
9919
10093
|
importReasoning: z.string().default("").volatile(),
|
|
@@ -9978,6 +10152,38 @@ function apply(ctx, config) {
|
|
|
9978
10152
|
const languages = new AuthoringLanguages(ctx, () => join(root.path, "worlds"));
|
|
9979
10153
|
const authoringTools = new AuthoringTools(ctx, () => config.authoringTools.get());
|
|
9980
10154
|
const agent = new AgentSessions(agentServicesOf(ctx), () => root.path);
|
|
10155
|
+
const autonomy = new AutonomyTicker({
|
|
10156
|
+
sessions: () => listSessions({
|
|
10157
|
+
state: ctx.roleplayState,
|
|
10158
|
+
sessionsDir: () => join(root.path, "sessions")
|
|
10159
|
+
}).sessions.map((session) => ({
|
|
10160
|
+
id: session.id,
|
|
10161
|
+
name: session.name,
|
|
10162
|
+
archived: session.archivedAt !== void 0
|
|
10163
|
+
})),
|
|
10164
|
+
settings: (id) => liveSettings(sessionFolder(join(root.path, "sessions"), id)),
|
|
10165
|
+
ensure: async (id, name) => await agent.ensure(id, name),
|
|
10166
|
+
tick: async (chat, signal) => await orchestration.autonomy(chat, signal),
|
|
10167
|
+
problem: (message) => {
|
|
10168
|
+
ctx.logger.warn(`roleplay: ${message}`);
|
|
10169
|
+
}
|
|
10170
|
+
});
|
|
10171
|
+
ctx.effect(() => {
|
|
10172
|
+
let timer;
|
|
10173
|
+
const controller = new AbortController();
|
|
10174
|
+
const later = () => {
|
|
10175
|
+
const seconds = config.autonomyTickSeconds.get();
|
|
10176
|
+
timer = setTimeout(() => {
|
|
10177
|
+
(seconds === 0 ? Promise.resolve(0) : autonomy.run(controller.signal)).finally(later);
|
|
10178
|
+
}, Math.max(5, seconds === 0 ? 60 : seconds) * 1e3);
|
|
10179
|
+
timer.unref();
|
|
10180
|
+
};
|
|
10181
|
+
later();
|
|
10182
|
+
return () => {
|
|
10183
|
+
controller.abort();
|
|
10184
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
10185
|
+
};
|
|
10186
|
+
}, "roleplay: stories that go on while the player is away");
|
|
9981
10187
|
const authoring = new AuthoringSessions(agentServicesOf(ctx), () => root.path, prompts, languages);
|
|
9982
10188
|
const presetAuthoring = new PresetAuthoringSessions(agentServicesOf(ctx), () => root.path, prompts, languages);
|
|
9983
10189
|
const lorebookAuthoring = new LorebookAuthoringSessions(agentServicesOf(ctx), () => root.path, prompts, languages);
|
|
@@ -10157,6 +10363,14 @@ function apply(ctx, config) {
|
|
|
10157
10363
|
catalogue,
|
|
10158
10364
|
presets: presetLibrary,
|
|
10159
10365
|
lorebooks: lorebookLibrary,
|
|
10366
|
+
folders: new StoryFoldersService({
|
|
10367
|
+
root: () => root.path,
|
|
10368
|
+
sessionFolder: (id) => {
|
|
10369
|
+
const sessions = join(root.path, "sessions");
|
|
10370
|
+
if (!isSessionId(id) || !existsSync(sessionDatabase(sessions, id))) throw new SessionNotFoundError(`no session "${id}"`);
|
|
10371
|
+
return sessionFolder(sessions, id);
|
|
10372
|
+
}
|
|
10373
|
+
}),
|
|
10160
10374
|
prompts: new PromptManager(prompts),
|
|
10161
10375
|
packs: new InterfaceService({
|
|
10162
10376
|
open: (id) => ctx.roleplayState.openSession(deps.sessionsDir(), id),
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { j as roleplaySessionOf } from "./child-D3QUNb3m.js";
|
|
2
|
+
import { i as isInside } from "./service-mRKwpWjX.js";
|
|
3
|
+
import { dirname, isAbsolute, resolve } from "node:path";
|
|
4
|
+
import { readdirSync, realpathSync, statSync } from "node:fs";
|
|
5
|
+
// src/host/workspace/jail.ts
|
|
6
|
+
/** DSH's file tools whose path is a `file_path` argument, and those that search under a `path`. */
|
|
7
|
+
const FILE_TOOLS = [
|
|
8
|
+
"read",
|
|
9
|
+
"read_image",
|
|
10
|
+
"write",
|
|
11
|
+
"edit"
|
|
12
|
+
];
|
|
13
|
+
const SEARCH_TOOLS = ["glob", "grep"];
|
|
14
|
+
const WRITING = ["write", "edit"];
|
|
15
|
+
const PATCHING = "apply_patch";
|
|
16
|
+
const PATCH_FILES = /^\*\*\* (?:Add|Update|Delete) File: (.+)$|^\*\*\* Move to: (.+)$/gmu;
|
|
17
|
+
/** The real path of a file that may not exist yet: the nearest folder above it that does, followed through links, with the rest put back. */
|
|
18
|
+
function realPathOf(path) {
|
|
19
|
+
const rest = [];
|
|
20
|
+
let current = resolve(path);
|
|
21
|
+
for (;;) try {
|
|
22
|
+
return rest.reduceRight((made, part) => resolve(made, part), realpathSync(current));
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error.code !== "ENOENT" && error.code !== "ENOTDIR") throw error;
|
|
25
|
+
const up = dirname(current);
|
|
26
|
+
if (up === current) return resolve(path);
|
|
27
|
+
rest.push(current.slice(up.length + 1));
|
|
28
|
+
current = up;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const MOST_LISTED = 30;
|
|
32
|
+
/** Where a model that tried to read a folder is sent: what the folder holds. A bare "not a regular file" made helpers try the same folder twenty times. */
|
|
33
|
+
function folderListing(path) {
|
|
34
|
+
try {
|
|
35
|
+
if (!statSync(path).isDirectory()) return void 0;
|
|
36
|
+
const names = readdirSync(path, { withFileTypes: true }).map((entry) => entry.isDirectory() ? `${entry.name}/` : entry.name).sort();
|
|
37
|
+
const shown = names.slice(0, MOST_LISTED).join(", ");
|
|
38
|
+
return `${path} is a folder, not a file, so it cannot be read. It holds: ${names.length === 0 ? "nothing" : shown}${names.length > MOST_LISTED ? ` and ${names.length - MOST_LISTED} more` : ""}. Read one of those files by its whole path (${path}/<name>)`;
|
|
39
|
+
} catch {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Why a path is out of reach for a story, or nothing when it is inside a folder the story may use (and may write, when it writes). */
|
|
44
|
+
function folderProblem(path, writing, roots, workspace) {
|
|
45
|
+
if (!isAbsolute(path)) return `give the whole path (it is not relative to anything the tools know): the story's workspace is ${workspace}`;
|
|
46
|
+
const real = realPathOf(path);
|
|
47
|
+
const found = roots.filter((root) => isInside(root.path, real));
|
|
48
|
+
if (found.length === 0) return `${path} is outside the folders this story's tools may use: its workspace ${workspace}${roots.length > 1 ? ` and ${roots.filter((root) => root.path !== workspace).map((root) => `${root.path} (${root.write ? "read and write" : "read only"})`).join(", ")}` : ""}. Nothing, not another path and not sandbox_permissions, lifts that: tell the person if it is needed`;
|
|
49
|
+
if (writing && !found.some((root) => root.write)) return `${path} is in a folder this story may only read: tell the person if it should be changed`;
|
|
50
|
+
}
|
|
51
|
+
function patchPaths(patch) {
|
|
52
|
+
return [...patch.matchAll(PATCH_FILES)].map((match) => (match[1] ?? match[2] ?? "").trim()).filter((path) => path !== "");
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Keeps DSH's file tools of a story's agents (the game master and its helpers) inside the story's workspace and the folders the person gave the story.
|
|
56
|
+
* It stands first in the chain, so that what it refuses cannot be let through by a listener after it. Shell and terminal tools are not held to folders:
|
|
57
|
+
* they stay off unless the person turns them on.
|
|
58
|
+
*/
|
|
59
|
+
async function foldersJail(exec, next, deps) {
|
|
60
|
+
const header = exec.agent?.session.header;
|
|
61
|
+
const chat = header?.origin === "subagent" ? header.parentSession : exec.agent?.session.id;
|
|
62
|
+
const session = chat === void 0 ? void 0 : roleplaySessionOf(chat);
|
|
63
|
+
if (session === void 0) return await next();
|
|
64
|
+
const files = FILE_TOOLS.includes(exec.name);
|
|
65
|
+
const search = SEARCH_TOOLS.includes(exec.name);
|
|
66
|
+
if (!files && !search && exec.name !== PATCHING) return await next();
|
|
67
|
+
const roots = await deps.roots(session);
|
|
68
|
+
if (roots === void 0) return await next();
|
|
69
|
+
const args = exec.arguments;
|
|
70
|
+
const check = (paths, writing) => {
|
|
71
|
+
for (const path of paths) {
|
|
72
|
+
if (typeof path !== "string" || path === "" || path.startsWith("~")) return {
|
|
73
|
+
kind: "deny",
|
|
74
|
+
reason: `the path must be a whole path inside the story's workspace ${deps.workspace()} or a folder it was given`
|
|
75
|
+
};
|
|
76
|
+
const problem = folderProblem(path, writing, roots, deps.workspace());
|
|
77
|
+
if (problem !== void 0) return {
|
|
78
|
+
kind: "deny",
|
|
79
|
+
reason: problem
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
if (files) {
|
|
84
|
+
const refused = check([args["file_path"]], WRITING.includes(exec.name));
|
|
85
|
+
if (refused !== void 0) return refused;
|
|
86
|
+
const listing = exec.name === "read" || exec.name === "read_image" ? folderListing(args["file_path"]) : void 0;
|
|
87
|
+
return listing === void 0 ? await next() : {
|
|
88
|
+
kind: "deny",
|
|
89
|
+
reason: listing
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
if (search) return check([args["path"] ?? deps.workspace()], false) ?? await next();
|
|
93
|
+
const patch = args["patch"] ?? args["input"];
|
|
94
|
+
const paths = typeof patch === "string" ? patchPaths(patch) : [];
|
|
95
|
+
if (paths.length === 0) return {
|
|
96
|
+
kind: "deny",
|
|
97
|
+
reason: "apply_patch must name its files: write them as whole paths inside the story's folders"
|
|
98
|
+
};
|
|
99
|
+
return check(paths, true) ?? await next();
|
|
100
|
+
}
|
|
101
|
+
/** Puts the jail first in the chain of `tools/pre-execute`. */
|
|
102
|
+
function registerFoldersJail(ctx, deps) {
|
|
103
|
+
ctx.on("tools/pre-execute", (exec, next) => foldersJail(exec, next, deps), { prepend: true });
|
|
104
|
+
}
|
|
105
|
+
export { registerFoldersJail as t };
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=jail-BIF79PJO.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as atomicWrite } from "./access-
|
|
2
|
-
import { i as translator, n as withoutExtension, r as languageOf, t as trimCharacters } from "./text-
|
|
1
|
+
import { n as atomicWrite } from "./access-DAw54-NI.js";
|
|
2
|
+
import { i as translator, n as withoutExtension, r as languageOf, t as trimCharacters } from "./text-Dfv8S8eq.js";
|
|
3
3
|
import { dirname, extname, join } from "node:path";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
@@ -374,4 +374,4 @@ async function addToLibrary(sessionFolder, bytes, originalName) {
|
|
|
374
374
|
}
|
|
375
375
|
export { slug as C, norm as S, uniqueKey as T, writeImageFileMetadata as _, LIBRARY_FOLDER as a, NoEmbeddingService as b, nextSceneSerial as c, sceneImagePath as d, writeImage as f, sidecarOf as g, readImageFileMetadata as h, libraryHashes as i, readImageMetadata as l, mediaTypeOf as m, addToLibraryOnce as n, entityImageDirectory as o, MEDIA_TYPES as p, imageExtensionOf as r, inheritImages as s, addToLibrary as t, referenceImagePath as u, readPngMetadata as v, trOf as w, mapLimit as x, withPngMetadata as y };
|
|
376
376
|
|
|
377
|
-
//# sourceMappingURL=library-
|
|
377
|
+
//# sourceMappingURL=library-BF9ZMSFz.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./access-
|
|
2
|
-
import { _t as writeLorebookEntry, ct as deleteLorebookEntry, ft as loadLorebook, gt as updateLorebookInfo, i as contextOf, lt as entriesOf, mt as readLorebook$1, pt as lorebookDirectory, r as MAX_PREVIEW_TEXT, tn as ImportCardError } from "./authoring-tools-
|
|
3
|
-
import { $ as IMPORT_FOLDER, Q as withPlayer,
|
|
4
|
-
import { C as slug, T as uniqueKey, w as trOf, x as mapLimit } from "./library-
|
|
5
|
-
import { i as translator, r as languageOf } from "./text-
|
|
6
|
-
import { it as shippedPromptsDirectory } from "./hooks-
|
|
1
|
+
import "./access-DAw54-NI.js";
|
|
2
|
+
import { _t as writeLorebookEntry, ct as deleteLorebookEntry, ft as loadLorebook, gt as updateLorebookInfo, i as contextOf, lt as entriesOf, mt as readLorebook$1, pt as lorebookDirectory, r as MAX_PREVIEW_TEXT, tn as ImportCardError } from "./authoring-tools-4NgDhIJV.js";
|
|
3
|
+
import { $ as IMPORT_FOLDER, Bt as LORE_KINDS, Q as withPlayer, Vt as LORE_SCOPES, Y as cleanText, Z as partsOf, n as createPresetFromGuidance } from "./presets-DQ5rioMh.js";
|
|
4
|
+
import { C as slug, T as uniqueKey, w as trOf, x as mapLimit } from "./library-BF9ZMSFz.js";
|
|
5
|
+
import { i as translator, r as languageOf } from "./text-Dfv8S8eq.js";
|
|
6
|
+
import { it as shippedPromptsDirectory } from "./hooks-BNeoGMHZ.js";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { existsSync, readFileSync } from "node:fs";
|
|
9
9
|
import { readFile, rm, writeFile } from "node:fs/promises";
|
|
@@ -696,4 +696,4 @@ async function lorebookApproval(exec, next, state) {
|
|
|
696
696
|
}
|
|
697
697
|
export { lorebookImportMessage as a, readLorebook as c, lorebookOfChat as d, lorebookAuthorTools as i, selectEntries as l, LorebookReader as n, pendingTargets as o, lorebookApproval as r, previewLorebook as s, LOREBOOK_UPLOAD as t, lorebookChatSessionId as u };
|
|
698
698
|
|
|
699
|
-
//# sourceMappingURL=lorebook-author-tools-
|
|
699
|
+
//# sourceMappingURL=lorebook-author-tools-DBk-V0hp.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as limitAuthoringAgents, pt as lorebookDirectory } from "./authoring-tools-
|
|
2
|
-
import { t as guardAuthoringTurns } from "./turn-guard-
|
|
3
|
-
import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-
|
|
4
|
-
import "./hooks-
|
|
1
|
+
import { n as limitAuthoringAgents, pt as lorebookDirectory } from "./authoring-tools-4NgDhIJV.js";
|
|
2
|
+
import { t as guardAuthoringTurns } from "./turn-guard-BSAba8sp.js";
|
|
3
|
+
import { d as lorebookOfChat, i as lorebookAuthorTools, n as LorebookReader, o as pendingTargets, r as lorebookApproval } from "./lorebook-author-tools-DBk-V0hp.js";
|
|
4
|
+
import "./hooks-BNeoGMHZ.js";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { existsSync, readdirSync } from "node:fs";
|
|
7
7
|
// src/lorebook-authoring.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as atomicWriteSync } from "./access-
|
|
1
|
+
import { i as atomicWriteSync } from "./access-DAw54-NI.js";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
4
4
|
// ../dsh-roleplay-model/src/clock.ts
|
|
@@ -14,8 +14,11 @@ const DECISION_SITES = [
|
|
|
14
14
|
"reflection",
|
|
15
15
|
"agency",
|
|
16
16
|
"refusal",
|
|
17
|
+
"repeats",
|
|
17
18
|
"rules",
|
|
18
19
|
"secrets",
|
|
20
|
+
"messages",
|
|
21
|
+
"errands",
|
|
19
22
|
"variables",
|
|
20
23
|
"reuse"
|
|
21
24
|
];
|
|
@@ -37,6 +40,12 @@ const DECISION_MODES = [
|
|
|
37
40
|
];
|
|
38
41
|
/** What a gate can be set to: the modes of any site, or off. */
|
|
39
42
|
const GATE_MODES = ["off", ...DECISION_MODES];
|
|
43
|
+
/** What the repeat check can be set to: a gate's modes, or `strict`, which refuses every repeated sentence by code alone, with no model, and so may refuse a repeat that was meant. */
|
|
44
|
+
const REPEAT_MODES = [
|
|
45
|
+
"off",
|
|
46
|
+
"strict",
|
|
47
|
+
...DECISION_MODES
|
|
48
|
+
];
|
|
40
49
|
const emptySiteStats = () => ({
|
|
41
50
|
runs: 0,
|
|
42
51
|
items: 0,
|
|
@@ -136,6 +145,18 @@ const SETTINGS_SPEC = {
|
|
|
136
145
|
joint: flag(true),
|
|
137
146
|
summary: flag(true)
|
|
138
147
|
},
|
|
148
|
+
schedule: { enabled: flag(true) },
|
|
149
|
+
autonomy: {
|
|
150
|
+
enabled: flag(false),
|
|
151
|
+
messages: flag(true),
|
|
152
|
+
maxUnanswered: integer(1, 20, 3),
|
|
153
|
+
idleMinutes: integer(1, 10080, 15),
|
|
154
|
+
awayHours: integer(1, 720, 12),
|
|
155
|
+
chance: ratio(0, 1, .05),
|
|
156
|
+
decay: ratio(0, 1, .5),
|
|
157
|
+
transitionChance: ratio(0, 1, .4),
|
|
158
|
+
messageGapMinutes: integer(5, 10080, 180)
|
|
159
|
+
},
|
|
139
160
|
sampling: {
|
|
140
161
|
master: ratio(0, 2, .7),
|
|
141
162
|
characters: ratio(0, 2, .8),
|
|
@@ -188,11 +209,17 @@ const SETTINGS_SPEC = {
|
|
|
188
209
|
reflection: choice(DECISION_MODES, "llm"),
|
|
189
210
|
agency: choice(GATE_MODES, "off"),
|
|
190
211
|
refusal: choice(GATE_MODES, "off"),
|
|
212
|
+
repeats: choice(REPEAT_MODES, "off"),
|
|
213
|
+
repeatTurns: integer(1, 30, 6),
|
|
214
|
+
repeatChars: integer(6, 60, 12),
|
|
191
215
|
rules: choice(EXTRA_MODES, "off"),
|
|
192
216
|
secrets: choice(EXTRA_MODES, "off"),
|
|
217
|
+
messages: choice(EXTRA_MODES, "off"),
|
|
218
|
+
errands: choice(EXTRA_MODES, "on"),
|
|
193
219
|
variables: choice(GATE_MODES, "llm"),
|
|
194
220
|
reuse: choice(EXTRA_MODES, "off"),
|
|
195
221
|
gateThreshold: ratio(.1, .95, .5),
|
|
222
|
+
reuseThreshold: ratio(.1, .95, .85),
|
|
196
223
|
confidence: ratio(0, 1, .7)
|
|
197
224
|
},
|
|
198
225
|
interface: { pack: text(60, "") },
|
|
@@ -458,4 +485,4 @@ function decodeOutput(text) {
|
|
|
458
485
|
}
|
|
459
486
|
export { emptyStats as _, liveSettings as a, writeSettings as c, parseSettings as d, parseSwitchboard as f, GATE_SITES as g, DECISION_SITES as h, InvalidSettingsError as i, DEFAULT_SETTINGS as l, rulesOf as m, encodeOutput as n, readSettings as o, WORLD_RULES_KEY as p, encodePreview as r, useChildReasoning as s, decodeOutput as t, SETTINGS_SPEC as u };
|
|
460
487
|
|
|
461
|
-
//# sourceMappingURL=narration-
|
|
488
|
+
//# sourceMappingURL=narration-xvErE2yp.js.map
|