dsh-fish-home 0.1.1 → 0.1.2

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/lib/host.js +173 -105
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.1.2 — 2026-11-21
2
+
3
+ - 农活工具改成 `batch` / `list` 两个入口:同一轮可以一次提交多种作物的出售、买种和播种,重复请求复用原回执,每轮最多执行两批,避免模型逐格、逐品种循环调用。
4
+ - 鱼鱼窝设置增加「显示我的小菜园」,只控制庭院工具栏的显示,不影响地块、池塘或自动照料。
5
+ - 悬停提示增加命中缓冲,聊天气泡加宽并放大,长句更容易阅读。
6
+ - 修复没有星汐或文本日记时自动把更新当天当成相伴起始日的问题,保留房间存档天数作为兜底。
7
+ - 修复「检查更新」的路由重复拼了一段路径、点了没反应的问题。
8
+ - 保留本地更新脚本的存档备份、回滚和自定义配置保护逻辑。
9
+
1
10
  ## 0.1.1 — 2026-11-20
2
11
 
3
12
  - 回忆簿支持配置 .md / .txt 文件或文件夹;没有星汐插件时可用文本日记和存档起始日计算相伴天数。
package/lib/host.js CHANGED
@@ -95,7 +95,7 @@ const 默认配置 = {
95
95
  睡着不理: true,
96
96
  // 动态现场默认不塞进每一轮 runtime-context;需要时用 fish_home 查明细。
97
97
  每轮注入现场: false,
98
- 上下文策略版本: 2,
98
+ 上下文策略版本: 3,
99
99
  状态变化通知: true,
100
100
  主动生活通知: { milestone: true, wallet: true, scene: true },
101
101
  文本记忆路径: '',
@@ -109,9 +109,23 @@ function 读配置() {
109
109
  const 合 = { ...默认配置, ...(存 && typeof 存 === 'object' ? 存 : {}) }
110
110
  // 0.1.0 曾把现场上下文默认塞进每一轮。升级后强制迁移一次,
111
111
  // 否则旧的 fish-room.json 会把新默认值重新覆盖回 true。
112
- if (Number(存?.上下文策略版本 || 0) < 2) {
112
+ const 上下文迁移 = Number(存?.上下文策略版本 || 0)
113
+ if (上下文迁移 < 2) {
113
114
  合.每轮注入现场 = false
114
- 合.上下文策略版本 = 2
115
+ }
116
+ if (上下文迁移 < 3) {
117
+ // 0.1.1 早期版本在没有星汐日记时把「今天」误写成相伴起始日,
118
+ // 让存档天数兜底看起来像从更新当天重新开始。只有这个自动生成的
119
+ // 近两天日期才清掉;用户在设置里填过的旧日期保留。
120
+ const 今天 = new Intl.DateTimeFormat('sv-SE', { timeZone: 'Asia/Shanghai' }).format(new Date())
121
+ const 旧日 = String(存?.相伴起始日 || '')
122
+ const 今天毫秒 = Date.parse(今天 + 'T00:00:00Z')
123
+ const 旧日毫秒 = Date.parse(旧日 + 'T00:00:00Z')
124
+ const 近两天自动日 = /^\d{4}-\d{2}-\d{2}$/.test(旧日) && Number.isFinite(旧日毫秒) && Math.abs(今天毫秒 - 旧日毫秒) <= 2 * 86400000
125
+ if (近两天自动日 && !String(存?.文本日记路径 || '').trim() && !String(存?.文本记忆路径 || '').trim()) 合.相伴起始日 = ''
126
+ }
127
+ if (上下文迁移 < 3) {
128
+ 合.上下文策略版本 = 3
115
129
  try { fs.mkdirSync(家, { recursive: true }); fs.writeFileSync(配置路, JSON.stringify(合, null, 2), 'utf8') } catch {}
116
130
  }
117
131
  合.开 = 合.开 !== false
@@ -125,20 +139,14 @@ function 读配置() {
125
139
  delete 合.上次醒来招呼
126
140
  合.睡着不理 = 合.睡着不理 !== false
127
141
  合.每轮注入现场 = 合.每轮注入现场 === true
128
- 合.上下文策略版本 = 2
142
+ 合.上下文策略版本 = 3
129
143
  合.状态变化通知 = 合.状态变化通知 !== false
130
144
  合.主动生活通知 = Object.fromEntries(['milestone','wallet','scene'].map(key=>[key,合.主动生活通知?.[key]!==false]))
131
145
  合.文本记忆路径 = String(合.文本记忆路径 || '').trim()
132
146
  合.文本日记路径 = String(合.文本日记路径 || '').trim()
133
147
  合.相伴起始日 = /^\d{4}-\d{2}-\d{2}$/.test(String(合.相伴起始日 || '')) ? String(合.相伴起始日) : ''
134
- if (!合.相伴起始日) {
135
- const now = new Intl.DateTimeFormat('sv-SE', { timeZone: 'Asia/Shanghai' }).format(new Date())
136
- 合.相伴起始日 = now
137
- try {
138
- fs.mkdirSync(家, { recursive: true })
139
- fs.writeFileSync(配置路, JSON.stringify(合, null, 2), 'utf8')
140
- } catch (error) {}
141
- }
148
+ // 没有来源时保持空白,让房间自己的存档天数作为兜底。
149
+
142
150
  合.会话 = String(合.会话 || '').trim()
143
151
  合.令牌 = String(合.令牌 || '').trim()
144
152
  const 秒 = Number(合.心跳秒)
@@ -1452,47 +1460,113 @@ function 起来(ctx, 配置参数 = {}) {
1452
1460
  return lines.join(' ');
1453
1461
  }
1454
1462
 
1463
+ const 每轮农活上限 = 2;
1464
+
1455
1465
  function 农活工具() {
1456
- const 进行中的批量操作 = new Set()
1457
- const rounds = new WeakMap()
1466
+ const operations = ['plant','water','harvest','replant','buy','sell','stock','feed','catch'];
1467
+ const actionFields = {
1468
+ op: {type:'string',enum:operations},
1469
+ item: {type:'string',description:'品种 ID 或中文名。'},
1470
+ count: {type:'integer',minimum:1,maximum:999,description:'数量。收获、浇水、补种和捞鱼默认全部符合条件的。'},
1471
+ 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。'},
1475
+ };
1476
+ let pending = Promise.resolve();
1477
+
1478
+ async function plan(args, catalog) {
1479
+ const {op, zone, bed, kind} = args;
1480
+ const item = string(args.item);
1481
+ const count = args.count ?? (['harvest','water','replant'].includes(op) ? 65 : op==='catch' ? 8 : 1);
1482
+ if (!operations.includes(op)) throw new Error('请选择有效的农活。');
1483
+ if (args.plotId!==undefined) throw new Error('使用品种和数量批量操作,不需要地块编号。');
1484
+ if (!Number.isSafeInteger(count) || count<1 || count>999) throw new Error('数量必须是 1 到 999 的整数。');
1485
+ if (['plant','water','harvest','replant'].includes(op) && count>65) throw new Error('田地操作一次最多 65 格。');
1486
+ if (['stock','catch'].includes(op) && count>8) throw new Error('池塘操作一次最多 8 条。');
1487
+ if (zone!==undefined && !['vegetable','flower'].includes(zone)) throw new Error('请选择菜田或花田。');
1488
+ if (bed!==undefined && ![0,1,2].includes(bed)) throw new Error('菜畦编号为 0 到 2。');
1489
+ if (op==='feed') return {op, route:'feed', payload:{}};
1490
+ if (['water','harvest'].includes(op) && !item) return {op, route:op+'-batch', payload:{count,zone}};
1491
+ if (op==='catch' && !item) return {op, route:'catch-batch', payload:{count}};
1492
+
1493
+ const data = await catalog();
1494
+ const seeds = data.商店 || [], fish = data.鱼 || [], giants = data.giantItems || [];
1495
+ const match = list => list.find(x => x.id===item || x.name===item);
1496
+ if (op==='buy' || op==='sell') {
1497
+ const goods = op==='buy' && kind==='fish' ? fish : op==='buy' && kind==='seed' ? seeds : [...seeds,...fish,...(op==='sell'?giants:[])];
1498
+ const found = match(goods);
1499
+ if (!found) throw new Error('找不到商品 '+item+'。');
1500
+ const category = fish.includes(found) ? 'fish' : giants.includes(found) ? 'giant' : op==='buy' ? 'seed' : 'crop';
1501
+ if (kind && kind!==category) throw new Error(found.name+'的商品分类不符。');
1502
+ if (op==='buy' && count>99) throw new Error('一次可以买 1 到 99 份。');
1503
+ return {op, route:op, name:found.name, payload:{kind:category,id:found.id,数量:count}};
1504
+ }
1505
+ if (op==='stock' || op==='catch') {
1506
+ const species = match(fish);
1507
+ if (!species) throw new Error('请指定有效的鱼种。');
1508
+ return {op, route:op+'-batch', name:species.name, payload:{item:species.id,count}};
1509
+ }
1510
+ const crop = match(seeds);
1511
+ if (!crop) throw new Error('找不到作物 '+item+'。');
1512
+ 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}};
1515
+ }
1516
+ const payload = op==='plant' ? {cropId:crop.id,count,bed} : {item:crop.id,count,zone};
1517
+ return {op, route:op+'-batch', name:crop.name, payload};
1518
+ }
1519
+
1520
+ async function executeAction(action, write) {
1521
+ const {op, route, payload, name} = action;
1522
+ if (op==='replant') {
1523
+ 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};
1545
+ }
1546
+ }
1547
+ const result = await write(route,payload);
1548
+ let 说 = result.say;
1549
+ if (op==='buy') 说 = `买了 ${result.买到.n} 份${name},花费 ${result.花了} 金币。`;
1550
+ if (op==='sell') 说 = `卖了 ${result.卖出.n} 份${name},入账 ${result.得了} 金币。`;
1551
+ if (op==='stock' || op==='catch') 说 = 鱼塘回执(result,op,name);
1552
+ return {ok:true,说,wallet:result.wallet};
1553
+ }
1554
+
1458
1555
  return {
1459
1556
  name:'fish_home_farm',
1460
- description:'批量种田、养鱼与买卖。收熟作物并补种同品种,一次用 replant + item;获准花钱补足种子时加 buyMissing:true,不用先查地、分别收、买、种或查余额。仅收获、浇水或捞鱼,省略 item 一次处理全部,count 可限量。种 10 格用 plant + item + count。list 默认摘要,scope:layout 看 3×3 布局。',
1557
+ description:'种田、养鱼和买卖。执行任务用一次 batch,把所有品种及步骤按顺序放进 actions。先卖、再买种、再播种都放同一批。收获后原地回种用 replant。回执已含结果和余额,完成后直接回复。只查询用 list,无需在操作前后例行查询。每轮最多提交两批。',
1461
1558
  parameters:{type:'object',properties:{
1462
- op:{type:'string',enum:['list','plant','water','harvest','replant','buy','sell','stock','feed','catch']},
1463
- buyMissing:{type:'boolean',description:'仅用于 replant;明确允许花金币时才填 true,按缺少的份数补买。默认只用现有种子。'},
1464
- item:{type:'string',description:'品种 ID 或中文名。'},
1465
- kind:{type:'string',enum:['seed','fish','crop','giant'],description:'商品分类,仅用于买卖。'},
1466
- zone:{type:'string',enum:['vegetable','flower'],description:'批量浇水或收获的分区,省略则处理两区。'},
1467
- bed:{type:'integer',minimum:0,maximum:2,description:'指定 0 到 2 号菜畦,适用于播种,或用 list+layout 看逐格布局。'},
1468
- count:{type:'integer',minimum:1,maximum:999,description:'数量。收获、浇水、补种和捞鱼默认全部符合条件的;播种和放养默认 1。'},
1469
- scope:{type:'string',enum:['farm','pond','layout','all'],description:'list 的查询范围,layout 查看真实 3×3 布局。'},
1559
+ op:{type:'string',enum:['batch','list']},
1560
+ actions:{type:'array',minItems:1,maxItems:16,items:{type:'object',properties:actionFields,required:['op'],additionalProperties:false},description:'batch 的完整操作列表,按顺序执行。多个品种各放一项,数量填 count。'},
1561
+ scope:{type:'string',enum:['farm','pond','layout','all'],description:'list 的查询范围。'},
1562
+ bed:{type:'integer',minimum:0,maximum:2,description:'list + layout 时展开指定菜畦。'},
1470
1563
  },required:['op'],additionalProperties:false},
1471
1564
  output:textOutput,
1472
1565
  async execute(args={}, exec) {
1473
- const {op, zone, bed} = args;
1474
- const item=string(args.item);
1475
- const count=args.count??(['harvest','water','replant'].includes(op)?65:op==='catch'?8:1);
1476
- const operations=['list','plant','water','harvest','replant','buy','sell','stock','feed','catch'];
1566
+ const {op,bed} = args;
1477
1567
  const request = (route,params) => roomRequest('/api/farm'+route,params,8000,exec?.signal);
1478
- const activeTurn=当前轮.get(目标会话());
1479
- if(activeTurn&&!rounds.has(activeTurn))rounds.set(activeTurn,new Set());
1480
- const tried=activeTurn&&rounds.get(activeTurn);
1481
- const once = async (kind,payload,run) => {
1482
- const key=JSON.stringify([kind,Object.fromEntries(Object.entries(payload||{}).sort(([a],[b])=>a.localeCompare(b)))]);
1483
- if(进行中的批量操作.has(key)||tried?.has(key)){
1484
- throw Object.assign(new Error('这项相同的操作本轮已提交,请使用原回执。'),{code:'DUPLICATE_FARM_OPERATION'});
1485
- }
1486
- tried?.add(key);
1487
- 进行中的批量操作.add(key);
1488
- try{return await run()}
1489
- finally{进行中的批量操作.delete(key)}
1490
- };
1491
- const write = (kind,payload) => request('/'+kind,{...payload,requestId:randomUUID(),actor:'dayu'});
1492
- const mutate = (kind,payload) => once(kind,payload,()=>write(kind,payload));
1568
+ const write = (route,payload) => request('/'+route,{...payload,requestId:randomUUID(),actor:'dayu'});
1493
1569
  try {
1494
- if(!operations.includes(op))throw new Error('需要有效的 op。');
1495
- if(!Number.isSafeInteger(count)||count<1||count>999)throw new Error('数量必须是正整数。');
1496
1570
  if(op==='list') {
1497
1571
  if(args.scope!=='layout')return {ok:true,说:farmSummary(await request(''),args.scope)};
1498
1572
  if(bed!==undefined&&![0,1,2].includes(bed))throw new Error('菜畦编号为 0 到 2。');
@@ -1510,69 +1584,54 @@ function 起来(ctx, 配置参数 = {}) {
1510
1584
  }
1511
1585
  return {ok:true,说:lines.join('\n\n')};
1512
1586
  }
1513
- if(op==='feed')return {ok:true,说:(await mutate('feed',{})).say};
1514
- if(args.plotId!==undefined)throw new Error('播种、浇水和收获已改成批量。请用 item、zone 或 count,不需要地块编号。');
1515
- if(['plant','water','harvest','replant'].includes(op)&&count>65)throw new Error('田地操作一次最多 65 格。');
1516
- if(['stock','catch'].includes(op)&&count>8)throw new Error('池塘操作一次最多 8 条。');
1517
- if(['water','harvest'].includes(op)&&!item){
1518
- const result = await mutate(op+'-batch',{count,zone});
1519
- return {ok:true,说:result.say};
1520
- }
1521
- if(op==='catch'&&!item){
1522
- const result=await mutate('catch-batch',{count});
1523
- return {ok:true,说:鱼塘回执(result,'catch')};
1524
- }
1525
- const data=await request('');
1526
- const seeds=data.商店||[], fish=data.鱼||[], giants=data.giantItems||[];
1527
- const match=catalog=>catalog.find(x=>x.id===item||x.name===item);
1528
- if(op==='replant'){
1529
- const crop=match(seeds);
1530
- if(!crop||zone!==undefined||bed!==undefined)throw new Error('收后补种需要一个作物品种,不用填 zone 或 bed。');
1531
- return await once('replant',{item:crop.id,count,buyMissing:args.buyMissing===true},async()=>{
1532
- const harvested=await write('harvest-batch',{item:crop.id,count});
1533
- const plots=harvested.plotIds?.length||0;
1534
- const lines=[harvested.say];
1535
- let wallet=harvested.wallet;
1536
- try{
1537
- const missing=Math.max(0,plots-(wallet.seeds?.[crop.id]||0));
1538
- if(args.buyMissing===true&&missing){
1539
- const bought=await write('buy',{kind:'seed',id:crop.id,数量:missing});
1540
- wallet=bought.wallet;
1541
- lines.push(`补买了 ${bought.买到.n} 份种子,花费 ${bought.花了} 金币。`);
1542
- }
1543
- if((wallet.seeds?.[crop.id]||0)>0&&plots){
1544
- const planted=await write('plant-batch',{cropId:crop.id,count:plots,plotIds:harvested.plotIds});
1545
- wallet=planted.wallet;
1546
- lines.push(planted.say);
1547
- if(planted.count<plots)lines.push(`还有 ${plots-planted.count} 格没有补种。`);
1548
- }else lines.push('背包没有种子,已收获,未补种。');
1549
- }catch(error){lines.push('已收获;补种流程未全部完成:'+error.message);}
1550
- return {ok:true,说:lines.join(' ')+' 余额 '+wallet.coins+' 金币。'};
1551
- });
1552
- }
1553
- if(op==='buy'||op==='sell'){
1554
- const found=match(op==='buy'?(args.kind==='fish'?fish:args.kind==='seed'?seeds:[...seeds,...fish]):[...seeds,...fish,...giants]);
1555
- if(!found)throw new Error('找不到这个商品。用 fish_home 的 price 查看商店。');
1556
- const kind=args.kind||(fish.includes(found)?'fish':giants.includes(found)?'giant':op==='buy'?'seed':'crop');
1557
- if(op==='buy'&&(!['seed','fish'].includes(kind)||count>99))throw new Error('一次可以买 1 到 99 份。');
1558
- const result=await mutate(op,{kind,id:found.id,数量:count});
1559
- const summary=op==='buy'?'买了 '+count+' 份'+found.name+',花费 '+result.花了+' 金币。':'卖了 '+count+' 份'+found.name+',入账 '+result.得了+' 金币。';
1560
- return {ok:true,说:summary+'余额 '+result.wallet.coins+' 金币。'};
1561
- }
1562
- if(op==='catch'||op==='stock'){
1563
- const species=match(fish)?.id;
1564
- if(species){
1565
- const result=await mutate(op+'-batch',{item:species,count});
1566
- return {ok:true,说:鱼塘回执(result,op,match(fish)?.name)};
1587
+ // Keep accepting old single-action requests while the model learns the new schema.
1588
+ const entries = op==='batch' ? args.actions : [args];
1589
+ if (!Array.isArray(entries) || !entries.length || entries.length>16) throw new Error('请在 actions 中填写 1 到 16 项农活。');
1590
+ let catalog;
1591
+ const getCatalog = () => catalog ??= request('');
1592
+ const turn = 当前轮.get(目标会话());
1593
+ const actions = [];
1594
+ for (const [index, entry] of entries.entries()) {
1595
+ try {
1596
+ if (!entry || typeof entry!=='object' || Array.isArray(entry)) throw new Error('请填写操作对象。');
1597
+ if (op==='batch' && Object.keys(entry).some(key=>!Object.hasOwn(actionFields,key))) throw new Error('该项包含不支持的参数。');
1598
+ actions.push(await plan(entry,getCatalog));
1599
+ } catch (error) {
1600
+ throw new Error(op==='batch' ? `第 ${index+1} 项未提交:${error.message}` : error.message);
1567
1601
  }
1568
- throw new Error('请指定有效的鱼种。要捞不限品种的成鱼,可只填写数量。');
1569
1602
  }
1570
- const crop=item?match(seeds):null;
1571
- if((item||op==='plant')&&!crop)throw new Error('请指定有效的种子或作物品种。');
1572
- const payload=op==='plant'?{cropId:crop.id,count,bed}:{item:crop?.id,count,zone};
1573
- return {ok:true,说:(await mutate(op+'-batch',payload)).say};
1603
+ const run = async () => {
1604
+ 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]));
1606
+ const hasNewWork = keys.some(key=>!progress.receipts.has(key));
1607
+ if (hasNewWork && progress.batches>=每轮农活上限) return {ok:false,说:'本轮已执行两次农活操作。请根据已有回执回复,剩余操作下一轮再安排。'};
1608
+ if (hasNewWork) progress.batches++;
1609
+ let lastWallet;
1610
+ const results = [];
1611
+ for (const [index, action] of actions.entries()) {
1612
+ if (exec?.signal?.aborted) break;
1613
+ const key = keys[index];
1614
+ let result = progress.receipts.get(key);
1615
+ const repeated = Boolean(result);
1616
+ if (!repeated) {
1617
+ try { result = await executeAction(action,write); }
1618
+ catch (error) { result = {ok:false,说:error.message}; }
1619
+ progress.receipts.set(key,result);
1620
+ }
1621
+ if (!repeated && result.wallet) lastWallet = result.wallet;
1622
+ const label = action.name ? action.name+':' : '';
1623
+ const receipt = repeated ? '本轮已提交,原回执:'+result.说 : result.说;
1624
+ results.push({ok:result.ok,说:op==='batch'?`${index+1}. ${label}${receipt}`:receipt});
1625
+ }
1626
+ const lines = results.map(row=>row.说);
1627
+ if (results.length<actions.length) lines.push(`已停止,还有 ${actions.length-results.length} 项未提交。`);
1628
+ if (lastWallet && (op==='batch' || ['replant','buy','sell'].includes(op))) lines.push(`余额 ${lastWallet.coins} 金币。`);
1629
+ return {ok:results.length===actions.length&&results.every(row=>row.ok),说:lines.join(op==='batch'?'\n':' ')};
1630
+ };
1631
+ const receipt = pending.then(run);
1632
+ pending = receipt.catch(()=>{});
1633
+ return await receipt;
1574
1634
  } catch (error) {
1575
- if(error.code==='DUPLICATE_FARM_OPERATION')return {ok:true,说:error.message};
1576
1635
  return {ok:false,说:error.message};
1577
1636
  }
1578
1637
  },
