@dsh-agentic-roleplay/state 0.3.2 → 0.3.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/index.d.ts +15 -0
- package/lib/index.js +109 -1
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -2487,6 +2487,20 @@ interface RoutineWindowSpec {
|
|
|
2487
2487
|
position?: string;
|
|
2488
2488
|
interruptible?: boolean;
|
|
2489
2489
|
}
|
|
2490
|
+
/** One day on which a character does something other than its routine says: it takes the place of the routine's windows on that date and is dropped when the same date is set again. */
|
|
2491
|
+
interface RoutineExceptionSpec {
|
|
2492
|
+
character: string;
|
|
2493
|
+
/** The date, `YYYY-MM-DD`, in the story's time zone. */
|
|
2494
|
+
date: string;
|
|
2495
|
+
activity: string;
|
|
2496
|
+
/** `HH:MM`; the whole day when left out. */
|
|
2497
|
+
from?: string;
|
|
2498
|
+
to?: string;
|
|
2499
|
+
location?: string;
|
|
2500
|
+
feature?: string;
|
|
2501
|
+
position?: string;
|
|
2502
|
+
interruptible?: boolean;
|
|
2503
|
+
}
|
|
2490
2504
|
/** Sets the recurring day of a character, replacing what it had. */
|
|
2491
2505
|
interface RoutineSet {
|
|
2492
2506
|
character: string;
|
|
@@ -2506,6 +2520,7 @@ interface RecordsEdit {
|
|
|
2506
2520
|
engagements?: NewEngagementSpec[];
|
|
2507
2521
|
engagementEdits?: EngagementEditSpec[];
|
|
2508
2522
|
routines?: RoutineSet[];
|
|
2523
|
+
routineExceptions?: RoutineExceptionSpec[];
|
|
2509
2524
|
/** Things the world does when their conditions come true, only by the agent whose work that is. */
|
|
2510
2525
|
triggers?: TriggerDefinition[];
|
|
2511
2526
|
states?: StatePatch[];
|
package/lib/index.js
CHANGED
|
@@ -573,6 +573,16 @@ const ZH = {
|
|
|
573
573
|
"{where}: one passing moment is not yet a belief; rest it on things from at least two different turns, or on one event that turned the story": "{where}:一个转瞬即逝的瞬间还不是看法;请以至少两个不同回合的经历为依据,或以一件扭转了故事的事件为依据",
|
|
574
574
|
"{where}: to be sure of something it must rest on things from at least two different turns": "{where}:要对某事确信,必须以至少两个不同回合的经历为依据",
|
|
575
575
|
"{where}: \"{name}\" is not a character; name them as they are named": "{where}:“{name}”不是角色;请使用他们的名字",
|
|
576
|
+
"say in a sentence what the belief claims and what the things say, before the verdict": "先用一句话说明这个看法主张什么、这些内容说了什么,再给出判断",
|
|
577
|
+
"the verdict is consistent or contradicted": "判断是 consistent 或 contradicted",
|
|
578
|
+
"a belief that can be true together with all of them names none of them": "与它们全都可以同时成立的看法,不应列出其中任何一条",
|
|
579
|
+
"name the things that cannot be true together with the belief": "写出与这个看法不可能同时成立的内容",
|
|
580
|
+
"there is no thing listed numbered {id}": "列出的内容里没有编号为 {id} 的",
|
|
581
|
+
"thing {id} came before the belief was formed": "内容 {id} 出现在这个看法形成之前",
|
|
582
|
+
"A belief held by {name}: {text}": "{name} 持有的一个看法:{text}",
|
|
583
|
+
"What they took in since that bears on it:": "此后他们接收到的、与之有关的内容:",
|
|
584
|
+
"Can the belief and each of these be true together? Name the ones that cannot be.": "这个看法与其中每一件事能否同时成立?指出不能同时成立的。",
|
|
585
|
+
"{names} could not be sorted this time and will be tried again: {reason}": "{names} 这一次没能整理,下次会再试:{reason}",
|
|
576
586
|
"{where}: belief {id} is already changed in this pass": "{where}:看法 {id} 在这一轮中已经修改过",
|
|
577
587
|
"{where}: say what it took in since that bears on it": "{where}:请写出此后与之相关的经历",
|
|
578
588
|
"{where}: thing {id} came before the belief was formed; cite what came after": "{where}:经历 {id} 发生在看法形成之前;请引用之后发生的事",
|
|
@@ -634,7 +644,8 @@ const ZH = {
|
|
|
634
644
|
"{names} noticed: {text}": "{names}注意到:{text}",
|
|
635
645
|
"{name} went to {place}.": "{name}去了{place}。",
|
|
636
646
|
"## MCP resource servers\n\nUse {tools} with the server argument naming an MCP server.": "## MCP 资源服务器\n\n使用 {tools},server 参数填 MCP 服务器的名称。",
|
|
637
|
-
"## MCP resource servers\n\nUse {tools} with one of these names as the server argument: {servers}.": "## MCP 资源服务器\n\n使用 {tools},server 参数填下列名称之一:{servers}。"
|
|
647
|
+
"## MCP resource servers\n\nUse {tools} with one of these names as the server argument: {servers}.": "## MCP 资源服务器\n\n使用 {tools},server 参数填下列名称之一:{servers}。",
|
|
648
|
+
"{where}: the text is longer than {max} characters. A belief is not rewritten to hold what speaks against it: leave the text out and list the belief under doubt with the numbers of what speaks against it, and put what was learned as a new belief of its own": "{where}:文字超过 {max} 个字符。不要通过改写信念来容纳与之相悖的事:不要写文字,把这条信念列入 doubt 并给出与之相悖的编号;新了解到的内容另写成一条新信念"
|
|
638
649
|
};
|
|
639
650
|
//#endregion
|
|
640
651
|
//#region ../dsh-roleplay-model/src/messages.ts
|
|
@@ -1476,6 +1487,12 @@ const MAX_PLAN_STEPS = 8;
|
|
|
1476
1487
|
const MAX_LIST_ENTRY = 240;
|
|
1477
1488
|
const present$1 = (value) => value !== void 0 && value.trim() !== "";
|
|
1478
1489
|
const list$1 = (value) => value ?? [];
|
|
1490
|
+
const FULL_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
1491
|
+
const isExceptionOn = (on, date) => on.length === 1 && on[0] === date;
|
|
1492
|
+
const ALL_DAY = {
|
|
1493
|
+
from: "00:00",
|
|
1494
|
+
to: "23:59"
|
|
1495
|
+
};
|
|
1479
1496
|
/** Checks the goals, engagements and routines of an edit, and says what they would write. Problems are added to the context's. */
|
|
1480
1497
|
function prepareAgenda(target, edit, context) {
|
|
1481
1498
|
const { idOf, placeKnown, problems } = context;
|
|
@@ -1641,6 +1658,39 @@ function prepareAgenda(target, edit, context) {
|
|
|
1641
1658
|
character,
|
|
1642
1659
|
windows
|
|
1643
1660
|
}];
|
|
1661
|
+
}),
|
|
1662
|
+
exceptions: list$1(edit.routineExceptions).flatMap((spec, index) => {
|
|
1663
|
+
const where = `routine_exceptions[${index}]`;
|
|
1664
|
+
const character = idOf(spec.character, where);
|
|
1665
|
+
if (!FULL_DATE.test(spec.date)) problems.push(`${where}.date: "${spec.date}" is not a date (YYYY-MM-DD)`);
|
|
1666
|
+
else problems.push(...dayTokenProblems([spec.date], `${where}.date`));
|
|
1667
|
+
if (!present$1(spec.activity)) problems.push(`${where}: say what the character does that day`);
|
|
1668
|
+
if (spec.from === void 0 !== (spec.to === void 0)) problems.push(`${where}: give both from and to, or neither for the whole day`);
|
|
1669
|
+
const start = parseTimeOfDay(spec.from ?? ALL_DAY.from);
|
|
1670
|
+
const end = parseTimeOfDay(spec.to ?? ALL_DAY.to);
|
|
1671
|
+
if (start === void 0) problems.push(`${where}.from: "${spec.from}" is not a time of day (HH:MM)`);
|
|
1672
|
+
if (end === void 0) problems.push(`${where}.to: "${spec.to}" is not a time of day (HH:MM)`);
|
|
1673
|
+
if (start !== void 0 && start === end) problems.push(`${where}: it starts and ends at the same time`);
|
|
1674
|
+
if (spec.location !== void 0) {
|
|
1675
|
+
placeKnown(spec.location, `${where}.location`);
|
|
1676
|
+
const place = context.places.get(spec.location);
|
|
1677
|
+
if (spec.feature !== void 0 && place !== void 0 && !place.features.some((feature) => feature.key === spec.feature)) problems.push(`${where}: ${place.name} has no feature "${spec.feature}"`);
|
|
1678
|
+
} else if (spec.feature !== void 0) problems.push(`${where}: a feature needs a location`);
|
|
1679
|
+
if (character === void 0 || start === void 0 || end === void 0) return [];
|
|
1680
|
+
return [{
|
|
1681
|
+
character,
|
|
1682
|
+
window: {
|
|
1683
|
+
days: [],
|
|
1684
|
+
on: [spec.date],
|
|
1685
|
+
start,
|
|
1686
|
+
end,
|
|
1687
|
+
activity: spec.activity.trim(),
|
|
1688
|
+
interruptible: spec.interruptible ?? true,
|
|
1689
|
+
...spec.location === void 0 ? {} : { location: spec.location },
|
|
1690
|
+
...spec.feature === void 0 ? {} : { featureKey: spec.feature },
|
|
1691
|
+
...spec.position === void 0 || spec.position.trim() === "" ? {} : { position: spec.position.trim() }
|
|
1692
|
+
}
|
|
1693
|
+
}];
|
|
1644
1694
|
})
|
|
1645
1695
|
};
|
|
1646
1696
|
}
|
|
@@ -1687,6 +1737,17 @@ function writeAgenda(target, prepared, turn, placeId) {
|
|
|
1687
1737
|
})));
|
|
1688
1738
|
writes += 1;
|
|
1689
1739
|
}
|
|
1740
|
+
for (const { character, window } of prepared.exceptions) {
|
|
1741
|
+
const date = window.on[0];
|
|
1742
|
+
const kept = target.routines.list(character).filter((existing) => !isExceptionOn(existing.on, date));
|
|
1743
|
+
if (kept.length + 1 > 24) throw new InvalidEditError([`routine_exceptions: the character's day already has 24 windows`]);
|
|
1744
|
+
const { location, ...rest } = window;
|
|
1745
|
+
target.routines.replace(character, [{
|
|
1746
|
+
...rest,
|
|
1747
|
+
...location === void 0 ? {} : { locationId: placeId(location) }
|
|
1748
|
+
}, ...kept]);
|
|
1749
|
+
writes += 1;
|
|
1750
|
+
}
|
|
1690
1751
|
return writes;
|
|
1691
1752
|
}
|
|
1692
1753
|
//#endregion
|
|
@@ -3542,6 +3603,17 @@ function parseRecordsEdit(value) {
|
|
|
3542
3603
|
}
|
|
3543
3604
|
return [parsed.definition];
|
|
3544
3605
|
}),
|
|
3606
|
+
routineExceptions: array("routine_exceptions").map((entry) => defined({
|
|
3607
|
+
character: text(entry, "character") ?? "",
|
|
3608
|
+
date: text(entry, "date") ?? "",
|
|
3609
|
+
activity: text(entry, "activity") ?? "",
|
|
3610
|
+
from: text(entry, "from"),
|
|
3611
|
+
to: text(entry, "to"),
|
|
3612
|
+
location: text(entry, "location"),
|
|
3613
|
+
feature: text(entry, "feature"),
|
|
3614
|
+
position: text(entry, "position"),
|
|
3615
|
+
interruptible: bool(entry, "interruptible")
|
|
3616
|
+
})),
|
|
3545
3617
|
routines: array("routines").map((entry) => ({
|
|
3546
3618
|
character: text(entry, "character") ?? "",
|
|
3547
3619
|
windows: Array.isArray(entry["windows"]) ? entry["windows"].filter(isObject$1).map((window) => defined({
|
|
@@ -4218,6 +4290,42 @@ function recordsEditSchema(options = {}) {
|
|
|
4218
4290
|
additionalProperties: false
|
|
4219
4291
|
}
|
|
4220
4292
|
},
|
|
4293
|
+
routine_exceptions: {
|
|
4294
|
+
type: "array",
|
|
4295
|
+
description: "A day on which a character does something other than its routine says (ill in bed, away on an errand, a day off): the date (YYYY-MM-DD, story-local), what it does and where; it takes the place of the routine on that date only. Setting the same date again replaces it.",
|
|
4296
|
+
items: {
|
|
4297
|
+
type: "object",
|
|
4298
|
+
properties: {
|
|
4299
|
+
character,
|
|
4300
|
+
date: {
|
|
4301
|
+
type: "string",
|
|
4302
|
+
description: "YYYY-MM-DD."
|
|
4303
|
+
},
|
|
4304
|
+
activity: {
|
|
4305
|
+
type: "string",
|
|
4306
|
+
description: "What it does that day: \"keeps to bed with a fever\"."
|
|
4307
|
+
},
|
|
4308
|
+
from: {
|
|
4309
|
+
type: "string",
|
|
4310
|
+
description: "HH:MM; leave out with to for the whole day."
|
|
4311
|
+
},
|
|
4312
|
+
to: {
|
|
4313
|
+
type: "string",
|
|
4314
|
+
description: "HH:MM."
|
|
4315
|
+
},
|
|
4316
|
+
location: placeKey,
|
|
4317
|
+
feature: { type: "string" },
|
|
4318
|
+
position: { type: "string" },
|
|
4319
|
+
interruptible: { type: "boolean" }
|
|
4320
|
+
},
|
|
4321
|
+
required: [
|
|
4322
|
+
"character",
|
|
4323
|
+
"date",
|
|
4324
|
+
"activity"
|
|
4325
|
+
],
|
|
4326
|
+
additionalProperties: false
|
|
4327
|
+
}
|
|
4328
|
+
},
|
|
4221
4329
|
engagement_edits: {
|
|
4222
4330
|
type: "array",
|
|
4223
4331
|
description: "An engagement that moved on (the ids are in read_records): it was kept, missed, cancelled, or put off. Give only what changes.",
|