dsh-fish-home 0.1.2 → 0.1.3

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
@@ -1,3 +1,15 @@
1
+ ## 0.1.3 — 2026-11-21
2
+
3
+ - 收菜、出售及原地补种可一单完成;卖本批新收的菜或鱼不用先查数量。补种期间给这单留出原地和种子,代理继续照料其它地块。
4
+ - 修复普通聊天未统一计入本地心情和陪伴的问题;提示可区分插件心情与本地兜底,并说明六项数值的来源。
5
+ - 所有作物均支持巨型,菜田按 3×3 判定,花田每朵花成熟时单独判定。普通播种可一单种满并按实际缺口补买;巨型这一步失败不会撤回已完成的鱼塘或农活步骤。
6
+ - 巨型作物按同品种当日售价的 1.8 倍出售,菜田按九份普通菜计价,花田按一份普通花计价。DSH 可查单价,成熟提醒与收获回执按实际收成计数,出售显示到账与余量,不混扣普通收成。
7
+ - 农活查询直接显示总空位,收获失败区分空田、没种该作物和未成熟;同批唯一品种可自动接续放苗。超过本轮写入限制仍可查询,工具不会被卸载。
8
+ - `fish_home status` 一次查询实际位置、活动、身体感受和有效心情;留存未主动推送的近期场景体验。已送达的场景摘要不会在状态和可选的会话现场中再出现。
9
+ - 稍累时,等当前活动结束后会找地方休息;农活结束、手需要清洗时会去洗手。料理动作保持原样,整理厨房不会恢复个人清爽。
10
+ - 修复右上角退出图标的悬停提示空白。
11
+ - 重新生成可独立启动的纯净房间包;通过原更新脚本替换程序,保留已有存档和自定义配置。
12
+
1
13
  ## 0.1.2 — 2026-11-21
2
14
 
3
15
  - 农活工具改成 `batch` / `list` 两个入口:同一轮可以一次提交多种作物的出售、买种和播种,重复请求复用原回执,每轮最多执行两批,避免模型逐格、逐品种循环调用。
package/README.md CHANGED
@@ -78,7 +78,8 @@
78
78
  - **卡册**。fish_home_card 按卡名或 ID 一次看一张图,抽卡和兑换只返回文字。fish_home_draw 加上 op=exchange 可换金币、星辉或指定卡。金币兑换数量填消耗的星尘,星辉兑换数量填要得到的星辉。
79
79
 
80
80
  - **田地布局**。fish_home_farm 的 list 使用 scope=layout 查看菜畦按 3×3 分组的作物。加 bed=0、1 或 2 可看该菜畦每个格子。
81
- - **批量收种**。一次说清作物,用 `op=replant,item=...` 会批量收成熟的同类作物并用背包种子补种;明确允许花金币时再加 `buyMissing=true`,整套流程只需一次工具调用。
81
+ - **批量收种**。用一次 `batch` 交整单:`actions` 只填 `replant` 会收获并原地补种(可用 `item` 指定品种);要顺手卖菜就按 `harvest` → `sell` → `replant` 排。`sell` 省略品种和数量时只卖本批刚入包的作物或成鱼。默认用背包里的种子,允许花金币买种子才填 `buyMissing: true`。回执会写明已完成的步骤和余额。
82
+ - **种满与巨型候选**。普通 `plant` 用 `fill: true` 自动算空位;菜田用 `layout: "giant"` 自动找 3×3,九格同种全熟时有一次 15% 的机会。花田用普通播种,每朵花成熟时独立有 15% 的机会变异。只有获准花金币才加 `buyMissing: true`,按实际可种和库存补买;允许碎地备用才加 `fallback: "normal"`。收、卖、播种可以仍在一批内完成。
82
83
  - **集市**。商店里的「集市行情」和 fish_home 的 market、price 共用售价。每天北京时间零点更新,明日预告也可提前查询。price 可按 kind 或 item 筛选。
83
84
 
84
85
  ## 画架
