@kanadego/dsh-heartbeat 1.9.1 → 1.9.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.
Files changed (43) hide show
  1. package/README.md +351 -374
  2. package/client.js +96 -20
  3. package/config/policy.json +4 -3
  4. package/cordis.patch.yml +18 -39
  5. package/dist/{chunk-BQCXYE7N.js → chunk-3MDBU6WY.js} +2 -2
  6. package/dist/{chunk-OYVNWB5G.js → chunk-CUOSICYJ.js} +2 -2
  7. package/dist/{chunk-KOOQOMQY.js → chunk-JDH2LDFS.js} +2 -2
  8. package/dist/chunk-K5Y6JP2B.js +399 -0
  9. package/dist/chunk-K5Y6JP2B.js.map +1 -0
  10. package/dist/{chunk-QOQ7EPZZ.js → chunk-KB5SMG3F.js} +3 -3
  11. package/dist/{chunk-HT57FOEF.js → chunk-TRO4E6WG.js} +164 -35
  12. package/dist/chunk-TRO4E6WG.js.map +1 -0
  13. package/dist/{chunk-WRJCINZ7.js → chunk-WLZSABBH.js} +20 -6
  14. package/dist/chunk-WLZSABBH.js.map +1 -0
  15. package/dist/{chunk-2NB4QILF.js → chunk-XFNCTOW7.js} +2 -2
  16. package/dist/{chunk-ZLV4NMFX.js → chunk-XYYEJK3W.js} +4 -1
  17. package/dist/chunk-XYYEJK3W.js.map +1 -0
  18. package/dist/cli/index.js +10 -10
  19. package/dist/cli/index.js.map +1 -1
  20. package/dist/{inbox-JLT5G7TL.js → inbox-P26DDMWC.js} +3 -3
  21. package/dist/index.d.ts +35 -0
  22. package/dist/index.js +137 -26
  23. package/dist/index.js.map +1 -1
  24. package/dist/{migrate-WDVFHUP7.js → migrate-D4VKAKYT.js} +3 -3
  25. package/dist/{orchestrator-2ZLU7RGE.js → orchestrator-ZPRGVDCB.js} +16 -10
  26. package/dist/{pool-B34NTH6D.js → pool-UTXQJJ5C.js} +3 -3
  27. package/dist/{snapshot-JQDJ346Z.js → snapshot-K5VHETTK.js} +4 -4
  28. package/package.json +83 -83
  29. package/dist/chunk-7TW6DD6Q.js +0 -208
  30. package/dist/chunk-7TW6DD6Q.js.map +0 -1
  31. package/dist/chunk-HT57FOEF.js.map +0 -1
  32. package/dist/chunk-WRJCINZ7.js.map +0 -1
  33. package/dist/chunk-ZLV4NMFX.js.map +0 -1
  34. /package/dist/{chunk-BQCXYE7N.js.map → chunk-3MDBU6WY.js.map} +0 -0
  35. /package/dist/{chunk-OYVNWB5G.js.map → chunk-CUOSICYJ.js.map} +0 -0
  36. /package/dist/{chunk-KOOQOMQY.js.map → chunk-JDH2LDFS.js.map} +0 -0
  37. /package/dist/{chunk-QOQ7EPZZ.js.map → chunk-KB5SMG3F.js.map} +0 -0
  38. /package/dist/{chunk-2NB4QILF.js.map → chunk-XFNCTOW7.js.map} +0 -0
  39. /package/dist/{inbox-JLT5G7TL.js.map → inbox-P26DDMWC.js.map} +0 -0
  40. /package/dist/{migrate-WDVFHUP7.js.map → migrate-D4VKAKYT.js.map} +0 -0
  41. /package/dist/{orchestrator-2ZLU7RGE.js.map → orchestrator-ZPRGVDCB.js.map} +0 -0
  42. /package/dist/{pool-B34NTH6D.js.map → pool-UTXQJJ5C.js.map} +0 -0
  43. /package/dist/{snapshot-JQDJ346Z.js.map → snapshot-K5VHETTK.js.map} +0 -0
