@starsharryzhu/complete-subagent 0.1.0 → 0.1.1

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/AGENTS.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## 1. Role
4
4
 
5
- complete-subagent is a DeepSeek Harness plugin with its own delegation tools beside the official ones: `delegate` starts a fresh child and `delegate_fork` a child that inherits the conversation. The `cwd` a parent passes becomes the child's sub-workspace and `writable_paths` grants more up front; the child may modify files only there (plus temporary directories). To modify anything else it calls `request_write_access` and is paused until the parent answers with `answer_write_request`; the parent can also grant or revoke at any time with `grant_write_access` and `revoke_write_access`. A parent may choose the child's model and reasoning effort among the models the user lists on the plugin's settings page. Children run on the host's own subagent runtime, so messaging, the child conversations in the UI, result notices, and cold resume behave as for the official tools, which stay installed and untouched. Access is enforced by narrowing the sandbox policy the host already applies to bash, file tools, terminals, and code mode, and anything a confined agent starts by other means is confined the same way. The `presets` setting limits the tools and prompt texts to the agents of the listed agent presets: empty (the default) serves every preset. The `childPreset` setting names the agent preset `delegate` children run instead of their parent's. The `ownModel` setting, on by default, can keep `delegate` children off the parent's own model, and a bundle can set the model list at run time through the `completeSubagent` service. The `dsh-assisstant` bundle mounts the plugin as a sub-plugin with `presets: [dsh-assisstant, dsh-assisstant-worker]` and `childPreset: dsh-assisstant-worker`: the family's router sessions delegate and approve, and their workers do the work. The plugin supports hosts from 0.2.1-rc.5 on and reads what each host offers; `src/host/legacy.ts` holds what differs on a host older than 0.2.2-alpha.2.
5
+ complete-subagent is a DeepSeek Harness plugin with its own delegation tools beside the official ones: `delegate` starts a fresh child and `delegate_fork` a child that inherits the conversation. The `cwd` a parent passes becomes the child's sub-workspace and `writable_paths` grants more up front; the child may modify files only there (plus temporary directories). To modify anything else it calls `request_write_access` and is paused until the parent answers with `answer_write_request`; the parent can also grant or revoke at any time with `grant_write_access` and `revoke_write_access`. A parent may choose the child's model and reasoning effort among the models the user lists on the plugin's settings page. Children run on the host's own subagent runtime, so messaging, the child conversations in the UI, result notices, and cold resume behave as for the official tools, which stay installed and untouched. Access is enforced by narrowing the sandbox policy the host already applies to bash, file tools, terminals, and code mode, and anything a confined agent starts by other means is confined the same way. The `presets` setting limits the tools and prompt texts to the agents of the listed agent presets: empty (the default) serves every preset. The `childPreset` setting names the agent preset `delegate` children run instead of their parent's. The `ownModel` setting, on by default, can keep `delegate` children off the parent's own model, and a bundle can set the model list at run time through the `completeSubagent` service. The `dsh-assisstant` bundle mounts the plugin as a sub-plugin with `presets: [dsh-assisstant, dsh-assisstant-worker]` and `childPreset: dsh-assisstant-worker`: the assistant's router sessions delegate and approve, and their workers do the work. The plugin supports hosts from 0.2.1-rc.5 up to 0.3 and reads what each host offers: `src/host/legacy.ts` holds what differs on a host older than 0.2.2-alpha.2, and a start carries its task in both shapes, the one hosts before 0.2.2-rc.2 read and the one later hosts read.
6
6
 
7
7
  ## 2. Constraints
8
8
 
@@ -18,7 +18,8 @@ complete-subagent is a DeepSeek Harness plugin with its own delegation tools bes
18
18
  - Fail closed: a child is bound before it starts, a failed start drops its binding, and an uncertain inherited chain leaves no access.
19
19
  - A plugin failure must not reach the host: event listeners, visibility checks, and prompt texts run for every session of every preset, so they log a warning and fall back instead of throwing. `tools/execute` passes through only what `next` throws, which is the host's own pipeline.