@@ -138,7 +139,7 @@ Windows 就是 `C:\Users\<你>\.dsh\fish-home-room\`,打开里面要能直接
138
139
 
139
140
  内置房间使用原版蓝色大肥鱼模型和配套动作。
140
141
 
141
- 回忆簿可在 DSH 设置里的「上下文与回忆」填写纯文本记忆路径、日记路径和相伴起始日;逐轮 runtime-context 默认关闭,需要时可按需查询现场,天气、成熟与生活里程碑、消费和场景事件也能分别控制是否通知绑定会话。模型制作:水原镜,MMD 转换与绑定:耶栗Yaki。模型的署名和原始使用规约随房间本体一起下发(房间目录 `dist/models/dayu-mmd/` 里的 `使用规约.txt` 和 `MODEL-CREDITS.md`),请一并保留。
142
+ 回忆簿可在 DSH 设置里的「上下文与回忆」填写纯文本记忆路径、日记路径和相伴起始日;逐轮 runtime-context 默认关闭。`fish_home status` 可一次读到所在位置、活动、身体感受和心情;重要天气变化、成熟与生活里程碑、消费和场景事件仍分别控制是否通知绑定会话。模型制作:水原镜,MMD 转换与绑定:耶栗Yaki。模型的署名和原始使用规约随房间本体一起下发(房间目录 `dist/models/dayu-mmd/` 里的 `使用规约.txt` 和 `MODEL-CREDITS.md`),请一并保留。
142
143
 
143
144
  卡包大部分立绘来源于 B站 UP 主 **ZipZipPipe**,版权归原作者,随游戏一起分发、未作修改。
144
145
 
package/lib/host.js CHANGED
@@ -835,7 +835,7 @@ function 起来(ctx, 配置参数 = {}) {
835
835
  if (快 && 快.pond) 家当.push('池塘 ' + (Number(快.pond.条数) || 0) + '/' + (Number(快.pond.容量) || 8))
836
836
  if (快 && 快.卡册) 家当.push('卡册 ' + (Number(快.卡册.已集) || 0) + '/' + (Number(快.卡册.总) || 0))
837
837
  const 攒 = 家当.length ? (现场 ? '' : '上次同步:') + 家当.join(' · ') + '。' : ''
838
- const 最近 = 生活事件.filter(e => e.sessionId === 目标会话() && Date.now() - e.at < 5 * 60000 && ['milestone','farm'].includes(e.kind)).slice(-2)
838
+ const 最近 = 生活事件.filter(e => e.sessionId === 目标会话() && Date.now() - e.at < 5 * 60000 && !e.notified && ['milestone','farm'].includes(e.kind)).slice(-2)
839
839
  .map((x) => String((x && x.text) || '').trim())
840
840
  .filter(Boolean)
841
841
  .map((t) => (t.length > 24 ? t.slice(0, 24) + '…' : t))
@@ -850,10 +850,12 @@ function 起来(ctx, 配置参数 = {}) {
850
850
  function 状态通知文本(previous, next, oldWeather = '') {
851
851
  const lines = []
852
852
  const after = next?.snapshot || {}
853
- const newWeather = String(after.weather || 房间环境?.weather || '')
854
- if (oldWeather && newWeather && oldWeather !== newWeather) {
855
- const labels = { clear: '晴天', cloudy: '阴天', rain: '下雨', snow: '下雪', storm: '雷雨' }
856
- lines.push('窗外天气变成' + (labels[newWeather] || newWeather) + '。')
853
+ const newWeather = String(after.weather || '')
854
+ const labels = { clear: '晴天', cloudy: '阴天', rain: '下雨', snow: '下雪', storm: '雷雨' }
855
+ const affectsOutdoors = value => ['rain','snow','storm'].includes(value);
856
+ if (Object.hasOwn(labels,oldWeather) && Object.hasOwn(labels,newWeather) && oldWeather !== newWeather &&
857
+ (affectsOutdoors(oldWeather)||affectsOutdoors(newWeather))) {
858
+ lines.push(affectsOutdoors(newWeather) ? '窗外天气变了:'+labels[newWeather]+'。' : '窗外的雨雪停了。');
857
859
  }
858
860
  return lines
859
861
  }
@@ -896,6 +898,33 @@ function 起来(ctx, 配置参数 = {}) {
896
898
  return '当前安排:'+[地点名字[activity?.room],label].filter(Boolean).join(' · ')+'。';
897
899
  }
898
900
 
901
+ function 身体简报(live) {
902
+ const lines=[活动简报(live.activity,live.observation,live.presence)];
903
+ const observation=live.observation;
904
+ const fresh = value => Number.isFinite(value?.at)&&Date.now()-value.at<36000;
905
+ if (lines[0]==='活动:闲着。') lines[0]='当前安排:闲着。';
906
+ if (fresh(live.presence) && live.presence.visible && observation?.activityId===live.activity?.id &&
907
+ ['moving','blocked'].includes(observation?.phase) && fresh(observation)) {
908
+ const dest=地点名字[live.activity?.room];
909
+ if (dest) lines.push((observation.phase==='moving'?'正在去':'暂时没走到')+dest+',安排是'+String(live.activity.label||'').slice(0,30)+'。');
910
+ }
911
+ const feelings=[];
912
+ const {energy,satiety,hygiene}=live.needs||{};
913
+ if (Number.isFinite(energy)&&energy<55) feelings.push(energy<35?'很累':'有点累');
914
+ if (Number.isFinite(satiety)&&satiety<54) feelings.push(satiety<40?'饿了':'有点饿');
915
+ if (Number.isFinite(hygiene)&&hygiene<65) feelings.push(hygiene<35?'想洗漱':'想洗洗手');
916
+ if (Number.isFinite(energy)&&Number.isFinite(satiety)&&Number.isFinite(hygiene)&&!feelings.length) feelings.push('状态还好');
917
+ if (Number.isFinite(live.mood)) {
918
+ const source=live.mood来源==='feiyu-mood'?'(鱼的心情)':live.mood来源==='local'?'(本地)':'';
919
+ feelings.push('心情 '+Math.round(live.mood)+'/100'+source);
920
+ }
921
+ if (feelings.length) lines.push('身体:'+feelings.join(',')+'。');
922
+ const scene=最近场景?.sid===目标会话() && Date.now()-最近场景.at<SCENE_TTL_MS ? 最近场景.text : '';
923
+ const recent=scene || live.recentBodyActivity;
924
+ if (recent) lines.push('刚才:'+String(recent).trim().slice(0,100).replace(/[。!?]+$/,'')+'。');
925
+ return lines.join('');
926
+ }
927
+
899
928
  // 房间时间 + 画架工具,都挂在绑定的那间会话上(跟心情插件一样按 agent 实例记)
900
929
  const 上下文挂着 = new Map() // scoped registrations and their disposers
901
930
  function 画工具() {
@@ -986,12 +1015,12 @@ function 起来(ctx, 配置参数 = {}) {
986
1015
  function 鱼鱼窝工具() {
987
1016
  return {
988
1017
  name: 'fish_home',
989
- description: '鱼鱼窝的生活数据。what 的可选范围:status(当前地点和活动)、farm(田里种的、还有多久熟、剩什么种子和收成)、pond(池塘几条鱼、什么鱼、多久能捞)、cards(卡册集了多少、还差哪几张、哪几张还没到珠光)、pity(卡池保底和下一抽概率,不花金币)、price(完整价目,可按类别 kind 或品名 item 筛选)、market(今天和明天的行情摘要)、wallet(正式存档的当前金币、星尘和星辉)、today(今天做过什么)、weather(庭院当前天气)、forecast(设置地区的三天预报)、all(全看一遍)。',
1018
+ description: '鱼鱼窝的生活数据。what 的可选范围:status(实际地点、身体感受、心情和一条近期身体经历)、farm(田里种的、还有多久熟、剩什么种子和收成)、pond(池塘几条鱼、什么鱼、多久能捞)、cards(卡册集了多少、还差哪几张、哪几张还没到珠光)、pity(卡池保底和下一抽概率,不花金币)、price(完整价目,可按类别 kind 或品名 item 筛选)、market(今天和明天的行情摘要)、wallet(正式存档的当前金币、星尘和星辉)、today(今天做过什么)、weather(庭院当前天气)、forecast(设置地区的三天预报)、all(全看一遍)。',
990
1019
  parameters: {
991
1020
  type: 'object',
992
1021
  properties: {
993
1022
  what: { type: 'string', enum: ['status','farm','pond','cards','pity','wallet','price','market','today','weather','forecast','all'], description:'要看哪一块' },
994
- kind: {type:'string',enum:['crop','flower','fish','all'],description:'价目类别,省略时列出全部'},
1023
+ kind: {type:'string',enum:['crop','flower','fish','giant','all'],description:'价目类别。giant 查巨型作物,省略时列出普通商品。'},
995
1024
  item: {type:'string',description:'价目查询可填一个品名或 ID'},
996
1025
  },
997
1026
  required: ['what'],
@@ -1026,6 +1055,14 @@ function 起来(ctx, 配置参数 = {}) {
1026
1055
  }
1027
1056
  if (要==='market'||要==='price') {
1028
1057
  try {
1058
+ if(args.kind==='giant'){
1059
+ const {market,giantItems=[]}=await roomRequest('/api/farm',undefined,8000,exec?.signal);
1060
+ const query=String(args.item||'').trim().toLowerCase();
1061
+ const matches=giantItems.filter(item=>!query||item.id.includes(query)||item.name.toLowerCase().includes(query));
1062
+ if(!matches.length)return {ok:false,说:'没有匹配的巨型作物。'};
1063
+ const lines=matches.map(item=>`${item.name} · 今日售 ${item.sellPrice} / 明日售 ${item.tomorrowSellPrice} 金币`);
1064
+ return {ok:true,说:[`巨型作物单份售价(${market.today.date})`,...lines].join('\n')};
1065
+ }
1029
1066
  const {market}=await roomRequest('/api/farm/market',undefined,8000,exec?.signal);
1030
1067
  const lines=[market.today.date+' · '+market.today.note,market.tomorrow.date+' 预告 · '+market.tomorrow.note];
1031
1068
  if (要==='market'&&!args.item&&!args.kind) return {ok:true,说:lines.join('\n')};
@@ -1069,36 +1106,33 @@ function 起来(ctx, 配置参数 = {}) {
1069
1106
  }
1070
1107
  if (要 === 'status' || 要 === 'all') {
1071
1108
  try {
1072
- const live = await roomRequest('/api/life/activity', undefined, 5000, exec?.signal);
1073
- const 说 = 活动简报(live.activity, live.observation, live.presence);
1109
+ const live = await roomRequest('/api/life/activity?status=1', undefined, 5000, exec?.signal);
1110
+ const 说 = 身体简报(live);
1074
1111
  if (要 === 'status') return {ok:true, 说};
1075
1112
  段.push(说);
1076
1113
  } catch (error) {
1077
1114
  if (要 === 'status') return {ok:false, 说: '暂时读不到鱼鱼窝的当前状态。'};
1078
1115
  }
1079
1116
  }
1117
+ if (要 === 'farm' || 要 === 'all') {
1118
+ try {
1119
+ const data = await roomRequest('/api/farm', undefined, 8000, exec?.signal);
1120
+ const 说 = farmSummary(data, 'farm');
1121
+ if (要 === 'farm') return {ok:true,说};
1122
+ 段.push(说);
1123
+ } catch (error) {
1124
+ const 说 = '暂时读不到当前田地:' + error.message;
1125
+ if (要 === 'farm') return {ok:false,说};
1126
+ 段.push(说);
1127
+ }
1128
+ }
1080
1129
  const 快 = 最近状态 && 最近状态.snapshot
1081
1130
  if (!快 && 段.length) return {ok:true, 说:段.join('\n\n')};
1082
1131
  if (!快) return { ok: false, 说: '房间那边还没报上来,等一下再问。' }
1083
- const 田 = 快.farm || null
1084
1132
  const 池 = 快.pond || null
1085
1133
  const 册 = 快.卡册 || null
1086
1134
 
1087
1135
  if (要 === 'all')段.push('行情可用 fish_home 的 market 或 price 单独查看。');
1088
- if ((要 === 'farm' || 要 === 'all') && 田) {
1089
- const 行 = []
1090
- 行.push(`田里 ${田.planted} 块种着,${田.空地} 块空着`)
1091
- for (const 批 of 田.作物 || []) {
1092
- const 名 = String(批.cropId || '')
1093
- 行.push(` ${名} ${批.块数} 块` + (批.熟 ? `,熟了 ${批.熟} 块` : `,最快还要 ${批.最快分钟} 分钟`))
1094
- }
1095
- const 种 = Object.entries(田.种子 || {}).map(([k, v]) => `${k}×${v}`).join('、')
1096
- const 收 = Object.entries(田.收成 || {}).map(([k, v]) => `${k}×${v}`).join('、')
1097
- 行.push(`背包种子:${种 || '空'};收成:${收 || '空'}`)
1098
- 行.push(田.autoCare ? '开启了自动照料;启用自动播种时,空地会用背包种子补种。' : '自动照料关闭。')
1099
- if (Number(田.ready)) 行.push('可用 fish_home_farm 一次收获。item 可指定品种。');
1100
- 段.push(行.join('\n'))
1101
- }
1102
1136
  if ((要 === 'pond' || 要 === 'all') && 池) {
1103
1137
  const 行 = [`池塘 ${池.条数}/${池.容量} 条`]
1104
1138
  for (const 鱼 of 池.鱼 || []) 行.push(` ${鱼.species}:` + (鱼.ready ? '能捞了' : `还要 ${鱼.剩余分钟} 分钟`))
@@ -1341,8 +1375,11 @@ function 起来(ctx, 配置参数 = {}) {
1341
1375
  redirect: 'error', signal: signal ? AbortSignal.any([signal, deadline]) : deadline,
1342
1376
  ...(params === undefined ? {} : { method: 'POST', headers: {'content-type':'application/json'}, body: JSON.stringify(params) }),
1343
1377
  });
1378
+ if (route==='/api/farm/plant-giant-batch' && response.status===404) {
1379
+ throw new Error('当前房间还没更新到支持整块 3×3 播种的版本;这一步没有买种或播种。');
1380
+ }
1344
1381
  const result = await response.json();
1345
- if (result.ok === false || !response.ok) throw Object.assign(new Error(result.say || result.说 || result.error || '鱼鱼窝没有完成这次操作。'),{code:result.code});
1382
+ if (result.ok === false || !response.ok) throw Object.assign(new Error(result.say || result.说 || result.error || '鱼鱼窝没有完成这次操作。'),{code:result.code,result});
1346
1383
  return result;
1347
1384
  }
1348
1385
 
@@ -1416,11 +1453,23 @@ function 起来(ctx, 配置参数 = {}) {
1416
1453
  return Object.entries(items).map(([id,n])=>id+'×'+n).join('、')||'空';
1417
1454
  }
1418
1455
 
1456
+ function saleReceipt(result) {
1457
+ const {id,name,n,unitPrice} = result.卖出;
1458
+ const summary = `卖了 ${n} 份${name},入账 ${result.得了} 金币。`;
1459
+ if (!id.startsWith('giant_')) return summary;
1460
+ const remaining = result.wallet?.giants?.[id.slice('giant_'.length)] || 0;
1461
+ return `${summary} 每份 ${unitPrice} 金币,背包还剩 ${remaining} 份${name}。`;
1462
+ }
1463
+
1419
1464
  function farmSummary(data,scope='all') {
1420
1465
  const farm=data.farm;
1421
1466
  const lines=[];
1422
1467
  if(scope!=='pond') {
1423
1468
  const groups=new Map();
1469
+ const giants=farm.giants || [];
1470
+ const giantNames=new Map((data.giantItems || []).map(item=>[item.cropId,item.name]));
1471
+ const giantName=cropId=>giantNames.get(cropId) || `巨型${cropId}`;
1472
+ const occupiedByGiants=new Set(giants.flatMap(item=>item.plotIds));
1424
1473
  let emptyVegetables=0,emptyFlowers=0;
1425
1474
  for(const plot of farm.plots){
1426
1475
  if(!plot.cropId){
@@ -1428,14 +1477,22 @@ function 起来(ctx, 配置参数 = {}) {
1428
1477
  else emptyVegetables++;
1429
1478
  continue;
1430
1479
  }
1480
+ if (occupiedByGiants.has(plot.id)) continue;
1431
1481
  const group=groups.get(plot.cropId)||{growing:0,ready:0};
1432
1482
  if(plot.ready)group.ready++;
1433
1483
  else group.growing++;
1434
1484
  groups.set(plot.cropId,group);
1435
1485
  }
1436
- lines.push('菜田空 '+emptyVegetables+' 格,花田空 '+emptyFlowers+' 格。');
1486
+ lines.push(`总空位 ${emptyVegetables+emptyFlowers} 格:菜田 ${emptyVegetables}、花田 ${emptyFlowers}。`);
1437
1487
  if(groups.size)lines.push([...groups].map(([id,g])=>id+' '+g.growing+' 格生长、'+g.ready+' 格成熟').join(';')+'。');
1438
- lines.push('种子:'+inventoryLine(data.seeds)+'。收成:'+inventoryLine({...data.crops,...Object.fromEntries(Object.entries(data.giants||{}).map(([id,n])=>['giant_'+id,n]))})+'。');
1488
+ if (giants.length) {
1489
+ const counts=new Map();
1490
+ for (const giant of giants) counts.set(giant.cropId,(counts.get(giant.cropId)||0)+1);
1491
+ const mature=[...counts].map(([id,n])=>`${giantName(id)}×${n}`).join('、');
1492
+ lines.push(`田里已长成:${mature},共占 ${occupiedByGiants.size} 格。`);
1493
+ }
1494
+ const inventory=Object.entries(data.giants||{}).map(([id,n])=>`${giantName(id)}×${n}`).join('、');
1495
+ lines.push(`种子:${inventoryLine(data.seeds)}。普通收成:${inventoryLine(data.crops)}。巨型收成:${inventory||'空'}。`);
1439
1496
  if(farm.autoCare&&data.自动播种开启)lines.push('自动补种已开,鱼鱼会使用背包种子种空地。');
1440
1497
  }
1441
1498
  if(scope!=='farm'){
@@ -1466,28 +1523,44 @@ function 起来(ctx, 配置参数 = {}) {
1466
1523
  const operations = ['plant','water','harvest','replant','buy','sell','stock','feed','catch'];
1467
1524
  const actionFields = {
1468
1525
  op: {type:'string',enum:operations},
1469
- item: {type:'string',description:'品种 ID 或中文名。'},
1526
+ item: {type:'string',description:'品种 ID 或中文名。replant 省略时处理成熟作物;sell 省略时卖本批新收获,指定巨型收成用巨型品名或 kind=giant 加普通品名;stock 省略时接同一批中唯一买过的鱼种。'},
1470
1527
  count: {type:'integer',minimum:1,maximum:999,description:'数量。收获、浇水、补种和捞鱼默认全部符合条件的。'},
1471
1528
  kind: {type:'string',enum:['seed','fish','crop','giant'],description:'仅用于买卖。'},
1472
- zone: {type:'string',enum:['vegetable','flower'],description:'仅用于浇水和收获。播种按品种自动选菜田或花田。'},
1473
- bed: {type:'integer',minimum:0,maximum:2,description:'仅用于指定 0 到 2 号菜畦播种。'},
1474
- buyMissing: {type:'boolean',description:'仅用于 replant。用户允许花金币补买种子时才填 true。'},
1529
+ zone: {type:'string',enum:['vegetable','flower'],description:'限制浇水和收获范围。播种自动选对应田地。'},
1530
+ bed: {type:'integer',minimum:0,maximum:2,description:'可指定 0 到 2 号菜畦播种、浇水或收获。'},
1531
+ buyMissing: {type:'boolean',description:'用于 plant 或 replant。允许花金币时填 true,只买实际种得下且缺的种子。'},
1532
+ fill: {type:'boolean',description:'仅用于普通 plant;种满用 true,按执行时的空格数播种,省略 count。'},
1533
+ layout: {type:'string',enum:['giant'],description:'只用于菜田的 plant,giant 会找完整 3×3。花田普通播种,每朵花成熟时独立判定。'},
1534
+ fallback: {type:'string',enum:['normal'],description:'仅用于 layout=giant。用户明确接受没整区时普通种,才填 normal。'},
1475
1535
  };
1476
1536
  let pending = Promise.resolve();
1477
1537
 
1478
1538
  async function plan(args, catalog) {
1479
- const {op, zone, bed, kind} = args;
1539
+ const {op, zone, bed, kind, layout, fallback} = args;
1480
1540
  const item = string(args.item);
1541
+ if (layout!==undefined&&(op!=='plant'||layout!=='giant')||fallback!==undefined&&(layout!=='giant'||fallback!=='normal')) {
1542
+ throw new Error('整块和备用布局只能用于 plant;layout 填 giant,允许普通备用时 fallback 填 normal。');
1543
+ }
1481
1544
  const count = args.count ?? (['harvest','water','replant'].includes(op) ? 65 : op==='catch' ? 8 : 1);
1545
+ if (args.fill!==undefined&&(typeof args.fill!=='boolean'||op!=='plant'||layout==='giant'||(args.fill&&args.count!==undefined))) throw new Error('种满用普通 plant 加 fill=true,不用填写 count。');
1546
+ if (args.buyMissing!==undefined&&(typeof args.buyMissing!=='boolean'||!['plant','replant'].includes(op))) throw new Error('buyMissing 只用于播种或补种。');
1482
1547
  if (!operations.includes(op)) throw new Error('请选择有效的农活。');
1483
1548
  if (args.plotId!==undefined) throw new Error('使用品种和数量批量操作,不需要地块编号。');
1484
1549
  if (!Number.isSafeInteger(count) || count<1 || count>999) throw new Error('数量必须是 1 到 999 的整数。');
1485
1550
  if (['plant','water','harvest','replant'].includes(op) && count>65) throw new Error('田地操作一次最多 65 格。');
1486
1551
  if (['stock','catch'].includes(op) && count>8) throw new Error('池塘操作一次最多 8 条。');
1487
1552
  if (zone!==undefined && !['vegetable','flower'].includes(zone)) throw new Error('请选择菜田或花田。');
1488
- if (bed!==undefined && ![0,1,2].includes(bed)) throw new Error('菜畦编号为 0 到 2。');
1553
+ if (bed!==undefined && (![0,1,2].includes(bed)||zone==='flower'||!['plant','water','harvest','replant'].includes(op))) throw new Error('请指定 0 到 2 号菜畦;花田不按菜畦编号。');
1489
1554
  if (op==='feed') return {op, route:'feed', payload:{}};
1490
- if (['water','harvest'].includes(op) && !item) return {op, route:op+'-batch', payload:{count,zone}};
1555
+ if (op==='sell' && !item) {
1556
+ if (args.count!==undefined || kind!==undefined) throw new Error('只卖本批收获时不用填 count 或 kind;要指定数量或分类请填品种。');
1557
+ return {op,route:'sell-current',payload:{}};
1558
+ }
1559
+ if (op==='replant' && !item) {
1560
+ if (zone!==undefined || bed!==undefined) throw new Error('原地补种不需要指定田地。');
1561
+ return {op,route:op,payload:{count,buyMissing:args.buyMissing===true}};
1562
+ }
1563
+ if (['water','harvest'].includes(op) && !item) return {op, route:op+'-batch', payload:{count,zone,bed}};
1491
1564
  if (op==='catch' && !item) return {op, route:'catch-batch', payload:{count}};
1492
1565
 
1493
1566
  const data = await catalog();
@@ -1495,7 +1568,9 @@ function 起来(ctx, 配置参数 = {}) {
1495
1568
  const match = list => list.find(x => x.id===item || x.name===item);
1496
1569
  if (op==='buy' || op==='sell') {
1497
1570
  const goods = op==='buy' && kind==='fish' ? fish : op==='buy' && kind==='seed' ? seeds : [...seeds,...fish,...(op==='sell'?giants:[])];
1498
- const found = match(goods);
1571
+ const found = op==='sell' && kind==='giant'
1572
+ ? match(giants) || giants.find(giant=>giant.cropId===match(seeds)?.id)
1573
+ : match(goods);
1499
1574
  if (!found) throw new Error('找不到商品 '+item+'。');
1500
1575
  const category = fish.includes(found) ? 'fish' : giants.includes(found) ? 'giant' : op==='buy' ? 'seed' : 'crop';
1501
1576
  if (kind && kind!==category) throw new Error(found.name+'的商品分类不符。');
@@ -1507,54 +1582,114 @@ function 起来(ctx, 配置参数 = {}) {
1507
1582
  if (!species) throw new Error('请指定有效的鱼种。');
1508
1583
  return {op, route:op+'-batch', name:species.name, payload:{item:species.id,count}};
1509
1584
  }
1510
- const crop = match(seeds);
1511
- if (!crop) throw new Error('找不到作物 '+item+'。');
1512
1585
  if (op==='replant') {
1513
- if (zone!==undefined || bed!==undefined) throw new Error('收后补种会用原地块,不用指定田地。');
1514
- return {op, route:op, name:crop.name, payload:{item:crop.id,count,buyMissing:args.buyMissing===true}};
1586
+ if (zone!==undefined || bed!==undefined) throw new Error('原地补种不需要指定田地。');
1587
+ const crop = item && match(seeds);
1588
+ if (item && !crop) throw new Error('商店里没有「'+item+'」这个作物品种。');
1589
+ return {op, route:op, name:crop?.name, payload:{item:crop?.id,count,buyMissing:args.buyMissing===true}};
1590
+ }
1591
+ const crop = match(seeds);
1592
+ if (!crop && layout==='giant') return {op,route:'invalid-giant',payload:{item,bed},localError:`${bed===undefined?'巨型播种':'菜畦 '+bed}:商店里没有「${item||'未指定品种'}」这种种子,这一步没买种或播种。`};
1593
+ if (!crop) throw new Error('商店里没有「'+item+'」这种作物;这与田里是否成熟无关。');
1594
+ if (op==='plant' && (zone && zone!==(Number(crop.tier)===5?'flower':'vegetable') || bed!==undefined&&Number(crop.tier)===5)) {
1595
+ throw new Error(`${crop.name}要种在${Number(crop.tier)===5?'花田,不指定菜畦':'菜田'}。`);
1596
+ }
1597
+ if (layout==='giant' && Number(crop.tier)!==5) {
1598
+ if (args.count!==undefined && count!==9) return {op,route:'invalid-giant',payload:{item,bed},localError:'菜田 3×3 固定种 9 格,count 可以省略。'};
1599
+ if (!crop.巨大) return {op,route:'invalid-giant',payload:{item,bed},localError:crop.name+'在当前房间不能长成巨型。可尝试:'+seeds.filter(seed=>seed.巨大).map(seed=>seed.name).join('、')+'。'};
1600
+ return {op,route:'plant-giant-batch',name:crop.name,payload:{cropId:crop.id,bed,buyMissing:args.buyMissing===true,fallback}};
1515
1601
  }
1516
- const payload = op==='plant' ? {cropId:crop.id,count,bed} : {item:crop.id,count,zone};
1602
+ const payload = op==='plant' ? {cropId:crop.id,count,bed,...(args.fill?{fill:true}:{}),...(args.buyMissing?{buyMissing:true}:{})} : {item:crop.id,count,zone,bed};
1517
1603
  return {op, route:op+'-batch', name:crop.name, payload};
1518
1604
  }
1519
1605
 
1520
- async function executeAction(action, write) {
1606
+ // Previous harvests in this batch provide exact plot IDs for a subsequent replant.
1607
+ async function harvestForBatch(payload, write, work) {
1608
+ const before = await work.farm();
1609
+ const harvested = await write('harvest-batch',payload);
1610
+ work.update(harvested);
1611
+ const plots = new Map(before.plots.map(plot=>[plot.id,plot]));
1612
+ const claimed = harvested.harvestedPlots || (harvested.plotIds||[]).map(id=>({id,cropId:payload.item||plots.get(id)?.cropId}));
1613
+ for (const {id,cropId} of claimed) if (cropId) work.harvested.set(id,cropId);
1614
+ harvested.claimed = claimed;
1615
+ return harvested;
1616
+ }
1617
+
1618
+ async function executeAction(action, write, work, harvestOptions) {
1521
1619
  const {op, route, payload, name} = action;
1620
+ if (action.localError) return {ok:false,说:action.localError,wallet:work.wallet};
1621
+ if (route==='sell-current') {
1622
+ if (!work.lots.size) return {ok:false,说:'本批没有新收获可在此步出售,现有库存没有扣减。',wallet:work.wallet};
1623
+ const lines=[];
1624
+ let ok=true;
1625
+ const lots=[...work.lots.values()];
1626
+ for (const {id,kind,name,quantity} of lots) {
1627
+ try {
1628
+ const sold=await write('sell',{id,kind,数量:quantity});
1629
+ work.update(sold);
1630
+ work.consume(id,sold.卖出.n);
1631
+ lines.push(saleReceipt(sold));
1632
+ } catch(error) {
1633
+ ok=false; work.update(error.result||{}); lines.push(`${name}没有卖出:${error.message}`);
1634
+ }
1635
+ }
1636
+ if (lots.some(lot=>lot.kind==='fish')) lines.push('卖完后鱼篓成鱼:'+inventoryLine(work.wallet?.fish)+'。');
1637
+ return {ok,说:lines.join(' '),wallet:work.wallet};
1638
+ }
1522
1639
  if (op==='replant') {
1523
1640
  const {item,count,buyMissing} = payload;
1524
- const harvested = await write('harvest-batch',{item,count});
1525
- const plots = harvested.plotIds?.length || 0;
1526
- let wallet = harvested.wallet;
1527
- const lines = [harvested.say];
1528
- try {
1529
- const missing = Math.max(0,plots-(wallet.seeds?.[item]||0));
1530
- if (buyMissing && missing) {
1531
- const bought = await write('buy',{kind:'seed',id:item,数量:missing});
1532
- wallet = bought.wallet;
1533
- lines.push(`补买了 ${bought.买到.n} 份种子,花费 ${bought.花了} 金币。`);
1534
- }
1535
- if (plots && (wallet.seeds?.[item]||0)>0) {
1536
- const planted = await write('plant-batch',{cropId:item,count:plots,plotIds:harvested.plotIds});
1537
- wallet = planted.wallet;
1538
- lines.push(planted.say);
1539
- if (planted.count<plots) lines.push(`还有 ${plots-planted.count} 格没有补种。`);
1540
- } else if (plots) lines.push('背包没有种子,已收获,未补种。');
1541
- return {ok:true,说:lines.join(' '),wallet};
1542
- } catch (error) {
1543
- lines.push('已收获,补种未全部完成:'+error.message);
1544
- return {ok:false,说:lines.join(' '),wallet};
1641
+ const prior = [...work.harvested].filter(([,crop])=>!item || crop===item);
1642
+ const lines = [];
1643
+ let wallet, allOk = true;
1644
+ if (!prior.length) {
1645
+ const result = await harvestForBatch({item,count,forReplant:true},write,work);
1646
+ work.collect(result.collectedItems);
1647
+ lines.push(result.say); wallet=result.wallet;
1648
+ }
1649
+ const exact = prior.length ? prior.slice(0,count) : [...work.harvested].filter(([,crop])=>!item || crop===item);
1650
+ const groups = new Map();
1651
+ for (const [id,crop] of exact) {
1652
+ if (!groups.has(crop)) groups.set(crop,[]);
1653
+ groups.get(crop).push(id);
1545
1654
  }
1655
+ wallet ??= work.wallet;
1656
+ if (!groups.size) return {ok:false,说:lines.join(' ')||'没有可补种的地块。',wallet};
1657
+ for (const [crop,plotIds] of groups) {
1658
+ try {
1659
+ const missing=Math.max(0,plotIds.length-(wallet.seeds?.[crop]||0));
1660
+ if (buyMissing && missing) {
1661
+ const bought=await write('buy',{kind:'seed',id:crop,数量:missing}); work.update(bought); wallet=bought.wallet;
1662
+ lines.push(`补买了 ${bought.买到.n} 份种子,花费 ${bought.花了} 金币。`);
1663
+ }
1664
+ if (!(wallet.seeds?.[crop]>0)) {
1665
+ allOk=false; lines.push(`收成已入账,缺少种子,${plotIds.length} 格未补种。`); continue;
1666
+ }
1667
+ const planted=await write('plant-batch',{cropId:crop,count:plotIds.length,plotIds});
1668
+ work.update(planted); wallet=planted.wallet; lines.push(planted.say);
1669
+ for (const id of planted.plotIds||[]) work.harvested.delete(id);
1670
+ if (planted.count<plotIds.length) { allOk=false; lines.push(`还有 ${plotIds.length-planted.count} 格未补种。`); }
1671
+ } catch(error) { work.update(error.result || {}); wallet=work.wallet; allOk=false; lines.push('收成已入账,补种未全部完成:'+error.message); }
1672
+ }
1673
+ return {ok:allOk,说:lines.join(' '),wallet};
1546
1674
  }
1547
- const result = await write(route,payload);
1675
+ const result = op==='harvest' && harvestOptions.forReplant
1676
+ ? await harvestForBatch({...payload,...harvestOptions},write,work)
1677
+ : await write(route,{...payload,...harvestOptions});
1678
+ work.update(result);
1548
1679
  let 说 = result.say;
1549
- if (op==='buy') 说 = `买了 ${result.买到.n} 份${name},花费 ${result.花了} 金币。`;
1550
- if (op==='sell') 说 = `卖了 ${result.卖出.n} 份${name},入账 ${result.得了} 金币。`;
1680
+ if (op==='buy') 说 = `买了 ${result.买到.n} 份${name}${payload.kind==='fish'?'鱼苗':'种子'},花费 ${result.花了} 金币。`;
1681
+ if (op==='sell') {
1682
+ work.consume(payload.id,result.卖出.n);
1683
+ 说 = saleReceipt(result);
1684
+ }
1685
+ work.collect(result.collectedItems);
1551
1686
  if (op==='stock' || op==='catch') 说 = 鱼塘回执(result,op,name);
1552
- return {ok:true,说,wallet:result.wallet};
1687
+ return {ok:true,说,wallet:result.wallet,claimed:result.claimed};
1553
1688
  }
1554
1689
 
1555
1690
  return {
1556
1691
  name:'fish_home_farm',
1557
- description:'种田、养鱼和买卖。执行任务用一次 batch,把所有品种及步骤按顺序放进 actions。先卖、再买种、再播种都放同一批。收获后原地回种用 replant。回执已含结果和余额,完成后直接回复。只查询用 list,无需在操作前后例行查询。每轮最多提交两批。',
1692
+ description:'种田、养鱼和买卖。用一次 batch 交全单。收、卖、原地补种可按 actions 顺序填 harvest → sell → replant;replant 会用本批刚收的地。sell 不填品种和数量,只卖本批刚收获或刚捞的,免查背包。只收后补种时,actions 里放一项 replant(可填 item)。种满某片田用 plant + fill=true,不查地、不猜数量;菜田巨型候选用 plant + layout=giant 找 3×3。花田普通播种,每朵花成熟时独立有 15% 概率变异。获准花钱才用 buyMissing,不另加 buy。stock 可用同批唯一买过的鱼种。没空区直接回报,允许普通备选才填 fallback=normal。以回执为准,无需重复查询。',
1558
1693
  parameters:{type:'object',properties:{
1559
1694
  op:{type:'string',enum:['batch','list']},
1560
1695
  actions:{type:'array',minItems:1,maxItems:16,items:{type:'object',properties:actionFields,required:['op'],additionalProperties:false},description:'batch 的完整操作列表,按顺序执行。多个品种各放一项,数量填 count。'},
@@ -1565,13 +1700,15 @@ function 起来(ctx, 配置参数 = {}) {
1565
1700
  async execute(args={}, exec) {
1566
1701
  const {op,bed} = args;
1567
1702
  const request = (route,params) => roomRequest('/api/farm'+route,params,8000,exec?.signal);
1568
- const write = (route,payload) => request('/'+route,{...payload,requestId:randomUUID(),actor:'dayu'});
1703
+
1569
1704
  try {
1570
1705
  if(op==='list') {
1571
1706
  if(args.scope!=='layout')return {ok:true,说:farmSummary(await request(''),args.scope)};
1572
1707
  if(bed!==undefined&&![0,1,2].includes(bed))throw new Error('菜畦编号为 0 到 2。');
1573
- const {beds}=await request('/layout'+(bed===undefined?'':'?bed='+bed));
1574
- const lines=[];
1708
+ const {beds,flowers}=await request('/layout'+(bed===undefined?'':'?bed='+bed));
1709
+ const emptyVeg=beds.reduce((n,field)=>n+field.blocks.reduce((sum,b)=>sum+b.empty,0),0);
1710
+ const emptyFlowers=flowers?.filter(p=>!p.cropId).length;
1711
+ const lines=[bed===undefined?(flowers?`总空位 ${emptyVeg+emptyFlowers} 格:菜田 ${emptyVeg}、花田 ${emptyFlowers}。`:`菜田共空 ${emptyVeg} 格。`):`菜畦 ${bed} 共空 ${emptyVeg} 格。`];
1575
1712
  for(const field of beds){
1576
1713
  const blocks=field.blocks.map((block,i)=>{
1577
1714
  const marks=block.crops.map(c=>c.name+'×'+c.count);
@@ -1582,6 +1719,7 @@ function 起来(ctx, 配置参数 = {}) {
1582
1719
  });
1583
1720
  lines.push('bed-'+field.bed+'\n'+blocks.join('\n'));
1584
1721
  }
1722
+ if (flowers) lines.push('花田:'+flowers.map(p=>p.cropId?(p.giant?'巨型 ':'')+p.cropId:'空').join(' · '));
1585
1723
  return {ok:true,说:lines.join('\n\n')};
1586
1724
  }
1587
1725
  // Keep accepting old single-action requests while the model learns the new schema.
@@ -1595,17 +1733,51 @@ function 起来(ctx, 配置参数 = {}) {
1595
1733
  try {
1596
1734
  if (!entry || typeof entry!=='object' || Array.isArray(entry)) throw new Error('请填写操作对象。');
1597
1735
  if (op==='batch' && Object.keys(entry).some(key=>!Object.hasOwn(actionFields,key))) throw new Error('该项包含不支持的参数。');
1598
- actions.push(await plan(entry,getCatalog));
1736
+ let normalized=entry;
1737
+ if (entry.op==='stock' && !string(entry.item)) {
1738
+ const purchased=new Set(actions.filter(step=>step.op==='buy'&&step.payload.kind==='fish').map(step=>step.payload.id));
1739
+ if (purchased.size!==1) throw new Error('放苗请指定鱼种;同一批前面只买了一种鱼苗时可以省略。');
1740
+ normalized={...entry,item:[...purchased][0]};
1741
+ }
1742
+ const action=await plan(normalized,getCatalog);
1743
+ if (action.route==='sell-current' && !actions.some(prev=>['harvest','replant','catch'].includes(prev.op))) {
1744
+ throw new Error('只卖本批收获时,请在 sell 前安排收获或捞鱼;要卖背包库存请指定品种和数量。');
1745
+ }
1746
+ actions.push(action);
1599
1747
  } catch (error) {
1600
- throw new Error(op==='batch' ? `第 ${index+1} 项未提交:${error.message}` : error.message);
1748
+ throw new Error(op==='batch' ? `整批未执行:第 ${index+1} 项:${error.message.replace(/[。;]+$/,'')}。前面的项目也没有提交。` : error.message);
1601
1749
  }
1602
1750
  }
1603
1751
  const run = async () => {
1604
1752
  const progress = turn ? (turn.farmWork ??= {batches:0,receipts:new Map()}) : {batches:0,receipts:new Map()};
1605
- const keys = actions.map(({route,payload})=>JSON.stringify([route,payload]));
1753
+ const keys = actions.map(({route,payload},index)=>JSON.stringify([route,payload,...(route==='sell-current'
1754
+ ? [actions.slice(0,index).filter(action=>['harvest','replant','catch'].includes(action.op)).map(action=>[action.route,action.payload])]
1755
+ : [])]));
1606
1756
  const hasNewWork = keys.some(key=>!progress.receipts.has(key));
1607
1757
  if (hasNewWork && progress.batches>=每轮农活上限) return {ok:false,说:'本轮已执行两次农活操作。请根据已有回执回复,剩余操作下一轮再安排。'};
1608
- if (hasNewWork) progress.batches++;
1758
+ let committed=false;
1759
+ const write=async (route,payload)=>{
1760
+ const result=await request('/'+route,{...payload,requestId:randomUUID(),actor:'dayu'});
1761
+ if (result.code!=='ALREADY_FULL') committed=true;
1762
+ return result;
1763
+ };
1764
+ let currentFarm;
1765
+ const work = {harvested:new Map(),lots:new Map(),wallet:null,
1766
+ collect(items){for (const item of items||[]) {
1767
+ const lot=this.lots.get(item.id);
1768
+ this.lots.set(item.id,{...item,quantity:(lot?.quantity||0)+item.quantity});
1769
+ }},consume(id,quantity){
1770
+ const lot=this.lots.get(id);
1771
+ if (!lot) return;
1772
+ lot.quantity-=quantity;
1773
+ if (lot.quantity<=0) this.lots.delete(id);
1774
+ },async farm(){
1775
+ if (!currentFarm) { const data=await getCatalog(); currentFarm=data.farm; this.wallet ??= data.wallet||data; }
1776
+ return currentFarm;
1777
+ },update(data){
1778
+ if (data.farm) currentFarm=data.farm;
1779
+ if (data.wallet) this.wallet=data.wallet;
1780
+ }};
1609
1781
  let lastWallet;
1610
1782
  const results = [];
1611
1783
  for (const [index, action] of actions.entries()) {
@@ -1614,16 +1786,31 @@ function 起来(ctx, 配置参数 = {}) {
1614
1786
  let result = progress.receipts.get(key);
1615
1787
  const repeated = Boolean(result);
1616
1788
  if (!repeated) {
1617
- try { result = await executeAction(action,write); }
1618
- catch (error) { result = {ok:false,说:error.message}; }
1789
+ const harvestOptions = {};
1790
+ if (action.op==='harvest') {
1791
+ const next=actions.slice(index+1);
1792
+ if (next.some(step=>step.op==='replant' &&
1793
+ (!step.payload.item || !action.payload.item || step.payload.item===action.payload.item))) harvestOptions.forReplant=true;
1794
+ const giant=next.find(step=>step.route==='plant-giant-batch');
1795
+ if (giant) harvestOptions.forGiant={cropId:giant.payload.cropId,bed:giant.payload.bed};
1796
+ }
1797
+ try { result = await executeAction(action,write,work,harvestOptions); }
1798
+ catch (error) { work.update(error.result || {}); result = {ok:false,说:error.message,wallet:error.result?.wallet}; }
1619
1799
  progress.receipts.set(key,result);
1620
1800
  }
1801
+ if (repeated && result.claimed) {
1802
+ const farm=await work.farm();
1803
+ const empty=new Set(farm.plots.filter(plot=>!plot.cropId).map(plot=>plot.id));
1804
+ for (const {id,cropId} of result.claimed) if (cropId&&empty.has(id)) work.harvested.set(id,cropId);
1805
+ }
1621
1806
  if (!repeated && result.wallet) lastWallet = result.wallet;
1622
1807
  const label = action.name ? action.name+':' : '';
1623
1808
  const receipt = repeated ? '本轮已提交,原回执:'+result.说 : result.说;
1624
1809
  results.push({ok:result.ok,说:op==='batch'?`${index+1}. ${label}${receipt}`:receipt});
1625
1810
  }
1811
+ if (committed) progress.batches++;
1626
1812
  const lines = results.map(row=>row.说);
1813
+ if (op==='batch' && results.some(row=>!row.ok)) lines.unshift('各项独立结算,已完成的操作已入账;未完成的见下。');
1627
1814
  if (results.length<actions.length) lines.push(`已停止,还有 ${actions.length-results.length} 项未提交。`);
1628
1815
  if (lastWallet && (op==='batch' || ['replant','buy','sell'].includes(op))) lines.push(`余额 ${lastWallet.coins} 金币。`);
1629
1816
  return {ok:results.length===actions.length&&results.every(row=>row.ok),说:lines.join(op==='batch'?'\n':' ')};
@@ -1748,13 +1935,6 @@ function 起来(ctx, 配置参数 = {}) {
1748
1935
  if (typeof agent.ctx.tools?.register==='function') {
1749
1936
  for (const create of [画工具,睡眠工具,鱼鱼窝工具,日常工具,抽卡工具,卡面工具,菜谱工具,走过去工具,农活工具,看一眼工具]) {
1750
1937
  const tool = create();
1751
- if (tool.name==='fish_home_farm' && 当前轮.get(target)?.farmWork?.batches>=每轮农活上限) {
1752
- const off = entry.off们.get(tool.name);
1753
- if (typeof off==='function') {
1754
- try { off(); entry.off们.delete(tool.name); } catch {}
1755
- }
1756
- continue;
1757
- }
1758
1938
  register(tool.name,()=>agent.ctx.tools.register(tool));
1759
1939
  }
1760
1940
  }
@@ -2227,7 +2407,7 @@ function 起来(ctx, 配置参数 = {}) {
2227
2407
  let 体
2228
2408
  try { 体 = await 读体(req) } catch (error) { return 回错(res, 400, 'BAD_BODY', String((error && error.message) || error)) }
2229
2409
  if (!体 || 体.schema !== PET_STATE_SCHEMA) return 回错(res, 400, 'BAD_SCHEMA', '这份数据的版本不对')
2230
- const 旧天气 = String(房间环境?.weather || '')
2410
+ const 旧天气 = String(最近状态?.snapshot?.weather || '')
2231
2411
  收下环境(体.snapshot)
2232
2412
  if(typeof 体.room?.url==='string'){
2233
2413
  try{
@@ -2294,13 +2474,15 @@ function 起来(ctx, 配置参数 = {}) {
2294
2474
  try {
2295
2475
  await agent.followup({id:randomUUID(),role:'user',source:{kind:'fish-home-life'},
2296
2476
  content:[{type:'text',text:'【鱼鱼窝】'+事件.text.slice(0,300)}]})
2477
+ 事件.notified = true
2297
2478
  } catch (error) {
2298
2479
  return 回错(res,502,'SEND_FAILED','生活事件没送进会话')
2299
2480
  } finally {互动送达中.delete(id)}
2300
2481
  }
2301
2482
  }
2302
- if (事件.kind === 'scene' && 配置.开 && 目标会话() && Math.abs(Date.now() - 事件.at) < SCENE_TTL_MS) {
2303
- 最近场景 = { sid: targetSession, at: 事件.at, text: 事件.text.slice(0, 240) }
2483
+ if (事件.kind === 'scene' && 配置.开 && targetSession && Math.abs(Date.now() - 事件.at) < SCENE_TTL_MS) {
2484
+ // A scene already delivered as a message does not need a second copy in context or status.
2485
+ if (事件.at >= (最近场景?.at||0)) 最近场景 = 事件.notified ? null : { sid: targetSession, at: 事件.at, text: 事件.text.slice(0, 240) }
2304
2486
  }
2305
2487
  生活事件.push(事件)
2306
2488
  if (生活事件.length > 200) 生活事件.shift()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-fish-home",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "鱼鱼窝:把「大肥鱼的小日子」那个 3D 房间接进 DSH —— 房间里打字能送到会话里,会话里回的话、她自己打的字,都顺着事件流回到房间里。",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "engines": {