dsh-galatea 0.3.11 → 0.4.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/index.js +34 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import z from '@deepseek-ai/schemastery';
|
|
|
16
16
|
import { renderIndex, dataRoot, listEntries } from './lib/store.js';
|
|
17
17
|
import { remember, recall } from './lib/tools.js';
|
|
18
18
|
import { makeBeatTool, snapshotAgents } from './lib/beat-tool.js';
|
|
19
|
-
import { loadState, noteUserMessage, stateFile } from './lib/heartbeat-runner.js';
|
|
19
|
+
import { loadState, noteUserMessage, stateFile, tick } from './lib/heartbeat-runner.js';
|
|
20
20
|
import { DEFAULTS } from './lib/heartbeat.js';
|
|
21
21
|
|
|
22
22
|
/** Cordis 插件名。 */
|
|
@@ -66,6 +66,11 @@ export const Config = z.object({
|
|
|
66
66
|
.default(DEFAULTS.quietRounds)
|
|
67
67
|
.description('连续这么多轮没开口,就强制说一次。0 = 关掉这个保底。关掉的话,它可能安静到让你以为坏了。')
|
|
68
68
|
.volatile(),
|
|
69
|
+
autoBeatMinutes: z
|
|
70
|
+
.number()
|
|
71
|
+
.default(0)
|
|
72
|
+
.description('每隔多少分钟自己跑一次心跳。0 = 关(默认)。开着的话,它会按自己判断的节奏记下决定 —— 但这一版还不会真的发消息出去。想验证它是不是在动,看心跳账本里有没有新记录。')
|
|
73
|
+
.volatile(),
|
|
69
74
|
});
|
|
70
75
|
|
|
71
76
|
/** 需要宿主注入的服务。 */
|
|
@@ -182,4 +187,32 @@ export function apply(ctx, config) {
|
|
|
182
187
|
} else {
|
|
183
188
|
console.warn('[galatea] 宿主没有 ctx.on,cooldown 不会生效。');
|
|
184
189
|
}
|
|
190
|
+
|
|
191
|
+
// ── 自动心跳 ────────────────────────────────────────────
|
|
192
|
+
// 手动档(galatea_beat)能证明判定链路通,但它证明不了「它自己会动」。
|
|
193
|
+
// 定时器补的就是这一段:到点了自己跑一次,把决定记进账本。
|
|
194
|
+
//
|
|
195
|
+
// **这一步只算不发。**
|
|
196
|
+
// 真的「开口」(构造一条消息、叫醒某个会话)还没接 —— 那一步一错,
|
|
197
|
+
// 就是真的发消息打扰人,不该和「证明定时器活着」混在同一版里。
|
|
198
|
+
// 想确认它在动,看心跳账本里有没有新记录就够了。
|
|
199
|
+
//
|
|
200
|
+
// 默认关(autoBeatMinutes = 0):一个会自己转的东西,不该在装上的那一刻就开始转。
|
|
201
|
+
const everyMin = Number(raw.autoBeatMinutes ?? 0);
|
|
202
|
+
if (Number.isFinite(everyMin) && everyMin > 0) {
|
|
203
|
+
if (ctx && typeof ctx.setInterval === 'function') {
|
|
204
|
+
const ms = Math.max(60_000, everyMin * 60_000);
|
|
205
|
+
ctx.setInterval(() => {
|
|
206
|
+
try {
|
|
207
|
+
tick({});
|
|
208
|
+
} catch (err) {
|
|
209
|
+
// 定时器抛出去会打断整个宿主,所以在这里兜住,但要说出来
|
|
210
|
+
console.warn('[galatea] 自动心跳失败:', err && err.message);
|
|
211
|
+
}
|
|
212
|
+
}, ms);
|
|
213
|
+
console.log(`[galatea] 自动心跳已开:每 ${everyMin} 分钟跑一次(只算不发)`);
|
|
214
|
+
} else {
|
|
215
|
+
console.warn('[galatea] 宿主没有 setInterval,自动心跳没接上。');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
185
218
|
}
|