20
20
  - A host older than 0.2.2-alpha.2 silently drops `when` and ignores `additionalWritableRoots`. The plugin must keep working there: the same visibility conditions become per-agent `tools.restrict` filters, and a granted `write` or `edit` call is rooted at its grant. Newer hosts are detected by `ctx.tools.resolve`, which arrived with `when`, and never get the filters.
21
- - Package identity: `@starsharryzhu/complete-subagent` version `0.1.0`, `engines.dsh` `>=0.2.1-rc.5 <0.3.0-0`; `tests/manifest.test.ts` pins them.
21
+ - A start (`subagents.startActivation`) carries its task twice: at the top level of the spec, where hosts from 0.2.2-rc.2 read it, and under `request`, where older hosts read it. Each host ignores the other copy, so no host version is detected; drop neither while both generations are in `engines.dsh`.
22
+ - Package identity: `@starsharryzhu/complete-subagent` version `0.1.1`, `engines.dsh` `>=0.2.1-rc.5 <0.3.0-0`; `tests/manifest.test.ts` pins them.
22
23
  - `lib/` is generated by `node build.js` and committed, because `link:` and git installs do not build.
23
24
  - Every folder carries this four-section English file; `tests/agents-md.test.ts` enforces it.
24
25
 
@@ -38,13 +39,18 @@ complete-subagent is a DeepSeek Harness plugin with its own delegation tools bes
38
39
  - `vitest.config.ts` — test runner settings.
39
40
  - `README.md` — user documentation in Chinese.
40
41
  - `.gitignore` — ignores dependencies, browser compile output, and local notes, keeps `lib/`.
42
+ - `.github/workflows/publish.yml` — tag-triggered npm publish with OIDC provenance.
41
43
 
42
44
  ## 4. Progress
43
45
 
44
46
  - Done (2026-11-01): standalone `delegate` / `delegate_fork` on the host's `spawn` and `fork` backends with sub-workspaces, `writable_paths`, reserved child ids bound before start, model and reasoning-effort choice limited by the settings, a settings page on the Plugins screen, inherited confinement for children a confined agent starts by other means, and the four write-access tools; all specs pass.
45
- - Done (2026-11-01): the `presets` setting, so `dsh-assisstant` can mount the plugin for its hidden presets only, and the `childPreset` setting for its two-layer router and worker design; version stays `0.1.0`, as it was never published.
47
+ - Done (2026-11-01): the `presets` setting, so `dsh-assisstant` can mount the plugin for its hidden presets only, and the `childPreset` setting for its two-layer router and worker design; version `0.1.0` is published on npm.
48
+ - Done (2026-11-05): the package source is at StarsHarryZhu/complete-subagent with a tag-triggered publish workflow; its npm trusted publisher is configured and pending validation, which the next version tag will complete.
46
49
  - Done (2026-11-02): support for DSH Desktop 0.2.1-rc.5, which has neither `presetForSession` nor `when` nor `additionalWritableRoots`, and no plugin failure reaches the host. The built plugin passed a throwaway check on the real rc.5 tool, prompt, projection, and sandbox-policy services, with small stand-ins for the agents, the subagent start, and the working directory; the host's real subagent start and the web app are not exercised on rc.5.
47
50
  - Done (2026-11-02): the `ownModel` setting and the `completeSubagent` service, so a bundle can offer only the worker models it picks. A throwaway check on real hosts, 0.2.1-rc.5 and the 0.2.2-alpha.2 checkout, with a mock model and two probe presets, read each child's first recorded request: it runs the chosen model and effort on both, through the host's real subagent start. A standalone row ignored the service on both. The `dsh-assisstant` bundle itself was not part of that check.
