@morlay/dsh-subagent 0.0.2 → 0.0.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/README.md CHANGED
@@ -1,74 +1,21 @@
1
1
  # @morlay/dsh-subagent
2
2
 
3
- 上游 `@deepseek-ai/dsh-subagent` 的**薄壳 fork**:host 半只改两件事——continuable 子代理首条任务后面的
4
- **回报指引**换成中文(上游是英文,且只在"会话挂着本部署那份 preset"时用,其余会话保持上游那套),以及
5
- **接管官方那一行**(行 id 仍是 `subagent`,见下)。服务名(`ctx.subagents`)、providers、其余子路径
6
- (`./internal` 等)与装配位置都不变。配置页由**官方**那张卡片承担(行 id 没换,`subagent` namespace 照旧)。
3
+ 上游 `@deepseek-ai/dsh-subagent` 的**薄壳 fork**:接管官方 `subagent` 行,改两处文案——
7
4
 
8
- 装配由本包的装配数据完成(`cordis.patch.yml` / `rows` 出口):**按官方行 id 复用**——插一条
9
- `{ id: "subagent", name: "@morlay/dsh-subagent" }`,Loader 对同 id 复用同一个 Entry、后者替换入口 options,
10
- 所以行 id 与 settings namespace 都还是 `subagent`,官方设置卡(`ui-settings-subagent`)与它的服务行
11
- (`subagent-model-selection-settings`)都不动;顺序前提是本包排在 `@deepseek-ai/dsh-base` 之后。理由与被否的
12
- 路线见 [ADR 接管官方行按 id 复用](./.agents/adrs/20260928-接管官方行按id复用而非换id.md)。
5
+ 1. continuable 子代理首条任务后面的**回报指引**换成中文,**默认对任意会话生效**(官方四个 shipped preset、还没绑
6
+ preset 的会话都在内);只有在装配面给了 `localizedReturnGuidancePresets` 名单时才收窄成「只有名单里的 preset
7
+ 用中文」,其余会话保持上游那套;
8
+ 2. 子代理自己的**委派范围说明**(运行时上下文 `subagent:delegation`)换成中文,两条派发路径(continuable 与一次性)
9
+ 一起覆盖。
13
10
 
14
- 回报指引的名单走这一行的 `config.localizedReturnGuidancePresets`(装配给,`.hidden()` 不进设置页);app 的
15
- `dsh.profile.bundles` 里引用本包。
11
+ ## 用法
16
12
 
17
- ## 保留文件(3 个)
13
+ 行数据在本包 `./rows` 出口(`subagentRows()`),由 [`@morlay/session-mode-profile`](../../bundles/session-mode-profile/README.md) 展开——它**不传** `localizedReturnGuidancePresets`(不配名单 = 不限 preset),传了才收窄。**按官方行 id 复用**,所以服务名(`ctx.subagents`)、providers、settings namespace 与官方设置卡都不变,限额字段(`maxDepth` / `maxActiveSubagents`)仍在那张卡上——本包没有 client 半。
18
14
 
19
- 薄壳 fork 只留**有意改过**的文件,其余上游文件不复制——保留文件里指向它们的 import 走相对路径指向
20
- `vendor/deepseek-harness/packages/subagent/subagent/src/...`,构建时内联进 `dist/index.mjs`
21
- (发布物自包含)。
15
+ 保留文件、偏离登记与结构性约束见[设计 薄壳fork的接管面与保留文件](./.agents/designs/20260929-薄壳fork的接管面与保留文件.md)。
22
16
 
23
- | 保留文件(`src/`) | 保留什么 |
24
- | -------------------------- | ------------------------------------------------------------------------------------------ |
25
- | `continuation-messages.ts` | 中文文案 + 判定函数 `localizedReturnGuidance`("这个会话要不要本包那份文案") |
26
- | `continuation.ts` | 接线 + 调用点从"永远是本包文案"改成"按会话选"(读 `ctx.agentPresets` 的 `composedPreset`) |
27
- | `index.ts` | 接线 + 装配面配置字段(`localizedReturnGuidancePresets`)+ 两处结构性偏离(见下) |
17
+ ## 委派范围说明怎么换的
28
18
 
