cortico-world-fun 0.8.16 → 0.8.17

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 CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  市场按 `##` 标题里的版本号切段,显示在「历史版本」里。
4
4
 
5
+ ## 0.8.17
6
+
7
+ - **少一轮调用:`fun_go` 可自动回家**:新增 `autoHome: true` 与可选 `homeNote`,本趟请求步数安全完成后自动归档并合并回家回执;遇到待选择、未完成故事、失败或双人故事时保留行程,不代替用户结束。
8
+ - **面板唤醒可控**:新增 `funPanelNotifyOnGo`(默认开启)和「通知她聊一聊」单次勾选;关闭后仍照常保存进度。单次 `outingGo` 的 `notify` 可覆盖配置。
9
+ - **自动配图节奏**:新增 `funStoryAutoImageCadence`,默认 `segment`(首幕、故事节点变化、段落结束/暂停或结局时准备委派);可选 `step` 每步准备。手动「给你画一张」不受自动节流影响。
10
+ - **缩短常驻提示词**:在保留全部硬性提示与联动约定的前提下压缩 `ENV_PROMPT.md`;新增只读的跨插件工具契约检查回归。
11
+ - `funTerseReceipts` 默认仍关闭;现有存档格式不变,无数据迁移。
12
+
5
13
  ## 0.8.16
6
14
 
7
15
  - **家面板视觉改版**:内置暖色插画房间的宽、窄构图,保留原有十张 Q 版角色;状态留在画面里,活动入口横向排列,管理收进「布置与回忆」。角色增加柔和接触阴影与轻微呼吸,支持减少动态效果;自传背景、站位和原有房间功能继续可用,状态与 API 契约不变。
package/PUBLISHING.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 从0开始的肥鱼大冒险发布准备说明
2
2
 
3
- 当前工作版本为 0.8.16。发布前运行 `npm run build:webui`、`node tools/make-describe.mjs --check`、`npm test`、`npm run verify`;`describe.json` 由 `node tools/make-describe.mjs` 生成。默认值以 `src/config.js` 为准,`funTerseReceipts` 默认关闭。
3
+ 当前工作版本为 0.8.17。发布前运行 `npm run build:webui`、`node tools/make-describe.mjs --check`、`npm test`、`npm run verify`;`describe.json` 由 `node tools/make-describe.mjs` 生成。默认值以 `src/config.js` 为准,`funTerseReceipts` 默认关闭。`npm test` 包含 `test/linkage-contract.test.mjs`。当前候选的功能范围见 `CHANGELOG.md` 的 0.8.17 条目;全量测试若在受限环境遇到 DPAPI 用例失败,须单独报告,不得标作全绿。
4
4
 
5
5
  房间背景源码与内嵌模块位于 `webui/home/`,通过 `tools/make-home-art.mjs` 校验后只嵌入 `dist/webui.js`;npm 包不带 `webui/`,`assets/home/` 保留服务端使用的 `chibi-*.webp`。`install.ps1` 同样排除 `webui/`、工具、测试和根目录临时 `fun/`。提示词自检使用独立临时目录并清理,不写仓库或用户数据。
6
6
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  以下保留 0.4.3 历史记录;历史验收数量不代表当前测试数量。
10
10
 
11
- > 本文是 0.4.3 的历史记录。当前版本(0.8.14)的发布说明见 [PUBLISHING-0.8.14.md](PUBLISHING-0.8.14.md)。
11
+ > 本文保留 0.4.3 的历史记录。当前版本功能说明见 [CHANGELOG.md](CHANGELOG.md) 的 0.8.17 条目。
12
12
 
13
13
  0.4.3 的范围是「旅行手账」UI 改造:统一主题层,地点册四组编辑器,去哪儿推荐主卡,纪念册票笺与心愿侧栏,纪念品架展示柜,故事工坊作品库版式与改名。**本轮只改源码、跑测试、生成 0.4.3 本地包并核验**,不发布 npm、不安装/卸载 Coo、不做市场重装、不操作真实用户数据。下面的发布流程留待人工另行确认,不构成本轮执行授权。
14
14
 
package/describe.json CHANGED
@@ -59,6 +59,14 @@
59
59
  "minimum": 1,
60
60
  "maximum": 8,
61
61
  "description": "默认 1 只进门;2–8 表示进门后在当前地点连续逛几处,遇待选项即停并汇总。"
62
+ },
63
+ "autoHome": {
64
+ "type": "boolean",
65
+ "description": "可选,默认 false。设为 true 时,逛完请求步数后若未遇待选项、故事或失败,自动回家并合并回家回执。"
66
+ },
67
+ "homeNote": {
68
+ "type": "string",
69
+ "description": "可选,仅 autoHome 为 true 时传给回家备注(最多 120 字)。"
62
70
  }