@@ -1689,6 +1748,13 @@ function 起来(ctx, 配置参数 = {}) {
1689
1748
  if (typeof agent.ctx.tools?.register==='function') {
1690
1749
  for (const create of [画工具,睡眠工具,鱼鱼窝工具,日常工具,抽卡工具,卡面工具,菜谱工具,走过去工具,农活工具,看一眼工具]) {
1691
1750
  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
+ }
1692
1758
  register(tool.name,()=>agent.ctx.tools.register(tool));
1693
1759
  }
1694
1760
  }
@@ -1741,6 +1807,8 @@ function 起来(ctx, 配置参数 = {}) {
1741
1807
 
1742
1808
  // 会话一醒就把房间时间挂上(这时候才有 agent.ctx.systemPrompt 可挂)
1743
1809
  if (event.type === 'turn/start') {
1810
+ const existing = 当前轮.get(sid);
1811
+ if (existing && existing.turn===event.data?.turn) return;
1744
1812
  当前轮.set(sid, { turn: event.data?.turn, replies: [], direct: false, 身体工具:false })
1745
1813
  挂agent工具(找agent(sid))
1746
1814
  // 「她开始想了」——房间那边收到就冒个气泡,别让人干等
@@ -2446,7 +2514,7 @@ function 起来(ctx, 配置参数 = {}) {
2446
2514
  const 自查更新 = createSelfUpdate({ packageRoot: fileURLToPath(new URL('..', import.meta.url)), diag: 记一笔 })
2447
2515
  // 「查更新」和「一键更新」这两个路由由 selfupdate 自己注册 —— 跟其它五个插件是同一份实现。
2448
2516
  // 准入用同源检查:本机别的网页不该能触发安装。
2449
- 自查更新.register(ctx, 管理前缀 + '/update', (req) => (同源(req) ? null : { 码: 403, 说: '只给本页用' }))
2517
+ 自查更新.register(ctx, 管理前缀, (req) => (同源(req) ? null : { 码: 403, 说: '只给本页用' }))
2450
2518
 
2451
2519
  // 房间本体:插件不带它(三百多兆),所以设置页得告诉人「装没装、去哪下」。
2452
2520
  // 找的路径顺序跟启动时完全一致,不然会出现「界面说装了、启动却说找不到」。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-fish-home",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "鱼鱼窝:把「大肥鱼的小日子」那个 3D 房间接进 DSH —— 房间里打字能送到会话里,会话里回的话、她自己打的字,都顺着事件流回到房间里。",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "engines": {