29
- 静态 import 链决定了复制面:`continuation-messages` ← `continuation` ← `index`,要替换中间那一份就得
30
- 连同引用它的两个文件一起接管。原因、被否掉的路线与后果见
31
- [ADR 薄壳 fork 接管 subagent 行只改回报文案](./.agents/adrs/20260923-薄壳fork接管subagent行只改回报文案.md)。
32
-
33
- **偏离清单是可执行的**:`src/__tests__/upstream-wiring.spec.ts` 的 `DELTAS` 表逐条登记上面每处偏离(新增
34
- 块、改过的行、装配面字段),偏离表里的片段没命中就红——加偏离必须同时登记,否则测试报"偏离表里的片段不在
35
- 文件里"。
36
-
37
- ## 两处结构性偏离
38
-
39
- - **`index.ts` 不复述 cordis 合并接口**:上游此处 `declare module '@deepseek-ai/cordis'` 声明
40
- `Context.subagents` 与 `subagent/*` 事件;本包 `import type {} from '@deepseek-ai/dsh-subagent'`
41
- 引用上游那一份(同形声明复述两遍会在同一个 program 里撞 `TS2717`)。
42
- - **标准装饰器在构建期降级**:`@Remote(...)` 是 TC39 标准装饰器,rolldown/oxc 不降级它(上游管线里这步
43
- 由 tsc 完成),所以 `tsdown.config.ts` 里有一个 esbuild 预转换(只在检测到装饰器语法时生效)。
44
-
45
- 本包三个保留文件**不做格式化**(`.oxfmtrc.json` 的 `ignorePatterns`):它们与上游逐行对照是同步纪律的
46
- 守护面,格式改了那条守护就失去意义。
47
-
48
- ## 配置页
49
-
50
- **子代理用哪个模型不在这张卡上**:它跟着**父会话的模式**走(`@morlay/dsh-session-mode` 顶层 `models` 里
51
- 「模式 → 服务商 / 模型」那两个选择器)。
52
-
53
- 限额两个字段(`maxDepth` / `maxActiveSubagents`,标了 `.volatile()`)由**官方**那张设置卡承担:接管没换行 id,
54
- `subagent` namespace 照旧,`ui-settings-subagent` 与 `subagent-model-selection-settings` 都不动。
55
-
56
- 本包**不再有 client 半**(`./client` 出口、字典与字段文案槽都删了):卡片回来之后它是重复面——两套都注册
57
- `settings.subagent` 字典时,`locale.register` 对同 namespace 同 locale 直接抛错
58
- (`locale namespace "settings.subagent" already has locale "zh"`),官方卡片那一行会加载失败。
59
-
60
- `Config` 的 `localizedReturnGuidancePresets` 是**装配面**字段(`.hidden()`):它不进设置页,由装配那一行给。
61
-
62
- ## 文档
63
-
64
- - 决策与理由:
65
- [ADR 薄壳 fork 接管 subagent 行只改回报文案](./.agents/adrs/20260923-薄壳fork接管subagent行只改回报文案.md)、
66
- [ADR 接管官方行按 id 复用](./.agents/adrs/20260928-接管官方行按id复用而非换id.md)、
67
- (已作废)[ADR 停掉官方设置卡的两条入口行](./.agents/adrs/20260923-停掉官方设置卡的两条入口行.md)
68
- - 已知的债(两处 `continuation-messages` 实例、保留文件跟随方式):
69
- [债务 continuation-messages 两份实例与保留文件跟随](./.agents/debts/20260923-continuation-messages两份实例与保留文件跟随.md)
70
- - 测试落点与判据:[本包规范 how-to-verify](./.agents/standards/how-to-verify.md);薄壳 fork 的通用写法约束见
71
- [`session/ui-conversation` 的 how-to-write](../../session/ui-conversation/.agents/standards/how-to-write.md)
72
- (同一形态的包共享那份约束)。
73
-
74
- 上游同步(patch / 裁剪 / 升级评估)走 `dsh-plugin-upstream-sync` 技能;发布走 CI,本地只构建验证。
19
+ `subagent:delegation` 由上游在**子代理自己的 agent 作用域**上注册,两条常规接管手法都不通:同层重复注册同名 context
20
+ 会抛错;fork `child-agent.ts` 也不改变运行期(注册这条文本的调用方都在上游未复制的文件里)。所以本包改的是**装配
21
+ 结果**——`system-prompt/assemble` 瀑布里把该名字那条的文本换成中文(`src/delegation-context.ts`),在该次装配内生效。
package/dist/index.d.mts CHANGED
@@ -1977,10 +1977,10 @@ interface Config {
1977
1977
  /** Default delegation depth for tools without an explicit limit; defaults to 1. */
1978
1978
  maxDepth: Volatile<number>;
1979
1979
  /**
1980
- * Preset ids whose sessions get this package's Chinese return guidance; default empty.
1980
+ * Preset ids the Chinese return guidance is restricted to; empty (default) means no restriction.
1981
1981
  *
1982
- * 名单由**装配**给(这一行的 `config`):文案是模型可见的东西,跟着 preset 走,其余会话走上游英文那套。
1983
- * 装配面,不是用户面——所以不进设置页(`.hidden()`)。
1982
+ * 不配 = 任意 preset 的会话都用本包的中文回报指引(官方四个 shipped preset 也在内,还有还没绑 preset 的会话)。
1983
+ * 要反过来只让某几份 preset 用中文,就在这里列出来。装配面,不是用户面——所以不进设置页(`.hidden()`)。
1984
1984
  */
1985
1985
  localizedReturnGuidancePresets: string[];
1986
1986
  }