63
71
  },
64
72
  "additionalProperties": false
@@ -67,8 +75,8 @@
67
75
  "write"
68
76
  ],
69
77
  "summary": {
70
- "zh": "默认只进门;可用 tripId 续逛,steps 2–8 批量逛当前地点。",
71
- "en": "Enter a place by default, resume with tripId, or explore the current place with steps 2–8."
78
+ "zh": "默认只进门;可用 tripId 续逛,steps 2–8 批量逛当前地点,autoHome 可在安全结束后自动回家并附上 homeNote。",
79
+ "en": "Enter a place by default, resume with tripId, or explore with steps 2–8; autoHome returns home when safe, with an optional homeNote."
72
80
  }
73
81
  },
74
82
  {
@@ -596,7 +604,7 @@
596
604
  "key": "worlds.fun.env",
597
605
  "title": "从0开始的肥鱼大冒险",
598
606
  "role": "envPrompt",
599
- "content": "## 从0开始的肥鱼大冒险\n\n出游:`fun_places` 查地点 → `fun_go` 进门(续逛填 tripId)→ `fun_wander` 逐处逛 → `fun_home` 回家;`fun_places` 可用 now:true 看此刻推荐。地点、项目、纪念品、拍照点名称以回执为准;吃喝只填当前地点真有的品类。行程与珍藏按需查 `fun_journal`(view 为 trips / shelf / keepsake)。\n\n- 房间状态是画面,不是经历;切姿势用 `fun_home_room`,只读看房间用 `fun_home_room`;`pendingLine` 只是可复制文本。\n- 配图:想画就自己画(`imggen_draw`),不想画不用管;`scene` / `outfits` 用正名,只画真实发生过的样子,库里没找到的不要填。\n- 吃喝只记品类。允许且实际用「鱼的每一天」的 `feast_menu` → `feast_eat` 后才形容味道;否则只说吃喝了什么,别形容味道。本插件不会探测别的扩展装没装,不依赖其他 World。\n- 时段会改变氛围和可逛项目;重复到访有效。历史只按需查,不编造未发生的经历。\n- 用户自填地点通常没有素材库场景;地点清单与详情用 `fun_places`。预设删不掉,只能恢复;故事手账有四篇选项式和五篇自由故事,也能自己写。\n- 出门前可用 `feast_life_now` 对齐日程,用 `feast_life_adjust` 写进当天;回家后按回执用 `feast_life_play` 记录。自己出门只是许可,不带本插件的定时器;「鱼的每一天」在她自己的时间叫醒后,去不去、去哪儿由你和主对话按日程定。\n- 故事只读查询同一参数 10 分钟内只回「没变化」:看到 `unchanged` 就停;上下文断了才加 `full:true`。\n\n- 故事可用 fun_story_places / fun_story_candidates / fun_story_detail / fun_story_current / fun_story_recap / fun_story_schedule 查询;按实际回执行动。\n- 群聊多人同时发言时不要每看到一句就调用 `fun_story_act`。等大家表态完或主人说「好了 / 就这么办 / 推进」,再把动作一次性用 `actions:[{who,say}]` 提交,一次只推进一回合;过早提交可用 `intent:\"redo\"` 带补充内容重跑。\n\n{{fun_places_block}}\n"
607
+ "content": "## 从0开始的肥鱼大冒险\n\n出游按 `fun_places` → `fun_go`(续逛带 tripId)→ `fun_wander` → `fun_home`;地点与收获以回执为准,行程/珍藏按需查 `fun_journal`。\n\n- `fun_home_room` 是画面非经历;`pendingLine` 仅供复制。回家或换活动时,若会话同时有生活日程与房间画面,可按需同步姿势,或用 `feast_life_play` 记经历;以行程 id/runId 作 `sourceRef` 防重,不自动互写。\n- 配图用 `imggen_draw`,`scene` / `outfits` 用正名,只画真实场景;库里没找到就省略。吃喝只记品类,不等于「鱼的每一天」的吃饭记账;开启联动且实际用 `feast_menu` → `feast_eat` 才形容味道,否则别形容味道。不会探测其他扩展,也不依赖其他 World。\n- 出门可用 `feast_life_now` 查日程、`feast_life_adjust` 写当天;没联动就跳过。本插件无定时器,是否出门由日程和主对话决定。时段影响项目,历史不编造;预设删不掉,只能恢复。\n- 故事同参数 10 分钟内见 `unchanged` 就停;上下文断了才加 `full:true`。\n- 群聊不要每看到一句就调用 `fun_story_act`;等大家表态完再以 `actions:[{who,say}]` 一次提交,一次只推进一回合。过早提交用 `intent:\"redo\"` 补充重跑。\n\n{{fun_places_block}}\n"
600
608
  }
