dsh-trellis 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -44,18 +44,21 @@ dsh plugin --profile headless add file:C:/path/to/dsh-trellis
44
44
 
45
45
  `file:` 插件会作为 profile 内的 pnpm 快照安装;拉取源码更新后,尤其是版本新增文件时,需要先 remove 再 add 刷新该 profile。
46
46
 
47
- 配套要求:项目的 Trellis 平台需包含 dsh(`trellis init --dsh`,见 Trellis-DeepSeekHarness 适配分支),且 `.trellis/scripts` 需包含读取原生 `DSH_SESSION_ID` 的适配(已含在同一分支)。插件以 DSH `0.1.0-rc.8` 作为开发/测试基线;Host 功能的 peer dependency 下限仍是 `rc.6`,用于兼容已安装的旧 profile,Web 配置卡片则只在具备 settings/client surface 的 rc.8 profile 中加载。
48
-
49
- ### DSH rc.8 对齐说明
50
-
51
- - 已采用:command lifecycle 的 `recordInput`、command attachment envelope 的 fail-closed 输入检查、`subagent/end` 的 run/provider/final-output 元数据、rc.8 的 report-before-settlement 与 idle-parent 原生唤醒语义。
52
- - 已接入:Host `dsh-trellis` settings namespace 与 `dsh.client` 浏览器卡片。保存值写入 DSH 的 `settings.yaml` 用户层,并实时重挂插件 runtime;rc.6 不具备该服务时自动退回原有 loader 配置,不影响 Host 插件加载。
53
- - 保持可选:`trellis_wait` 仍是“父会话还在当前轮里、需要明确同步点”时的工具;已经 yield 的父会话直接由 DSH 原生 settlement notice 唤醒。
54
- - 暂不接入:Agent Teams 在 rc.8 仍位于 `packages/experimental` 且不随正式 npm family 发布。Trellis 不应为此引入私有依赖;等它进入公开稳定面后再评估共享 task board / mailbox 映射。
55
-
56
- ## 配置
57
-
58
- DSH rc.8 Web profile 直接打开“设置 → 插件 → 插件配置 → Trellis 工作流”。保存内容进入该 DSH_HOME 的 `settings.yaml`,优先级高于 profile 组合层并立即生效。
47
+ 配套要求:项目的 Trellis 平台需包含 dsh(`trellis init --dsh`,见 Trellis-DeepSeekHarness 适配分支),且 `.trellis/scripts` 需包含读取原生 `DSH_SESSION_ID` 的适配(已含在同一分支)。Host peer 范围显式覆盖 DSH `0.1.0-rc.6+`、`0.1.1-rc.1+`、`0.1.2-alpha.1+`、`0.1.3-alpha.1+` 与 `0.1.5-alpha.1+` 五条已知预发布线,避免 npm 的 prerelease 语义把新版 Host 误判为不兼容;本仓开发与回归基线固定在 `0.1.5-alpha.2`。Host 侧 Settings 桥同时兼容旧版包级 helper 与当前 provider 方法,Web 配置卡片只在具备 settings/client surface 的 profile 中加载。
48
+
49
+ ### DSH 0.1.5-alpha.2 对齐说明
50
+
51
+ - 已适配:Session V3 通过 `eventAt()` / `snapshotEvents()` 读取可见事件,并保留旧 session collection 回退;插件不直接读取磁盘会话日志,因此不需要自行迁移 V3 文件格式。
52
+ - 已核对:插件不依赖 0.1.5 移除的 `ctx.agent` 或可构造 `Inbox`;pre-step 从事件载荷取得 agent,工具从 `exec.agent` 取得调用方,待处理消息只使用 `agent.inbox` 当前公开的 `nextStep`、`prepend`、`replace` 与 `remove`。
53
+ - 已采用:command lifecycle 的 `recordInput`、command attachment envelope 的 fail-closed 输入检查、`subagent/end` 的 run/provider/final-output 元数据,以及 report-before-settlement 与 idle-parent 原生唤醒语义。
54
+ - 已接入:Host `dsh-trellis` settings namespace 与 `dsh.client` 浏览器卡片。保存值写入 DSH 的 `settings.yaml` 用户层,并实时重挂插件 runtime;settings provider 单独重载时退回 loader 配置,插件自身卸载时则不会错误重挂 runtime。没有 settings 服务的 profile 继续使用原有 loader 配置。当前可选 Settings 生命周期由 `settings.installSection()` 承担;插件仍在运行时兼容旧版 helper。
55
+ - 已对齐:`dsh.client.inject` 指向的三个 DSH client 包与 React 都只作为浏览器构建输入保留在 `devDependencies`,发布安装不会重复解析 Web 壳已经提供的模块。
56
+ - 保持可选:`trellis_wait` 仍是“父会话还在当前轮里、需要明确同步点”时的工具;已经 yield 的父会话直接由 DSH 原生 settlement notice 唤醒。
57
+ - 保持直接归属:`trellis_wait` 继续使用 `listChildren(parent.id)` 验证 direct continuable child;这与 0.1.5 修正后的可继续子代理归属一致,不会把子代理误当作根会话参与调度。
58
+
59
+ ## 配置
60
+
61
+ 支持 Settings provider 的 DSH Web profile 可直接打开“设置 → 插件 → 插件配置 → Trellis 工作流”。保存内容进入该 DSH_HOME 的 `settings.yaml`,优先级高于 profile 组合层并立即生效。
59
62
 