package/dist/index.mjs CHANGED
@@ -6572,15 +6572,17 @@ function createAgentMessage(sender, content) {
6572
6572
  /**
6573
6573
  * Whether this session's return guidance takes this package's Chinese wording.
6574
6574
  *
6575
- * 判据是**会话挂着的 preset**:文案是模型可见的东西,跟着 preset 走;名单由装配给(本行的
6576
- * `config.localizedReturnGuidancePresets`),默认空——没配、或会话没挂 preset(不装 registry 的部署、还没绑的
6577
- * agent)一律走上游英文,官方 shipped preset 的会话因此不会被换文案。
6575
+ * **默认对任意 preset 生效**:名单(本行的 `config.localizedReturnGuidancePresets`)不配就是不限制——官方四个
6576
+ * shipped preset、部署自建的、以及还没绑 preset 的会话(不装 registry 的部署、还没 join 的 agent)都拿中文。
6577
+ * 配了名单才反过来收窄成"只有这些 preset 的会话用中文"。文案是模型可见的东西,判据留在 host 平面
6578
+ * (`subagents` 是进程单例,这一行不能搬进 preset realm)。
6578
6579
  *
6579
6580
  * @param composedPreset - the preset id the session is mounted on, if any.
6580
- * @param configured - preset ids this deployment asked to localize.
6581
+ * @param configured - preset ids this deployment restricts the Chinese wording to; empty means every session.
6581
6582
  * @returns whether the Chinese guidance applies to this session.
6582
6583
  */
6583
6584
  function localizedReturnGuidance(composedPreset, configured) {
6585
+ if (configured.length === 0) return true;
6584
6586
  return composedPreset !== void 0 && configured.includes(composedPreset);
6585
6587
  }
6586
6588
  /**
@@ -7207,8 +7209,8 @@ var SubagentContinuationManager = class {
7207
7209
  /**
7208
7210
  * Return guidance for a continuable child's initial task, per session.
7209
7211
  *
7210
- * 会话挂着本部署名单里的 preset 时用本包的中文文案,其余(官方 shipped preset、还没绑 preset 的会话、
7211
- * 不装 registry 的部署)保持上游英文。文案是模型可见的东西,跟着 preset 走;但 `subagents` 是**进程单例**
7212
+ * 默认(没配名单)对**任意**会话用本包的中文文案,官方四个 shipped preset 与还没绑 preset 的会话都覆盖;
7213
+ * 配了名单才收窄成"只有这些 preset 的会话用中文"。文案是模型可见的东西;但 `subagents` 是**进程单例**
7212
7214
  * (跨会话查询面由 host 的 api-proxy 服务、provider 名全局唯一),realm 内的服务 realm 外读不到,所以这一行
7213
7215
  * 不能搬进 preset realm——只能在 host 平面按会话判。
7214
7216
  * @param parent - the exact live parent whose session owns the child.
@@ -7454,6 +7456,20 @@ var SubagentContinuationManager = class {
7454
7456
  return query;
7455
7457
  }
7456
7458
  };
7459
+ const DELEGATION_CONTEXT_TEXT = "你是被派发的子代理:权限范围在创建时就固定,本会话内不能放宽——需要审批的操作一律被自动拒绝。\n任务需要超出这个范围时不要重试被拒的操作,在回复里说明这个限制,让派发你的智能体处理。";
7460
+ function installDelegationContext(ctx) {
7461
+ ctx.on("system-prompt/assemble", async (assembly, context, next) => {
7462
+ const assembled = await next();
7463
+ if (context.agent?.session.header.parentSession === void 0) return assembled;
7464
+ return {
7465
+ ...assembled,
7466
+ contexts: assembled.contexts.map((entry) => entry.name === "subagent:delegation" ? {
7467
+ ...entry,
7468
+ text: DELEGATION_CONTEXT_TEXT
7469
+ } : entry)
7470
+ };
7471
+ });
7472
+ }
7457
7473
  //#endregion
7458
7474
  //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/list-children.ts
7459
7475
  /**
@@ -8140,6 +8156,7 @@ var SubagentRuntime = class extends (_b = TypertRemoteService) {
8140
8156
  * composes into the carrier.
8141
8157
  */
8142
8158
  __publicField(this, "emitLifecycle");
8159
+ installDelegationContext(ctx);
8143
8160
  this.emitLifecycle = createLifecycleEmitter(this.ctx, (parent) => scopeTarget(this, parent));
8144
8161
  ctx.inject(["agents"], (childCtx) => {
8145
8162
  const manager = new SubagentContinuationManager(childCtx, {
package/dist/rows.d.mts CHANGED
@@ -1,35 +1,17 @@
1
1
  //#region src/rows.d.ts
2
- /**
3
- * 本包作为能力包发布的**装配数据**:行本身在部署那一层装
4
- * (`packages/bundles/session-mode-profile` 引用它渲染 patch)。
5
- *
6
- * 接管方式是**按官方行 id 复用**,不是"禁掉官方行再插一行自己的":Loader 对同 id 的条目复用同一个 Entry、
7
- * 后者替换入口 options(`EntryGroup.create` 的 `create: true`),所以行 id 与 settings namespace(namespace
8
- * 就是行 id)都还是 `subagent`——官方设置卡 `ui-settings-subagent` 读得到那两个 namespace,照常可用;换掉的
9
- * 只是实现包。顺序前提:本包排在 `@deepseek-ai/dsh-base` 之后(app 的 `dsh.profile.bundles` 已如此)。
10
- *
11
- * 模型白名单服务行(`subagent-model-selection-settings`)留给官方卡片第二段,本包不动它。
12
- */
13
- /** 一行装配条目:与 `cordis.patch.yml` 的顶层结构同形。 */
14
2
  interface PatchRow {
15
3
  readonly id?: string;
16
4
  readonly disabled?: boolean;
17
5
  readonly insert?: readonly RowEntry[];
18
6
  }
19
- /** `insert` 里的一个条目。 */
20
7
  interface RowEntry {
21
8
  readonly id: string;
22
9
  readonly name: string;
23
10
  readonly config?: Readonly<Record<string, unknown>>;
24
11
  }
25
12
  interface SubagentRowsOptions {
26
- /**
27
- * 哪些 preset 的会话用本包的中文回报指引(本行 `config.localizedReturnGuidancePresets`)。
28
- * 由装配给:它才知道自己注册的那份 preset 叫什么;不传即一律上游英文。
29
- */
30
13
  readonly localizedReturnGuidancePresets?: readonly string[];
31
14
  }
32
- /** 服务接管的装配行:占官方 `subagent` 那个行 id。 */
33
15
  declare function subagentRows(options?: SubagentRowsOptions): readonly PatchRow[];
34
16
  //#endregion
35
17
  export { PatchRow, RowEntry, SubagentRowsOptions, subagentRows };
package/dist/rows.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  //#region src/rows.ts
2
- /** 服务接管的装配行:占官方 `subagent` 那个行 id。 */
3
2
  function subagentRows(options = {}) {
4
3
  const presets = options.localizedReturnGuidancePresets;
5
4
  return [{ insert: [{
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Subagent Service",
4
- "description": "Thin-shell fork of @deepseek-ai/dsh-subagent: takes over the `subagent` row only to replace the continuable child's return guidance with Chinese wording."
4
+ "description": "Thin-shell fork of @deepseek-ai/dsh-subagent: takes over the official `subagent` row for two wording changes — the continuable child's return guidance and the child's delegation-scope statement, both in Chinese — plus row-id reuse; everything not intentionally changed is imported from the vendored upstream source."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "子智能体服务",
4
- "description": "上游 @deepseek-ai/dsh-subagent 的薄壳 fork:只接管 `subagent` 行,把连续子智能体的回报指引换成中文。"
4
+ "description": "上游 @deepseek-ai/dsh-subagent 的薄壳 fork:接管官方 `subagent` 行,改两处文案——连续子智能体的回报指引与子代理的委派范围说明都换成中文;并按官方行 id 复用(设置卡照旧)。其余未有意改动的都从 vendor 上游源码内联。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morlay/dsh-subagent",
3
- "version": "0.0.2",
4
- "description": "Thin-shell fork of @deepseek-ai/dsh-subagent: takes over the `subagent` row only to replace the continuable-child return guidance with Chinese wording; everything not intentionally changed is imported from the vendored upstream source",
3
+ "version": "0.0.3",
4
+ "description": "Thin-shell fork of @deepseek-ai/dsh-subagent: takes over the official `subagent` row for two wording changes — the continuable child's return guidance in Chinese wording and the child's Chinese delegation-scope runtime context (`subagent:delegation`) — plus the row-id reuse (same `subagent` id, so the official settings card stays); everything not intentionally changed is imported from the vendored upstream source.",
5
5
  "keywords": [
6
6
  "dsh",
7
7
  "dsh-bundle",
@@ -37,6 +37,7 @@
37
37
  "@deepseek-ai/dsh-session-persistence-jsonl": "0.2.0-rc.1",
38
38
  "@deepseek-ai/dsh-subagent-fork-in-process": "0.2.0-rc.1",
39
39
  "@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.0-rc.1",
40
+ "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.1",
40
41
  "@deepseek-ai/dsh-tool-subagent-control": "0.2.0-rc.1",
41
42
  "@deepseek-ai/dsh-util-values": "0.2.0-rc.1",
42
43
  "@deepseek-ai/schemastery": "~3.18.4",