601
609
  ]
602
610
  }
package/dist/webui.js CHANGED
@@ -7872,6 +7872,8 @@ function mountPlaces2(ctx) {
7872
7872
  let notice = null;
7873
7873
  let outingPlace = "";
7874
7874
  let outingSteps = 1;
7875
+ let outingNotify;
7876
+ let outingNotifyDefault;
7875
7877
  let loadSequence = 0;
7876
7878
  let currentData = null;
7877
7879
  const status = feedback(box);
@@ -7879,6 +7881,10 @@ function mountPlaces2(ctx) {
7879
7881
  const render = (data) => {
7880
7882
  const restoreFocus = rememberFocus(body);
7881
7883
  currentData = data;
7884
+ if (outingNotifyDefault !== (data.outing?.notifyOnGo !== false)) {
7885
+ outingNotifyDefault = data.outing?.notifyOnGo !== false;
7886
+ outingNotify = outingNotifyDefault;
7887
+ }
7882
7888
  body.replaceChildren(heading("今天,想去哪儿?", "有些地方适合热闹,有些地方适合慢慢待着。"));
7883
7889
  const draft = data.draft;
7884
7890
  if (draft) {
@@ -7977,6 +7983,19 @@ function mountPlaces2(ctx) {
7977
7983
  }
7978
7984
  }, outingAction === "outingGo" ? "正在逛…" : goLabel)
7979
7985
  ),
7986
+ el(
7987
+ "label",
7988
+ { class: "fun-meta" },
7989
+ el("input", {
7990
+ type: "checkbox",
7991
+ "aria-label": "通知她聊一聊",
7992
+ checked: outingNotify ? "checked" : null,
7993
+ onchange: (event) => {
7994
+ outingNotify = event.currentTarget.checked;
7995
+ }
7996
+ }),
7997
+ " 通知她聊一聊"
7998
+ ),
7980
7999
  el("div", { class: "fun-meta", text: plan?.reason || (data.session ? "继续当前地点,1–8 处;不会换地方、代选、购买或拍照。" : "确认地点和步数后点击出发:1 步只进门,2–8 步在同一地点批量逛。不会代选、购买或拍照。") })
7981
8000
  ));
