@sshirkit/dsh-orchestrator 1.0.0 → 1.0.2
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 +24 -10
- package/README.zh.md +23 -10
- package/docs/images/plugin-icon.png +0 -0
- package/lib/client.js +262 -37
- package/lib/delegate.js +35 -19
- package/lib/gate.js +2 -2
- package/lib/index.js +35 -12
- package/lib/orchestrate.js +56 -24
- package/lib/rules.js +11 -0
- package/lib/session-tools.js +344 -0
- package/lib/tool-surface.js +28 -6
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|

|
|
14
14
|
|
|
15
|
-
[](https://github.com/SShiRkiT/dsh-orchestrator)
|
|
16
16
|
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
17
17
|
[](https://github.com/SShiRkiT/dsh-orchestrator)
|
|
18
18
|
[](https://nodejs.org)
|
|
@@ -98,8 +98,18 @@ At handoff, the plugin also checks whether a subagent touched files outside its
|
|
|
98
98
|
In the **Dispatch** panel next to the composer, main-agent and subagent models are configured completely separately:
|
|
99
99
|
- Both the default main model and default subagent model can be set explicitly.
|
|
100
100
|
|
|
101
|
-
>
|
|
102
|
-
> The workspace
|
|
101
|
+
> Specify a subagent model for a turn or workspace in your prompt or `AGENTS.md`. The main agent passes `provider` and `model` together and adds `reasoning_effort` only when requested.
|
|
102
|
+
> The workspace’s main-agent model can still be switched independently in DSH’s native model selector.
|
|
103
|
+
|
|
104
|
+
**Set up a tiered model routing table in `AGENTS.md` or your prompt**
|
|
105
|
+
|
|
106
|
+
Copy the table below into your workspace’s `AGENTS.md` or your prompt. The main agent reads and applies these rules; the plugin does not parse the table. An explicit route in the current message takes precedence over workspace rules. Replace the placeholders with actual provider and model IDs available in DSH. If no rule matches, omit all three route parameters.
|
|
107
|
+
|
|
108
|
+
| Task type | `provider` | `model` | `reasoning_effort` |
|
|
109
|
+
| --- | --- | --- | --- |
|
|
110
|
+
| Lightweight tasks (e.g. extraction or classification) | `<light-provider-id>` | `<light-model-id>` | Omit |
|
|
111
|
+
| Heavyweight tasks (e.g. architecture analysis or complex review) | `<heavy-provider-id>` | `<heavy-model-id>` | `high` (if supported by the model) |
|
|
112
|
+
| Other tasks | Omit | Omit | Omit |
|
|
103
113
|
|
|
104
114
|

|
|
105
115
|
|
|
@@ -132,6 +142,8 @@ For repetitive or multi-step jobs like "inspect → edit → verify across 20 fi
|
|
|
132
142
|
|
|
133
143
|
> Powered by `orchestrate`, supporting 1–64 items × 1–8 stages and 1–16 concurrent workers (default 4), with optional per-stage JSON format checks; in isolated mode each item gets its own working directory reused across stages, excluded from background check-ins.
|
|
134
144
|
|
|
145
|
+
To explicitly select a model for a stage, pass `provider` and `model` together in that `stages` entry, with optional `reasoning_effort`. Each stage chooses one whole route: **stage override > top-level batch override > panel default worker route**. Routes are never combined, and reasoning effort is not inherited from a fallback route. The panel default is required only when a stage needs it; if it is missing, the batch starts no workers.
|
|
146
|
+
|
|
135
147
|
---
|
|
136
148
|
|
|
137
149
|
<div align="center">
|
|
@@ -144,11 +156,13 @@ The plugin exposes 4 orchestration and review tools exclusively to the main agen
|
|
|
144
156
|
|
|
145
157
|
| Tool | What It Does | Common Parameters | Good to Know |
|
|
146
158
|
| --- | --- | --- | --- |
|
|
147
|
-
| `delegate` | Async task dispatch; supports parallel fan-out in one turn | `prompt`, `description`, `writeScope` (required for writes), `readOnly`, `isolation`, `expectedFingerprints`, `expectedTargets`, `cwd`, `provider` + `model` | Main agent only; auto-allocates an isolated directory or file lock for writes; attaches audit results at handoff and includes background check-ins |
|
|
148
|
-
| `orchestrate` | Parallel batch & multi-stage pipelines | `items` (1–64), `stages` (1–8, optional `schema`), `maxConcurrency` (1–16, default 4), `writeScope`, `readOnly`, `isolation`, `cwd`, `provider` + `model` |
|
|
159
|
+
| `delegate` | Async task dispatch; supports parallel fan-out in one turn | `prompt`, `description`, `writeScope` (required for writes), `readOnly`, `isolation`, `expectedFingerprints`, `expectedTargets`, `cwd`, `provider` + `model`, optional `team_task_id` | Main agent only; auto-allocates an isolated directory or file lock for writes; attaches audit results at handoff and includes background check-ins |
|
|
160
|
+
| `orchestrate` | Parallel batch & multi-stage pipelines | `items` (1–64), `stages` (1–8, optional `schema`), `maxConcurrency` (1–16, default 4), `writeScope`, `readOnly`, `isolation`, `cwd`, optional top-level `team_task_id`; `provider` + `model` with optional `reasoning_effort` at the top level or per stage | Route priority: stage override > batch override > panel default. Items advance independently, reuse their own isolated directory, and run synchronously without background check-ins |
|
|
149
161
|
| `delegate_status` | One-stop acceptance overview for all subagents in this session | `childId` (optional), `includeCompleted` (default `true`), `limit` (1–64, default 20) | Read-only; separates run state, audit status, file locks, and directories awaiting review; missing records never mean "passed" |
|
|
150
162
|
| `worktree_manage` | List, inspect, merge, discard, or prune isolated directories | `action` (`list`/`inspect`/`merge`/`discard`/`prune`), `worktreeId` / `childId`, `strategy` (`merge`/`squash`/`ff-only`), `autoStageDirty`, `deleteAfterMerge`, `force`, `dryRun` | Main agent only; passing audit ≠ merged to your branch; merge conflicts preserve the scene; cleaning up or discarding locks retired workers |
|
|
151
163
|
|
|
164
|
+
When native Agent Teams is on for the host's root session and dispatch mode permits `team_task_create` in that session, the main agent can create a shared goal before dispatching complex work. Pass the returned `id` as `team_task_id`; subagents (every stage in `orchestrate`) can read the goal with `team_task_get` when available. Keep the task prompt self-contained: the shared goal is a reference, not a substitute for dispatch or write leases.
|
|
165
|
+
|
|
152
166
|
---
|
|
153
167
|
|
|
154
168
|
<div align="center">
|
|
@@ -219,7 +233,7 @@ The bilingual panel adapts automatically to DSH's locale and provides live contr
|
|
|
219
233
|
- **Enable Git Worktree isolation by default**: controls `isolation: "auto"` behavior for Git write tasks;
|
|
220
234
|
- **Main agent / Subagent default model & reasoning effort**: searchable model picker; main writes host `agent-default-model` (new sessions only), subagent applies from the next dispatch;
|
|
221
235
|
- **Subagent check interval / check count / Unlimited checks**: adjusts sidecar supervision live while workers run;
|
|
222
|
-
- **Right-hand `Allowed Tools` checklist**:
|
|
236
|
+
- **Right-hand `Allowed Tools` checklist**: search, check individual tools, or reset to defaults. Turn on **Only for this session** (shown as **仅当前会话** in Chinese) to edit a separate list for the current conversation. Turn it off to restore inheritance from the global list.
|
|
223
237
|
|
|
224
238
|
## Configuration Reference
|
|
225
239
|
|
|
@@ -229,10 +243,10 @@ All 13 user-configurable fields below are `volatile` (dynamic hot config, no res
|
|
|
229
243
|
| --- | --- | --- |
|
|
230
244
|
| `enabled` | `true` | Master switch for dispatch mode. Turning it off restores the native host tool surface; `delegate` / `orchestrate` stay disabled and bound supervision-turn hard locks still take priority. |
|
|
231
245
|
| `worktreeIsolationEnabled` | `true` | Controls whether `isolation: "auto"` creates isolated Git Worktrees with `git diff` / `git log` audits for Git write tasks (non-Git directories fall back to snapshot audits). |
|
|
232
|
-
| `allowedTools` | Unset (9 base tools; plus 4 registered native Team tools when `allowAgentTeam: true`) | Explicit main-agent tool whitelist. An explicit array (including `[]`) **replaces** the defaults rather than appending
|
|
233
|
-
| `allowAgentTeam` | `true` |
|
|
234
|
-
| `workerProvider` | `""` | Default worker route provider
|
|
235
|
-
| `workerModel` | `""` | Default worker route model
|
|
246
|
+
| `allowedTools` | Unset (9 base tools; plus 4 registered native Team tools when `allowAgentTeam: true`) | Explicit main-agent tool whitelist. An explicit array (including `[]`) **replaces** the defaults rather than appending. The panel's `Allowed Tools` checklist updates this field when **Only for this session** is off. |
|
|
247
|
+
| `allowAgentTeam` | `true` | Controls only the main agent's access to native task-board tools (`team_task_*`) in dispatch mode; it does not switch host Agent Teams on or off. `false` overrides the session and global whitelists. When the root session has native Agent Teams on and its whitelist permits `team_task_create`, the main agent can create a shared goal and pass its ID as optional `team_task_id` for subagents to read. |
|
|
248
|
+
| `workerProvider` | `""` | Default worker route provider. When no explicit override applies, both this and `workerModel` are required; there is no fallback to the main model. |
|
|
249
|
+
| `workerModel` | `""` | Default worker route model; same requirement as above. |
|
|
236
250
|
| `workerReasoningEffort` | `""` | Default worker reasoning effort; leave empty to let the chosen worker model use its own default. |
|
|
237
251
|
| `superviseEnabled` | `true` | Master switch for background sidecar supervision (in the host plugin settings card). |
|
|
238
252
|
| `superviseIntervalSeconds` | `600` | Sidecar supervision interval in seconds (`10–86400`); changes apply immediately to running workers. |
|
package/README.zh.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|

|
|
14
14
|
|
|
15
|
-
[](https://github.com/SShiRkiT/dsh-orchestrator)
|
|
16
16
|
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
17
17
|
[](https://github.com/SShiRkiT/dsh-orchestrator)
|
|
18
18
|
[](https://nodejs.org)
|
|
@@ -99,8 +99,17 @@
|
|
|
99
99
|
在输入栏右侧的「调度模式」面板里,主模型和子代理模型彻底分开配置:
|
|
100
100
|
- 默认主模型与子模型都可以指定设置。
|
|
101
101
|
|
|
102
|
-
>
|
|
103
|
-
|
|
102
|
+
> 可在提示词或 `AGENTS.md` 中指定本轮或本工作区的子代理模型,由主代理派发时成对传入 `provider` 和 `model`,并按需添加 `reasoning_effort`。工作区的主代理模型仍可在 DSH 原生模型选择器中独立切换。
|
|
103
|
+
|
|
104
|
+
**在 `AGENTS.md` 或提示词中配置分级模型路由表**
|
|
105
|
+
|
|
106
|
+
可把下面的表写进工作区的 `AGENTS.md` 或直接放入提示词。这是供主代理阅读和应用的规则,插件不会解析表格。当前消息显式点名的路由优先于工作区规则。请把占位符替换成 DSH 中真实可用的 Provider ID 和 Model ID;任务未匹配时,省略三个路由参数。
|
|
107
|
+
|
|
108
|
+
| 任务类别 | `provider` | `model` | `reasoning_effort` |
|
|
109
|
+
| --- | --- | --- | --- |
|
|
110
|
+
| 轻量任务(如提取、分类) | `<轻量-provider-id>` | `<轻量-model-id>` | 省略 |
|
|
111
|
+
| 重量任务(如架构推演、复杂复核) | `<重量-provider-id>` | `<重量-model-id>` | `high`(模型支持时) |
|
|
112
|
+
| 其他任务 | 省略 | 省略 | 省略 |
|
|
104
113
|
|
|
105
114
|

|
|
106
115
|
|
|
@@ -134,6 +143,8 @@
|
|
|
134
143
|
|
|
135
144
|
> 由 `orchestrate` 驱动,支持 1–64 个条目 × 1–8 个阶段、1–16 路并发(默认 4),每阶段可选 JSON 格式校验;隔离模式下按条目自动分配并跨阶段复用独立目录,不进入后台巡检。
|
|
136
145
|
|
|
146
|
+
显式指定某个阶段的模型时,在对应的 `stages` 条目中成对传入 `provider` 和 `model`,可同时传入 `reasoning_effort`。每个阶段按 **阶段覆盖 > 顶层批次覆盖 > 面板默认子代理路由** 的顺序选择整组路由,不跨层拼接,也不从后备路由继承推理强度。仅当某个阶段需要回退到面板默认路由时,才要求面板已配置子代理模型;缺失时整批不会启动。
|
|
147
|
+
|
|
137
148
|
---
|
|
138
149
|
|
|
139
150
|
<div align="center">
|
|
@@ -146,11 +157,13 @@
|
|
|
146
157
|
|
|
147
158
|
| 工具 | 做什么用 | 常用参数 | 注意事项 |
|
|
148
159
|
| --- | --- | --- | --- |
|
|
149
|
-
| `delegate` | 异步派活,支持同回合同时派多个 | `prompt`、`description`、`writeScope`(写任务必填)、`readOnly`、`isolation`、`expectedFingerprints`、`expectedTargets`、`cwd`、`provider` + `model` | 仅主代理可用;写任务自动开隔离目录或加文件锁;交工时自动附上审计结果,运行中受后台巡检覆盖 |
|
|
150
|
-
| `orchestrate` | 批量 / 多步骤流水线自动并行跑 | `items`(1–64)、`stages`(1–8,可配 `schema`)、`maxConcurrency`(1–16,默认 4)、`writeScope`、`readOnly`、`isolation`、`cwd
|
|
160
|
+
| `delegate` | 异步派活,支持同回合同时派多个 | `prompt`、`description`、`writeScope`(写任务必填)、`readOnly`、`isolation`、`expectedFingerprints`、`expectedTargets`、`cwd`、`provider` + `model`、可选 `team_task_id` | 仅主代理可用;写任务自动开隔离目录或加文件锁;交工时自动附上审计结果,运行中受后台巡检覆盖 |
|
|
161
|
+
| `orchestrate` | 批量 / 多步骤流水线自动并行跑 | `items`(1–64)、`stages`(1–8,可配 `schema`)、`maxConcurrency`(1–16,默认 4)、`writeScope`、`readOnly`、`isolation`、`cwd`、可选顶层 `team_task_id`;顶层或单个阶段均可指定 `provider` + `model`,可选 `reasoning_effort` | 路由优先级:阶段覆盖 > 顶层批次覆盖 > 面板默认;各条目独立推进,隔离模式按条目复用目录,同步等待,不进后台巡检 |
|
|
151
162
|
| `delegate_status` | 一眼查看当前会话所有子代理的验收进度 | `childId`(可选)、`includeCompleted`(默认 `true`)、`limit`(1–64,默认 20) | 只读查询;清晰区分运行状态、审计结果、文件锁与待评审目录,没查到记录不代表已通过 |
|
|
152
163
|
| `worktree_manage` | 查看、审阅、合并、丢弃或清理隔离目录 | `action`(`list`/`inspect`/`merge`/`discard`/`prune`)、`worktreeId` / `childId`、`strategy`(`merge`/`squash`/`ff-only`)、`autoStageDirty`、`deleteAfterMerge`、`force`、`dryRun` | 仅主代理可用;审计通过不等于已合回主分支;合并冲突会保留现场;清理或丢弃后自动锁死旧子代理 |
|
|
153
164
|
|
|
165
|
+
宿主根会话已开启原生「智能体团队协作」,且调度模式放行当前会话的 `team_task_create` 时,主代理可在派发复杂任务前建立共享目标,将工具返回的 `id` 作为 `team_task_id` 传给子代理(编排时传给每个阶段)。子代理可在 `team_task_get` 可用时读取目标作为参考;任务说明仍须自包含,共享目标不替代派发或写租约。
|
|
166
|
+
|
|
154
167
|
---
|
|
155
168
|
|
|
156
169
|
<div align="center">
|
|
@@ -219,7 +232,7 @@ dsh plugin --profile desktop add @sshirkit/dsh-orchestrator
|
|
|
219
232
|
- **默认启用 Git Worktree 隔离**:控制 `isolation: "auto"` 在 Git 仓库写任务下的隔离行为;
|
|
220
233
|
- **主代理 / 子代理默认模型与推理强度**:支持关键词搜索选择模型;主代理写入宿主 `agent-default-model`(仅影响新会话),子代理从下一次派发生效;
|
|
221
234
|
- **子代理巡检间隔 / 巡检次数 / 无限巡检**:运行中动态调整后台旁路巡检策略;
|
|
222
|
-
- **右侧 `Allowed Tools`
|
|
235
|
+
- **右侧 `Allowed Tools` 列表**支持按关键字搜索、勾选主代理可用工具和重置默认白名单。打开「仅当前会话」开关(英文界面显示 `Only for this session`)可单独编辑当前会话的白名单,关闭后恢复继承全局设置。
|
|
223
236
|
|
|
224
237
|
## 配置项速查表
|
|
225
238
|
|
|
@@ -229,10 +242,10 @@ dsh plugin --profile desktop add @sshirkit/dsh-orchestrator
|
|
|
229
242
|
| --- | --- | --- |
|
|
230
243
|
| `enabled` | `true` | 调度模式总开关。关闭后一键恢复宿主原生工具面;`delegate` / `orchestrate` 仍禁用,已绑定巡检回合的硬禁仍优先。 |
|
|
231
244
|
| `worktreeIsolationEnabled` | `true` | 控制 `isolation: "auto"` 下是否为 Git 仓库写任务默认启用独立 Worktree 隔离与 `git diff` / `git log` 审计(非 Git 目录自动降级快照审计)。 |
|
|
232
|
-
| `allowedTools` | 未配置(默认 9 项基础工具;`allowAgentTeam: true` 时自动追加已注册的 4 项原生 Team 工具) | 主代理显式工具白名单。显式数组(包括 `[]
|
|
233
|
-
| `allowAgentTeam` | `true` |
|
|
234
|
-
| `workerProvider` | `""` | 子代理默认路由 Provider
|
|
235
|
-
| `workerModel` | `""` | 子代理默认路由 Model
|
|
245
|
+
| `allowedTools` | 未配置(默认 9 项基础工具;`allowAgentTeam: true` 时自动追加已注册的 4 项原生 Team 工具) | 主代理显式工具白名单。显式数组(包括 `[]`)会**替换**默认名单。关闭「仅当前会话」开关时,右侧 `Allowed Tools` 列表的改动实时写入此项。 |
|
|
246
|
+
| `allowAgentTeam` | `true` | 只控制调度模式下主代理能否调用原生 Team 任务板工具(`team_task_*`),不切换宿主「智能体团队协作」模式。设为 `false` 时优先于会话和全局白名单。宿主根会话已开启原生 Team 且会话放行 `team_task_create` 时,主代理可建立共享目标并用可选 `team_task_id` 传给子代理读取。 |
|
|
247
|
+
| `workerProvider` | `""` | 子代理默认路由 Provider。未命中任何显式路由覆盖时,必须同时配置此项和 `workerModel`;不会回退到主模型。 |
|
|
248
|
+
| `workerModel` | `""` | 子代理默认路由 Model;约束同上。 |
|
|
236
249
|
| `workerReasoningEffort` | `""` | 子代理默认推理强度;留空则由所选子代理模型自行决定默认值。 |
|
|
237
250
|
| `superviseEnabled` | `true` | 子代理后台旁路巡检总开关(位于宿主插件设置卡片)。 |
|
|
238
251
|
| `superviseIntervalSeconds` | `600` | 旁路巡检间隔(秒),范围 `10–86400`,运行中修改立即生效。 |
|
|
Binary file
|
package/lib/client.js
CHANGED
|
@@ -28,7 +28,7 @@ window.__ModuleLoader__.load({
|
|
|
28
28
|
'route.catalogFailed': '无法加载模型目录',
|
|
29
29
|
'route.readonly': '当前不可写,无法保存',
|
|
30
30
|
'route.saveFailed': '保存失败',
|
|
31
|
-
'route.note': '
|
|
31
|
+
'route.note': '主代理的改动对新会话生效;子代理的改动从下一次委派起生效。子代理共享默认路由,可在任务或阶段中显式覆盖。',
|
|
32
32
|
'route.search': '搜索模型…',
|
|
33
33
|
'route.noMatch': '没有匹配的模型',
|
|
34
34
|
'route.noMatchHint': '换个关键词,或清空搜索看全部',
|
|
@@ -42,9 +42,16 @@ window.__ModuleLoader__.load({
|
|
|
42
42
|
'allowed.search': '搜索工具…',
|
|
43
43
|
'allowed.empty': '没有匹配的工具',
|
|
44
44
|
'allowed.reset': '重置',
|
|
45
|
+
'allowed.session': '仅当前会话',
|
|
46
|
+
'allowed.sessionOn': '仅本会话独立生效。',
|
|
47
|
+
'allowed.sessionOff': '继承全局默认;编辑将修改全局设置。',
|
|
48
|
+
'allowed.sessionMissing': '没有可用于保存的会话。',
|
|
49
|
+
'allowed.sessionLoading': '正在加载会话白名单…',
|
|
50
|
+
'allowed.sessionFailed': '无法加载会话白名单',
|
|
51
|
+
'allowed.sessionStorage': '会话白名单存储不可用。',
|
|
45
52
|
'allowed.hint': '白名单式驱动:勾选 = 允许主代理使用;未勾选(含新插件工具)= 自动禁用。',
|
|
46
53
|
'allowed.nativeBlocked': '按 ADR-0004 默认禁用;建议改用 delegate / orchestrate。显式勾选可覆盖。',
|
|
47
|
-
'allowed.teamDisabled': '
|
|
54
|
+
'allowed.teamDisabled': '调度模式下禁止主代理调用原生 Team 任务板工具(allowAgentTeam: false)。',
|
|
48
55
|
'supervise.label': '子代理巡检间隔(秒)',
|
|
49
56
|
'supervise.hint': '默认 600 秒(10 分钟)。主代理会按此间隔检查运行中的子代理,运行中修改立即生效。范围 10–86400。',
|
|
50
57
|
'supervise.invalid': '请输入 10–86400 之间的整数',
|
|
@@ -67,7 +74,7 @@ window.__ModuleLoader__.load({
|
|
|
67
74
|
'route.catalogFailed': 'Could not load the model catalog',
|
|
68
75
|
'route.readonly': 'Not writable right now, cannot save',
|
|
69
76
|
'route.saveFailed': 'Could not save',
|
|
70
|
-
'route.note': 'A main agent change applies to new sessions; a subagent change applies from the next delegation.
|
|
77
|
+
'route.note': 'A main agent change applies to new sessions; a subagent change applies from the next delegation. Subagents share a default route that can be explicitly overridden for a task or stage.',
|
|
71
78
|
'route.search': 'Search models…',
|
|
72
79
|
'route.noMatch': 'No matching models',
|
|
73
80
|
'route.noMatchHint': 'Try another keyword, or clear the search to see everything',
|
|
@@ -81,9 +88,16 @@ window.__ModuleLoader__.load({
|
|
|
81
88
|
'allowed.search': 'Filter tools…',
|
|
82
89
|
'allowed.empty': 'No matching tools',
|
|
83
90
|
'allowed.reset': 'Reset',
|
|
91
|
+
'allowed.session': 'Only for this session',
|
|
92
|
+
'allowed.sessionOn': 'Uses a separate list for this session.',
|
|
93
|
+
'allowed.sessionOff': 'Inherits global defaults; edits change the global settings.',
|
|
94
|
+
'allowed.sessionMissing': 'No session is available for saving.',
|
|
95
|
+
'allowed.sessionLoading': 'Loading session allowed tools…',
|
|
96
|
+
'allowed.sessionFailed': 'Could not load session allowed tools',
|
|
97
|
+
'allowed.sessionStorage': 'Session tools storage is unavailable.',
|
|
84
98
|
'allowed.hint': 'Whitelist-driven: checked = allowed for the main agent; unchecked (including new plugin tools) = blocked automatically.',
|
|
85
99
|
'allowed.nativeBlocked': 'Disabled by default under ADR-0004; prefer delegate / orchestrate. Check explicitly to override.',
|
|
86
|
-
'allowed.teamDisabled': '
|
|
100
|
+
'allowed.teamDisabled': 'In dispatch mode, the main agent cannot call native Team task-board tools (allowAgentTeam: false).',
|
|
87
101
|
'supervise.label': 'Subagent check interval (seconds)',
|
|
88
102
|
'supervise.hint': 'Default 600 seconds (10 minutes). The main agent checks running subagents at this interval; changes apply immediately. Range 10–86400.',
|
|
89
103
|
'supervise.invalid': 'Enter an integer between 10 and 86400',
|
|
@@ -414,6 +428,150 @@ window.__ModuleLoader__.load({
|
|
|
414
428
|
return [{ op: 'unset', path: [ALLOW_KEY] }]
|
|
415
429
|
}
|
|
416
430
|
|
|
431
|
+
// The Web ModuleLoader loads this factory as a script, not as ESM. Mirror the
|
|
432
|
+
// host's descriptor browser-side and check the complete wire contract in tests.
|
|
433
|
+
const SESSION_REMOTE_PACKAGE = '@sshirkit/dsh-orchestrator'
|
|
434
|
+
const SESSION_REMOTE = 'orchestratorSession'
|
|
435
|
+
const SESSION_REMOTE_INJECT = `remote.${SESSION_REMOTE}`
|
|
436
|
+
function createSessionToolsDescriptors() {
|
|
437
|
+
const nonempty = (value, field) => {
|
|
438
|
+
if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${field} must be a non-empty string`)
|
|
439
|
+
return value
|
|
440
|
+
}
|
|
441
|
+
const parseSession = (value) => nonempty(value, 'sessionId')
|
|
442
|
+
const parseNames = (value) => {
|
|
443
|
+
if (!Array.isArray(value)) throw new TypeError('allowedTools must be an array')
|
|
444
|
+
return [...new Set(Array.from(value, (name) => nonempty(name, 'tool name')))]
|
|
445
|
+
}
|
|
446
|
+
const parseRevision = (value) => {
|
|
447
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new TypeError('revision must be a non-negative safe integer')
|
|
448
|
+
return value
|
|
449
|
+
}
|
|
450
|
+
const fields = (value, names) => {
|
|
451
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value) ||
|
|
452
|
+
Object.keys(value).length !== names.length || !names.every((key) => Object.hasOwn(value, key))) {
|
|
453
|
+
throw new TypeError(`expected record with fields ${names.join(', ')}`)
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
const parseResult = (value) => {
|
|
457
|
+
if (value?.ok === false) {
|
|
458
|
+
fields(value, ['ok', 'error'])
|
|
459
|
+
fields(value.error, ['code', 'message'])
|
|
460
|
+
nonempty(value.error.code, 'error code')
|
|
461
|
+
nonempty(value.error.message, 'error message')
|
|
462
|
+
} else {
|
|
463
|
+
fields(value, ['sessionId', 'enabled', 'allowedTools', 'revision', 'storageReady'])
|
|
464
|
+
if (typeof value.enabled !== 'boolean' || typeof value.storageReady !== 'boolean') {
|
|
465
|
+
throw new TypeError('enabled and storageReady must be booleans')
|
|
466
|
+
}
|
|
467
|
+
parseSession(value.sessionId)
|
|
468
|
+
parseNames(value.allowedTools)
|
|
469
|
+
parseRevision(value.revision)
|
|
470
|
+
}
|
|
471
|
+
return value
|
|
472
|
+
}
|
|
473
|
+
const codec = (typeSymbol, parse) => ({ mode: 'strict', typeSymbol, create: () => ({ parse }) })
|
|
474
|
+
const parameter = (name, typeSymbol, parse) => ({
|
|
475
|
+
name, wire: name, source: 'json', codec: codec(typeSymbol, parse),
|
|
476
|
+
})
|
|
477
|
+
const session = parameter('sessionId', 'SessionId', parseSession)
|
|
478
|
+
const names = parameter('allowedTools', 'OrchestratorToolNames', parseNames)
|
|
479
|
+
const revision = parameter('expectedRevision', 'OrchestratorToolsRevision', parseRevision)
|
|
480
|
+
const result = codec('OrchestratorSessionToolsResult', parseResult)
|
|
481
|
+
return Object.entries({ get: [session], set: [session, names, revision], clear: [session, revision] })
|
|
482
|
+
.map(([method, parameters]) => ({
|
|
483
|
+
id: `${SESSION_REMOTE_PACKAGE}/${SESSION_REMOTE}/${method}`,
|
|
484
|
+
service: SESSION_REMOTE,
|
|
485
|
+
namespace: SESSION_REMOTE,
|
|
486
|
+
method,
|
|
487
|
+
invocation: { kind: 'direct' },
|
|
488
|
+
parameters,
|
|
489
|
+
result,
|
|
490
|
+
}))
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function mountSessionRemote(ctx) {
|
|
494
|
+
const unavailable = () => new Error('Session tools Remote is unavailable')
|
|
495
|
+
let stopped = false
|
|
496
|
+
let service
|
|
497
|
+
let unmount
|
|
498
|
+
let injectFiber
|
|
499
|
+
let injectTimeout
|
|
500
|
+
let closing
|
|
501
|
+
let resolveReady, rejectReady
|
|
502
|
+
const ready = new Promise((resolve, reject) => {
|
|
503
|
+
resolveReady = resolve
|
|
504
|
+
rejectReady = reject
|
|
505
|
+
})
|
|
506
|
+
const setup = Promise.resolve().then(async () => {
|
|
507
|
+
if (stopped || typeof ctx.remote?.$mount !== 'function') throw unavailable()
|
|
508
|
+
unmount = await ctx.remote.$mount({
|
|
509
|
+
package: SESSION_REMOTE_PACKAGE,
|
|
510
|
+
descriptors: createSessionToolsDescriptors(),
|
|
511
|
+
})
|
|
512
|
+
if (typeof unmount !== 'function') throw new Error('Session tools Remote registration was not confirmed')
|
|
513
|
+
if (stopped) return
|
|
514
|
+
if (typeof ctx.inject !== 'function') {
|
|
515
|
+
service = typeof ctx.get === 'function' ? ctx.get(SESSION_REMOTE_INJECT) : ctx.remote?.[SESSION_REMOTE]
|
|
516
|
+
if (!service) throw unavailable()
|
|
517
|
+
resolveReady()
|
|
518
|
+
return
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
injectTimeout = setTimeout(() => {
|
|
522
|
+
rejectReady(new Error('Timed out waiting for Session tools Remote injection'))
|
|
523
|
+
}, 5000)
|
|
524
|
+
injectFiber = ctx.inject([SESSION_REMOTE_INJECT], (scopedCtx) => {
|
|
525
|
+
if (stopped) return
|
|
526
|
+
try {
|
|
527
|
+
const injected = scopedCtx.remote[SESSION_REMOTE]
|
|
528
|
+
if (!injected) throw unavailable()
|
|
529
|
+
scopedCtx.on('dispose', () => {
|
|
530
|
+
if (service === injected) service = undefined
|
|
531
|
+
})
|
|
532
|
+
service = injected
|
|
533
|
+
// Cordis fibers are thenable. Wait for activation after the callback binds the service.
|
|
534
|
+
void activation.then(resolveReady, rejectReady)
|
|
535
|
+
} catch (error) {
|
|
536
|
+
rejectReady(error)
|
|
537
|
+
}
|
|
538
|
+
})
|
|
539
|
+
})
|
|
540
|
+
const activation = setup.then(() => injectFiber)
|
|
541
|
+
void activation.catch(rejectReady)
|
|
542
|
+
void ready.then(() => clearTimeout(injectTimeout), () => dispose().catch(() => {}))
|
|
543
|
+
|
|
544
|
+
function dispose() {
|
|
545
|
+
if (closing) return closing
|
|
546
|
+
stopped = true
|
|
547
|
+
service = undefined
|
|
548
|
+
clearTimeout(injectTimeout)
|
|
549
|
+
rejectReady(unavailable())
|
|
550
|
+
// Wait only for setup to acquire the handles. Activation may still be pending.
|
|
551
|
+
closing = setup.catch(() => {}).then(async () => {
|
|
552
|
+
try {
|
|
553
|
+
await injectFiber?.dispose?.()
|
|
554
|
+
} finally {
|
|
555
|
+
if (typeof unmount === 'function') await unmount()
|
|
556
|
+
}
|
|
557
|
+
})
|
|
558
|
+
return closing
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
return {
|
|
562
|
+
async call(method, sessionId, ...args) {
|
|
563
|
+
await ready
|
|
564
|
+
if (typeof service?.[method] !== 'function') throw unavailable()
|
|
565
|
+
const { ok, value, error } = await service[method](sessionId, ...args)
|
|
566
|
+
if (ok !== true) throw error ?? new Error('Session tools Remote call failed')
|
|
567
|
+
if (value?.ok === false) throw value.error
|
|
568
|
+
if (value?.sessionId !== sessionId) throw new Error('Session tools Remote returned a different session')
|
|
569
|
+
return value
|
|
570
|
+
},
|
|
571
|
+
dispose,
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
417
575
|
const h = React.createElement
|
|
418
576
|
// The popover is two columns: the original panel keeps its width, padding and
|
|
419
577
|
// outline, and its own right border separates it from the allowed-tools column.
|
|
@@ -1180,18 +1338,36 @@ window.__ModuleLoader__.load({
|
|
|
1180
1338
|
* Every change writes the single allow key from the checkbox state, so the stored
|
|
1181
1339
|
* config always describes exactly what the panel shows.
|
|
1182
1340
|
*/
|
|
1183
|
-
function AllowedToolsPanel({ scope, t }) {
|
|
1341
|
+
function AllowedToolsPanel({ scope, t, sessionId, sessionRemote }) {
|
|
1184
1342
|
const snapshot = useScope(scope)
|
|
1185
1343
|
const [query, setQuery] = React.useState('')
|
|
1186
|
-
const [
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1344
|
+
const [view, setView] = React.useState(null)
|
|
1345
|
+
const active = React.useRef(null)
|
|
1346
|
+
// Global-only consumers omit both props; the conversation slot always supplies Remote.
|
|
1347
|
+
const scoped = sessionRemote !== undefined || sessionId !== undefined
|
|
1348
|
+
const validId = typeof sessionId === 'string' && sessionId.trim() !== ''
|
|
1349
|
+
const display = view?.sessionId === sessionId && view?.remote === sessionRemote ? view : null
|
|
1350
|
+
const state = display?.state
|
|
1351
|
+
const sessionEnabled = state?.enabled === true
|
|
1352
|
+
const saving = display?.saving === true
|
|
1353
|
+
const problem = display?.problem ?? null
|
|
1189
1354
|
React.useEffect(() => {
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1355
|
+
const request = { sessionId, remote: sessionRemote, saving: false }
|
|
1356
|
+
active.current = request
|
|
1357
|
+
const render = () => { if (active.current === request) setView({ ...request }) }
|
|
1358
|
+
render()
|
|
1359
|
+
if (scoped && validId && sessionRemote) {
|
|
1360
|
+
Promise.resolve().then(() => sessionRemote.call('get', sessionId)).then((state) => {
|
|
1361
|
+
request.state = state
|
|
1362
|
+
request.problem = null
|
|
1363
|
+
render()
|
|
1364
|
+
}, (error) => {
|
|
1365
|
+
request.problem = error?.message || t('allowed.sessionFailed')
|
|
1366
|
+
render()
|
|
1367
|
+
})
|
|
1193
1368
|
}
|
|
1194
|
-
|
|
1369
|
+
return () => { if (active.current === request) active.current = null }
|
|
1370
|
+
}, [sessionId, sessionRemote])
|
|
1195
1371
|
|
|
1196
1372
|
// Shipped order first, then the catalog/config extras alphabetically, so a row
|
|
1197
1373
|
// keeps its place when the live catalog changes. The remembered copy survives the
|
|
@@ -1199,37 +1375,61 @@ window.__ModuleLoader__.load({
|
|
|
1199
1375
|
const remembered = React.useRef([])
|
|
1200
1376
|
const live = catalogFor(snapshot.value, remembered.current)
|
|
1201
1377
|
if (live.length > 0) remembered.current = live
|
|
1202
|
-
const
|
|
1203
|
-
const
|
|
1378
|
+
const value = sessionEnabled ? { ...snapshot.value, [ALLOW_KEY]: state.allowedTools } : snapshot.value
|
|
1379
|
+
const names = toolListOf(value, live)
|
|
1380
|
+
const allowed = allowedSetOf(value, live)
|
|
1204
1381
|
const teamEnabled = snapshot.value?.[ALLOW_AGENT_TEAM_KEY] !== false
|
|
1205
1382
|
const visible = filterTools(names, query)
|
|
1206
|
-
const
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1383
|
+
const sessionReady = state?.storageReady === true
|
|
1384
|
+
const editable = (!scoped || sessionReady) && (sessionEnabled ||
|
|
1385
|
+
(snapshot.status === 'ready' && snapshot.writable === true))
|
|
1386
|
+
const sessionProblem = !scoped ? null
|
|
1387
|
+
: !validId ? t('allowed.sessionMissing')
|
|
1388
|
+
: !sessionRemote ? t('allowed.sessionFailed')
|
|
1389
|
+
: state?.storageReady === false ? t('allowed.sessionStorage') : null
|
|
1390
|
+
|
|
1391
|
+
const write = async (operation) => {
|
|
1392
|
+
const request = active.current
|
|
1393
|
+
if (!request || request.sessionId !== sessionId || request.remote !== sessionRemote || request.saving) return
|
|
1394
|
+
if (scoped && request.state?.storageReady !== true) return
|
|
1395
|
+
request.saving = true
|
|
1396
|
+
request.problem = null
|
|
1397
|
+
const render = () => { if (active.current === request) setView({ ...request }) }
|
|
1398
|
+
render()
|
|
1217
1399
|
try {
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1400
|
+
const current = scope.getSnapshot()
|
|
1401
|
+
const currentCatalog = catalogFor(current.value, remembered.current)
|
|
1402
|
+
const global = () => [...allowedSetOf(current.value, currentCatalog)]
|
|
1403
|
+
if (operation === 'enable' || operation === 'disable' || request.state?.enabled) {
|
|
1404
|
+
const revision = request.state.revision
|
|
1405
|
+
if (operation === 'disable') request.state = await sessionRemote.call('clear', sessionId, revision)
|
|
1406
|
+
else {
|
|
1407
|
+
const next = Array.isArray(operation) ? operation : global()
|
|
1408
|
+
request.state = await sessionRemote.call('set', sessionId, next, revision)
|
|
1409
|
+
}
|
|
1410
|
+
} else {
|
|
1411
|
+
if (current.status !== 'ready' || current.writable !== true) throw new Error(t('route.readonly'))
|
|
1412
|
+
const ops = operation === 'reset' ? resetAllowOps() : allowOps(operation, current.value, currentCatalog)
|
|
1413
|
+
if (await scope.mutate(ops, current.revision) === false) throw new Error(t('route.saveFailed'))
|
|
1414
|
+
}
|
|
1415
|
+
} catch (error) {
|
|
1416
|
+
request.problem = error?.message || t('route.saveFailed')
|
|
1417
|
+
if (error?.code === 'REVISION_CONFLICT' && active.current === request) {
|
|
1418
|
+
try { request.state = await sessionRemote.call('get', sessionId) } catch { request.state = undefined }
|
|
1419
|
+
}
|
|
1223
1420
|
} finally {
|
|
1224
|
-
|
|
1421
|
+
request.saving = false
|
|
1422
|
+
render()
|
|
1225
1423
|
}
|
|
1226
1424
|
}
|
|
1227
1425
|
|
|
1228
1426
|
const toggle = (name, on) => {
|
|
1229
|
-
|
|
1427
|
+
// Preserve latent Team settings when ordinary checkboxes are edited; the
|
|
1428
|
+
// hard Team switch still filters what is shown and what the backend permits.
|
|
1429
|
+
const next = new Set(sessionEnabled ? state.allowedTools : allowed)
|
|
1230
1430
|
if (on) next.add(name)
|
|
1231
1431
|
else next.delete(name)
|
|
1232
|
-
return write(
|
|
1432
|
+
return write([...next])
|
|
1233
1433
|
}
|
|
1234
1434
|
|
|
1235
1435
|
return h(
|
|
@@ -1245,11 +1445,29 @@ window.__ModuleLoader__.load({
|
|
|
1245
1445
|
type: 'button',
|
|
1246
1446
|
style: resetLinkStyle(editable && !saving),
|
|
1247
1447
|
disabled: saving || !editable,
|
|
1248
|
-
onClick: () => write(
|
|
1448
|
+
onClick: () => write('reset'),
|
|
1249
1449
|
},
|
|
1250
1450
|
t('allowed.reset'),
|
|
1251
1451
|
),
|
|
1252
1452
|
),
|
|
1453
|
+
h(
|
|
1454
|
+
'div',
|
|
1455
|
+
{ 'data-scope': 'session-tools', style: { display: 'grid', gap: '3px', padding: '4px 8px' } },
|
|
1456
|
+
h(
|
|
1457
|
+
'div',
|
|
1458
|
+
{ style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '10px' } },
|
|
1459
|
+
h('span', { style: { fontWeight: 600, whiteSpace: 'nowrap' } }, t('allowed.session')),
|
|
1460
|
+
h(EnableSwitch, {
|
|
1461
|
+
checked: sessionEnabled,
|
|
1462
|
+
disabled: !sessionReady || saving,
|
|
1463
|
+
label: t('allowed.session'),
|
|
1464
|
+
onChange: (next) => write(next ? 'enable' : 'disable'),
|
|
1465
|
+
}),
|
|
1466
|
+
),
|
|
1467
|
+
h('span', { style: { color: 'var(--dsw-alias-label-tertiary, inherit)', lineHeight: 1.3 } },
|
|
1468
|
+
!state && !problem && scoped && !sessionProblem ? t('allowed.sessionLoading')
|
|
1469
|
+
: t(sessionEnabled ? 'allowed.sessionOn' : 'allowed.sessionOff')),
|
|
1470
|
+
),
|
|
1253
1471
|
h(
|
|
1254
1472
|
'div',
|
|
1255
1473
|
{ style: allowedListBoxStyle },
|
|
@@ -1295,7 +1513,9 @@ window.__ModuleLoader__.load({
|
|
|
1295
1513
|
}),
|
|
1296
1514
|
),
|
|
1297
1515
|
),
|
|
1298
|
-
problem === null ? null : h('div', {
|
|
1516
|
+
problem === null && sessionProblem === null ? null : h('div', {
|
|
1517
|
+
role: 'alert', style: { color: 'var(--dsw-alias-label-error, #ff7b72)' },
|
|
1518
|
+
}, problem ?? sessionProblem),
|
|
1299
1519
|
)
|
|
1300
1520
|
}
|
|
1301
1521
|
|
|
@@ -1563,7 +1783,7 @@ window.__ModuleLoader__.load({
|
|
|
1563
1783
|
)
|
|
1564
1784
|
}
|
|
1565
1785
|
/** Button plus panel: pick the default model and effort for the main agent and for workers. */
|
|
1566
|
-
function RoutePicker({ t, scopes, orch, loadCatalog, modelDirectories, sessionId }) {
|
|
1786
|
+
function RoutePicker({ t, scopes, orch, loadCatalog, modelDirectories, sessionId, sessionRemote }) {
|
|
1567
1787
|
const [open, setOpen] = React.useState(false)
|
|
1568
1788
|
const [room, setRoom] = React.useState(null)
|
|
1569
1789
|
const anchor = React.useRef(null)
|
|
@@ -1737,7 +1957,7 @@ window.__ModuleLoader__.load({
|
|
|
1737
1957
|
: null,
|
|
1738
1958
|
h('div', { style: { color: 'var(--dsw-alias-label-tertiary, inherit)', lineHeight: 1.3 } }, t('route.note')),
|
|
1739
1959
|
),
|
|
1740
|
-
h(AllowedToolsPanel, { scope: scopes.orch, t }),
|
|
1960
|
+
h(AllowedToolsPanel, { key: sessionId, scope: scopes.orch, t, sessionId, sessionRemote }),
|
|
1741
1961
|
)
|
|
1742
1962
|
: null,
|
|
1743
1963
|
)
|
|
@@ -1748,6 +1968,8 @@ window.__ModuleLoader__.load({
|
|
|
1748
1968
|
|
|
1749
1969
|
function apply(ctx) {
|
|
1750
1970
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'orchestrator: dictionaries')
|
|
1971
|
+
const sessionRemote = mountSessionRemote(ctx)
|
|
1972
|
+
ctx.effect(() => sessionRemote.dispose, 'orchestrator: session tools Remote')
|
|
1751
1973
|
const scopes = { main: ctx.configForms.get(MAIN.ns), worker: ctx.configForms.get(WORKER.ns), orch: ctx.configForms.get(NS) }
|
|
1752
1974
|
ctx.slots.inject('conversation.input.right', () =>
|
|
1753
1975
|
ctx.slots.register(
|
|
@@ -1761,6 +1983,7 @@ window.__ModuleLoader__.load({
|
|
|
1761
1983
|
orch: scopes.orch,
|
|
1762
1984
|
loadCatalog: () => ctx.remote.session.modelCatalog(),
|
|
1763
1985
|
sessionId,
|
|
1986
|
+
sessionRemote,
|
|
1764
1987
|
// Cordis property access can throw for undeclared services.
|
|
1765
1988
|
modelDirectories: typeof ctx.get === 'function' ? ctx.get('modelDirectories') : ctx.modelDirectories,
|
|
1766
1989
|
}),
|
|
@@ -1805,6 +2028,8 @@ window.__ModuleLoader__.load({
|
|
|
1805
2028
|
EnableSwitch,
|
|
1806
2029
|
WorktreeIsolationField,
|
|
1807
2030
|
AllowedToolsPanel,
|
|
2031
|
+
createSessionToolsDescriptors,
|
|
2032
|
+
mountSessionRemote,
|
|
1808
2033
|
RoutePicker,
|
|
1809
2034
|
routeKey,
|
|
1810
2035
|
parseRouteKey,
|