51
+ - Found (2026-11-16, on Desktop 0.2.2-rc.3 and in the user's real assistant): 0.1.0 could not start any child on hosts from 0.2.2-rc.2, which read `parent`, `prompt`, `cwd`, `agentPreset`, `agentOptions`, and `maxDepth` at the top level of the start spec, where 0.1.0 nested them under `request`; every `delegate` call failed with `Cannot read properties of undefined (reading 'id')` before a child existed.
52
+ - Fixed (2026-11-17): 0.1.1 sends the task in both shapes. Run on four real hosts installed from npm (0.2.1-rc.5, 0.2.2-rc.1, 0.2.2-rc.2, 0.2.2-rc.3) inside the `dsh-assisstant` bundle, with a mock model and a workspace outside the temporary directory: the router's `delegate` started a worker on the worker preset; the worker wrote inside its sub-workspace and was refused next to it; its `request_write_access` reached the router, whose `answer_write_request` allowed it; the worker then wrote the granted file and its report came back to the router. No host logged a warning or an error. A control run on 0.2.2-rc.3 with 0.1.0 in the same setup failed with exactly that error. Not exercised there: `delegate_fork`, shell commands, a standalone install, the settings page.
53
+ - Done (2026-11-17, user approved): 0.1.1 is installed in the user's Desktop profile from a local tarball, and the installed copy passed the same run on the packaged 0.2.2-rc.3 host in a fake-home copy of that plugin set. Not yet published; the real app with the real model has not been tried.
48
54
  - Carried over from dsh-better-subagent and verified there in the web app (host 0.2.2-alpha.2, 2026-10-29 to 2026-11-01): the kernel-level fence for the write tool and bash, file and directory grants, denials with notes, read-only children without `cwd`, parallel children, grants after a restart and cold resume, a four-child team run, `writable_paths`, grant, and revoke.
49
55
  - Open: the new tools, the model choice, the settings page, inherited confinement, and the `presets`, `childPreset`, and `ownModel` settings are not yet verified in the web app; the desktop app, which runs 0.2.1-rc.5, is not verified.
50
56
  - Known limits on 0.2.1-rc.5: shell commands cannot reach any grant, only `write` and `edit` can, and the child context says so; a visibility change other than a new agent or a preset selection takes effect on the agent's next step, so a parent at the depth limit that gets a request sees `answer_write_request` one step late, and the request may time out as denied.
package/README.md CHANGED
@@ -93,7 +93,7 @@ ctx.inject(['completeSubagent'], (child) => {
93
93
 
94
94
  助理(`@starsharryzhu/dsh-assistant`)把本插件挂成子插件,分两层:
95
95
 
96
- - 家人的会话跑在隐藏的 `dsh-assisstant` preset(router)上,没有写文件的工具,只负责派活,以及审批子代理的写入申请。
96
+ - 用户的会话跑在隐藏的 `dsh-assisstant` preset(router)上,没有写文件的工具,只负责派活,以及审批子代理的写入申请。
97
97
  - 子代理跑在 `dsh-assisstant-worker` preset 上,有完整工具,要改子工作区以外的东西时用 `request_write_access` 向 router 申请。
98
98
  - `presets` 只列这两个 preset,所以这些工具不会出现在普通会话里。
99
99
 
@@ -126,7 +126,9 @@ ctx.inject(['completeSubagent'], (child) => {
126
126
 
127
127
  ## 支持的宿主版本
128
128
 
129
- DeepSeek Harness 0.2.1-rc.5 及以后、0.3 以前。DSH Desktop 现在用的就是 rc.5。
129
+ DeepSeek Harness 0.2.1-rc.5 及以后、0.3 以前。在 0.2.1-rc.5、0.2.2-rc.1、0.2.2-rc.2、0.2.2-rc.3 四个宿主上实测过派子代理、限制写入、申请和批准写权限(mock 模型)。
130
+
131
+ 0.2.2-rc.2 起宿主改了启动子代理的参数写法,0.1.0 在这些宿主上派不出子代理(报 `Cannot read properties of undefined (reading 'id')`)。0.1.1 两种写法一起传,新旧宿主都能用,请升级。
130
132
 
131
133
  rc.5 比 0.2.2-alpha.2 少三样东西,插件会自己判断并换一种做法,不用配置:
132
134
 
package/lib/client.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @starsharryzhu/complete-subagent 0.1.0 — generated by build.js from src/; do not edit. */
1
+ /* @starsharryzhu/complete-subagent 0.1.1 — generated by build.js from src/; do not edit. */
2
2
  window.__ModuleLoader__.load({
3
3
  id: "@starsharryzhu/complete-subagent",
4
4
  factory: (require) => {
@@ -78,19 +78,23 @@ export function createDelegateTool(tool, models, deps) {
78
78
  const agentPreset = provider === 'spawn' ? deps.childPreset : undefined;
79
79
  const childId = deps.newId?.() ?? randomUUID();
80
80
  deps.store.set({ version: 1, child: childId, parent: parent.session.id, workspace: access.workspace, grants: access.grants });
81
+ const task = {
82
+ ...access.cwd === undefined ? {} : { cwd: access.cwd },
83
+ prompt: [{ type: 'text', text: args.prompt }],
84
+ parent,
85
+ ...agentPreset === undefined ? {} : { agentPreset },
86
+ ...route === undefined ? {} : { agentOptions: route },
87
+ ...maxDepth === undefined ? {} : { maxDepth },
88
+ };
81
89
  try {
90
+ // The task goes both ways: hosts from 0.2.2-rc.2 read it at the top level and those before under
91
+ // `request`, and neither reads the other's fields, so one call starts the child on every host.
82
92
  const started = await deps.subagents.startActivation({
83
93
  provider,
84
94
  label: args.description,
85
95
  childId,
86
- request: {
87
- ...access.cwd === undefined ? {} : { cwd: access.cwd },
88
- prompt: [{ type: 'text', text: args.prompt }],
89
- parent,
90
- ...agentPreset === undefined ? {} : { agentPreset },
91
- ...route === undefined ? {} : { agentOptions: route },
92
- ...maxDepth === undefined ? {} : { maxDepth },
93
- },
96
+ ...task,
97
+ request: task,
94
98
  signal: exec.signal,
95
99
  delivery: 'parent',
96
100
  });
@@ -101,23 +101,31 @@ export interface TextBlock {
101
101
  readonly type: 'text';
102
102
  readonly text: string;
103
103
  }
104
- /** `SubagentActivationSpec` with a reserved child id, as this plugin fills it. */
105
- export interface ActivationSpecLike {
104
+ /** `SubagentStartRequest`: the task part of a start, as this plugin fills it. */
105
+ export interface StartRequestLike {
106
+ readonly cwd?: string;
107
+ readonly prompt: TextBlock[];
108
+ readonly parent: AgentLike;
109
+ /** Preset the child runs instead of the parent's; only a backend that does not inherit the parent's context accepts it. */
110
+ readonly agentPreset?: string;
111
+ readonly agentOptions?: RouteLike;
112
+ readonly maxDepth?: number;
113
+ }
114
+ /**
115
+ * `SubagentActivationSpec` with a reserved child id, as this plugin fills it.
116
+ * Hosts from 0.2.2-rc.2 read the task at the top level; older ones read it
117
+ * under `request` and ignore the top-level copy, and newer ones the reverse,
118
+ * so the plugin sends both.
119
+ */
120
+ export interface ActivationSpecLike extends StartRequestLike {
106
121
  /** Registered backend: `spawn` (fresh child) or `fork` (inherits the conversation). */
107
122
  readonly provider: string;
108
123
  /** Short task label shown with the child. */
109
124
  readonly label: string;
110
125
  /** Reserved child session id, so the child is bound before it exists. */
111
126
  readonly childId: string;
112
- readonly request: {
113
- readonly cwd?: string;
114
- readonly prompt: TextBlock[];
115
- readonly parent: AgentLike;
116
- /** Preset the child runs instead of the parent's; only a backend that does not inherit the parent's context accepts it. */
117
- readonly agentPreset?: string;
118
- readonly agentOptions?: RouteLike;
119
- readonly maxDepth?: number;
120
- };
127
+ /** The same task, for hosts before 0.2.2-rc.2. */
128
+ readonly request: StartRequestLike;
121
129
  readonly signal: AbortSignal;
122
130
  /** `parent`: the runtime notifies the parent model when the child finishes. */
123
131
  readonly delivery: 'parent';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starsharryzhu/complete-subagent",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Complete subagents for DeepSeek Harness: delegate and delegate_fork tools beside the official ones, where the cwd a parent gives a child is the only place the child may modify, writable_paths grants more up front, anything else needs the parent agent's permission, and the parent can choose the child's model and reasoning effort from the models listed in the settings.",
5
5
  "keywords": [
6
6
  "dsh-plugin",
@@ -85,5 +85,13 @@
85
85
  "access": "public",
86
86
  "tag": "latest"
87
87
  },
88
+ "repository": {
89
+ "type": "git",
90
+ "url": "git+https://github.com/StarsHarryZhu/complete-subagent.git"
91
+ },
92
+ "homepage": "https://github.com/StarsHarryZhu/complete-subagent#readme",
93
+ "bugs": {
94
+ "url": "https://github.com/StarsHarryZhu/complete-subagent/issues"
95
+ },
88
96
  "license": "MIT"
89
97
  }
@@ -14,6 +14,7 @@ The host modules. A delegation call decides the child's sub-workspace and `writa
14
14
  - An inherited binding holds no access of its own; the fence resolves it to the nearest ancestor's current access, and a broken chain leaves none.
15
15
  - The delegation result text is `started subagent <id>`, as the official tools write it.
16
16
  - Only a `spawn` start carries the configured `childPreset` as `agentPreset`; a `fork` start never selects a preset.
17
+ - A start's task (`cwd`, `prompt`, `parent`, `agentPreset`, `agentOptions`, `maxDepth`) goes both at the top level of the spec, for hosts from 0.2.2-rc.2, and under `request`, for older ones; `delegate.ts` builds it once and `types.ts` mirrors both shapes.
17
18
  - A child's route goes only through the start's `agentOptions`, which both 0.2.1-rc.5 and 0.2.2-alpha.2 use for its first request; nothing selects a model afterwards.
18
19
  - `ownModel` off applies to `delegate` only. On the parent's own route the host hands down the parent's effort unless one is named, so `models.ts` names the effort there.
19
20
  - A model outside the list fails first in the tool's own `enum` check, with the host's "must be one of" message; the message in `models.ts` covers a call that gets past it.
@@ -47,5 +48,6 @@ The host modules. A delegation call decides the child's sub-workspace and `writa
47
48
  - Verified in the real web app, before the move to standalone tools: the fence, grants, requests, and storage with the host's own sandbox enforcing the narrowed policy (2026-10-29 to 2026-11-01).
48
49
  - Checked on the real rc.5 tool, prompt, projection, and sandbox-policy services (2026-11-02): `legacy.ts`, `scope.ts`, and the single-root grant, with stand-ins for agents and the subagent start.
49
50
  - Checked on real 0.2.1-rc.5 and 0.2.2-alpha.2 hosts with a mock model (2026-11-02): `delegate.ts` and `models.ts`, from the tool call to the child's first recorded request.
51
+ - Fixed and checked on real 0.2.1-rc.5, 0.2.2-rc.1, 0.2.2-rc.2, and 0.2.2-rc.3 hosts with a mock model (2026-11-17): `delegate.ts` starts a child on each, where before it failed from 0.2.2-rc.2 on; the fence, a write-access request, its answer, and the grant worked on all four.
50
52
  - Open: `delegate.ts`, `models.ts`, `scope.ts`, `legacy.ts`, and inherited confinement are not yet verified in a real web app.
51
53
  - Goal later: nothing planned.
@@ -29,7 +29,7 @@ import {
29
29
  delegateDescription,
30
30
  } from './prompt.ts'
31
31
  import { DELEGATE_TOOLS } from './types.ts'
32
- import type { AgentLike, DelegateTool, LlmLike, SubagentsLike } from './types.ts'
32
+ import type { AgentLike, DelegateTool, LlmLike, StartRequestLike, SubagentsLike } from './types.ts'
33
33
 
34
34
  /** What the delegation tools read. */
35
35
  export interface DelegateDeps extends AccessDeps {
@@ -114,19 +114,23 @@ export function createDelegateTool(tool: DelegateTool, models: readonly ChildMod
114
114
  const agentPreset = provider === 'spawn' ? deps.childPreset : undefined
115
115
  const childId = deps.newId?.() ?? randomUUID()
116
116
  deps.store.set({ version: 1, child: childId, parent: parent.session.id, workspace: access.workspace, grants: access.grants })
117
+ const task: StartRequestLike = {
118
+ ...access.cwd === undefined ? {} : { cwd: access.cwd },
119
+ prompt: [{ type: 'text', text: args.prompt }],
120
+ parent,
121
+ ...agentPreset === undefined ? {} : { agentPreset },
122
+ ...route === undefined ? {} : { agentOptions: route },
123
+ ...maxDepth === undefined ? {} : { maxDepth },
124
+ }
117
125
  try {
126
+ // The task goes both ways: hosts from 0.2.2-rc.2 read it at the top level and those before under
127
+ // `request`, and neither reads the other's fields, so one call starts the child on every host.
118
128
  const started = await deps.subagents.startActivation({
119
129
  provider,
120
130
  label: args.description,
121
131
  childId,
122
- request: {
123
- ...access.cwd === undefined ? {} : { cwd: access.cwd },
124
- prompt: [{ type: 'text', text: args.prompt }],
125
- parent,
126
- ...agentPreset === undefined ? {} : { agentPreset },
127
- ...route === undefined ? {} : { agentOptions: route },
128
- ...maxDepth === undefined ? {} : { maxDepth },
129
- },
132
+ ...task,
133
+ request: task,
130
134
  signal: exec.signal,
131
135
  delivery: 'parent',
132
136
  })
package/src/host/types.ts CHANGED
@@ -107,23 +107,32 @@ export interface TextBlock {
107
107
  readonly text: string
108
108
  }
109
109
 
110
- /** `SubagentActivationSpec` with a reserved child id, as this plugin fills it. */
111
- export interface ActivationSpecLike {
110
+ /** `SubagentStartRequest`: the task part of a start, as this plugin fills it. */
111
+ export interface StartRequestLike {
112
+ readonly cwd?: string
113
+ readonly prompt: TextBlock[]
114
+ readonly parent: AgentLike
115
+ /** Preset the child runs instead of the parent's; only a backend that does not inherit the parent's context accepts it. */
116
+ readonly agentPreset?: string
117
+ readonly agentOptions?: RouteLike
118
+ readonly maxDepth?: number
119
+ }
120
+
121
+ /**
122
+ * `SubagentActivationSpec` with a reserved child id, as this plugin fills it.
123
+ * Hosts from 0.2.2-rc.2 read the task at the top level; older ones read it
124
+ * under `request` and ignore the top-level copy, and newer ones the reverse,
125
+ * so the plugin sends both.
126
+ */
127
+ export interface ActivationSpecLike extends StartRequestLike {
112
128
  /** Registered backend: `spawn` (fresh child) or `fork` (inherits the conversation). */
113
129
  readonly provider: string
114
130
  /** Short task label shown with the child. */
115
131
  readonly label: string
116
132
  /** Reserved child session id, so the child is bound before it exists. */
117
133
  readonly childId: string
118
- readonly request: {
119
- readonly cwd?: string
120
- readonly prompt: TextBlock[]
121
- readonly parent: AgentLike
122
- /** Preset the child runs instead of the parent's; only a backend that does not inherit the parent's context accepts it. */
123
- readonly agentPreset?: string
124
- readonly agentOptions?: RouteLike
125
- readonly maxDepth?: number
126
- }
134
+ /** The same task, for hosts before 0.2.2-rc.2. */
135
+ readonly request: StartRequestLike
127
136
  readonly signal: AbortSignal
128
137
  /** `parent`: the runtime notifies the parent model when the child finishes. */
129
138
  readonly delivery: 'parent'