@shgroup/dsh-serenity-hooks 1.16.2 → 1.16.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/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-serenity-hooks",
3
- "version": "1.16.2",
3
+ "version": "1.16.3",
4
4
  "main": "lib/index.js",
5
5
  "description": "宁静号 ACC harness(Native Cordis 插件):真实 DSH 工具 cc_fs/session/acc_msm/eap/neat/cce/loop + 拦截缝机械约束(safe-mode/路径守卫/会话落盘)。适配 DSH 公开版(0.1.0-rc,deepseek-ai/deepseek-harness)。私有(dsh-external 组织)。",
6
6
  "engines": {
package/lib/index.js CHANGED
@@ -1498,6 +1498,24 @@ const cceTool = defineTool({
1498
1498
  }
1499
1499
  });
1500
1500
  //#endregion
1501
+ //#region src/loop-preset-inherit.ts
1502
+ /**
1503
+ * 解析 loop agent 从父 agent 继承的 preset,并组装创建 setup 钩子。
1504
+ * @param parentCtx - 发起 loop 的 agent 的 scope ctx;无(headless/非 agent 上下文)时为 undefined。
1505
+ * @returns 继承结果:meta 用的 agentPreset 与创建 setup 钩子。
1506
+ */
1507
+ function loopPresetInheritance(parentCtx) {
1508
+ if (parentCtx === void 0) return {};
1509
+ const agentPreset = parentCtx.get("agentPresets")?.composedPreset(parentCtx);
1510
+ if (agentPreset === void 0) return {};
1511
+ return {
1512
+ agentPreset,
1513
+ setup: (childCtx) => {
1514
+ childCtx.get("agentPresets")?.composeFrom(childCtx, parentCtx);
1515
+ }
1516
+ };
1517
+ }
1518
+ //#endregion
1501
1519
  //#region src/loop-ops.ts
1502
1520
  /**
1503
1521
  * loop-ops.ts — acc_loop 纯逻辑层(零 DSH 依赖,可独立单测)
@@ -1587,9 +1605,13 @@ ${resumeNote}
1587
1605
  * model(选)provider/model(如 minimax-cn-coding-plan/MiniMax-M3);缺省读 loop.defaultModel
1588
1606
  * maxRounds(默认 100)轮次上限;每轮等待 agent **无超时**(loop 可永续,agent 工作多久等多久)
1589
1607
  *
1590
- * 机制:ctx.agentLoop.create({provider, model}) 创建专用 agent(进程内),
1608
+ * 机制:ctx.agents.create()(带 setup 钩子)创建专用 agent(进程内),
1591
1609
  * 每轮 followup → agent/status idle → 读 session.events 响应 → 写进度 → stop token 检查 → 续跑。
1592
1610
  * 工厂模式:apply 时闭包捕获插件 ctx(工具 execute 无 ctx 参数)。
1611
+ *
1612
+ * preset 继承:setup 钩子里对子 agent 执行 agentPresets.composeFrom(对齐 subagent 先例),
1613
+ * 使 loop agent 继承发起方会话的 agent preset 工具(read/write/edit 等 preset 层工具)。
1614
+ * agentPresets 是可选服务——无 preset 装配的环境(无 roster 部署)退化为空工具层(历史行为)。
1593
1615
  */
1594
1616
  function agentCwd$1(exec) {
1595
1617
  return (exec.agent?.session)?.header?.cwd ?? process.cwd();
@@ -1629,6 +1651,7 @@ function lastAssistantText(agent) {
1629
1651
  return "";
1630
1652
  }
1631
1653
  /** 创建 loop 工具(闭包捕获插件 ctx → 可访问 ctx.agentLoop) */
1654
+ /** 创建 loop 工具(闭包捕获插件 ctx → 可访问 ctx.agentLoop) */
1632
1655
  function createLoopTool(ctx) {
1633
1656
  return defineTool({
1634
1657
  name: "loop",
@@ -1673,10 +1696,23 @@ function createLoopTool(ctx) {
1673
1696
  const stopToken = newStopToken();
1674
1697
  let progress = readProgress(root, label);
1675
1698
  const startRound = progress ? Math.min(progress.round + 1, maxRounds) : 1;
1676
- const loopAgent = ctx.agentLoop.create(`loop-${label}`, {
1677
- provider,
1678
- model: modelName
1679
- }, { cwd: root });
1699
+ const parentCtx = exec.agent?.ctx;
1700
+ const inherited = loopPresetInheritance(parentCtx);
1701
+ if (!ctx.agents) throw new Error("loop: ctx.agents 不可用");
1702
+ const sessionId = `loop-${label}`;
1703
+ const handle = await ctx.agents.create({
1704
+ sessionId,
1705
+ meta: {
1706
+ cwd: root,
1707
+ ...inherited.agentPreset === void 0 ? {} : { agentPreset: inherited.agentPreset }
1708
+ },
1709
+ agentOptions: {
1710
+ provider,
1711
+ model: modelName
1712
+ },
1713
+ ...inherited.setup === void 0 ? {} : { setup: inherited.setup }
1714
+ });
1715
+ const loopAgent = handle.agent;
1680
1716
  let done = false;
1681
1717
  let lastResponse = progress?.lastResponse ?? "";
1682
1718
  let finalRound = startRound - 1;
@@ -1727,7 +1763,9 @@ function createLoopTool(ctx) {
1727
1763
  updated: (/* @__PURE__ */ new Date()).toISOString(),
1728
1764
  lastResponse
1729
1765
  });
1730
- } finally {}
1766
+ } finally {
1767
+ await handle.dispose().catch(() => {});
1768
+ }
1731
1769
  const { json } = loopProgressPaths(root, label);
1732
1770
  return {
1733
1771
  done,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.16.2",
3
+ "version": "1.16.3",
4
4
  "description": "宁静号 ACC harness — Native Cordis 插件(DeepSeek Harness 运行时)。真实 DSH 工具注册(cc_fs/session/acc_msm 等 9 工具)+ 拦截缝机械约束(safe-mode/路径守卫/会话落盘)+ 系统提示词注入(ACC/CCE/Constraints/SKILL/Session 五块)。适配 DSH 公开版(deepseek-ai/deepseek-harness 0.1.0-rc)。",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -50,6 +50,7 @@
50
50
  "peerDependencies": {
51
51
  "@deepseek-ai/dsh-agent": "^0.1.0-rc.5",
52
52
  "@deepseek-ai/dsh-agent-loop": "^0.1.0-rc.5",
53
+ "@deepseek-ai/dsh-agent-presets": "^0.1.0-rc.5",
53
54
  "@deepseek-ai/dsh-compaction": "^0.1.0-rc.5",
54
55
  "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.5",
55
56
  "@deepseek-ai/dsh-llm": "^0.1.0-rc.5",
@@ -75,6 +76,9 @@
75
76
  "@deepseek-ai/dsh-agent-loop": {
76
77
  "optional": true
77
78
  },
79
+ "@deepseek-ai/dsh-agent-presets": {
80
+ "optional": true
81
+ },
78
82
  "@deepseek-ai/dsh-compaction": {
79
83
  "optional": true
80
84
  }