@dsh-agentic-roleplay/core 0.12.2 → 0.12.4
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-BZr4bgBy.js → authoring-tools-B_qYKK8c.js} +2135 -1863
- package/lib/authoring.js +208 -35
- package/lib/client.js +850 -491
- package/lib/client.js.map +1 -1
- package/lib/doctor.js +1 -1
- package/lib/{gallery-BNg0rPTp.js → gallery-Bu6eZMKk.js} +2 -2
- package/lib/{generator-9-5at9cZ.js → generator-CTWQWbSW.js} +2 -2
- package/lib/{hooks-Dtq5KZQX.js → hooks-YXQZ9G2d.js} +200 -41
- package/lib/images.js +4 -4
- package/lib/index.js +62 -42
- package/lib/{library-DTxakw0z.js → library-BmlHNCah.js} +2 -2
- package/lib/{lorebook-author-tools-BjcEUo22.js → lorebook-author-tools-C3rRpMt7.js} +6 -6
- package/lib/lorebook-authoring.js +5 -5
- package/lib/orchestration.js +8 -8
- package/lib/{pack-jail-Dt0VTsu0.js → pack-jail-VbcXiukr.js} +42 -14
- package/lib/{packs-DWfR2Ted.js → packs-CzVh2ZNe.js} +2 -2
- package/lib/{presenter-agent-vFOxIuWv.js → presenter-agent-CF3fneuJ.js} +4 -4
- package/lib/{preset-Dv5YF2qj.js → preset-C595KRUM.js} +3 -3
- package/lib/{preset-author-tools-BUzO9mTW.js → preset-author-tools-CF_JKKTE.js} +6 -6
- package/lib/preset-authoring.js +5 -5
- package/lib/{reflection-Dd3pEiZB.js → reflection-ByIQSOKC.js} +6 -6
- package/lib/{serial-BUaJGwVy.js → serial-ULGUKWsu.js} +1136 -1056
- package/lib/{text-Dfv8S8eq.js → text-hiKTooVb.js} +3 -1
- package/lib/{turn-guard-87NE-Cnp.js → turn-guard-DXMeAJdv.js} +2 -2
- package/package.json +3 -2
- package/prompts/en/import/opening.md +17 -0
- package/prompts/en/roleplay/decide-opening.md +1 -0
- package/prompts/en/world/procedure.md +1 -1
- package/prompts/zh/import/opening.md +17 -0
- package/prompts/zh/roleplay/decide-opening.md +1 -0
- package/prompts/zh/world/procedure.md +1 -1
package/lib/doctor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as silenceRuntimeContext, t as silenceHarnessDevContext } from "./dev-context-Cgv_wZbG.js";
|
|
2
2
|
import { A as chatSessionId } from "./child-DTdY14S9.js";
|
|
3
3
|
import { n as doctorSessionOf } from "./doctor-chat-hL1a61hp.js";
|
|
4
|
-
import {
|
|
4
|
+
import { s as externalTools, t as externalToolLimit } from "./hooks-YXQZ9G2d.js";
|
|
5
5
|
import { a as liveSettings } from "./narration--K2XVIHI.js";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { createTools, isSessionId, sessionDatabase, sessionFolder } from "@dsh-agentic-roleplay/state";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as atomicWrite } from "./access-Csp80TFX.js";
|
|
2
|
-
import { _ as writeImageFileMetadata, a as LIBRARY_FOLDER, g as sidecarOf, h as readImageFileMetadata, m as mediaTypeOf, x as mapLimit } from "./library-
|
|
2
|
+
import { _ as writeImageFileMetadata, a as LIBRARY_FOLDER, g as sidecarOf, h as readImageFileMetadata, m as mediaTypeOf, x as mapLimit } from "./library-BmlHNCah.js";
|
|
3
3
|
import { join, sep } from "node:path";
|
|
4
4
|
import { lstat, readFile, readdir, realpath, stat } from "node:fs/promises";
|
|
5
5
|
// src/host/images/gallery.ts
|
|
@@ -187,4 +187,4 @@ async function updateImage(sessionFolder, path, update) {
|
|
|
187
187
|
}
|
|
188
188
|
export { updateImage as i, galleryFile as n, listGallery as r, describeGalleryImage as t };
|
|
189
189
|
|
|
190
|
-
//# sourceMappingURL=gallery-
|
|
190
|
+
//# sourceMappingURL=gallery-Bu6eZMKk.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as sceneImagePath, f as writeImage, u as referenceImagePath } from "./library-
|
|
1
|
+
import { d as sceneImagePath, f as writeImage, u as referenceImagePath } from "./library-BmlHNCah.js";
|
|
2
2
|
// src/host/images/generator.ts
|
|
3
3
|
const unique = (values) => [...new Set(values.map((value) => value.trim()).filter((value) => value !== ""))];
|
|
4
4
|
/** What a reference image shows: the subject and its stable look. */
|
|
@@ -147,4 +147,4 @@ async function generateTransientImage(service, request) {
|
|
|
147
147
|
}
|
|
148
148
|
export { uploadReferenceImage as a, transientPrompt as i, generateTransientImage as n, referencePrompt as r, generateReferenceImage as t };
|
|
149
149
|
|
|
150
|
-
//# sourceMappingURL=generator-
|
|
150
|
+
//# sourceMappingURL=generator-CTWQWbSW.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as addTokens, D as finishOf, E as cutOff, O as estimateAnswer, S as NO_TOKENS, a as childTrace, b as estimateTokens, f as tracerOf, j as roleplaySessionOf, l as runChild, n as childModel, r as childSampling, u as TurnTraces, v as requestsOf, x as tokensOf, y as blockText } from "./child-DTdY14S9.js";
|
|
2
2
|
import { _ as emptyStats, a as liveSettings, h as DECISION_SITES, m as rulesOf, n as encodeOutput, p as WORLD_RULES_KEY, r as encodePreview } from "./narration--K2XVIHI.js";
|
|
3
3
|
import { t as promptFor } from "./access-Csp80TFX.js";
|
|
4
|
-
import { i as translator, r as languageOf$1, t as trimCharacters } from "./text-
|
|
4
|
+
import { i as translator, r as languageOf$1, t as trimCharacters } from "./text-hiKTooVb.js";
|
|
5
5
|
import { n as storyRoots } from "./service-mRKwpWjX.js";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
7
7
|
import { DAY, ENGAGEMENT_GRACE, ITEM_ACTIONS, MINUTE, SECOND, addLocalDays, agendaAt, announcements, applyItemPlan, changeItem, changeVariable, clockTime, createCharacterTools, createDiceTools, createTools, dayPart, describeDuration, describeInstant, describeValue, holidaysOn, inAudience, isSessionId, itemKey, localTime, locationKey, mentioned, nextOccurrence, nextTimeOfDay, occurrenceAt, overlap, parseInstant, planItemChange, planVariableChange, readCalendar, rollPlain, seasonOf, sessionDatabase, sessionFolder, shownVariables, tokens } from "@dsh-agentic-roleplay/state";
|
|
@@ -193,6 +193,51 @@ function skipTime(session, config, turn, round, wall, request) {
|
|
|
193
193
|
};
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
|
+
// src/host/commands/registry.ts
|
|
197
|
+
/**
|
|
198
|
+
* Registers the commands of the plugin's scope with DSH while the registry exists: they are listed, completed and run by the interface, and a command is not sent to the model.
|
|
199
|
+
* A plugin mounted by an agent preset registers them for that preset's agents only.
|
|
200
|
+
*/
|
|
201
|
+
function registerCommands(ctx, specs) {
|
|
202
|
+
ctx.inject(["commands"], (scope) => {
|
|
203
|
+
for (const spec of specs) scope.effect(() => scope.commands.register({
|
|
204
|
+
name: spec.name,
|
|
205
|
+
description: spec.description,
|
|
206
|
+
input: { hint: spec.hint },
|
|
207
|
+
...spec.recordInput === void 0 ? {} : { recordInput: spec.recordInput },
|
|
208
|
+
handler: (call) => spec.handler(call)
|
|
209
|
+
}), `roleplay: /${spec.name}`);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/** The registry of the running profile, or nothing when it has none. */
|
|
213
|
+
const registryOf = (ctx) => ctx.get("commands");
|
|
214
|
+
/**
|
|
215
|
+
* Runs a line the way the input box does when the agent knows the command it starts, for callers that are not the input box (the plugin's own starts, the HTTP API, the benchmark).
|
|
216
|
+
* Nothing when the line is no command of this agent; the caller then sends it on as a message.
|
|
217
|
+
*/
|
|
218
|
+
async function runCommandLine(ctx, agent, line, signal) {
|
|
219
|
+
const registry = registryOf(ctx);
|
|
220
|
+
if (registry === void 0) return void 0;
|
|
221
|
+
return (await registry.execute(agent, line, [], signal))?.result;
|
|
222
|
+
}
|
|
223
|
+
/** A command that was run from outside the input box and refused: what it says is for the person. */
|
|
224
|
+
var CommandRefusedError = class extends Error {};
|
|
225
|
+
/**
|
|
226
|
+
* Registers commands for one agent only, through the agent's own context: they are listed and run for that chat and for no other, and go with the agent. For commands that depend on
|
|
227
|
+
* what the chat holds (the commands a world defines).
|
|
228
|
+
*/
|
|
229
|
+
function registerAgentCommands(agent, specs) {
|
|
230
|
+
if (specs.length === 0) return;
|
|
231
|
+
agent.ctx.inject(["commands"], (scope) => {
|
|
232
|
+
for (const spec of specs) scope.effect(() => scope.commands.register({
|
|
233
|
+
name: spec.name,
|
|
234
|
+
description: spec.description,
|
|
235
|
+
input: { hint: spec.hint },
|
|
236
|
+
...spec.recordInput === void 0 ? {} : { recordInput: spec.recordInput },
|
|
237
|
+
handler: (call) => spec.handler(call)
|
|
238
|
+
}), `roleplay: /${spec.name}`);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
196
241
|
// src/host/sessions/errors.ts
|
|
197
242
|
var WorldNotFoundError = class extends Error {};
|
|
198
243
|
/** The world cannot be played as it is; `problems` say what to fix. */
|
|
@@ -2944,6 +2989,7 @@ function storeOf(session, folder, problem, queryVector, wall, prompt) {
|
|
|
2944
2989
|
recordDecisions: (site, report) => {
|
|
2945
2990
|
recordDecisions(folder, site, report);
|
|
2946
2991
|
},
|
|
2992
|
+
commands: () => commandsOf(session.metadata.getValue(COMMANDS_KEY)),
|
|
2947
2993
|
raiseCommand: (word, turn) => {
|
|
2948
2994
|
const commands = commandsOf(session.metadata.getValue(COMMANDS_KEY));
|
|
2949
2995
|
const used = word === void 0 ? void 0 : commands.find((command) => command.word === word.toLowerCase());
|
|
@@ -3059,20 +3105,6 @@ function storesOf(state, sessionsDir, problem = () => void 0, queryVector = () =
|
|
|
3059
3105
|
}
|
|
3060
3106
|
};
|
|
3061
3107
|
}
|
|
3062
|
-
// src/shared/ooc.ts
|
|
3063
|
-
/** The command or question in a player's message, or nothing when the message is an ordinary action. The request may be empty. */
|
|
3064
|
-
function parseOoc(text) {
|
|
3065
|
-
const value = text.trimStart();
|
|
3066
|
-
const boundary = value.search(/\s/u);
|
|
3067
|
-
const command = value.slice(0, boundary < 0 ? value.length : boundary).toLowerCase();
|
|
3068
|
-
if (command !== "/ooc" && command !== "/ask") return void 0;
|
|
3069
|
-
return {
|
|
3070
|
-
request: value.slice(command.length).trim(),
|
|
3071
|
-
question: command === "/ask"
|
|
3072
|
-
};
|
|
3073
|
-
}
|
|
3074
|
-
/** The longest answer to an out-of-character question. */
|
|
3075
|
-
const MAX_OOC_ANSWER = 1200;
|
|
3076
3108
|
// src/shared/tools.ts
|
|
3077
3109
|
/** What this version can offer. A name in a settings file or a world that is not here is kept and ignored. */
|
|
3078
3110
|
const OPTIONAL_TOOLS = [
|
|
@@ -4130,6 +4162,9 @@ function externalWithheld(registry, board, agent) {
|
|
|
4130
4162
|
function charactersGiven(registry, board, away) {
|
|
4131
4163
|
return away ? [] : externalGiven(registry, board, "characters");
|
|
4132
4164
|
}
|
|
4165
|
+
// src/shared/ooc.ts
|
|
4166
|
+
/** The longest answer to an out-of-character question. */
|
|
4167
|
+
const MAX_OOC_ANSWER = 1200;
|
|
4133
4168
|
// src/host/workspace/describe.ts
|
|
4134
4169
|
/** What an agent with file tools is told of where they reach: the shared workspace first, then the folders given to this story. Nothing for a story with no workspace. */
|
|
4135
4170
|
function foldersLine(roots, language) {
|
|
@@ -4312,19 +4347,10 @@ function answerRunner(deps) {
|
|
|
4312
4347
|
})).answer;
|
|
4313
4348
|
};
|
|
4314
4349
|
}
|
|
4315
|
-
// src/shared/dream.ts
|
|
4316
|
-
/** The dream a player asks to enter (`/dream`, `/dream Clara`, `/dream 做梦的人`), or nothing when the message does not start with `/dream`. `who` is empty when no one is named. */
|
|
4317
|
-
function parseDream(text) {
|
|
4318
|
-
const value = text.trimStart();
|
|
4319
|
-
if (value.slice(0, 6).toLowerCase() !== "/dream" || value.length > 6 && !/\s/u.test(value[6])) return void 0;
|
|
4320
|
-
return { who: value.slice(6).trim() };
|
|
4321
|
-
}
|
|
4322
4350
|
// src/shared/roll.ts
|
|
4323
|
-
/** The
|
|
4324
|
-
function
|
|
4325
|
-
const
|
|
4326
|
-
if (value.slice(0, 5).toLowerCase() !== "/roll" || value.length > 5 && !/\s/u.test(value[5])) return void 0;
|
|
4327
|
-
const body = value.slice(5).trimStart();
|
|
4351
|
+
/** The dice and the reason in what a player typed after `/roll`. The notation may be empty, and is then refused. */
|
|
4352
|
+
function rollArguments(rawInput) {
|
|
4353
|
+
const body = rawInput.trimStart();
|
|
4328
4354
|
const boundary = body.search(/\s/u);
|
|
4329
4355
|
return boundary < 0 ? {
|
|
4330
4356
|
expression: body,
|
|
@@ -4341,13 +4367,10 @@ const UNITS = [
|
|
|
4341
4367
|
[/^(?:d|day|days|天|日)$/iu, 1440]
|
|
4342
4368
|
];
|
|
4343
4369
|
/**
|
|
4344
|
-
* The wait in a player
|
|
4345
|
-
* unreadable, and is then `undefined` in `minutes`.
|
|
4370
|
+
* The wait in what a player typed after `/wait` (`2 hours`, `30m until the ferry`, `3天`). The time may be missing or unreadable, and is then `undefined` in `minutes`.
|
|
4346
4371
|
*/
|
|
4347
|
-
function
|
|
4348
|
-
const
|
|
4349
|
-
if (value.slice(0, 5).toLowerCase() !== "/wait" || value.length > 5 && !/\s/u.test(value[5])) return void 0;
|
|
4350
|
-
const body = value.slice(5).trim();
|
|
4372
|
+
function waitArguments(rawInput) {
|
|
4373
|
+
const body = rawInput.trim();
|
|
4351
4374
|
const match = /^(\d+(?:\.\d+)?)\s*([\p{L}]+)\s*(.*)$/su.exec(body);
|
|
4352
4375
|
if (match === null) return {
|
|
4353
4376
|
minutes: void 0,
|
|
@@ -4364,6 +4387,139 @@ function parseWait(text) {
|
|
|
4364
4387
|
reason: match[3].trim()
|
|
4365
4388
|
};
|
|
4366
4389
|
}
|
|
4390
|
+
// src/host/orchestration/player-commands.ts
|
|
4391
|
+
/** The most commands waiting for their turn to start: a command is taken the moment its message begins a turn, so this is only a bound. */
|
|
4392
|
+
const MAX_WAITING = 200;
|
|
4393
|
+
/**
|
|
4394
|
+
* What each command message was meant to do, by the id of the message the command sent: the turn that message begins takes it. Nothing reads the words of a message to tell a command from a move.
|
|
4395
|
+
*/
|
|
4396
|
+
var PlayerIntents = class {
|
|
4397
|
+
byMessage = /* @__PURE__ */ new Map();
|
|
4398
|
+
intend(messageId, command) {
|
|
4399
|
+
this.byMessage.set(messageId, command);
|
|
4400
|
+
for (const key of this.byMessage.keys()) {
|
|
4401
|
+
if (this.byMessage.size <= MAX_WAITING) break;
|
|
4402
|
+
this.byMessage.delete(key);
|
|
4403
|
+
}
|
|
4404
|
+
}
|
|
4405
|
+
/** The command of the first of these messages that has one, which is then forgotten. */
|
|
4406
|
+
take(messageIds) {
|
|
4407
|
+
for (const id of messageIds) {
|
|
4408
|
+
const command = this.byMessage.get(id);
|
|
4409
|
+
if (command !== void 0) {
|
|
4410
|
+
this.byMessage.delete(id);
|
|
4411
|
+
return command;
|
|
4412
|
+
}
|
|
4413
|
+
}
|
|
4414
|
+
}
|
|
4415
|
+
};
|
|
4416
|
+
/** The game master of a roleplay chat: the agent a player's command is for. */
|
|
4417
|
+
const isGameMaster = (agent) => agent.session.header.origin !== "subagent" && roleplaySessionOf(agent.session.id) !== void 0;
|
|
4418
|
+
/** Sends the command to the game master as the player's own message, which is what the turn it begins is the answer to. */
|
|
4419
|
+
function play(intents, agent, name, rawInput, command) {
|
|
4420
|
+
if (!isGameMaster(agent)) return {
|
|
4421
|
+
kind: "error",
|
|
4422
|
+
text: `/${name} is played in a roleplay chat`
|
|
4423
|
+
};
|
|
4424
|
+
const message = createUserMessage({
|
|
4425
|
+
content: [{
|
|
4426
|
+
type: "text",
|
|
4427
|
+
text: `/${name}${rawInput}`
|
|
4428
|
+
}],
|
|
4429
|
+
source: { kind: "user" }
|
|
4430
|
+
});
|
|
4431
|
+
intents.intend(String(message.id), command);
|
|
4432
|
+
agent.followup(message);
|
|
4433
|
+
return { kind: "success" };
|
|
4434
|
+
}
|
|
4435
|
+
/** The commands every roleplay chat has: out-of-character commands and questions, dice, time and dreams. */
|
|
4436
|
+
function playerCommands(intents) {
|
|
4437
|
+
const ooc = (name, description) => ({
|
|
4438
|
+
name,
|
|
4439
|
+
description,
|
|
4440
|
+
hint: name === "ooc" ? "<what to change in the story>" : "<what to ask>",
|
|
4441
|
+
recordInput: false,
|
|
4442
|
+
handler: ({ agent, rawInput }) => {
|
|
4443
|
+
const request = rawInput.trim();
|
|
4444
|
+
if (request === "") return {
|
|
4445
|
+
kind: "error",
|
|
4446
|
+
text: name === "ooc" ? "Say what to change: /ooc <what the story should do>" : "Say what to ask: /ask <your question>"
|
|
4447
|
+
};
|
|
4448
|
+
return play(intents, agent, name, rawInput, {
|
|
4449
|
+
kind: "ooc",
|
|
4450
|
+
request,
|
|
4451
|
+
question: name === "ask"
|
|
4452
|
+
});
|
|
4453
|
+
}
|
|
4454
|
+
});
|
|
4455
|
+
return [
|
|
4456
|
+
ooc("ooc", "Give the story an out-of-character instruction, outside what your character does"),
|
|
4457
|
+
ooc("ask", "Ask the story a question out of character; nothing in the story changes"),
|
|
4458
|
+
{
|
|
4459
|
+
name: "roll",
|
|
4460
|
+
description: "Roll dice as yourself: the result is told to the game master as a fact",
|
|
4461
|
+
hint: "<dice, for example 2d6+1> [why]",
|
|
4462
|
+
recordInput: false,
|
|
4463
|
+
handler: ({ agent, rawInput }) => {
|
|
4464
|
+
const roll = rollArguments(rawInput);
|
|
4465
|
+
if (roll.expression === "") return {
|
|
4466
|
+
kind: "error",
|
|
4467
|
+
text: "Say what to roll, for example /roll 2d6"
|
|
4468
|
+
};
|
|
4469
|
+
return play(intents, agent, "roll", rawInput, {
|
|
4470
|
+
kind: "roll",
|
|
4471
|
+
...roll
|
|
4472
|
+
});
|
|
4473
|
+
}
|
|
4474
|
+
},
|
|
4475
|
+
{
|
|
4476
|
+
name: "wait",
|
|
4477
|
+
description: "Let time pass in the story",
|
|
4478
|
+
hint: "<how long, for example 2 hours> [until what]",
|
|
4479
|
+
recordInput: false,
|
|
4480
|
+
handler: ({ agent, rawInput }) => {
|
|
4481
|
+
const wait = waitArguments(rawInput);
|
|
4482
|
+
if (wait.minutes === void 0) return {
|
|
4483
|
+
kind: "error",
|
|
4484
|
+
text: "Say how long, for example /wait 2 hours or /wait 30 minutes until the ferry"
|
|
4485
|
+
};
|
|
4486
|
+
return play(intents, agent, "wait", rawInput, {
|
|
4487
|
+
kind: "wait",
|
|
4488
|
+
minutes: wait.minutes,
|
|
4489
|
+
reason: wait.reason
|
|
4490
|
+
});
|
|
4491
|
+
}
|
|
4492
|
+
},
|
|
4493
|
+
{
|
|
4494
|
+
name: "dream",
|
|
4495
|
+
description: "Enter the dream of a character who is asleep",
|
|
4496
|
+
hint: "[whose dream]",
|
|
4497
|
+
recordInput: false,
|
|
4498
|
+
handler: ({ agent, rawInput }) => play(intents, agent, "dream", rawInput, {
|
|
4499
|
+
kind: "dream",
|
|
4500
|
+
who: rawInput.trim()
|
|
4501
|
+
})
|
|
4502
|
+
}
|
|
4503
|
+
];
|
|
4504
|
+
}
|
|
4505
|
+
/** DSH names a command with lower case ASCII letters, digits, `_` and `-`; a world's word may be in any script, and is then offered under the key of its flag, which is always such a name. */
|
|
4506
|
+
const COMMAND_NAME = /^[a-z][a-z0-9_-]*$/;
|
|
4507
|
+
/** The commands a world defines, for its chat: each is the player's move in the story, and raises the world's flag for the turn. */
|
|
4508
|
+
function worldCommands(intents, defined) {
|
|
4509
|
+
return defined.map((command) => {
|
|
4510
|
+
const name = COMMAND_NAME.test(command.word) ? command.word : command.key;
|
|
4511
|
+
return {
|
|
4512
|
+
name,
|
|
4513
|
+
description: name === command.word ? command.description : `/${command.word}: ${command.description}`,
|
|
4514
|
+
hint: "[what you do]",
|
|
4515
|
+
recordInput: false,
|
|
4516
|
+
handler: ({ agent, rawInput }) => play(intents, agent, name, rawInput, {
|
|
4517
|
+
kind: "world",
|
|
4518
|
+
word: command.word
|
|
4519
|
+
})
|
|
4520
|
+
};
|
|
4521
|
+
});
|
|
4522
|
+
}
|
|
4367
4523
|
// src/host/agents/repeat-guard.ts
|
|
4368
4524
|
/**
|
|
4369
4525
|
* Keeps an agent that is stuck from making the same call again and again (found live: an assistant made one create-and-list pair 47 times in a review, a game master repeated one
|
|
@@ -4498,6 +4654,8 @@ function commandBringsPeopleIn(store, command) {
|
|
|
4498
4654
|
}
|
|
4499
4655
|
function installHooks(ctx, deps) {
|
|
4500
4656
|
const { engine, boundaries, stores, timelines, previewTool } = deps;
|
|
4657
|
+
const intents = deps.intents ?? new PlayerIntents();
|
|
4658
|
+
registerCommands(ctx, playerCommands(intents));
|
|
4501
4659
|
/** The tools of the game master as the chat's settings say: its optional ones, and none of other plugins' that it was not given. */
|
|
4502
4660
|
const applyLimit = (agent, store) => {
|
|
4503
4661
|
externalToolLimit(agent, externalWithheld(agent.ctx.tools, store.settings().tools, "gameMaster"));
|
|
@@ -4562,6 +4720,7 @@ function installHooks(ctx, deps) {
|
|
|
4562
4720
|
if (store === void 0) return;
|
|
4563
4721
|
registerConditionalTools(agent, conditionsOf(agent.session.id));
|
|
4564
4722
|
applyLimit(agent, store);
|
|
4723
|
+
registerAgentCommands(agent, worldCommands(intents, store.commands?.() ?? []));
|
|
4565
4724
|
});
|
|
4566
4725
|
/** Where the open turn of each chat began, so its own events can be read back without walking the whole log. */
|
|
4567
4726
|
const openTurns = /* @__PURE__ */ new Map();
|
|
@@ -4645,10 +4804,10 @@ function installHooks(ctx, deps) {
|
|
|
4645
4804
|
turns.begin(owner.chat, payload.turn, text);
|
|
4646
4805
|
deps.rolls?.begin(owner.chat, store.story.metadata.get().id, began.parent);
|
|
4647
4806
|
const cast = store.cast();
|
|
4648
|
-
const
|
|
4649
|
-
const
|
|
4650
|
-
const used = store.raiseCommand?.(
|
|
4651
|
-
const dream =
|
|
4807
|
+
const intent = intents.take(payload.messages.filter((message) => message.source.kind === "user").map((message) => String(message.id)));
|
|
4808
|
+
const ooc = intent?.kind === "ooc" ? intent : void 0;
|
|
4809
|
+
const used = store.raiseCommand?.(intent?.kind === "world" ? intent.word : void 0, payload.turn);
|
|
4810
|
+
const dream = intent?.kind === "dream" ? intent : void 0;
|
|
4652
4811
|
const verdict = ooc === void 0 ? boundaries().inputValidator.validate({
|
|
4653
4812
|
text,
|
|
4654
4813
|
turn: payload.turn,
|
|
@@ -4730,7 +4889,7 @@ function installHooks(ctx, deps) {
|
|
|
4730
4889
|
if (arrived.length > 0) addLine("messages", tr("While the player was away, these messages reached their character, who has read them: {messages}. Refer to them only if the player does.", { messages: arrived.map((message) => `${message.name}: "${message.text}"`).join(" ") }));
|
|
4731
4890
|
const rules = store.rules();
|
|
4732
4891
|
if (rules.length > 0) addLine("rules", store.text("roleplay/rules", { rules: rules.map((rule) => `- ${rule}`).join("\n") }));
|
|
4733
|
-
const wanted =
|
|
4892
|
+
const wanted = intent?.kind === "roll" ? intent : void 0;
|
|
4734
4893
|
if (wanted !== void 0) try {
|
|
4735
4894
|
const made = rollPlain(wanted.expression, deps.rolls?.roller(owner.chat));
|
|
4736
4895
|
const roll = store.story.dice.record({
|
|
@@ -4785,7 +4944,7 @@ function installHooks(ctx, deps) {
|
|
|
4785
4944
|
}));
|
|
4786
4945
|
}
|
|
4787
4946
|
}
|
|
4788
|
-
const waiting =
|
|
4947
|
+
const waiting = intent?.kind === "wait" ? intent : void 0;
|
|
4789
4948
|
if (waiting !== void 0) {
|
|
4790
4949
|
const clock = store.settings().clock;
|
|
4791
4950
|
const refusal = clock.mode === "real" ? tr("this chat follows the clock on the wall, so time cannot be skipped") : waiting.minutes === void 0 ? tr("say how long, for example /wait 2 hours or /wait 30 minutes until the ferry") : waiting.minutes > clock.maxSkipDays * 1440 ? tr("that is more than the {days} days this chat allows in one skip", { days: clock.maxSkipDays }) : void 0;
|
|
@@ -4849,6 +5008,6 @@ function installHooks(ctx, deps) {
|
|
|
4849
5008
|
};
|
|
4850
5009
|
});
|
|
4851
5010
|
}
|
|
4852
|
-
export { copyWorldPrompts as $, plotProgressOf as A, parsePlotsFile as B, readNotes as C, referent as D, sameWords as E, textLanguage as F, readDocument as G, COMMANDS_KEY as H, wrongLanguage as I, errorMessage as J, Reader as K, readUsage as L, LANGUAGE_NAMES as M, STORY_LANGUAGES as N, RESULTS as O, isStoryLanguage as P, PromptLibrary as Q, PLOTS_FILE_NAME as R, notesOfSession as S, defaultBoundaries as T, commandFlagKey as U, plotReferenceProblems as V, commandsOf as W, LANGUAGE_TAG as X, LANGUAGE_FOLDER as Y, PROMPTS_FOLDER as Z, readTraces as _,
|
|
5011
|
+
export { copyWorldPrompts as $, plotProgressOf as A, parsePlotsFile as B, readNotes as C, referent as D, sameWords as E, textLanguage as F, readDocument as G, COMMANDS_KEY as H, wrongLanguage as I, errorMessage as J, Reader as K, readUsage as L, LANGUAGE_NAMES as M, STORY_LANGUAGES as N, RESULTS as O, isStoryLanguage as P, PromptLibrary as Q, PLOTS_FILE_NAME as R, notesOfSession as S, defaultBoundaries as T, commandFlagKey as U, plotReferenceProblems as V, commandsOf as W, LANGUAGE_TAG as X, LANGUAGE_FOLDER as Y, PROMPTS_FOLDER as Z, readTraces as _, ClockError as _t, MAX_OOC_ANSWER as a, shippedPromptsDirectory as at, readWithdrawn as b, AUTHORING_NEEDS as bt, externalWithheld as c, InvalidStartError as ct, record as d, SessionArchivedError as dt, inheritPrompts as et, toolEnabled as f, SessionNotFoundError as ft, readRunDetail as g, runCommandLine as gt, readActivity as h, registerCommands as ht, characterRunner as i, shippedLanguages as it, populatePlots as j, PLOTS_METADATA_KEY as k, PREVIEW_TOOL as l, InvalidWorldError as lt, readDecisionStats as m, CommandRefusedError as mt, installHooks as n, listFiles as nt, externalGiven as o, shippedText as ot, storesOf as p, WorldNotFoundError as pt, formatIssue as q, guardRepeatedCalls as r, promptProblem as rt, externalTools as s, AgentUnavailableError as st, externalToolLimit as t, languageOf as tt, createTools$1 as u, ReflectionRefusedError as ut, readVerdicts as v, describeWhen as vt, observeAsPlayer as w, addToNote as x, COMPARISONS as xt, writeVerdicts as y, zoneOf as yt, loadPlots as z };
|
|
4853
5012
|
|
|
4854
|
-
//# sourceMappingURL=hooks-
|
|
5013
|
+
//# sourceMappingURL=hooks-YXQZ9G2d.js.map
|
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-CF3fneuJ.js";
|
|
2
|
+
import { i as updateImage, r as listGallery } from "./gallery-Bu6eZMKk.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-BmlHNCah.js";
|
|
4
|
+
import { i as transientPrompt, n as generateTransientImage, r as referencePrompt, t as generateReferenceImage } from "./generator-CTWQWbSW.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 };
|