60
63
  Headless、rc.6 或需要声明部署默认值时,仍可在 profile 的 `cordis.patch.yml` 里覆盖(整行替换);Web 卡片的“恢复配置文件值”会清除用户层字段并重新继承这里的值:
61
64
 
package/lib/breadcrumb.js CHANGED
@@ -61,10 +61,26 @@ export function isBreadcrumbMessage(message) {
61
61
  );
62
62
  }
63
63
 
64
+ /** Read one session event across the current and legacy DSH session APIs. */
65
+ export function sessionEventAt(session, seq) {
66
+ if (typeof session.eventAt === "function") return session.eventAt(seq);
67
+ if (typeof session.events?.get === "function") return session.events.get(seq);
68
+ return session.events?.[seq];
69
+ }
70
+
64
71
  /** Whether the same breadcrumb payload is already visible in the session surface. */
65
72
  export function isBreadcrumbVisible(agent, digest) {
66
- const visibleSeqs = new Set(agent.session.surface.nodes);
67
- for (const [seq, event] of agent.session.events.entries()) {
73
+ const { session } = agent;
74
+ const visibleSeqs = new Set(session.surface.nodes);
75
+ // Current DSH sessions, including Session V3, expose an immutable on-demand
76
+ // snapshot. Keep the legacy collection fallback for older versions covered
77
+ // by our peer range.
78
+ const events =
79
+ typeof session.snapshotEvents === "function"
80
+ ? session.snapshotEvents()
81
+ : session.events;
82
+ for (const [fallbackSeq, event] of events.entries()) {
83
+ const seq = event?.seq ?? fallbackSeq;
68
84
  if (!visibleSeqs.has(seq) || event.type !== "user/message") continue;
69
85
  const source = event.data?.source;
70
86
  if (
package/lib/config.js CHANGED
@@ -6,7 +6,7 @@
6
6
  import z from "@deepseek-ai/schemastery";
7
7
 
8
8
  export const Config = z.object({
9
- /** Runtime master switch; the rc.8 settings namespace remains available for re-enabling. */
9
+ /** Runtime master switch; the settings namespace remains available for re-enabling. */
10
10
  enabled: z
11
11
  .boolean()
12
12
  .default(true)
package/lib/index.js CHANGED
@@ -19,15 +19,21 @@
19
19
  *
20
20
  * @module dsh-trellis
21
21
  */
22
- import { isDeepStrictEqual } from "node:util";
23
- import { Config, resolveConfig } from "./config.js";
24
- import { createBreadcrumbComposer, isBreadcrumbMessage } from "./breadcrumb.js";
25
- import { registerCommands } from "./commands.js";
26
- import { registerSessionEnv } from "./session-env.js";
27
- import { registerWaitTool } from "./wait-tool.js";
28
-
29
- export const name = "dsh-trellis";
30
- export const SETTINGS_NAMESPACE = "dsh-trellis";
22
+ import { isDeepStrictEqual } from "node:util";
23
+ import * as settingsModule from "@deepseek-ai/dsh-settings";
24
+ import { Config, resolveConfig } from "./config.js";
25
+ import {
26
+ createBreadcrumbComposer,
27
+ isBreadcrumbMessage,
28
+ sessionEventAt,
29
+ } from "./breadcrumb.js";
30
+ import { registerCommands } from "./commands.js";
31
+ import { registerSessionEnv } from "./session-env.js";
32
+ import { installSettingsSectionCompat } from "./settings-compat.js";
33
+ import { registerWaitTool } from "./wait-tool.js";
34
+
35
+ export const name = "dsh-trellis";
36
+ export const SETTINGS_NAMESPACE = "dsh-trellis";
31
37
 
32
38
  /** @type {string[]} */
33
39
  export const inject = ["commands", "shellEnv", "subagents", "tools"];
@@ -46,9 +52,10 @@ function sameBreadcrumbPayload(left, right) {
46
52
  }
47
53
 
48
54
  /** @param {import("@deepseek-ai/cordis").Context} ctx */
49
- export function apply(ctx, config = {}) {
50
- let stopped = false;
51
- let disposeRuntime = () => {};
55
+ export function apply(ctx, config = {}) {
56
+ let stopped = false;
57
+ let disposeRuntime = () => {};
58
+ let currentConfig = () => config;
52
59
 
53
60
  const mountRuntime = (nextConfig) => {
54
61
  if (stopped) return;
@@ -74,37 +81,55 @@ export function apply(ctx, config = {}) {
74
81
  disposeRuntime = () => stopAll(disposers);
75
82
  };
76
83
 
77
- // Keep the composition entry working when no settings provider is mounted.
78
- // Once rc.8's settings service appears, its resolved section becomes the
79
- // live source and a saved Web card edit remounts only this plugin's runtime.
80
- ctx.effect(() => {
81
- mountRuntime(config);
82
- return () => {
83
- stopped = true;
84
- disposeRuntime();
84
+ // Keep the composition entry working when no settings provider is mounted.
85
+ // Once the service appears, its resolved section becomes the live source and
86
+ // a saved Web card edit remounts only this plugin's runtime.
87
+ ctx.effect(() => {
88
+ mountRuntime(currentConfig());
89
+ return () => {
90
+ stopped = true;
91
+ disposeRuntime();
85
92
  };
86
93
  }, "dsh-trellis.runtime");
87
94
 
88
- // Optional by design: rc.6 profiles have no settings service and retain the
89
- // loader-config behavior, while rc.8 Web profiles expose this namespace.
90
- ctx.inject(["settings"], (settingsCtx) => {
91
- const scope = settingsCtx.settings.register(
92
- SETTINGS_NAMESPACE,
93
- Config,
94
- { base: config, applies: "live" },
95
- );
96
- const adopt = () => mountRuntime(scope.get());
97
- adopt();
98
- const unwatch = scope.watch(adopt);
99
- settingsCtx.effect(
100
- () => () => {
101
- unwatch();
102
- mountRuntime(config);
103
- },
104
- "dsh-trellis.settings",
105
- );
106
- });
107
- }
95
+ // Optional by design: profiles without a settings service retain the
96
+ // loader-config behavior. The canonical bridge also distinguishes a settings
97
+ // provider reload (fall back to config) from this plugin's own teardown
98
+ // (leave the runtime alone until its owning effect disposes it).
99
+ installSettingsSectionCompat(
100
+ ctx,
101
+ settingsModule,
102
+ SETTINGS_NAMESPACE,
103
+ Config,
104
+ config,
105
+ {
106
+ setSource(source) {
107
+ currentConfig = source;
108
+ },
109
+ onChange() {
110
+ mountRuntime(currentConfig());
111
+ },
112
+ },
113
+ );
114
+ }
115
+
116
+ /**
117
+ * Insert a breadcrumb without discarding decision metadata added by DSH or
118
+ * another pre-step participant (for example `startsRequestSeries`).
119
+ *
120
+ * @param {{ messages: unknown[], [key: string]: unknown }} decision
121
+ * @param {unknown[]} claimedMessages
122
+ * @param {unknown} desired
123
+ */
124
+ export function insertBreadcrumbDecision(decision, claimedMessages, desired) {
125
+ const lastClaimedIndex = decision.messages.findLastIndex((message) =>
126
+ claimedMessages.includes(message),
127
+ );
128
+ return {
129
+ ...decision,
130
+ messages: decision.messages.toSpliced(lastClaimedIndex + 1, 0, desired),
131
+ };
132
+ }
108
133
 
109
134
  function registerBreadcrumb(ctx, resolved) {
110
135
  const { compose } = createBreadcrumbComposer(resolved, ctx);
@@ -112,9 +137,9 @@ function registerBreadcrumb(ctx, resolved) {
112
137
  const syncInbox = (agent, desired) => {
113
138
  const pending = agent.inbox.nextStep.filter(isBreadcrumbMessage);
114
139
  const alreadySupplied =
115
- desired === undefined ||
116
- agent.session.surface.nodes.some((seq) => {
117
- const event = agent.session.events[seq];
140
+ desired === undefined ||
141
+ agent.session.surface.nodes.some((seq) => {
142
+ const event = sessionEventAt(agent.session, seq);
118
143
  return (
119
144
  event?.type === "user/message" &&
120
145
  event.data !== undefined &&
@@ -175,12 +200,6 @@ function registerBreadcrumb(ctx, resolved) {
175
200
  ) {
176
201
  return decision;
177
202
  }
178
- const lastClaimedIndex = decision.messages.findLastIndex((message) =>
179
- messages.includes(message),
180
- );
181
- return {
182
- kind: "enter",
183
- messages: decision.messages.toSpliced(lastClaimedIndex + 1, 0, desired),
184
- };
185
- });
186
- }
203
+ return insertBreadcrumbDecision(decision, messages, desired);
204
+ });
205
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Install an optional settings section across the two published DSH APIs.
3
+ *
4
+ * DSH through 0.1.1 exposes `installSettingsSection` as a package helper.
5
+ * The 0.1.2 alpha line moved the same lifecycle onto
6
+ * `SettingsProvider.installSection` and removed the helper export. A namespace
7
+ * import keeps this module loadable on both lines while the provider remains
8
+ * optional for profiles that do not mount settings.
9
+ *
10
+ * @param {import("@deepseek-ai/cordis").Context} ctx
11
+ * @param {{ installSettingsSection?: Function }} settingsModule
12
+ * @param {string} namespace
13
+ * @param {unknown} schema
14
+ * @param {unknown} entry
15
+ * @param {{ setSource: Function, onChange: Function, validate?: Function }} hooks
16
+ */
17
+ export function installSettingsSectionCompat(
18
+ ctx,
19
+ settingsModule,
20
+ namespace,
21
+ schema,
22
+ entry,
23
+ hooks,
24
+ ) {
25
+ if (typeof settingsModule.installSettingsSection === "function") {
26
+ settingsModule.installSettingsSection(
27
+ ctx,
28
+ namespace,
29
+ schema,
30
+ entry,
31
+ hooks,
32
+ );
33
+ return;
34
+ }
35
+
36
+ ctx.inject(["settings"], (settingsCtx) => {
37
+ if (typeof settingsCtx.settings?.installSection !== "function") {
38
+ throw new TypeError(
39
+ "The mounted DSH settings service does not expose installSection().",
40
+ );
41
+ }
42
+ settingsCtx.settings.installSection(
43
+ ctx,
44
+ namespace,
45
+ schema,
46
+ entry,
47
+ hooks,
48
+ );
49
+ });
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-trellis",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Trellis workflow integration for DeepSeek Harness: per-turn workflow-state breadcrumbs, utility commands, and native session identity.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -53,17 +53,14 @@
53
53
  "prepack": "pnpm run build:client"
54
54
  },
55
55
  "peerDependencies": {
56
- "@deepseek-ai/cordis": "^4.0.1",
57
- "@deepseek-ai/dsh-commands": "^0.1.0-rc.6",
58
- "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.8",
59
- "@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.8",
60
- "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.0-rc.8",
61
- "@deepseek-ai/dsh-llm": "^0.1.0-rc.6",
62
- "@deepseek-ai/dsh-shell-env": "^0.1.0-rc.6",
63
- "@deepseek-ai/dsh-subagent": "^0.1.0-rc.6",
64
- "@deepseek-ai/dsh-tools": "^0.1.0-rc.6",
65
- "@deepseek-ai/schemastery": "^3.18.1",
66
- "react": "^18.2.0"
56
+ "@deepseek-ai/cordis": "^4.0.2",
57
+ "@deepseek-ai/dsh-commands": "^0.1.0-rc.6 || ^0.1.1-rc.1 || ^0.1.2-alpha.1 || ^0.1.3-alpha.1 || ^0.1.5-alpha.1",
58
+ "@deepseek-ai/dsh-llm": "^0.1.0-rc.6 || ^0.1.1-rc.1 || ^0.1.2-alpha.1 || ^0.1.3-alpha.1 || ^0.1.5-alpha.1",
59
+ "@deepseek-ai/dsh-settings": "^0.1.0-rc.6 || ^0.1.1-rc.1 || ^0.1.2-alpha.1 || ^0.1.3-alpha.1 || ^0.1.5-alpha.1",
60
+ "@deepseek-ai/dsh-shell-env": "^0.1.0-rc.6 || ^0.1.1-rc.1 || ^0.1.2-alpha.1 || ^0.1.3-alpha.1 || ^0.1.5-alpha.1",
61
+ "@deepseek-ai/dsh-subagent": "^0.1.0-rc.6 || ^0.1.1-rc.1 || ^0.1.2-alpha.1 || ^0.1.3-alpha.1 || ^0.1.5-alpha.1",
62
+ "@deepseek-ai/dsh-tools": "^0.1.0-rc.6 || ^0.1.1-rc.1 || ^0.1.2-alpha.1 || ^0.1.3-alpha.1 || ^0.1.5-alpha.1",
63
+ "@deepseek-ai/schemastery": "^3.18.2"
67
64
  },
68
65
  "peerDependenciesMeta": {
69
66
  "@deepseek-ai/cordis": {
@@ -72,18 +69,12 @@
72
69
  "@deepseek-ai/dsh-commands": {
73
70
  "optional": true
74
71
  },
75
- "@deepseek-ai/dsh-client-locale": {
76
- "optional": true
77
- },
78
- "@deepseek-ai/dsh-client-ui-settings": {
79
- "optional": true
80
- },
81
- "@deepseek-ai/dsh-client-ui-settings-plugins": {
82
- "optional": true
83
- },
84
- "@deepseek-ai/dsh-llm": {
85
- "optional": true
86
- },
72
+ "@deepseek-ai/dsh-llm": {
73
+ "optional": true
74
+ },
75
+ "@deepseek-ai/dsh-settings": {
76
+ "optional": true
77
+ },
87
78
  "@deepseek-ai/dsh-shell-env": {
88
79
  "optional": true
89
80
  },
@@ -93,22 +84,38 @@
93
84
  "@deepseek-ai/dsh-tools": {
94
85
  "optional": true
95
86
  },
96
- "@deepseek-ai/schemastery": {
97
- "optional": true
98
- },
99
- "react": {
100
- "optional": true
101
- }
87
+ "@deepseek-ai/schemastery": {
88
+ "optional": true
89
+ }
102
90
  },
103
- "devDependencies": {
104
- "@deepseek-ai/cordis": "^4.0.1",
105
- "@deepseek-ai/dsh-commands": "0.1.0-rc.8",
106
- "@deepseek-ai/dsh-llm": "0.1.0-rc.8",
107
- "@deepseek-ai/dsh-shell-env": "0.1.0-rc.8",
108
- "@deepseek-ai/dsh-subagent": "0.1.0-rc.8",
109
- "@deepseek-ai/dsh-tools": "0.1.0-rc.8",
110
- "@deepseek-ai/schemastery": "^3.18.1",
111
- "react": "^18.2.0",
91
+ "devDependencies": {
92
+ "@deepseek-ai/cordis": "^4.0.2",
93
+ "@deepseek-ai/dsh-attachment": "0.1.5-alpha.2",
94
+ "@deepseek-ai/dsh-agent": "0.1.5-alpha.2",
95
+ "@deepseek-ai/dsh-client-locale": "0.1.5-alpha.2",
96
+ "@deepseek-ai/dsh-client-ui-settings": "0.1.5-alpha.2",
97
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.5-alpha.2",
98
+ "@deepseek-ai/dsh-code-runtime": "0.1.5-alpha.2",
99
+ "@deepseek-ai/dsh-commands": "0.1.5-alpha.2",
100
+ "@deepseek-ai/dsh-home-paths": "0.1.5-alpha.2",
101
+ "@deepseek-ai/dsh-invariants": "0.1.5-alpha.2",
102
+ "@deepseek-ai/dsh-llm": "0.1.5-alpha.2",
103
+ "@deepseek-ai/dsh-sandbox": "0.1.5-alpha.2",
104
+ "@deepseek-ai/dsh-scope": "0.1.5-alpha.2",
105
+ "@deepseek-ai/dsh-session": "0.1.5-alpha.2",
106
+ "@deepseek-ai/dsh-session-persistence": "0.1.5-alpha.2",
107
+ "@deepseek-ai/dsh-session-projection": "0.1.5-alpha.2",
108
+ "@deepseek-ai/dsh-shell": "0.1.5-alpha.2",
109
+ "@deepseek-ai/dsh-settings": "0.1.5-alpha.2",
110
+ "@deepseek-ai/dsh-shell-env": "0.1.5-alpha.2",
111
+ "@deepseek-ai/dsh-subprocess": "0.1.5-alpha.2",
112
+ "@deepseek-ai/dsh-subagent": "0.1.5-alpha.2",
113
+ "@deepseek-ai/dsh-system-prompt": "0.1.5-alpha.2",
114
+ "@deepseek-ai/dsh-tools": "0.1.5-alpha.2",
115
+ "@deepseek-ai/dsh-user-approval": "0.1.5-alpha.2",
116
+ "@deepseek-ai/dsh-util-time": "0.1.5-alpha.2",
117
+ "@deepseek-ai/schemastery": "^3.18.2",
118
+ "react": "19.2.8",
112
119
  "tsdown": "^0.22.2"
113
120
  }
114
121
  }