cortico-world-fun 0.7.7 → 0.8.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/CHANGELOG.md +37 -0
- package/README.md +28 -28
- package/describe.json +124 -337
- package/dist/webui.js +491 -362
- package/package.json +5 -5
- package/src/ENV_PROMPT.md +15 -14
- package/src/config.js +52 -50
- package/src/definition.js +6 -48
- package/src/state.js +30 -8
- package/src/story-dm.js +63 -32
- package/src/story-examples.js +15 -0
- package/src/story-free.js +88 -22
- package/src/story-library.js +355 -316
- package/src/story-packs.js +753 -745
- package/src/story-panel.js +11 -4
- package/src/story-read.js +4 -4
- package/src/story-reliability.js +19 -3
- package/src/story-secrets.js +29 -0
- package/src/world.js +568 -511
- package/src/aquarium.js +0 -27
- package/src/branches.js +0 -62
- package/src/choices.js +0 -54
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-fun",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "从0
|
|
5
|
+
"description": "从0开始的肥鱼大冒险:四个面板(家、故事手账、自己去逛、回忆手账),15 个工具(默认可用 14 个),自由故事、地点探索与本地回忆。",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "青",
|
|
8
8
|
"repository": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"build:webui": "esbuild webui/webui.js --bundle --format=esm --platform=browser --target=es2022 --charset=utf8 --outfile=dist/webui.js",
|
|
43
43
|
"pretest": "npm run build:webui",
|
|
44
44
|
"prepack": "npm run build:webui",
|
|
45
|
-
"test": "node test/story-secrets.test.mjs && node test/story-images.test.mjs && node test/story-migration.test.mjs && node test/story-venue-migration.test.mjs && node test/story-config.test.mjs && node test/story-stages.test.mjs && node test/story-dm.test.mjs && node test/story-packs.test.mjs && node test/story-panel.test.mjs && node test/story-world.test.mjs && node test/story-free.test.mjs && node test/story-
|
|
45
|
+
"test": "node test/story-secrets.test.mjs && node test/story-images.test.mjs && node test/story-migration.test.mjs && node test/story-venue-migration.test.mjs && node test/story-config.test.mjs && node test/story-stages.test.mjs && node test/story-dm.test.mjs && node test/story-packs.test.mjs && node test/story-panel.test.mjs && node test/story-world.test.mjs && node test/story-free.test.mjs && node test/story-actions.test.mjs && node test/story-prose.test.mjs && node test/story-text.test.mjs && node test/story-read-cache.test.mjs && node test/memory-trash.test.mjs && node test/journal-world.test.mjs && node test/journeys.test.mjs && node test/exploration.test.mjs && node test/venues.test.mjs && node test/state.test.mjs && node test/events.test.mjs && node test/memories.test.mjs && node test/phases.test.mjs && node test/keepsakes.test.mjs && node test/user-venues.test.mjs && node test/wishes.test.mjs && node test/world.test.mjs && node test/panels.test.mjs && node webui/story/webui.test.mjs && node test/place-library.test.mjs && node webui/places/webui.test.mjs && node test/home-room.test.mjs && node test/home-entry.test.mjs && node test/home-tools.test.mjs && node test/home-circle.test.mjs && node webui/home/webui.test.mjs && node test/tools-contract.test.mjs && node test/config-0.8.test.mjs && node test/compat-0.8.test.mjs",
|
|
46
46
|
"verify": "node tools/check-webui.mjs && node tools/fix-ps1-bom.mjs install.ps1 && node tools/check-prompt.mjs && node tools/check-isolation.mjs && node tools/smoke.mjs && node tools/make-describe.mjs --check",
|
|
47
47
|
"describe": "node tools/make-describe.mjs",
|
|
48
48
|
"check:publish": "node tools/publish-check.mjs --online",
|
|
@@ -63,11 +63,11 @@
|
|
|
63
63
|
"locales": {
|
|
64
64
|
"zh": {
|
|
65
65
|
"displayName": "从0开始的肥鱼大冒险",
|
|
66
|
-
"description": "
|
|
66
|
+
"description": "从0开始的肥鱼大冒险:四个面板(家、故事手账、自己去逛、回忆手账),15 个工具(默认可用 14 个),自由故事、地点探索与本地回忆。 可联动鱼的每一天与生图工作室,但不依赖其他插件;数据保存在本机 fun/ 目录。"
|
|
67
67
|
},
|
|
68
68
|
"en": {
|
|
69
69
|
"displayName": "Adventures of Fat Fish from Scratch",
|
|
70
|
-
"description": "
|
|
70
|
+
"description": "Four panels and 15 tools (14 enabled by default) for free-form stories, place exploration, and local memories. Optional integrations do not create dependencies."
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
},
|
package/src/ENV_PROMPT.md
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
## 从0开始的肥鱼大冒险
|
|
2
|
-
|
|
3
|
-
出游:`fun_places` 查地点 → `fun_go`
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
1
|
+
## 从0开始的肥鱼大冒险
|
|
2
|
+
|
|
3
|
+
出游:`fun_places` 查地点 → `fun_go` 进门(续逛填 tripId)→ `fun_wander` 逐处逛 → `fun_home` 回家;`fun_places` 可用 now:true 看此刻推荐。地点、项目、纪念品、拍照点名称以回执为准;吃喝只填当前地点真有的品类。行程与珍藏按需查 `fun_journal`(view 为 trips / shelf / keepsake)。
|
|
4
|
+
|
|
5
|
+
- 房间状态是画面,不是经历;切姿势用 `fun_home_room`,只读看房间用 `fun_home_room`;`pendingLine` 只是可复制文本。
|
|
6
|
+
- 配图:想画就自己画(`imggen_draw`),不想画不用管;`scene` / `outfits` 用正名,只画真实发生过的样子,库里没找到的不要填。
|
|
7
|
+
- 吃喝只记品类。允许且实际用「鱼的每一天」的 `feast_menu` → `feast_eat` 后才形容味道;否则只说吃喝了什么,别形容味道。本插件不会探测别的扩展装没装,不依赖其他 World。
|
|
8
|
+
- 时段会改变氛围和可逛项目;重复到访有效。历史只按需查,不编造未发生的经历。
|
|
9
|
+
- 用户自填地点通常没有素材库场景;地点清单与详情用 `fun_places`。预设删不掉,只能恢复;故事手账优先推荐四篇内置自由故事,也能自己写。
|
|
10
|
+
- 出门前可用 `feast_life_now` 对齐日程,用 `feast_life_adjust` 写进当天;回家后按回执用 `feast_life_play` 记录。自己出门不限次数:到时段会收到提醒,去不去、去哪儿由你和主对话按日程定。
|
|
11
|
+
- 故事只读查询同一参数 10 分钟内只回「没变化」:看到 `unchanged` 就停;上下文断了才加 `full:true`。
|
|
12
|
+
|
|
13
|
+
- 故事可用 fun_story_places / fun_story_candidates / fun_story_detail / fun_story_current / fun_story_recap / fun_story_schedule 查询;按实际回执行动。
|
|
14
|
+
- 群聊多人同时发言时不要每看到一句就调用 `fun_story_act`。等大家表态完或主人说「好了 / 就这么办 / 推进」,再把动作一次性用 `actions:[{who,say}]` 提交,一次只推进一回合;过早提交可用 `intent:"redo"` 带补充内容重跑。
|
|
15
|
+
|
|
15
16
|
{{fun_places_block}}
|
package/src/config.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 段名是 `config.json` 的 `worlds.fun`。WebUI 热改就地写这个对象,
|
|
5
5
|
* World 每次用时现读,所以这里只有默认值与 schema,不持有副本。
|
|
6
6
|
*
|
|
7
|
-
* 目前用户可配的:funOn /
|
|
7
|
+
* 目前用户可配的:funOn / funAutoOuting / funShareAfter,
|
|
8
8
|
* 加上 0.7.3 归位的故事长度、主持地址与模型、剧情图片来源。
|
|
9
9
|
* **API Key 与自定义工作流不在配置里**:前者只存本机 DPAPI 密文,后者是 32 KB
|
|
10
10
|
* JSON(宿主 string 只渲染单行输入),入口都在「出游 → 设置 → 高级」。
|
|
@@ -23,6 +23,10 @@ export const DEFAULTS = Object.freeze({
|
|
|
23
23
|
enabled: false,
|
|
24
24
|
/** 总开关。关掉=不注入场所清单,工具与面板还在(想现在去随时能去)。 */
|
|
25
25
|
funOn: true,
|
|
26
|
+
/** 新配置名;旧名 funHomeAutoGo 在读取与迁移时兼容。 */
|
|
27
|
+
funAutoOuting: false,
|
|
28
|
+
/** 新配置名;旧名 funAskReport 在读取与迁移时兼容。 */
|
|
29
|
+
funShareAfter: true,
|
|
26
30
|
/** 一次出游挂多久自动回家(分钟)。到点不催,只是不再算「正在逛」。 */
|
|
27
31
|
funSessionTTLMin: 90,
|
|
28
32
|
/** 回家回执要不要提醒她 feast_life_play 记一笔、跟主人说一句。 */
|
|
@@ -69,9 +73,9 @@ export const DEFAULTS = Object.freeze({
|
|
|
69
73
|
*/
|
|
70
74
|
funStoryAuthorInChat: false,
|
|
71
75
|
/** 自由模式(version 3 场景包):作者写设定,DM 即兴演。 */
|
|
72
|
-
funStoryFree:
|
|
76
|
+
funStoryFree: true,
|
|
73
77
|
/** 自由模式单趟回合上限(1 回合 = 1 次模型调用)。 */
|
|
74
|
-
funStoryFreeTurns:
|
|
78
|
+
funStoryFreeTurns: 200,
|
|
75
79
|
/** 鱼自主游玩:每段最多几步(走一步 = 一次真实推进,含不花模型的那一步)。 */
|
|
76
80
|
funAutoSteps: 20,
|
|
77
81
|
/** 鱼自主游玩:每段最多几次「鱼自己决定」(每一次都是一次真实模型请求)。 */
|
|
@@ -109,8 +113,13 @@ const ZH = {
|
|
|
109
113
|
prompt: '从0开始的肥鱼大冒险 World 的环境说明:她可以真去逛二十处地方——游乐场、海洋馆、庙会、漫展、电影院、动物园、公园、电玩城、KTV、博物馆、猫咖、爬山、咖啡店、奶茶店、餐厅、图书馆、夜市、澡堂、旧货市场、江边。还能在面板上自己加地方、改预设。进门、逛摊位、买纪念品、拍照、回家;回家回执把这一趟收成一句话,交给她记进自己的日程。本插件自己不调用其他 World 的工具、也不读别人的私有状态;她要在家里点吃喝、查日程或配图,仍可以自己调 feast_* / imggen_draw。',
|
|
110
114
|
config: {
|
|
111
115
|
title: '从0开始的肥鱼大冒险',
|
|
116
|
+
advancedPrefix: '高级 · ',
|
|
112
117
|
funOn: '开着',
|
|
113
118
|
funOnDesc: '总开关。关掉之后不往提示词里注入场所清单;工具和面板照旧可用,她想逛随时能逛。',
|
|
119
|
+
funShareAfter: '回家说一声',
|
|
120
|
+
funShareAfterDesc: '开启时,回家回执会提醒她把「今天逛了什么」用 feast_life_play 记进自己的日程,再跟主人说一句。关掉就只给这段文字,不提记账。',
|
|
121
|
+
funAutoOuting: '家:允许她自己出门',
|
|
122
|
+
funAutoOutingDesc: '打开后,她自己出门的许可跟着「鱼的每一天」的「她自己的时间」走:那边叫醒她时,先看当天日程(feast_life_now),自由就出门、写着上班睡觉就不出门。本插件不再单独设「自己出门的时段」,也不读对方的日程、不挑地方、不会自己把她送出门。默认关闭。',
|
|
114
123
|
funSessionTTLMin: '一趟逛多久',
|
|
115
124
|
funSessionTTLMinDesc: '一次出游最多挂多少分钟,过了这段时间就不再算「正在逛」。不会催她回家,也不会替她记一笔;下一次游逛时会提醒她这趟已经挂了很久。',
|
|
116
125
|
funAskReport: '回家说一声',
|
|
@@ -120,7 +129,7 @@ const ZH = {
|
|
|
120
129
|
funHomeAutoGo: '家:允许她自己出门',
|
|
121
130
|
funHomeAutoGoDesc: '打开后,她自己出门的许可跟着「鱼的每一天」的「她自己的时间」走:那边叫醒她时,先看当天日程(feast_life_now),自由就出门、写着上班睡觉就不出门。本插件不再单独设「自己出门的时段」,也不读对方的日程、不挑地方、不会自己把她送出门。默认关闭。',
|
|
122
131
|
funStoryDM: '可选文本主持',
|
|
123
|
-
funStoryDMDesc: '
|
|
132
|
+
funStoryDMDesc: '高级设置里的「主持方式」可选宿主默认或外接接口;外接设置只在选中时显示。DPAPI 密钥仅存本机密文。外接请求失败时回退宿主一次并明确提示,不会自动更改选择。主持只提议合法选项,当前行动者明确提交才执行。每趟 6 次、每步 2 次(含重试、失败、取消),未知 token 不估算。',
|
|
124
133
|
funStoryNodeLimit: '故事长度(节点上限)',
|
|
125
134
|
funStoryNodeLimitDesc: '新建或导入故事最多几个节点,0 = 不限。单篇 JSON 仍最多 32 KB;改小不会删除或阻断已有故事。',
|
|
126
135
|
funStoryDmUrl: '文本主持接口地址',
|
|
@@ -134,7 +143,7 @@ const ZH = {
|
|
|
134
143
|
funStoryAuthorInChat: '聊天里也能管故事',
|
|
135
144
|
funStoryAuthorInChatDesc: '默认关闭。开启后,聊天里会多一个作者工具 fun_story(模板、校验、预览、导入导出、启停、删除);关着时它不出现——这能省下它每轮约 1.1k 字符的固定开销。面板里的「故事工坊」不靠这个工具,任何时候都能写、能管。',
|
|
136
145
|
funStoryFree: '自由模式(场景包)',
|
|
137
|
-
funStoryFreeDesc: '
|
|
146
|
+
funStoryFreeDesc: '默认开启。可以使用 version 3「场景包」:作者只写大方向、正史、人物和结局条件,具体怎么演交给主持即兴。主持只能修改作者登记过的状态,结局由程序按条件判定;旧的选项式故事完全不受影响,两种模式可以同时存在。',
|
|
138
147
|
funStoryFreeTurns: '自由模式一段走多少回合',
|
|
139
148
|
funStoryFreeTurnsDesc: '一段最多多少回合(1 回合 = 1 次模型调用)。场景包自己写了更小的 maxTurns 就按更小的来。用完后这一段的输入框会收起:可以点「再来一段」接着走(一趟最多三段,要你亲手点),也可以收起进回忆;不会自动续。',
|
|
140
149
|
funAutoSteps: '鱼自己玩:每段最多几步',
|
|
@@ -144,7 +153,7 @@ const ZH = {
|
|
|
144
153
|
storyDmApiUrl: '接口地址', storyDmApiKey: 'API Key', storyDmModel: '模型名(可留空)', storyDmApiSaved: '已保存 / 未设置', storyDmApiClear: '清除密钥',
|
|
145
154
|
storyDmApiInvalid: '接口地址与密钥必须成对设置或成对清空;不支持的加密环境不会保存。',
|
|
146
155
|
storyDmApiHint: '请到「出游」面板设置区填写。地址和密钥仅存本机 DPAPI 密文;模型名按你的服务商填,留空则不发送 model。都不会进入普通配置或故事导出,保存后只显示掩码。',
|
|
147
|
-
funStoryImages: '剧情图片生成', funStoryImagesDesc: '
|
|
156
|
+
funStoryImages: '剧情图片生成', funStoryImagesDesc: '高级设置里的「剧情图片来源」可选关闭、委派或本机 ComfyUI 直连;只有选直连时才显示 loopback 地址和工作流。委派可由主对话调用生图工作室;不会调用其他 World 工具。直连继续使用现有 30 秒与 8 MiB/格式校验。',
|
|
148
157
|
funStoryAutoImages: '自动准备配图参数', funStoryAutoImagesDesc: '默认开启。总闸开着、且有进行中的行程时,每走到新的一处(或故事翻到新的一页),本插件自动把这一屏的 scene/outfits/prompt 准备好递给她;45 分钟后自动过期,不会反复催。这个开关也在出游页顶部,无行程或总闸关时禁用。只对委派型来源生效——直连本机 ComfyUI 会花算力,仍然只由「出游 → 设置 → 高级」里的按钮触发。',
|
|
149
158
|
storyImageSource: '图片来源(留空为鱼的生图包)',
|
|
150
159
|
storyImageSourceHint: '留空由主对话调用 imggen_draw;本机 URL 由本插件直连 ComfyUI;其他文本交主对话委派。不会调用其他 World 的工具或读取其私有状态。',
|
|
@@ -168,8 +177,13 @@ const EN = {
|
|
|
168
177
|
prompt: 'Adventures of Fat Fish from Scratch: she can actually go out — amusement park, aquarium, temple fair, fan convention. Walk in, wander the stalls, buy a souvenir, take a photo; the closing receipt turns the trip into one line she can log into her own day, and image generation draws the scene and outfit she actually wore.',
|
|
169
178
|
config: {
|
|
170
179
|
title: 'Adventures of Fat Fish from Scratch',
|
|
180
|
+
advancedPrefix: 'Advanced · ',
|
|
171
181
|
funOn: 'Enabled',
|
|
172
182
|
funOnDesc: 'Master switch. Off: no venue list in the prompt; the tools and panel still work, she can go any time.',
|
|
183
|
+
funShareAfter: 'Say something at the end',
|
|
184
|
+
funShareAfterDesc: 'When on, the closing receipt reminds her to log the trip with feast_life_play and tell the owner one sentence.',
|
|
185
|
+
funAutoOuting: 'Home: let her go out on her own',
|
|
186
|
+
funAutoOutingDesc: 'On: her permission to head out follows "her own time" in Fish Every Day. When that wake-up arrives she checks the day\'s schedule (feast_life_now) first — go out if the stretch is free, stay in if it says work or sleep. This plugin no longer keeps its own time slots, does not read the other world\'s schedule, never picks a place and never sends her out by itself. Off by default.',
|
|
173
187
|
funSessionTTLMin: 'A trip lasts',
|
|
174
188
|
funSessionTTLMinDesc: 'How many minutes an outing stays open. Past this it no longer counts as in progress — she is never nagged to wrap up and nothing is logged for her; the next fun_wander just mentions the trip should close.',
|
|
175
189
|
funAskReport: 'Say something at the end',
|
|
@@ -179,7 +193,7 @@ const EN = {
|
|
|
179
193
|
funHomeAutoGo: 'Home: let her go out on her own',
|
|
180
194
|
funHomeAutoGoDesc: 'On: her permission to head out follows "her own time" in Fish Every Day. When that wake-up arrives she checks the day\'s schedule (feast_life_now) first — go out if the stretch is free, stay in if it says work or sleep. This plugin no longer keeps its own time slots, does not read the other world\'s schedule, never picks a place and never sends her out by itself. Off by default.',
|
|
181
195
|
funStoryDM: 'Optional text DM',
|
|
182
|
-
funStoryDMDesc: '
|
|
196
|
+
funStoryDMDesc: 'Choose host default or an external endpoint in Advanced settings; external controls appear only when selected. The DPAPI key stays encrypted locally. A failed external request falls back to the host once with a visible notice, without changing the setting. The current actor must explicitly submit a valid proposal. Limits: 6 calls per run, 2 attempts per step, including retries, failures and cancellations; unknown tokens remain unknown.',
|
|
183
197
|
funStoryNodeLimit: 'Story length (node limit)',
|
|
184
198
|
funStoryNodeLimitDesc: 'Maximum nodes when creating or importing a story; 0 = unlimited. Each story JSON is still capped at 32 KB, and lowering this never deletes or blocks existing stories.',
|
|
185
199
|
funStoryDmUrl: 'Text DM endpoint',
|
|
@@ -193,7 +207,7 @@ const EN = {
|
|
|
193
207
|
funStoryAuthorInChat: 'Manage stories from chat',
|
|
194
208
|
funStoryAuthorInChatDesc: 'Off by default. On: chat gains the author tool fun_story (template, validate, preview, import/export, enable/disable/remove). Off: it is not offered, saving about 1.1k characters of fixed schema on every turn. The Story Workshop panel does not use this tool and keeps working either way.',
|
|
195
209
|
funStoryFree: 'Free mode (scene packs)',
|
|
196
|
-
funStoryFreeDesc: '
|
|
210
|
+
funStoryFreeDesc: 'On by default. Version 3 scene packs become playable. The author writes only the premise, canon, cast and ending conditions; the host DM improvises. The DM may change only registered state, and endings are decided by the program. Option-based stories are untouched; both modes can coexist.',
|
|
197
211
|
funStoryFreeTurns: 'Free-mode turns per run',
|
|
198
212
|
funStoryFreeTurnsDesc: 'Maximum turns in one run (one turn = one model call). A pack that declares a smaller maxTurns wins. When the segment is spent the input closes: start another segment (at most three per run, always by an explicit click) or wrap the run up. It never continues on its own.',
|
|
199
213
|
funAutoSteps: 'Fish autoplay: steps per segment',
|
|
@@ -204,7 +218,7 @@ const EN = {
|
|
|
204
218
|
storyDmApiInvalid: 'Set or clear the URL and key together. Unsupported encryption environments cannot save credentials.',
|
|
205
219
|
storyDmApiHint: 'Use Fish Story World settings. Only local DPAPI ciphertext is stored; the model name is plain and optional (blank sends no model). No credentials enter ordinary configuration or story exports, and saved fields show masks only.',
|
|
206
220
|
funStoryImages: 'Story image generation',
|
|
207
|
-
funStoryImagesDesc: '
|
|
221
|
+
funStoryImagesDesc: 'Choose off, delegation, or direct local ComfyUI in Advanced settings. The loopback URL and workflow appear only in direct mode. Delegation may use Fish Image Studio through the main conversation; this World never calls another World’s tools. Direct mode keeps its 30-second timeout and 8 MiB/format checks.',
|
|
208
222
|
funStoryAutoImages: 'Prepare image parameters automatically',
|
|
209
223
|
funStoryAutoImagesDesc: 'On by default. While the master switch is on and a trip is in progress, every new spot (or story page) prepares that scene’s scene/outfits/prompt for her automatically; the offer expires after 45 minutes and is never nagged. The same switch sits at the top of the Outing panel and is disabled without a trip or with the master off. Delegation sources only — a direct local ComfyUI call costs compute and still needs the button in Outing → Settings → Advanced.',
|
|
210
224
|
storyImageSource: 'Image source (blank: Fish Image Studio)',
|
|
@@ -267,6 +281,7 @@ export function panelText(language = 'zh') {
|
|
|
267
281
|
export function configGroup(language = 'zh') {
|
|
268
282
|
const t = text(language).config;
|
|
269
283
|
const K = `worlds.${ID}`;
|
|
284
|
+
const advanced = (key) => `${t.advancedPrefix}${t[key]}`;
|
|
270
285
|
return {
|
|
271
286
|
id: `world:${ID}`,
|
|
272
287
|
owner: `world:${ID}`,
|
|
@@ -278,77 +293,64 @@ export function configGroup(language = 'zh') {
|
|
|
278
293
|
type: 'boolean',
|
|
279
294
|
title: t.funOn,
|
|
280
295
|
description: t.funOnDesc,
|
|
281
|
-
'x-hot': true,
|
|
282
296
|
},
|
|
283
|
-
[`${K}.
|
|
284
|
-
type: '
|
|
285
|
-
title: t.funSessionTTLMin,
|
|
286
|
-
description: t.funSessionTTLMinDesc,
|
|
287
|
-
minimum: 15,
|
|
288
|
-
maximum: 480,
|
|
289
|
-
'x-suffix': ' 分钟',
|
|
290
|
-
'x-hot': true,
|
|
297
|
+
[`${K}.funAutoOuting`]: {
|
|
298
|
+
type: 'boolean', title: t.funAutoOuting, description: t.funAutoOutingDesc,
|
|
291
299
|
},
|
|
292
|
-
[`${K}.
|
|
293
|
-
type: 'boolean',
|
|
294
|
-
title: t.funAskReport,
|
|
295
|
-
description: t.funAskReportDesc,
|
|
296
|
-
'x-hot': true,
|
|
300
|
+
[`${K}.funShareAfter`]: {
|
|
301
|
+
type: 'boolean', title: t.funShareAfter, description: t.funShareAfterDesc,
|
|
297
302
|
},
|
|
298
|
-
[`${K}.
|
|
299
|
-
type: '
|
|
300
|
-
|
|
301
|
-
description: t.funTasteFromFeastDesc,
|
|
302
|
-
'x-hot': true,
|
|
303
|
+
[`${K}.funSessionTTLMin`]: {
|
|
304
|
+
type: 'integer', title: advanced('funSessionTTLMin'), description: t.funSessionTTLMinDesc,
|
|
305
|
+
minimum: 15, maximum: 480, 'x-suffix': ' 分钟',
|
|
303
306
|
},
|
|
304
|
-
[`${K}.
|
|
305
|
-
type: 'boolean',
|
|
306
|
-
title: t.funHomeAutoGo,
|
|
307
|
-
description: t.funHomeAutoGoDesc,
|
|
308
|
-
'x-hot': true,
|
|
307
|
+
[`${K}.funTasteFromFeast`]: {
|
|
308
|
+
type: 'boolean', title: advanced('funTasteFromFeast'), description: t.funTasteFromFeastDesc,
|
|
309
309
|
},
|
|
310
310
|
[`${K}.funStoryNodeLimit`]: {
|
|
311
|
-
type: 'integer', title:
|
|
312
|
-
minimum: 0, maximum: Number.MAX_SAFE_INTEGER, 'x-suffix': ' 个节点',
|
|
311
|
+
type: 'integer', title: advanced('funStoryNodeLimit'), description: t.funStoryNodeLimitDesc,
|
|
312
|
+
minimum: 0, maximum: Number.MAX_SAFE_INTEGER, 'x-suffix': ' 个节点',
|
|
313
313
|
},
|
|
314
314
|
[`${K}.funStoryDM`]: {
|
|
315
|
-
type: 'boolean', title:
|
|
315
|
+
type: 'boolean', title: advanced('funStoryDM'), description: t.funStoryDMDesc,
|
|
316
316
|
},
|
|
317
317
|
[`${K}.funStoryDmUrl`]: {
|
|
318
|
-
type: 'string', title:
|
|
318
|
+
type: 'string', title: advanced('funStoryDmUrl'), description: t.funStoryDmUrlDesc,
|
|
319
319
|
},
|
|
320
320
|
[`${K}.funStoryDmModel`]: {
|
|
321
|
-
type: 'string', title:
|
|
321
|
+
type: 'string', title: advanced('funStoryDmModel'), description: t.funStoryDmModelDesc,
|
|
322
322
|
},
|
|
323
323
|
[`${K}.funStoryImages`]: {
|
|
324
|
-
type: 'boolean', title:
|
|
324
|
+
type: 'boolean', title: advanced('funStoryImages'), description: t.funStoryImagesDesc,
|
|
325
325
|
},
|
|
326
326
|
[`${K}.funStoryAutoImages`]: {
|
|
327
|
-
type: 'boolean', title:
|
|
327
|
+
type: 'boolean', title: advanced('funStoryAutoImages'), description: t.funStoryAutoImagesDesc,
|
|
328
328
|
},
|
|
329
329
|
[`${K}.funStoryImageSource`]: {
|
|
330
|
-
type: 'string', title:
|
|
330
|
+
type: 'string', title: advanced('funStoryImageSource'), description: t.funStoryImageSourceDesc,
|
|
331
331
|
},
|
|
332
332
|
[`${K}.funStoryTextOn`]: {
|
|
333
|
-
type: 'boolean', title:
|
|
333
|
+
type: 'boolean', title: advanced('funStoryTextOn'), description: t.funStoryTextOnDesc,
|
|
334
|
+
'x-hot': false,
|
|
334
335
|
},
|
|
335
336
|
[`${K}.funStoryAuthorInChat`]: {
|
|
336
|
-
type: 'boolean', title:
|
|
337
|
+
type: 'boolean', title: advanced('funStoryAuthorInChat'), description: t.funStoryAuthorInChatDesc,
|
|
338
|
+
'x-hot': false,
|
|
337
339
|
},
|
|
338
340
|
[`${K}.funStoryFree`]: {
|
|
339
|
-
type: 'boolean', title:
|
|
341
|
+
type: 'boolean', title: advanced('funStoryFree'), description: t.funStoryFreeDesc,
|
|
340
342
|
},
|
|
341
343
|
[`${K}.funStoryFreeTurns`]: {
|
|
342
|
-
type: 'integer', title:
|
|
343
|
-
minimum: 5, maximum:
|
|
344
|
+
type: 'integer', title: advanced('funStoryFreeTurns'), description: t.funStoryFreeTurnsDesc,
|
|
345
|
+
minimum: 5, maximum: 200, 'x-suffix': ' 回合',
|
|
344
346
|
},
|
|
345
347
|
[`${K}.funAutoSteps`]: {
|
|
346
|
-
type: 'integer', title:
|
|
347
|
-
minimum: 1, maximum: 200, 'x-suffix': ' 步',
|
|
348
|
+
type: 'integer', title: advanced('funAutoSteps'), description: t.funAutoStepsDesc,
|
|
349
|
+
minimum: 1, maximum: 200, 'x-suffix': ' 步',
|
|
348
350
|
},
|
|
349
351
|
[`${K}.funAutoCalls`]: {
|
|
350
|
-
type: 'integer', title:
|
|
351
|
-
minimum: 1, maximum: 120, 'x-suffix': ' 次',
|
|
352
|
+
type: 'integer', title: advanced('funAutoCalls'), description: t.funAutoCallsDesc,
|
|
353
|
+
minimum: 1, maximum: 120, 'x-suffix': ' 次',
|
|
352
354
|
},
|
|
353
355
|
},
|
|
354
356
|
},
|
package/src/definition.js
CHANGED
|
@@ -12,65 +12,23 @@ const TOOL_SUMMARIES = {
|
|
|
12
12
|
en: 'Query available places ranked by opening hours and crowd; filter by kind or list all.',
|
|
13
13
|
},
|
|
14
14
|
fun_go: {
|
|
15
|
-
zh: '
|
|
16
|
-
en: '
|
|
17
|
-
},
|
|
18
|
-
fun_choice: {
|
|
19
|
-
zh: '处理待选择事件,可按回执选择或略过。',
|
|
20
|
-
en: 'Resolve or skip a pending event choice.',
|
|
21
|
-
},
|
|
22
|
-
fun_resume: {
|
|
23
|
-
zh: '继续一趟未逛完的行程。',
|
|
24
|
-
en: 'Resume an unfinished outing.',
|
|
15
|
+
zh: '只进门开始行程,或用 tripId 继续未完行程。',
|
|
16
|
+
en: 'Enter a place without exploring it, or resume an unfinished trip with tripId.',
|
|
25
17
|
},
|
|
26
18
|
fun_wander: {
|
|
27
|
-
zh: '
|
|
28
|
-
en: 'Wander one spot and optionally record a purchase, photo or food
|
|
19
|
+
zh: '逛一个项目,可记录本次购买、拍照或吃喝。',
|
|
20
|
+
en: 'Wander one spot and optionally record a purchase, photo or food.',
|
|
29
21
|
},
|
|
30
22
|
fun_home: {
|
|
31
23
|
zh: '结束行程并返回本次摘要与记录提示。',
|
|
32
24
|
en: 'End the trip and return its summary and logging prompt.',
|
|
33
25
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
en: 'Read the room state and a copyable "one line to log"; no images, no writes.',
|
|
37
|
-
},
|
|
38
|
-
fun_home_activity: {
|
|
39
|
-
zh: '切换她在家的十个固定活动之一,可附备注;revision 冲突不自动重试。',
|
|
40
|
-
en: 'Switch one of her ten fixed home activities, optionally with a note; no retry on revision conflicts.',
|
|
41
|
-
},
|
|
42
|
-
fun_start: {
|
|
43
|
-
zh: '查看当前推荐地点;详细筛选用 fun_places。',
|
|
44
|
-
en: 'Show current place recommendations; use fun_places for filters.',
|
|
45
|
-
},
|
|
46
|
-
fun_route: {
|
|
47
|
-
zh: '规划和管理最多两站的出门路线,明确前往下一站或提前结束。',
|
|
48
|
-
en: 'Plan and manage a two-stop outing, explicitly move on or end early.',
|
|
49
|
-
},
|
|
50
|
-
fun_view: {
|
|
51
|
-
zh: '查看正在逛、未逛完或已回家的行程。',
|
|
52
|
-
en: 'View active, unfinished, or finished outings.',
|
|
53
|
-
},
|
|
54
|
-
fun_wishes: {
|
|
55
|
-
zh: '查看明确记下的出游心愿和状态,不催促。',
|
|
56
|
-
en: 'View outing wishes and their status without reminders.',
|
|
57
|
-
},
|
|
58
|
-
fun_wish: {
|
|
59
|
-
zh: '记录、暂缓、恢复或取消一个出游心愿。',
|
|
60
|
-
en: 'Add, pause, resume or cancel an outing wish.',
|
|
61
|
-
},
|
|
62
|
-
fun_keepsake: {
|
|
63
|
-
zh: '珍藏或取消珍藏一趟行程,不影响纪念册近期列表和长期收藏。',
|
|
64
|
-
en: 'Keep or unkeep a trip without changing the recent trip book or permanent collection.',
|
|
65
|
-
},
|
|
26
|
+
fun_home_room: { zh: '查看房间状态,可切换活动或写备注,不会写入经历。', en: 'Read the room, change an activity, or add a note without recording an outing.' },
|
|
27
|
+
fun_journal: { zh: '查看行程、纪念品或珍藏,也可珍藏或取消珍藏行程。', en: 'Browse trips, souvenirs, or keepsakes; keep or unkeep a trip.' },
|
|
66
28
|
fun_story: {
|
|
67
29
|
zh: '管理、校验与预览本地故事工坊,支持自填地点。',
|
|
68
30
|
en: 'Manage, validate, and preview local story packs, including custom places.',
|
|
69
31
|
},
|
|
70
|
-
fun_shelf: {
|
|
71
|
-
zh: '按地点查询长期纪念品收藏和收集进度。',
|
|
72
|
-
en: 'Query long-term souvenirs and collection progress by place.',
|
|
73
|
-
},
|
|
74
32
|
fun_story_places: { zh: '查询地点索引或单个地点详情,只读,不开始出游;JSON 回执经标准 text 返回。', en: 'Read the place index or one place detail; does not start an outing. JSON is returned in standard text.' },
|
|
75
33
|
fun_story_candidates: { zh: '查询故事候选和公开简介,不返回未来分支;JSON 回执经标准 text 返回。', en: 'Read story candidates and public synopses without future branches. JSON is returned in standard text.' },
|
|
76
34
|
fun_story_detail: { zh: '查询单个故事的公开资料与可用原因,不返回节点内容;JSON 回执经标准 text 返回。', en: 'Read one story’s public metadata and availability without node contents. JSON is returned in standard text.' },
|
package/src/state.js
CHANGED
|
@@ -30,7 +30,7 @@ import { normalizeTimeline, normalizeRoute, normalizeRoutes, addMoment, timeline
|
|
|
30
30
|
import { normalizeStoryCanon } from './story-canon.js';
|
|
31
31
|
import { dmBudget } from './story-dm.js';
|
|
32
32
|
import { normalizeStoryReceipts, storyBudget, AUTO_SEGMENTS } from './story-reliability.js';
|
|
33
|
-
import { FREE_TURN_CAP } from './story-free.js';
|
|
33
|
+
import { FREE_TURN_CAP, normalizeFreeActions, normalizeStoryParty } from './story-free.js';
|
|
34
34
|
|
|
35
35
|
/** 纪念册最多留几趟。 */
|
|
36
36
|
export const MAX_TRIPS = 40;
|
|
@@ -79,7 +79,7 @@ export function minutesIn(tz, nowMs) {
|
|
|
79
79
|
|
|
80
80
|
/** 当天的新状态。 */
|
|
81
81
|
export function newState(day) {
|
|
82
|
-
return { day, session: null, draft: null, route: null, routes: [], routeSeq: 0, exploration: [], storyCanon: [], trips: [], collection: [], keepsakeTrips: [], tripSeq: 0, wishes: [], trash: [] };
|
|
82
|
+
return { day, session: null, draft: null, route: null, routes: [], routeSeq: 0, exploration: [], storyCanon: [], trips: [], collection: [], keepsakeTrips: [], tripSeq: 0, wishes: [], trash: [], party: [] };
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
export function newTripId(placeId, enteredAt, leftAt) {
|
|
@@ -201,6 +201,7 @@ function normalizeFreeRun(raw) {
|
|
|
201
201
|
const turn = Number.isSafeInteger(raw.turn) && raw.turn >= 0 ? Math.min(raw.turn, turnCeiling) : 0;
|
|
202
202
|
const turnBase = Number.isSafeInteger(raw.turnBase) && raw.turnBase >= 0 ? Math.min(raw.turnBase, turnCeiling) : 0;
|
|
203
203
|
const segment = Number.isSafeInteger(raw.segment) && raw.segment >= 0 ? Math.min(raw.segment, AUTO_SEGMENTS - 1) : 0;
|
|
204
|
+
const redo = Number.isSafeInteger(raw.redo) && raw.redo >= 0 ? Math.min(raw.redo, 100_000) : 0;
|
|
204
205
|
const facts = {};
|
|
205
206
|
if (raw.facts && typeof raw.facts === 'object' && !Array.isArray(raw.facts)) {
|
|
206
207
|
for (const [id, value] of Object.entries(raw.facts).slice(0, 24)) {
|
|
@@ -221,12 +222,16 @@ function normalizeFreeRun(raw) {
|
|
|
221
222
|
}
|
|
222
223
|
const log = (Array.isArray(raw.log) ? raw.log : []).slice(-40).flatMap((entry) => {
|
|
223
224
|
if (!entry || typeof entry !== 'object') return [];
|
|
224
|
-
const narration =
|
|
225
|
+
const narration = entry.unstructured === true && typeof entry.narration === 'string'
|
|
226
|
+
? entry.narration.slice(0, 1500) : text(entry.narration, 900);
|
|
225
227
|
if (!narration) return [];
|
|
228
|
+
const actions = normalizeFreeActions(entry.actions, entry.actions);
|
|
226
229
|
return [{ turn: Number.isSafeInteger(entry.turn) && entry.turn >= 0 ? entry.turn : 0, from: text(entry.from, 40),
|
|
227
|
-
|
|
230
|
+
...(entry.who ? { who: text(entry.who, 200) } : {}), say: typeof entry.say === 'string' ? entry.say.trim().slice(0, 1500) : '', narration,
|
|
231
|
+
at: Number.isFinite(Number(entry.at)) ? Number(entry.at) : 0, ...(entry.unstructured === true ? { unstructured: true } : {}),
|
|
232
|
+
...(actions.ok ? { actions: actions.actions } : {}) }];
|
|
228
233
|
});
|
|
229
|
-
return { turn, turnBase, segment, facts, flags, counters, summary: text(raw.summary, 200), log,
|
|
234
|
+
return { turn, turnBase, segment, redo, facts, flags, counters, summary: text(raw.summary, 200), log,
|
|
230
235
|
ended: typeof raw.ended === 'string' && FREE_NAME_RE.test(raw.ended) ? raw.ended : null };
|
|
231
236
|
}
|
|
232
237
|
|
|
@@ -252,9 +257,10 @@ function normalizeStoryRun(raw) {
|
|
|
252
257
|
return { storyRun: { packId, revision, title, endingNodeId: text(raw.endingNodeId, 24) || null, seq, budget: storyBudget(raw.budget), dmBudget: dmBudget(raw.dmBudget),
|
|
253
258
|
...(free ? { free } : {}),
|
|
254
259
|
autoplay: raw.autoplay === true,
|
|
255
|
-
freeCalls: Number.isSafeInteger(raw.freeCalls) && raw.freeCalls >= 0 ? Math.min(raw.freeCalls,
|
|
260
|
+
freeCalls: Number.isSafeInteger(raw.freeCalls) && raw.freeCalls >= 0 ? Math.min(raw.freeCalls, AUTO_SEGMENTS * (FREE_TURN_CAP * 2 + 4)) : 0,
|
|
256
261
|
forkToken: typeof raw.forkToken === 'string' && /^[A-Za-z0-9_-]{16,80}$/.test(raw.forkToken) ? raw.forkToken : null,
|
|
257
262
|
participation: raw.participation === 'duo' ? 'duo' : 'solo',
|
|
263
|
+
party: normalizeStoryParty(raw.party),
|
|
258
264
|
runId: text(raw.runId, 100) || null, sourceRunId: text(raw.sourceRunId, 100) || null, sourceMemoryId: text(raw.sourceMemoryId, 100) || null,
|
|
259
265
|
sourceCheckpointId: text(raw.sourceCheckpointId, 80) || null,
|
|
260
266
|
canonical: raw.canonical !== false, resourceVersion: text(raw.resourceVersion, 80) || 'legacy-unknown', checkpoints } };
|
|
@@ -273,6 +279,13 @@ function normalizePendingChoice(v) {
|
|
|
273
279
|
...(actor ? { actor } : {}), ...(jointResolution ? { jointResolution } : {}), ...(Object.keys(votes).length ? { votes } : {}) };
|
|
274
280
|
}
|
|
275
281
|
|
|
282
|
+
function isStoryPendingChoice(outing) {
|
|
283
|
+
const run = outing?.storyRun;
|
|
284
|
+
const choiceId = text(outing?.pendingChoice?.id, 100);
|
|
285
|
+
return Boolean(run?.packId && run?.revision && choiceId && normalizeStoryProgress(outing?.storyProgress).some((entry) =>
|
|
286
|
+
entry.waitingChoiceId === choiceId && entry.packId === run.packId && entry.revision === run.revision));
|
|
287
|
+
}
|
|
288
|
+
|
|
276
289
|
function normalizeTrip(raw, fallbackId = '') {
|
|
277
290
|
if (!raw || typeof raw !== 'object') return null;
|
|
278
291
|
const placeId = text(raw.placeId, 40);
|
|
@@ -327,7 +340,8 @@ function normalizeSession(raw) {
|
|
|
327
340
|
...trip,
|
|
328
341
|
id: text(raw.id, 100) || `${trip.placeId}-${trip.enteredAt}`,
|
|
329
342
|
lastAt: Number.isFinite(Number(raw.lastAt)) ? Number(raw.lastAt) : trip.enteredAt,
|
|
330
|
-
|
|
343
|
+
// 仅选项式故事的真实待选由 storyProgress.waitingChoiceId 锚定;普通出游的旧岔路已下线。
|
|
344
|
+
pendingChoice: isStoryPendingChoice(raw) ? normalizePendingChoice(raw.pendingChoice) : null,
|
|
331
345
|
};
|
|
332
346
|
}
|
|
333
347
|
|
|
@@ -368,6 +382,7 @@ function normalizeTrash(raw) {
|
|
|
368
382
|
|
|
369
383
|
export function normalizeState(raw, day, nowMs = 0, ttlMin = DEFAULT_TTL_MIN, timezone = 'Asia/Shanghai') {
|
|
370
384
|
if (!raw || typeof raw !== 'object') return newState(day);
|
|
385
|
+
const choiceDropped = [raw.session, raw.draft].some((outing) => outing?.pendingChoice && !isStoryPendingChoice(outing));
|
|
371
386
|
const { session, draft } = outingStatus({
|
|
372
387
|
day: raw.day, session: normalizeSession(raw.session), draft: normalizeSession(raw.draft),
|
|
373
388
|
}, day, nowMs, ttlMin, timezone);
|
|
@@ -401,10 +416,17 @@ export function normalizeState(raw, day, nowMs = 0, ttlMin = DEFAULT_TTL_MIN, ti
|
|
|
401
416
|
tripSeq: nextTripSeq,
|
|
402
417
|
routeSeq: Math.max(0, Math.floor(Number(raw.routeSeq) || 0)),
|
|
403
418
|
route,
|
|
404
|
-
routes
|
|
419
|
+
routes,
|
|
405
420
|
exploration,
|
|
406
421
|
storyCanon: normalizeStoryCanon(raw.storyCanon, [...trips, ...mergeKeptTrips(raw.keepsakeTrips, trips)]),
|
|
407
422
|
wishes: normalizeWishes(raw.wishes),
|
|
423
|
+
party: normalizeStoryParty(raw.party),
|
|
424
|
+
...((raw.notices?.freeDefaultOn === true || choiceDropped || raw.notices?.choiceDropped)
|
|
425
|
+
? { notices: {
|
|
426
|
+
...(raw.notices?.freeDefaultOn === true ? { freeDefaultOn: true } : {}),
|
|
427
|
+
...(choiceDropped ? { choiceDropped: '这一趟的岔路已跳过' }
|
|
428
|
+
: typeof raw.notices?.choiceDropped === 'string' ? { choiceDropped: text(raw.notices.choiceDropped, 80) } : {}),
|
|
429
|
+
} } : {}),
|
|
408
430
|
trash: normalizeTrash(raw.trash),
|
|
409
431
|
...(raw.storyReceipts ? { storyReceipts: normalizeStoryReceipts(raw.storyReceipts, nowMs) } : {}),
|
|
410
432
|
};
|