package/client.js CHANGED
@@ -199,11 +199,12 @@ window.__ModuleLoader__.load({
199
199
  );
200
200
  }
201
201
 
202
- // ── 素材池 ────────────────────────────────────────────────────
202
+ // ── 素材池(v1.9.3 三版):话题 / 聊天 × 活跃 / 归档,四个按钮各看一类 ──
203
+ // 和画像分区同一套 tab 交互,风格统一;一次只看一类。
203
204
  function SeedsSection() {
204
205
  const [data, setData] = React.useState(null);
205
206
  const [error, setError] = React.useState(null);
206
- const [showArchived, setShowArchived] = React.useState(false);
207
+ const [tab, setTab] = React.useState("topic");
207
208
  const [confirmId, setConfirmId] = React.useState(null);
208
209
  const reload = React.useCallback(() => {
209
210
  rpc("seeds.list").then(setData, (e) => setError(String(e).slice(0, 100)));
@@ -213,8 +214,8 @@ window.__ModuleLoader__.load({
213
214
  if (!data) return React.createElement("div", { style: hintStyle }, "加载中…");
214
215
  const act = (endpoint, id) => rpc(endpoint, { id }).then(reload, (e) => setError(String(e).slice(0, 100)));
215
216
  const row = (s, archived) => React.createElement("div", { key: s.id, style: rowList },
216
- React.createElement("span", { style: { flex: 1, fontSize: 12 } },
217
- "[", s.tag, "/", s.source, "] ", s.text.slice(0, 42), " used:", s.used),
217
+ React.createElement("span", { style: { flex: 1, fontSize: 12, wordBreak: "break-word" } },
218
+ "[", s.tag, "/", s.source, "] ", s.text.slice(0, 60), " used:", s.used),
218
219
  archived
219
220
  ? React.createElement("button", { style: buttonGhost, onClick: () => act("seeds.restore", s.id) }, "恢复")
220
221
  : React.createElement("button", { style: buttonGhost, onClick: () => act("seeds.archive", s.id) }, "归档"),
@@ -222,15 +223,34 @@ window.__ModuleLoader__.load({
222
223
  ? React.createElement("button", { style: { ...buttonStyle, background: "#e5484d" }, onClick: () => { setConfirmId(null); act("seeds.delete", s.id); } }, "确认删除")
223
224
  : React.createElement("button", { style: buttonGhost, onClick: () => setConfirmId(s.id) }, "删除"),
224
225
  );
226
+ const isChat = (s) => (s.category || "topic") === "chat";
227
+ const topics = data.active.filter((s) => !isChat(s));
228
+ const chats = data.active.filter(isChat);
229
+ const arcTopics = data.archived.filter((s) => !isChat(s));
230
+ const arcChats = data.archived.filter(isChat);
231
+ const archived = tab.indexOf("arc") === 0;
232
+ const chat = tab.indexOf("chat") >= 0;
233
+ const list = archived ? (chat ? arcChats : arcTopics) : (chat ? chats : topics);
234
+ const tabButton = (key, label, count) => React.createElement("button", {
235
+ key,
236
+ style: tab === key ? buttonStyle : buttonGhost,
237
+ onClick: () => setTab(key),
238
+ }, label + "(" + count + ")");
225
239
  return React.createElement(
226
240
  "div",
227
241
  null,
228
- React.createElement("div", { style: hintStyle }, "活跃 ", data.active.length, " / ", data.cap, " 条"),
229
- data.active.map((s) => row(s, false)),
230
- data.active.length === 0 ? React.createElement("div", { style: hintStyle }, "(池子是空的——浏览流和画像会慢慢喂养它)") : null,
231
- React.createElement("div", { style: rowStyle },
232
- React.createElement("button", { style: buttonGhost, onClick: () => setShowArchived(!showArchived) }, showArchived ? "收起归档区" : "归档区(" + data.archived.length + ")")),
233
- showArchived ? data.archived.map((s) => row(s, true)) : null,
242
+ React.createElement("div", { style: hintStyle }, "活跃 ", data.active.length, " / ", data.cap, " 条;归档 ", data.archived.length, " 条"),
243
+ React.createElement("div", { style: tabRow },
244
+ tabButton("topic", "话题素材", topics.length),
245
+ tabButton("chat", "聊天素材", chats.length),
246
+ tabButton("arc-topic", "话题·归档", arcTopics.length),
247
+ tabButton("arc-chat", "聊天·归档", arcChats.length)),
248
+ React.createElement("div", { style: hintStyle }, archived
249
+ ? (chat ? "归档的聊天素材:不再被挑中,可以恢复" : "归档的话题素材:不再被挑中,可以恢复")
250
+ : (chat ? "对话里长出来的:说过一次就算用掉" : "浏览流、手写、画像喂进来的:随机挑,可重复用")),
251
+ list.length === 0
252
+ ? React.createElement("div", { style: hintStyle }, archived ? "(这类还没有归档条目)" : "(这类还没有条目)")
253
+ : React.createElement("div", { style: scrollBox }, list.map((s) => row(s, archived))),
234
254
  );
235
255
  }
236
256
 
@@ -303,29 +323,85 @@ window.__ModuleLoader__.load({
303
323
  );
304
324
  }
305
325
 
306
- // ── 画像入口 ──────────────────────────────────────────────────
326
+ // ── 画像入口(v2.0):四个分区 + 引擎室输入 ─────────────────────
327
+ // 一次只看一个分区,条目一条一块、正文自动换行;另给一个只读的
328
+ // 「引擎室输入」视图,直接回答「截断后引擎室到底看到了什么」。
329
+ const PARTITIONS = [
330
+ { key: "interest", label: "兴趣" },
331
+ { key: "projects", label: "进行中" },
332
+ { key: "comm", label: "沟通偏好" },
333
+ { key: "psy", label: "心理" },
334
+ ];
335
+ const entryBox = { borderLeft: "2px solid var(--dsw-alias-border-l2)", paddingLeft: 8, margin: "6px 0" };
336
+ // v1.9.3:分区条目一多就顶到屏幕外,给个固定高度的滚动区。
337
+ const scrollBox = { maxHeight: 320, overflowY: "auto", padding: "4px 6px", border: "1px solid var(--dsw-alias-border-l2)", borderRadius: 6 };
338
+ const groupHead = { fontSize: 12.5, fontWeight: 600, margin: "10px 0 2px" };
339
+ const entryHead = { fontSize: 12, color: "var(--dsw-alias-label-tertiary)", marginBottom: 2, wordBreak: "break-word" };
340
+ const entryBody = { fontSize: 12.5, lineHeight: 1.65, whiteSpace: "pre-wrap", wordBreak: "break-word", color: "var(--dsw-alias-label-secondary)", margin: "2px 0" };
341
+ const tabRow = { display: "flex", flexWrap: "wrap", gap: 6, margin: "6px 0" };
307
342
  function ProfileSection() {
308
343
  const [data, setData] = React.useState(null);
344
+ const [digest, setDigest] = React.useState(null);
345
+ const [tab, setTab] = React.useState("interest");
309
346
  const [error, setError] = React.useState(null);
347
+ const [status, setStatus] = React.useState("");
310
348
  const load = React.useCallback(() => {
311
- rpc("profile.digest").then(setData, (e) => setError(String(e).slice(0, 100)));
349
+ rpc("profile.partitions").then(setData, (e) => setError(String(e).slice(0, 120)));
350
+ rpc("profile.digest").then(setDigest, () => { /* 引擎室输入是附加视图,失败不挡分区 */ });
312
351
  }, []);
313
352
  React.useEffect(() => { load(); }, [load]);
314
353
  const doExport = () => rpc("profile.export").then(
315
- (v) => setData((d) => ({ ...d, exported: v.path })),
316
- (e) => setError(String(e).slice(0, 100)),
354
+ (v) => setStatus("已导出:" + v.path),
355
+ (e) => setError(String(e).slice(0, 120)),
317
356
  );
318
357
  if (error) return React.createElement("div", { style: hintStyle }, "加载失败:" + error);
319
358
  if (!data) return React.createElement("div", { style: hintStyle }, "加载中…");
359
+ const groups = data.partitions || {};
360
+ const group = groups[tab] || { total: 0, valid: 0, entries: [] };
361
+ const entries = group.entries || [];
362
+ const tabButton = (key, label, count) => React.createElement("button", {
363
+ key,
364
+ style: tab === key ? buttonStyle : buttonGhost,
365
+ onClick: () => setTab(key),
366
+ }, count === undefined ? label : label + "(" + count + ")");
367
+ const om = (digest && digest.omitted) || { tact: 0, topic: 0, wander: 0 };
320
368
  return React.createElement(
321
369
  "div",
322
370
  { style: listStyle },
323
- React.createElement("div", null, React.createElement("b", null, "处境切面"), React.createElement("pre", { style: { whiteSpace: "pre-wrap", margin: "2px 0", fontSize: 12 } }, data.tact || "(空)")),
324
- React.createElement("div", null, React.createElement("b", null, "话题切面"), React.createElement("pre", { style: { whiteSpace: "pre-wrap", margin: "2px 0", fontSize: 12 } }, data.topic || "(空)")),
371
+ React.createElement("div", { style: tabRow },
372
+ PARTITIONS.map((p) => tabButton(p.key, p.label, (groups[p.key] || {}).valid || 0)),
373
+ tabButton("__engine", "引擎室输入")),
374
+ tab === "__engine"
375
+ ? React.createElement("div", null,
376
+ React.createElement("div", { style: hintStyle }, digest
377
+ ? "共 " + digest.totalChars + " / " + digest.budgetChars + " 字符(" + (digest.withinBudget ? "在预算内" : "超预算") + ");按预算省略:处境 " + om.tact + " 条、话题 " + om.topic + " 条、兴趣 " + om.wander + " 条"
378
+ : "加载中…"),
379
+ React.createElement("div", { style: scrollBox },
380
+ React.createElement("div", null,
381
+ React.createElement("b", null, "处境切面"),
382
+ React.createElement("div", { style: entryBody }, (digest && digest.tact) || "(空)")),
383
+ React.createElement("div", null,
384
+ React.createElement("b", null, "话题切面"),
385
+ React.createElement("div", { style: entryBody }, (digest && digest.topic) || "(空)")),
386
+ React.createElement("div", null,
387
+ React.createElement("b", null, "兴趣切面"),
388
+ React.createElement("div", { style: entryBody }, (digest && digest.wander) || "(空)"))))
389
+ : React.createElement("div", null,
390
+ React.createElement("div", { style: hintStyle }, "有效 " + group.valid + " 条 / 历史 " + (group.total - group.valid) + " 条(过期条目不进引擎室输入,也不在这里列出)"),
391
+ entries.length === 0
392
+ ? React.createElement("div", { style: hintStyle }, "(这个分区还没有条目)")
393
+ : React.createElement("div", { style: scrollBox }, entries.map((e) => React.createElement("div", { key: e.id || (String(e.topic) + String(e.content).slice(0, 12)), style: entryBox },
394
+ React.createElement("div", { style: entryHead },
395
+ (e.topic || "") + "/" + (e.subTopic || "")
396
+ + " conf " + Number(e.confidence || 0).toFixed(2)
397
+ + (e.temporal ? " " + e.temporal : "")
398
+ + (e.lowActivity ? " 久未验证" : "")
399
+ + (e.updatedAt ? " 更新 " + String(e.updatedAt).slice(0, 10) : "")),
400
+ React.createElement("div", { style: entryBody }, e.content || ""))))),
325
401
  React.createElement("div", { style: rowStyle },
326
402
  React.createElement("button", { style: buttonGhost, onClick: () => { load(); } }, "刷新"),
327
403
  React.createElement("button", { style: buttonGhost, onClick: () => { void doExport(); } }, "导出 Markdown")),
328
- data.exported ? React.createElement("div", { style: hintStyle }, "已导出:" + data.exported) : null,
404
+ status ? React.createElement("div", { style: hintStyle }, status) : null,
329
405
  );
330
406
  }
331
407
 
@@ -339,10 +415,10 @@ window.__ModuleLoader__.load({
339
415
  React.useEffect(() => {
340
416
  rpc("config.get").then(setValue, (e) => setLoadErr(String(e).slice(0, 100)));
341
417
  }, []);
342
- const interval = value && Number(value.intervalMin) > 0 ? Number(value.intervalMin) : 20;
343
- const cap = value && Number(value.maxDailySend) > 0 ? Number(value.maxDailySend) : 3;
418
+ const interval = value && Number(value.intervalMin) > 0 ? Number(value.intervalMin) : 60;
419
+ const cap = value && Number(value.maxDailySend) > 0 ? Number(value.maxDailySend) : 10;
344
420
  const timeInject = value && value.timeInjectMin === 0 ? 0 : (value && Number(value.timeInjectMin) > 0 ? Number(value.timeInjectMin) : 25);
345
- const statusbar = !value || value.statusbar !== false;
421
+ const statusbar = !!value && value.statusbar === true;
346
422
  const idleMode = !!value && value.idleMode === true;
347
423
  const tokenSaver = !!value && value.tokenSaver === true;
348
424
  const psyEnabled = !!value && value.psyEnabled === true;
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "heartbeat": {
3
- "intervalMin": 20,
3
+ "intervalMin": 60,
4
4
  "idleMode": false,
5
5
  "archiveRotatedHome": true
6
6
  },
7
7
  "gate": {
8
- "maxDailySend": 3,
8
+ "maxDailySend": 10,
9
9
  "cooldownMinutes": 30,
10
10
  "quietHours": {
11
11
  "start": "01:00",
@@ -64,7 +64,8 @@
64
64
  "perBeat": 10
65
65
  },
66
66
  "weekly": {
67
- "enabled": true
67
+ "enabled": true,
68
+ "keepReports": 3
68
69
  },
69
70
  "retention": {
70
71
  "envPulseHours": 48,
package/cordis.patch.yml CHANGED
@@ -8,46 +8,25 @@
8
8
  # - id: heartbeat
9
9
  # config:
10
10
  # dataDir: D:/your/workspace/data
11
- # Default: <packageRoot>/data.
11
+ # Default: <DSH_HOME>/heartbeat-data (i.e. ~/.dsh/heartbeat-data), outside the
12
+ # package. Data written by v1.9.1 and earlier sits at <packageRoot>/data and is
13
+ # migrated out automatically on first start (backup, verify, then delete).
12
14
  - insert:
13
15
  - id: heartbeat
14
16
  name: '@kanadego/dsh-heartbeat'
15
17
 
16
- # ── Agent preset heartbeat(0.1.7 声明式预设,v1.7.1)─────────────────
17
- # 0.1.7 起 agentPresets 名册不再挂载文件系统用户根(~/.dsh/.agent-presets),
18
- # 预设改为组合里的 @deepseek-ai/dsh-agent-preset 声明行(与官方 preset-standard
19
- # 同款机制)。内容 = assets/presets/heartbeat/agent.cordis.yml 的移植:
20
- # compaction 组 + 唯一模型工具 tool-web(fetch:false)。
21
- # 刻意没有 persona 行:部署人格(soul card)+ 心跳提示词已够,绝不能让
22
- # "You are a coding agent" 盖掉人格。≤0.1.5 宿主继续走文件系统预设自装。
23
- - insert:
24
- - id: preset-heartbeat
25
- name: '@deepseek-ai/dsh-agent-preset'
26
- config:
27
- id: heartbeat
28
- name: 心跳模式
29
- description: 心跳 agent 专用:仅 web_search + 上下文折叠;无 shell、无文件、无子代理。
30
- order: 20
31
- plugins:
32
- - id: compaction
33
- name: cordis:group
34
- group: true
35
- isolate:
36
- compaction: true
37
- toolResultPruner: true
38
- config:
39
- - id: compaction-basic
40
- name: '@deepseek-ai/dsh-compaction-basic'
41
- - id: command-compact
42
- name: '@deepseek-ai/dsh-command-compact'
43
- - id: tool-result-pruner
44
- name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
45
- config:
46
- thresholdChars: 8192
47
- headChars: 4096
48
- tailChars: 1024
49
- - id: tool-web
50
- name: '@deepseek-ai/dsh-tool-web'
51
- config:
52
- fetch: false
53
- searchTimeoutMs: 60000
18
+ # ── Agent preset heartbeat(改为插件运行时注册,v1.9.2 / issue #2)────────
19
+ # 这里**故意不再**声明 `@deepseek-ai/dsh-agent-preset` 行。那行会让 profile
20
+ # 必须自己能解析该包,而它的 peer 闭包里含着 cordis 自己的装载机制
21
+ # (cordis-plugin-loader / -include / -group):
22
+ # · profile 解析不到 → 整个插件树加载失败(0.1.5-rc.2 实测);
23
+ # · 手工补进 peer 闭包 → 装载机制双实例,之后**任何会话 resume 全部失败**
24
+ # (`prompt section "deployment:persona-prefix" is already registered`,
25
+ # 0.2.0-rc.2 实测)。
26
+ # 两种都在 2026-10-10 被复现(见 issue #2)。现在预设定义活在插件里
27
+ # (src/core/preset-definition.ts),加载时经 `agentPresets.register()` 运行时
28
+ # 注册——declaring plugin 自己提供 definition 正是该 API 的用途;宿主没有这个
29
+ # API 时只记一条审计,绝不让宿主挂掉。老宿主(仍扫名册文件系统用户根)继续由
30
+ # preset-install 自装维持。内容与 assets/presets/heartbeat/agent.cordis.yml 一致:
31
+ # compaction 组 + 唯一模型工具 tool-web(fetch:false);刻意没有 persona 行——
32
+ # 部署人格(soul card)+ 心跳提示词已够,绝不能让 "You are a coding agent" 盖掉人格。
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  loadEncryptedText,
6
6
  saveEncryptedText
7
- } from "./chunk-7TW6DD6Q.js";
7
+ } from "./chunk-K5Y6JP2B.js";
8
8
 
9
9
  // src/profile/inbox.ts
10
10
  import fs from "fs";
@@ -110,4 +110,4 @@ export {
110
110
  inboxHealthCheck,
111
111
  inboxFileExists
112
112
  };
113
- //# sourceMappingURL=chunk-BQCXYE7N.js.map
113
+ //# sourceMappingURL=chunk-3MDBU6WY.js.map
@@ -3,7 +3,7 @@ import {
3
3
  readText,
4
4
  saveJson,
5
5
  writeText
6
- } from "./chunk-7TW6DD6Q.js";
6
+ } from "./chunk-K5Y6JP2B.js";
7
7
  import {
8
8
  atomicWriteFileSync
9
9
  } from "./chunk-WRUTATW4.js";
@@ -477,4 +477,4 @@ export {
477
477
  verifyProfile,
478
478
  rebuildProfile
479
479
  };
480
- //# sourceMappingURL=chunk-OYVNWB5G.js.map
480
+ //# sourceMappingURL=chunk-CUOSICYJ.js.map
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  loadEncryptedText,
6
6
  saveEncryptedText
7
- } from "./chunk-7TW6DD6Q.js";
7
+ } from "./chunk-K5Y6JP2B.js";
8
8
 
9
9
  // src/seeds/pool.ts
10
10
  import path from "path";
@@ -314,4 +314,4 @@ export {
314
314
  restoreSeed,
315
315
  deleteSeed
316
316
  };
317
- //# sourceMappingURL=chunk-KOOQOMQY.js.map
317
+ //# sourceMappingURL=chunk-JDH2LDFS.js.map