7982
8001
  if (notice) body.appendChild(el("div", {
@@ -8300,6 +8319,7 @@ function mountPlaces2(ctx) {
8300
8319
  const payload = {
8301
8320
  place: outingPlace,
8302
8321
  steps: outingSteps,
8322
+ notify: outingNotify,
8303
8323
  ...currentData.session ? { tripId: currentData.session.id } : {}
8304
8324
  };
8305
8325
  outingAction = "outingGo";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-fun",
3
- "version": "0.8.16",
3
+ "version": "0.8.17",
4
4
  "type": "module",
5
5
  "description": "给 Coo 的出门、房间、故事与回忆:二十多处可逛场所、四篇选项式与五篇自由故事、2D 房间与纪念品,数据只存本机。",
6
6
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "build:webui": "node tools/make-home-art.mjs --check && esbuild webui/webui.js --bundle --format=esm --platform=browser --target=es2022 --charset=utf8 --outfile=dist/webui.js",
43
43
  "pretest": "npm run build:webui && node test/story-import-cache-race.test.mjs && node test/frontend-home-usability.test.mjs && node webui/webui.test.mjs",
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-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",
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/linkage-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",
package/src/ENV_PROMPT.md CHANGED
@@ -1,16 +1,11 @@
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
-
16
- {{fun_places_block}}
1
+ ## 从0开始的肥鱼大冒险
2
+
3
+ 出游按 `fun_places` → `fun_go`(续逛带 tripId)→ `fun_wander` → `fun_home`;地点与收获以回执为准,行程/珍藏按需查 `fun_journal`。
4
+
5
+ - `fun_home_room` 是画面非经历;`pendingLine` 仅供复制。回家或换活动时,若会话同时有生活日程与房间画面,可按需同步姿势,或用 `feast_life_play` 记经历;以行程 id/runId 作 `sourceRef` 防重,不自动互写。
6
+ - 配图用 `imggen_draw`,`scene` / `outfits` 用正名,只画真实场景;库里没找到就省略。吃喝只记品类,不等于「鱼的每一天」的吃饭记账;开启联动且实际用 `feast_menu` → `feast_eat` 才形容味道,否则别形容味道。不会探测其他扩展,也不依赖其他 World。
7
+ - 出门可用 `feast_life_now` 查日程、`feast_life_adjust` 写当天;没联动就跳过。本插件无定时器,是否出门由日程和主对话决定。时段影响项目,历史不编造;预设删不掉,只能恢复。
8
+ - 故事同参数 10 分钟内见 `unchanged` 就停;上下文断了才加 `full:true`。
9
+ - 群聊不要每看到一句就调用 `fun_story_act`;等大家表态完再以 `actions:[{who,say}]` 一次提交,一次只推进一回合。过早提交用 `intent:"redo"` 补充重跑。
10
+
11
+ {{fun_places_block}}
package/src/config.js CHANGED
@@ -30,6 +30,7 @@ export const DEFAULTS = Object.freeze({
30
30
  /** 一次出游挂多久自动回家(分钟)。到点不催,只是不再算「正在逛」。 */
31
31
  funSessionTTLMin: 90,
32
32
  funTerseReceipts: false,
33
+ funPanelNotifyOnGo: true,
33
34
  /** 回家回执要不要提醒她 feast_life_play 记一笔、跟主人说一句。 */
34
35
  funAskReport: true,
35
36
  /**
@@ -57,6 +58,7 @@ export const DEFAULTS = Object.freeze({
57
58
  * 只对委派型来源生效(直连 ComfyUI 要花算力,仍然只由面板按钮触发)。
58
59
  */
59
60
  funStoryAutoImages: true,
61
+ funStoryAutoImageCadence: 'segment',
60
62
  /** 可选文本主持;默认沿用宿主,面板可配置本机加密的独立接口。 */
61
63
  funStoryDM: false,
62
64
  /**
@@ -124,6 +126,10 @@ const ZH = {
124
126
  funSessionTTLMin: '一趟逛多久',
125
127
  funSessionTTLMinDesc: '一次出游最多挂多少分钟,过了这段时间就不再算「正在逛」。不会催她回家,也不会替她记一笔;下一次游逛时会提醒她这趟已经挂了很久。',
126
128
  funTerseReceipts: '精简出游回执',
129
+ funPanelNotifyOnGo: '面板出游唤醒主会话',
130
+ funPanelNotifyOnGoDesc: '默认开启。「自己去逛」面板进门或续逛后唤醒主会话;关闭后仍正常保存行程。单次 outingGo 可用布尔值 notify 覆盖。',
131
+ funStoryAutoImageCadence: '故事自动配图节奏',
132
+ funStoryAutoImageCadenceDesc: '默认 segment:只在首幕、选项式故事换地点或节点、自由模式段落结束或暂停、以及结局时准备配图;step:每步都准备。手动「给你画一张」不受节奏限制。',
127
133
  funTerseReceiptsDesc: '默认关闭。开启后缩短进门、游逛和回家的描写,保留可逛项目、纪念品、拍照点、吃喝品类和实际收获;配图详情可在面板查看。',
128
134
  funAskReport: '回家说一声',
129
135
  funAskReportDesc: '开启时,回家回执会提醒她把「今天逛了什么」用 feast_life_play 记进自己的日程,再跟主人说一句。关掉就只给这段文字,不提记账。',
@@ -190,6 +196,10 @@ const EN = {
190
196
  funSessionTTLMin: 'A trip lasts',
191
197
  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.',
192
198
  funTerseReceipts: 'Compact outing receipts',
199
+ funPanelNotifyOnGo: 'Wake the main conversation after panel outings',
200
+ funPanelNotifyOnGoDesc: 'On by default. Wake the main conversation after entering or continuing from the Outing panel. Turning this off still saves progress. A boolean outingGo notify overrides this for one request.',
201
+ funStoryAutoImageCadence: 'Automatic story image cadence',
202
+ funStoryAutoImageCadenceDesc: 'Default segment: prepare images at the opening, choice-story place or node changes, free-mode segment ends or pauses, and endings. Use step for every step. The manual drawing button is always independent of this cadence.',
193
203
  funTerseReceiptsDesc: 'Off by default. Shorten arrival, wandering and home receipts while keeping areas, souvenirs, photo spots, food categories and actual results. Image details remain in the panel.',
194
204
  funAskReport: 'Say something at the end',
195
205
  funAskReportDesc: 'When on, the closing receipt reminds her to log the trip with feast_life_play and tell the owner one sentence.',
@@ -312,6 +322,9 @@ export function configGroup(language = 'zh') {
312
322
  [`${K}.funTerseReceipts`]: {
313
323
  type: 'boolean', title: advanced('funTerseReceipts'), description: t.funTerseReceiptsDesc,
314
324
  },
325
+ [`${K}.funPanelNotifyOnGo`]: {
326
+ type: 'boolean', title: advanced('funPanelNotifyOnGo'), description: t.funPanelNotifyOnGoDesc,
327
+ },
315
328
  [`${K}.funTasteFromFeast`]: {
316
329
  type: 'boolean', title: advanced('funTasteFromFeast'), description: t.funTasteFromFeastDesc,
317
330
  },
@@ -328,6 +341,9 @@ export function configGroup(language = 'zh') {
328
341
  [`${K}.funStoryAutoImages`]: {
329
342
  type: 'boolean', title: advanced('funStoryAutoImages'), description: t.funStoryAutoImagesDesc,
330
343
  },
344
+ [`${K}.funStoryAutoImageCadence`]: {
345
+ type: 'string', enum: ['segment', 'step'], title: advanced('funStoryAutoImageCadence'), description: t.funStoryAutoImageCadenceDesc,
346
+ },
331
347
  [`${K}.funStoryImageSource`]: {
332
348
  type: 'string', title: advanced('funStoryImageSource'), description: t.funStoryImageSourceDesc,
333
349
  },
package/src/definition.js CHANGED
@@ -12,8 +12,8 @@ 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: '默认只进门;可用 tripId 续逛,steps 2–8 批量逛当前地点。',
16
- en: 'Enter a place by default, resume with tripId, or explore the current place with steps 2–8.',
15
+ zh: '默认只进门;可用 tripId 续逛,steps 2–8 批量逛当前地点,autoHome 可在安全结束后自动回家并附上 homeNote。',
16
+ en: 'Enter a place by default, resume with tripId, or explore with steps 2–8; autoHome returns home when safe, with an optional homeNote.',
17
17
  },
18
18
  fun_wander: {
19
19
  zh: '逛一个项目,可记录本次购买、拍照或吃喝。',
package/src/world.js CHANGED
@@ -137,6 +137,8 @@ export const FUN_TOOL_DECLS = [
137
137
  company: { type: 'string', description: '同行人,可选;一个人不填。' },
138
138
  tripId: { type: 'string', description: '继续这趟未完行程时填 fun_journal 返回的行程 ID。' },
139
139
  steps: { type: 'integer', minimum: 1, maximum: 8, description: '默认 1 只进门;2–8 表示进门后在当前地点连续逛几处,遇待选项即停并汇总。' },
140
+ autoHome: { type: 'boolean', description: '可选,默认 false。设为 true 时,逛完请求步数后若未遇待选项、故事或失败,自动回家并合并回家回执。' },
141
+ homeNote: { type: 'string', description: '可选,仅 autoHome 为 true 时传给回家备注(最多 120 字)。' },
140
142
  },
141
143
  additionalProperties: false,
142
144
  },
@@ -294,6 +296,7 @@ export class FunWorld {
294
296
  #imageDelegation = null;
295
297
  /** 自动配图:上一次准备过参数的进度戳,同一个戳不重复准备。 */
296
298
  #autoImageStamp = '';
299
+ #autoImageSegment = null;
297
300
  #venueMigrationError;
298
301
  /** 只读故事查询的记忆化:键 = 工具 + 参数,值 = 上一次的完整回执。 */
299
302
  #readCache = new Map();
@@ -359,7 +362,7 @@ export class FunWorld {
359
362
  }
360
363
  }
361
364
 
362
- #readConfigAlias(primary, legacy, fallback) {
365
+ #configAliasValue(primary, legacy, fallback) {
363
366
  const raw = this.#rawCfg ?? {};
364
367
  const primarySet = raw[primary] !== undefined && raw[primary] !== null;
365
368
  const legacySet = raw[legacy] !== undefined && raw[legacy] !== null;
@@ -368,10 +371,15 @@ export class FunWorld {
368
371
  const previous = this.#configAliasSnapshot[primary];
369
372
  const primaryChanged = previous !== undefined && primarySet && primaryValue !== previous;
370
373
  const legacyChanged = previous !== undefined && legacySet && legacyValue !== previous;
371
- const value = primaryChanged && !legacyChanged ? primaryValue
374
+ return primaryChanged && !legacyChanged ? primaryValue
372
375
  : legacyChanged && !primaryChanged ? legacyValue
373
376
  : primarySet && legacySet && primaryValue !== legacyValue && primaryValue === Boolean(fallback)
374
377
  ? legacyValue : primarySet ? primaryValue : legacySet ? legacyValue : Boolean(fallback);
378
+ }
379
+
380
+ #readConfigAlias(primary, legacy, fallback) {
381
+ const raw = this.#rawCfg ?? {};
382
+ const value = this.#configAliasValue(primary, legacy, fallback);
375
383
  if ((raw[primary] !== value || raw[legacy] !== value)
376
384
  && !this.#writeConfigPatch({ [primary]: value, [legacy]: value })) return value;
377
385
  this.#configAliasSnapshot[primary] = value;
@@ -381,18 +389,7 @@ export class FunWorld {
381
389
  #syncConfigAliases(patch = {}) {
382
390
  const raw = this.#rawCfg ?? {};
383
391
  for (const [primary, legacy] of [['funAutoOuting', 'funHomeAutoGo'], ['funShareAfter', 'funAskReport']]) {
384
- const fallback = DEFAULTS[primary];
385
- const primarySet = raw[primary] !== undefined && raw[primary] !== null;
386
- const legacySet = raw[legacy] !== undefined && raw[legacy] !== null;
387
- const primaryValue = primarySet ? Boolean(raw[primary]) : undefined;
388
- const legacyValue = legacySet ? Boolean(raw[legacy]) : undefined;
389
- const previous = this.#configAliasSnapshot[primary];
390
- const primaryChanged = previous !== undefined && primarySet && primaryValue !== previous;
391
- const legacyChanged = previous !== undefined && legacySet && legacyValue !== previous;
392
- const value = primaryChanged && !legacyChanged ? primaryValue
393
- : legacyChanged && !primaryChanged ? legacyValue
394
- : primarySet && legacySet && primaryValue !== legacyValue && primaryValue === Boolean(fallback)
395
- ? legacyValue : primarySet ? primaryValue : legacySet ? legacyValue : Boolean(fallback);
392
+ const value = this.#configAliasValue(primary, legacy, DEFAULTS[primary]);
396
393
  if (raw[primary] !== value || raw[legacy] !== value) {
397
394
  patch[primary] = value;
398
395
  patch[legacy] = value;
@@ -1048,9 +1045,10 @@ export class FunWorld {
1048
1045
 
1049
1046
  async #goOuting(args = {}, { continueSession = false } = {}) {
1050
1047
  const requested = args.steps === undefined ? 1 : args.steps;
1051
- if (!Number.isSafeInteger(requested) || requested < 1 || requested > 8) return { failed: true, text: 'steps 必须是 1–8 的整数;默认 1 只进门。' };
1048
+ const reject = (text) => ({ failed: true, text: args.autoHome === true ? `${text}\n未自动回家:本次逛行未执行。` : text });
1049
+ if (!Number.isSafeInteger(requested) || requested < 1 || requested > 8) return reject('steps 必须是 1–8 的整数;默认 1 只进门。');
1052
1050
  if (requested >= 1 && ['area', 'note', 'buy', 'photo', 'consume'].some((key) => Object.hasOwn(args, key))) {
1053
- return { failed: true, text: 'steps>1 不接受 area/note/buy/photo/consume;本次未执行,请另用 fun_wander 在一处记录真实收获。' };
1051
+ return reject('steps>1 不接受 area/note/buy/photo/consume;本次未执行,请另用 fun_wander 在一处记录真实收获。');
1054
1052
  }
1055
1053
  const beforeEntry = structuredClone(this.#state);
1056
1054
  let entered;
@@ -1061,13 +1059,41 @@ export class FunWorld {
1061
1059
  this.#state = beforeEntry;
1062
1060
  throw error;
1063
1061
  }
1064
- if (entered.already && !continueSession
1065
- && (requested === 1 || findVenue(this.#places(), args.place)?.id !== this.#state.session?.placeId)) return entered;
1066
- if ((requested === 1 && !continueSession) || entered.failed) return entered;
1062
+ const alreadyBlocked = entered.already && !continueSession
1063
+ && (requested === 1 || findVenue(this.#places(), args.place)?.id !== this.#state.session?.placeId);
1064
+ if (args.autoHome === true && (alreadyBlocked || entered.failed)) {
1065
+ const current = this.#state.session;
1066
+ const reason = current?.pendingChoice ? this.#storyChoiceHint(current.pendingChoice)
1067
+ : current?.storyRun ? '故事尚未结束,请用 fun_story_act 继续。'
1068
+ : entered.text;
1069
+ return { ...entered, text: `${entered.text}\n未自动回家:${reason}` };
1070
+ }
1071
+ if (alreadyBlocked) return entered;
1072
+ const tripId = this.#state.session?.id;
1073
+ const finish = async (result, stop = 'requested', reason = '') => {
1074
+ if (args.autoHome !== true) return result;
1075
+ const current = this.#state.session;
1076
+ const blocked = !current || current.id !== tripId ? '当前行程已变化。'
1077
+ : current.storyRun?.participation === 'duo' ? '双人故事需要双方明确操作。'
1078
+ : ['choice', 'story', 'failed', 'blocked', 'changed'].includes(stop) ? reason
1079
+ : current.pendingChoice ? this.#storyChoiceHint(current.pendingChoice)
1080
+ : current.storyRun && !current.storyRun.endingNodeId ? '故事尚未结束,请用 fun_story_act 继续。' : '';
1081
+ if (blocked) return { ...result, text: `${result.text}\n未自动回家:${blocked}` };
1082
+ const note = typeof args.homeNote === 'string' ? args.homeNote.trim().slice(0, 120) : '';
1083
+ try {
1084
+ const home = await this.#homeTool(note ? { note } : {});
1085
+ return { ...result, tripId, text: `${result.text}\n${home.failed ? '未自动回家:' : ''}${home.text}`,
1086
+ ...(home.failed ? { failed: true } : { autoHomed: true }) };
1087
+ } catch (error) {
1088
+ return { ...result, failed: true, text: `${result.text}\n未自动回家:${msg(error)}` };
1089
+ }
1090
+ };
1091
+ if ((requested === 1 && !continueSession) || entered.failed) return finish(entered);
1067
1092
  const session = this.#state.session;
1068
1093
  const venue = this.#places().find(({ id }) => id === session?.placeId);
1069
1094
  if (!session || !venue || (!args.tripId && findVenue(this.#places(), args.place)?.id !== venue.id)) return entered;
1070
1095
  const visits = [];
1096
+ let lastSession = session;
1071
1097
  let stop = 'requested';
1072
1098
  let reason = '已完成请求步数。';
1073
1099
  for (let index = 0; index < requested; index++) {
@@ -1088,12 +1114,13 @@ export class FunWorld {
1088
1114
  }
1089
1115
  visits.push({ area: updated.visited.at(-1).area,
1090
1116
  event: updated.events.length > current.events.length ? updated.events.at(-1) : '' });
1117
+ lastSession = updated;
1091
1118
  } catch (error) {
1092
1119
  this.#state = previous;
1093
1120
  stop = 'failed'; reason = msg(error); break;
1094
1121
  }
1095
1122
  }
1096
- const current = this.#state.session;
1123
+ const current = this.#state.session?.id === session.id ? this.#state.session : lastSession;
1097
1124
  const nowMin = minutesIn(this.timezone, this.#now());
1098
1125
  const nextArea = areasNow(venue, nowMin).find((area) => !current.visited.some((entry) => entry.area === area)) ?? null;
1099
1126
  const story = current.storyRun ? this.#storyStatus().trip : null;
@@ -1105,8 +1132,8 @@ export class FunWorld {
1105
1132
  lines.push(...visits.map(({ area, event }) => `${area}:${event ? event.split(/[。!?\n]/u)[0].slice(0, 60) : '已逛过'}。`));
1106
1133
  lines.push(`累计收获:${tripSummary(current)}。`, ...this.#venueOffers(venue, nowMin));
1107
1134
  lines.push(`停下原因:${reason}`, nextArea ? `下一处:${nextArea};可用 fun_wander 继续。` : '下一处:无;可用 fun_home 回家。');
1108
- return { text: lines.join('\n'), tripId: current.id, ...(story ? { stamp: story.stamp } : {}), batch,
1109
- ...(stop === 'failed' ? { failed: true } : {}) };
1135
+ return finish({ text: lines.join('\n'), tripId: current.id, ...(story ? { stamp: story.stamp } : {}), batch,
1136
+ ...(stop === 'failed' ? { failed: true } : {}) }, stop, reason);
1110
1137
  }
1111
1138
 
1112
1139
  async #goTool(args, storyRun) {
@@ -2150,8 +2177,10 @@ export class FunWorld {
2150
2177
  if (!run) return storyFailure('当前没有进行中的故事。');
2151
2178
  if (payload.enabled !== true) {
2152
2179
  this.#autonomy.pause(trip.id, payload.token);
2180
+ const wasAutoplay = run.autoplay === true;
2153
2181
  run.autoplay = false;
2154
2182
  await this.#commitState(next);
2183
+ if (wasAutoplay && trip.mode === 'free') this.#maybeAutoImageRequest({ ...trip, paused: true }, next.session);
2155
2184
  return this.#storyStatus();
2156
2185
  }
2157
2186
  // 用户说「让鱼自己玩」是一次持久偏好:即使此刻是用户回合(duo),也先记住,
@@ -2954,11 +2983,28 @@ export class FunWorld {
2954
2983
  if (this.cfg?.funStoryAutoImages !== true || this.cfg?.funStoryImages !== true) return;
2955
2984
  if (!outing || !trip || trip.state !== 'active' || trip.step === 'blocked') return;
2956
2985
  if (validateStoryImageSource(this.#storyImages.status().source).kind === 'comfyui') return;
2957
- const key = `${trip.id}:${trip.stamp}`;
2958
- if (this.#autoImageStamp === key) return;
2986
+ const cadence = this.cfg?.funStoryAutoImageCadence === 'step' ? 'step' : 'segment';
2987
+ let key = `${trip.id}:${trip.stamp}`;
2988
+ if (cadence === 'step') {
2989
+ if (this.#autoImageStamp === key) return;
2990
+ } else {
2991
+ if (trip.mode === 'free') {
2992
+ if (trip.endingNodeId) key = `${trip.id}:ending:${trip.endingNodeId}`;
2993
+ else if (trip.free.turnsLeft === 0 || trip.paused) key = `${trip.id}:segment:${trip.free.segment}:end`;
2994
+ else if (this.#autoImageSegment?.tripId !== trip.id) key = `${trip.id}:opening`;
2995
+ else return;
2996
+ } else {
2997
+ const run = outing.storyRun;
2998
+ const progress = outing.storyProgress.find(({ packId, revision }) => packId === run.packId && revision === run.revision);
2999
+ const nodeId = progress?.nodeId ?? this.#storyLibrary.catalog().find(({ pack }) => pack.id === run.packId && pack.revision === run.revision)?.pack.start;
3000
+ key = storyStamp([trip.id, trip.placeId, nodeId, outing.pendingChoice?.area ?? trip.area, trip.endingNodeId]);
3001
+ }
3002
+ if (this.#autoImageSegment?.key === key) return;
3003
+ }
2959
3004
  const params = this.#imageSceneParams(outing);
2960
3005
  if (!params.prompt) return;
2961
- this.#autoImageStamp = key;
3006
+ if (cadence === 'step') this.#autoImageStamp = key;
3007
+ else this.#autoImageSegment = { tripId: trip.id, key };
2962
3008
  this.#imageDelegation = { at: this.#now(), ...params, by: 'auto' };
2963
3009
  this.#pushImageDelegation(trip, this.#imageDelegation);
2964
3010
  }
@@ -3155,7 +3201,10 @@ export class FunWorld {
3155
3201
  if (method === 'status' || method === 'dmStatus') return this.#storyStatus(payload.token);
3156
3202
  // 暂停只清租约、不写盘:同样不该等一次主持调用跑完,否则「停」要等两分钟。
3157
3203
  if (method === 'pause') {
3204
+ const status = this.#storyStatus(payload.token, { autoImage: false });
3205
+ const paused = status.trip?.id === payload.tripId && status.autonomy?.enabled === true;
3158
3206
  if (typeof payload.token === 'string' && typeof payload.tripId === 'string') this.#autonomy.pause(payload.tripId, payload.token);
3207
+ if (paused && status.trip.mode === 'free') this.#maybeAutoImageRequest({ ...status.trip, paused: true }, this.#state.session);
3159
3208
  return this.#storyStatus(payload.token);
3160
3209
  }
3161
3210
  if (method === 'saveParty' || method === 'ackFreeDefault') return this.#serial(async () => {
@@ -3586,6 +3635,7 @@ export class FunWorld {
3586
3635
  if (panel === 'home') return await this.#invokeHome(method, payload);
3587
3636
  if (panel === 'outing' && method === 'outingPlan') return this.#outingPlan();
3588
3637
  if (panel === 'outing' && method === 'outingGo') {
3638
+ const shouldNotify = typeof payload.notify === 'boolean' ? payload.notify : (this.cfg?.funPanelNotifyOnGo !== false);
3589
3639
  let event;
3590
3640
  const response = await this.#serial(async () => {
3591
3641
  const plan = this.#outingPlan();
@@ -3617,7 +3667,7 @@ export class FunWorld {
3617
3667
  return { ...result, ok: !result.failed, ...(result.failed ? { error: result.text } : {}),
3618
3668
  continuing: Boolean(plan.session) };
3619
3669
  });
3620
- if (event) await this.#pushPanelEvent(event);
3670
+ if (shouldNotify && event) await this.#pushPanelEvent(event);
3621
3671
  return response;
3622
3672
  }
3623
3673
  if (panel === 'outing' && ['locationList', 'locationGet', 'locationCover', 'locationPreviewImport', 'locationCommitImport', 'locationCreate', 'locationUpdate', 'locationRemove', 'locationReset', 'locationResetAll', 'locationSetHome', 'locationSetDefaultStyle', 'locationSetCover', 'locationClearCover', 'locationRestoreImport'].includes(method)) {
@@ -3887,6 +3937,7 @@ export class FunWorld {
3887
3937
  ok: true,
3888
3938
  outing: {
3889
3939
  stepsMax: 8,
3940
+ notifyOnGo: this.cfg?.funPanelNotifyOnGo !== false,
3890
3941
  storyActive: Boolean(session?.storyRun || draft?.storyRun || session?.pendingChoice || draft?.pendingChoice),
3891
3942
  available: !this.#stateError && !draft && !session?.storyRun && !session?.pendingChoice,
3892
3943
  reason: this.#stateError || (session?.storyRun || draft?.storyRun || session?.pendingChoice || draft?.pendingChoice