@sshirkit/dsh-orchestrator 0.9.1 → 0.9.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 +32 -20
- package/README.zh.md +32 -20
- package/lib/client.js +81 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,40 +30,50 @@
|
|
|
30
30
|
## Core Features
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
|
-
### 1. A powerful Main Agent and low-cost Subagents (independent panel, immediate updates)
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
- **Main Agent**: choose your strongest flagship model to focus on clarifying requirements, splitting tasks, correcting course, and accepting final results.
|
|
37
|
-
- > For example, `gpt-astra-6` or `claude-opus-5.5`
|
|
38
|
-
- **Subagent**: choose a slightly less capable but very inexpensive model with high throughput. **Every Worker launched through `delegate` or `orchestrate` must share this low-cost route**
|
|
39
|
-
- > For example, `deepseek-v4.1-flash` or `gpt-luna-6`
|
|
40
|
-
- **Anti-burn protection**: dispatch fails with an error if no subagent model is configured
|
|
41
|
-
|
|
42
|
-
## In your `prompt` or `AGENTS.md`, you can instruct the main agent in the current workspace to pass `provider` / `model` parameters when dispatching subagents, specifying which model to use for the current `session` \ `workspace`
|
|
34
|
+
### 1. A hard whitelist gate: the main agent plans and accepts results; subagents execute
|
|
43
35
|
|
|
36
|
+
Instead of relying on prompts asking the main model to use subagents more often, the plugin installs two guards at DSH's tool-definition outlet (`tools.definitions`) and execution layer (`tools.guard`), using a **whitelist-driven** approach:
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Instead of relying on prompts asking the main model to use subagents more often, the plugin installs two guards at DSH's tool-definition outlet (`tools.definitions`) and execution layer (`tools.guard`), using a **whitelist-driven** approach. The definition layer trims the tool table visible to the model in real time, treating global tools and tools in scopes such as `ops_*` equally; the execution layer rejects any calls that slip through. Both layers read the current configuration on every request or call, without creating `tools.restrict` event storms, avoiding tool-visibility churn and prompt-cache invalidation from the official tool-hiding mechanism.
|
|
50
|
-
- **Main Agent stripped of all execution tools**:
|
|
38
|
+
> ###### _The definition layer trims the tools visible to the model in real time; the execution layer rejects any calls that slip through._
|
|
39
|
+
> ###### _Both layers read the current configuration on every request or call without using `tools.restrict`, avoiding the tool-visibility churn and prompt-cache invalidation that come with the host's tool-hiding mechanism._
|
|
40
|
+
- #### The main agent loses access to execution tools:
|
|
51
41
|
<div align="center">
|
|
52
42
|
|
|
53
|
-
>
|
|
43
|
+
> ###### DEFAULT_ALLOWED_TOOLS permits only 12 planning, delegation, and read-only session tools by default
|
|
54
44
|
>
|
|
55
|
-
> _`delegate`, `orchestrate`, `send_message`, `interrupt_agent`, `todo_write`, `ask_user_question`, `compress`, and five read-only session log tools._
|
|
45
|
+
> ###### _`delegate`, `orchestrate`, `send_message`, `interrupt_agent`, `todo_write`, `ask_user_question`, `compress`, and five read-only session log tools._
|
|
56
46
|
>
|
|
57
|
-
>
|
|
47
|
+
> ###### All file access, search, and terminal tools, plus any future MCP or third-party plugin tools, are automatically hidden and blocked at execution time
|
|
58
48
|
>
|
|
59
|
-
>_(`read` / `edit` / `write` / `apply_patch`), (`grep` / `glob`), (`bash` / `pwsh`), `subagent` / `workflow`_
|
|
49
|
+
> ###### _(`read` / `edit` / `write` / `apply_patch`), (`grep` / `glob`), (`bash` / `pwsh`), `subagent` / `workflow`_
|
|
60
50
|
>
|
|
61
|
-
>
|
|
51
|
+
> ###### Even nested calls through `run_code` are blocked. To allow additional tools, check them under Allowed Tools on the right of the panel.
|
|
62
52
|
</div>
|
|
63
53
|
|
|
64
54
|
- **Subagents retain the full toolchain**: dispatched Workers are exempt from the gate and read or write files, run tests, and inspect errors in their own contexts. When finished, they return only a concise conclusion for the main agent to review.
|
|
65
55
|
- **Switch at any time**: turn off Enable dispatch mode to restore host tools without reopening the session. Plugin dispatch tools remain disabled, and gates for a bound inspection turn still take priority.
|
|
66
56
|
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
### 2. A powerful Main Agent and low-cost Subagents (independent panel, immediate updates)
|
|
60
|
+
|
|
61
|
+
In the dedicated **Dispatch mode panel** below the composer, the main-agent and subagent model routes are fully independent:
|
|
62
|
+
- **Main Agent**: choose your strongest flagship model to focus on clarifying requirements, splitting tasks, correcting course, and accepting final results.
|
|
63
|
+
- > For example, `gpt-astra-6` or `claude-opus-5.5`
|
|
64
|
+
- **Subagent**: choose a slightly less capable but very inexpensive model with high throughput. **Every Worker launched through `delegate` or `orchestrate` must share this low-cost route**
|
|
65
|
+
- > For example, `deepseek-v4.1-flash` or `gpt-luna-6`
|
|
66
|
+
- **Anti-burn protection**: dispatch fails with an error if no subagent model is configured
|
|
67
|
+
|
|
68
|
+
## In your `prompt` or `AGENTS.md`, you can instruct the main agent in the current workspace to pass `provider` / `model` parameters when dispatching subagents, specifying which model to use for the current `session` \ `workspace`
|
|
69
|
+
|
|
70
|
+
The session-level main-agent model can be switched directly with DSH's original model selector. Changing the main-agent global default route in the Dispatch mode panel does not override the model already selected for the current session. Each setting serves its own scope.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
67
77
|
### 3. Periodic background inspection of event logs and correction by the powerful model
|
|
68
78
|
|
|
69
79
|
Low-cost Subagents can occasionally get stuck on complex shell escaping or errors. The plugin includes a background inspector driven entirely by logs:
|
|
@@ -79,6 +89,8 @@ Low-cost Subagents can occasionally get stuck on complex shell escaping or error
|
|
|
79
89
|
|
|
80
90
|
*Inspection and correction in practice: a low-cost subagent got stuck on shell quotes and backslash escaping. After a scheduled inspection woke the main agent, it supplied the correct syntax directly through `send_message` to get the worker back on track.*
|
|
81
91
|
|
|
92
|
+
---
|
|
93
|
+
|
|
82
94
|
### 4. `delegate` and `orchestrate`, built for dispatch mode
|
|
83
95
|
|
|
84
96
|
- **`delegate` (asynchronous tasks on demand / parallel fan-out)**:
|
package/README.zh.md
CHANGED
|
@@ -30,40 +30,50 @@
|
|
|
30
30
|
## 核心特性
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
|
-
### 1. 强模型当 Main Agent,便宜模型当 Subagent(独立面板、即时生效)
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
- **主代理(Main Agent)**:配置为你最强的旗舰模型专门负责需求澄清、任务切分、途中纠偏与最终结果验收。
|
|
37
|
-
- > 例如 `gpt-astra-6`、`claude-opus-5.5` 等
|
|
38
|
-
- **子代理(Subagent)**:配置为能力稍弱但极其便宜、高吞吐的模型**所有通过 `delegate` 和 `orchestrate` 派出的 Worker 强制共用这条便宜路由**
|
|
39
|
-
- > 例如 `deepseek-v4.1-flash`、`gpt-luna-6` 等
|
|
40
|
-
- **防烧钱保护**:如果未配置子代理模型,派发时会直接报错拦截
|
|
41
|
-
|
|
42
|
-
## 可以在`prompt` 或 `AGENTS.md`中要求当前工作区域的main agent派发子代理时传输 `provider` / `model` 参数来指定当前`会话` \ `工作区`使用你指定的模型进行
|
|
34
|
+
### 1. 主代理「规划与验收」、子代理「纯粹 Work」的白名单式硬性闸门
|
|
43
35
|
|
|
36
|
+
不同于靠 Prompt 劝主模型“多用子代理”,本插件在 DSH 的工具声明出口(`tools.definitions`)与执行层(`tools.guard`)安装了双重守卫,且采用**白名单式驱动**:
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
不同于靠 Prompt 劝主模型“多用子代理”,本插件在 DSH 的工具声明出口(`tools.definitions`)与执行层(`tools.guard`)安装了双重守卫,且采用**白名单式驱动**:声明层实时裁剪模型可见的工具表(全局工具与 `ops_*` 等 scope 内工具一视同仁),执行层再兜底拒绝任何漏网调用;两层都按请求/按调用实时读取配置,不产生 `tools.restrict` 事件风暴,因此不会触发官方工具遮挡的抖动与 Prompt Cache 失效。
|
|
50
|
-
- **主代理被彻底收缴执行工具**:
|
|
38
|
+
> ###### _声明层实时裁剪模型可见的工具表,执行层再兜底拒绝任何漏网调用_
|
|
39
|
+
> ###### _两层都按请求/按调用实时读取配置,不产生 `tools.restrict` ,因此不会触发官方工具遮挡的抖动与 Prompt Cache 失效。_
|
|
40
|
+
- #### 主代理被彻底收缴执行工具 :
|
|
51
41
|
<div align="center">
|
|
52
42
|
|
|
53
|
-
>
|
|
43
|
+
> ###### DEFAULT_ALLOWED_TOOLS 默认只放行 12 项规划、委派与会话只读工具
|
|
54
44
|
>
|
|
55
|
-
> _`delegate`、`orchestrate`、`send_message`、`interrupt_agent`、`todo_write`、`ask_user_question`、`compress` 与 5 项只读会话日志工具。_
|
|
45
|
+
> ###### _`delegate`、`orchestrate`、`send_message`、`interrupt_agent`、`todo_write`、`ask_user_question`、`compress` 与 5 项只读会话日志工具。_
|
|
56
46
|
>
|
|
57
|
-
>
|
|
47
|
+
> ###### 所有文件读写、搜索、终端,以及未来新增的任何 MCP / 第三方插件工具,一律自动隐藏并在执行层强制拦截
|
|
58
48
|
>
|
|
59
|
-
>_(`read` / `edit` / `write` / `apply_patch`)、(`grep` / `glob`)、(`bash` / `pwsh`)、 `subagent` / `workflow`_
|
|
49
|
+
> ###### _(`read` / `edit` / `write` / `apply_patch`)、(`grep` / `glob`)、(`bash` / `pwsh`)、 `subagent` / `workflow`_
|
|
60
50
|
>
|
|
61
|
-
>
|
|
51
|
+
> ###### 连 run_code 嵌套偷调也拦。需要额外放行时,在面板右侧 Allowed Tools 勾选即可。
|
|
62
52
|
</div>
|
|
63
53
|
|
|
64
54
|
- **子代理独享完整工具链**:被派出的 Worker 不受闸门限制,在各自独立的上下文中读写文件、跑测试、看报错,完工后只把干净的结论交回主代理验收。
|
|
65
55
|
- **一键随时切换**:关闭面板上的「启用调度模式」即可恢复宿主工具,无需重开会话;插件派发工具仍禁用,已绑定巡检回合的硬禁仍优先。
|
|
66
56
|
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
### 2. 强模型当 Main Agent,便宜模型当 Subagent(独立面板、即时生效)
|
|
60
|
+
|
|
61
|
+
在输入框下方的**「调度模式」专属面板**中,主代理与子代理的模型路由完全解耦:
|
|
62
|
+
- **主代理(Main Agent)**:配置为你最强的旗舰模型专门负责需求澄清、任务切分、途中纠偏与最终结果验收。
|
|
63
|
+
- > 例如 `gpt-astra-6`、`claude-opus-5.5` 等
|
|
64
|
+
- **子代理(Subagent)**:配置为能力稍弱但极其便宜、高吞吐的模型**所有通过 `delegate` 和 `orchestrate` 派出的 Worker 强制共用这条便宜路由**
|
|
65
|
+
- > 例如 `deepseek-v4.1-flash`、`gpt-luna-6` 等
|
|
66
|
+
- **防烧钱保护**:如果未配置子代理模型,派发时会直接报错拦截
|
|
67
|
+
|
|
68
|
+
## 可以在`prompt` 或 `AGENTS.md`中要求当前工作区域的main agent派发子代理时传输 `provider` / `model` 参数来指定当前`会话` \ `工作区`使用你指定的模型进行
|
|
69
|
+
|
|
70
|
+
会话级主代理模型可直接使用 DSH 原版模型选择器切换;调整调度面板中的主代理全局默认路由不会覆盖已选定的当前会话模型,两者各司其职。
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
67
77
|
### 3. 后台事件日志定时巡检与强模型动态纠偏
|
|
68
78
|
|
|
69
79
|
便宜模型充当 Subagent 时,偶尔会在复杂的 shell 转义或报错上打转。插件内置了纯日志驱动的后台巡检器:
|
|
@@ -79,6 +89,8 @@
|
|
|
79
89
|
|
|
80
90
|
*巡检通知与纠偏实录:便宜的子代理卡在了 shell 引号和反斜杠转义上,巡检机制按间隔唤醒主代理后,主代理通过 `send_message` 直接给出正确写法完成纠偏。*
|
|
81
91
|
|
|
92
|
+
---
|
|
93
|
+
|
|
82
94
|
### 4. 专为调度模式定制的 `delegate` 与 `orchestrate`
|
|
83
95
|
|
|
84
96
|
- **`delegate`(按需异步单派 / 并行扇出)**:
|
package/lib/client.js
CHANGED
|
@@ -726,6 +726,49 @@ window.__ModuleLoader__.load({
|
|
|
726
726
|
return scope.getSnapshot()
|
|
727
727
|
}
|
|
728
728
|
|
|
729
|
+
/** Subscribe to a host snapshot store without requiring a newer React API. */
|
|
730
|
+
function useExternalSnapshot(store) {
|
|
731
|
+
const [, bump] = React.useReducer((n) => n + 1, 0)
|
|
732
|
+
React.useEffect(() => {
|
|
733
|
+
if (store === undefined || typeof store.subscribe !== 'function') return undefined
|
|
734
|
+
return store.subscribe(() => bump())
|
|
735
|
+
}, [store])
|
|
736
|
+
return store !== undefined && typeof store.getSnapshot === 'function' ? store.getSnapshot() : undefined
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/** Resolve a usable per-session host directory, or leave the caller on the RPC fallback. */
|
|
740
|
+
function resolveModelDirectory(modelDirectories, sessionId) {
|
|
741
|
+
if (
|
|
742
|
+
modelDirectories === undefined ||
|
|
743
|
+
sessionId === undefined ||
|
|
744
|
+
sessionId === null ||
|
|
745
|
+
sessionId === '' ||
|
|
746
|
+
typeof modelDirectories.directoryFor !== 'function'
|
|
747
|
+
) return undefined
|
|
748
|
+
try {
|
|
749
|
+
const directory = modelDirectories.directoryFor(sessionId)
|
|
750
|
+
const store = directory?.store
|
|
751
|
+
return store !== undefined && typeof store.subscribe === 'function' && typeof store.getSnapshot === 'function'
|
|
752
|
+
? directory
|
|
753
|
+
: undefined
|
|
754
|
+
} catch {
|
|
755
|
+
return undefined
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/** Read host model-directory lifecycle and groups. */
|
|
760
|
+
function useModelDirectory(directory) {
|
|
761
|
+
const snapshot = useExternalSnapshot(directory?.store)
|
|
762
|
+
if (directory === undefined || snapshot === undefined) {
|
|
763
|
+
return { groups: undefined, loading: false, error: null }
|
|
764
|
+
}
|
|
765
|
+
return {
|
|
766
|
+
groups: Array.isArray(snapshot.groups) ? snapshot.groups : [],
|
|
767
|
+
loading: snapshot.status === 'idle' || snapshot.status === 'loading',
|
|
768
|
+
error: typeof snapshot.error === 'string' && snapshot.error !== '' ? snapshot.error : null,
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
729
772
|
/**
|
|
730
773
|
* The subagent check interval. Edits stay local until blur or Enter; invalid input is
|
|
731
774
|
* rejected without writing and the shown value snaps back to the stored one. The panel's
|
|
@@ -1437,34 +1480,55 @@ window.__ModuleLoader__.load({
|
|
|
1437
1480
|
)
|
|
1438
1481
|
}
|
|
1439
1482
|
/** Button plus panel: pick the default model and effort for the main agent and for workers. */
|
|
1440
|
-
function RoutePicker({ t, scopes, orch, loadCatalog }) {
|
|
1483
|
+
function RoutePicker({ t, scopes, orch, loadCatalog, modelDirectories, sessionId }) {
|
|
1441
1484
|
const [open, setOpen] = React.useState(false)
|
|
1442
1485
|
const [room, setRoom] = React.useState(null)
|
|
1443
1486
|
const anchor = React.useRef(null)
|
|
1444
|
-
const [
|
|
1487
|
+
const [fallback, setFallback] = React.useState({ groups: undefined, loading: false })
|
|
1445
1488
|
const [problem, setProblem] = React.useState(null)
|
|
1446
1489
|
const [saving, setSaving] = React.useState(false)
|
|
1490
|
+
const request = React.useRef(0)
|
|
1491
|
+
const loader = React.useRef(loadCatalog)
|
|
1492
|
+
loader.current = loadCatalog
|
|
1447
1493
|
const main = useScope(scopes.main)
|
|
1448
1494
|
const worker = useScope(scopes.worker)
|
|
1449
1495
|
const plugin = useScope(orch)
|
|
1496
|
+
const directory = resolveModelDirectory(modelDirectories, sessionId)
|
|
1497
|
+
const directoryState = useModelDirectory(directory)
|
|
1498
|
+
const usingDirectory = directory !== undefined
|
|
1499
|
+
const groups = usingDirectory ? directoryState.groups : fallback.groups
|
|
1500
|
+
const catalogProblem = usingDirectory ? directoryState.error : problem
|
|
1450
1501
|
|
|
1451
1502
|
React.useEffect(() => {
|
|
1452
|
-
if (
|
|
1503
|
+
if (usingDirectory || !open) return undefined
|
|
1504
|
+
const current = request.current + 1
|
|
1505
|
+
request.current = current
|
|
1453
1506
|
let live = true
|
|
1454
|
-
|
|
1507
|
+
setProblem(null)
|
|
1508
|
+
setFallback((previous) => ({ ...previous, loading: true }))
|
|
1509
|
+
Promise.resolve().then(() => {
|
|
1510
|
+
if (typeof loader.current !== 'function') throw new Error('model catalog loader unavailable')
|
|
1511
|
+
return loader.current()
|
|
1512
|
+
}).then(
|
|
1455
1513
|
(response) => {
|
|
1456
|
-
if (!live) return
|
|
1457
|
-
if (response
|
|
1458
|
-
|
|
1514
|
+
if (!live || request.current !== current) return
|
|
1515
|
+
if (response?.ok === true && Array.isArray(response.value?.groups)) {
|
|
1516
|
+
setFallback({ groups: response.value.groups, loading: false })
|
|
1517
|
+
return
|
|
1518
|
+
}
|
|
1519
|
+
setFallback((previous) => ({ ...previous, loading: false }))
|
|
1520
|
+
setProblem(t('route.catalogFailed'))
|
|
1459
1521
|
},
|
|
1460
1522
|
() => {
|
|
1461
|
-
if (live
|
|
1523
|
+
if (!live || request.current !== current) return
|
|
1524
|
+
setFallback((previous) => ({ ...previous, loading: false }))
|
|
1525
|
+
setProblem(t('route.catalogFailed'))
|
|
1462
1526
|
},
|
|
1463
1527
|
)
|
|
1464
1528
|
return () => {
|
|
1465
1529
|
live = false
|
|
1466
1530
|
}
|
|
1467
|
-
}, [open,
|
|
1531
|
+
}, [open, usingDirectory])
|
|
1468
1532
|
|
|
1469
1533
|
const write = async (which, route) => {
|
|
1470
1534
|
setSaving(true)
|
|
@@ -1516,6 +1580,9 @@ window.__ModuleLoader__.load({
|
|
|
1516
1580
|
const close = () => {
|
|
1517
1581
|
setOpen(false)
|
|
1518
1582
|
}
|
|
1583
|
+
const showLoading = catalogProblem === null && (
|
|
1584
|
+
groups === undefined || (usingDirectory && directoryState.loading && groups.length === 0)
|
|
1585
|
+
)
|
|
1519
1586
|
return h(
|
|
1520
1587
|
'span',
|
|
1521
1588
|
{ ref: anchor, style: { position: 'relative', display: 'inline-flex' } },
|
|
@@ -1554,7 +1621,7 @@ window.__ModuleLoader__.load({
|
|
|
1554
1621
|
label: t('route.enable'),
|
|
1555
1622
|
}),
|
|
1556
1623
|
),
|
|
1557
|
-
|
|
1624
|
+
showLoading
|
|
1558
1625
|
? h('div', null, t('route.loading'))
|
|
1559
1626
|
: groups === undefined
|
|
1560
1627
|
? null
|
|
@@ -1580,7 +1647,7 @@ window.__ModuleLoader__.load({
|
|
|
1580
1647
|
],
|
|
1581
1648
|
h(SuperviseIntervalField, { scope: scopes.orch, t }),
|
|
1582
1649
|
h(SuperviseCountField, { scope: scopes.orch, t }),
|
|
1583
|
-
|
|
1650
|
+
catalogProblem === null ? null : h('div', { style: { color: 'var(--dsw-alias-label-error, #ff7b72)' }, role: 'alert' }, catalogProblem),
|
|
1584
1651
|
!writable && groups !== undefined
|
|
1585
1652
|
? h('div', { style: { color: 'var(--dsw-alias-label-tertiary, inherit)' } }, t('route.readonly'))
|
|
1586
1653
|
: null,
|
|
@@ -1610,6 +1677,9 @@ window.__ModuleLoader__.load({
|
|
|
1610
1677
|
scopes,
|
|
1611
1678
|
orch: scopes.orch,
|
|
1612
1679
|
loadCatalog: () => ctx.remote.session.modelCatalog(),
|
|
1680
|
+
sessionId,
|
|
1681
|
+
// Cordis property access can throw for undeclared services.
|
|
1682
|
+
modelDirectories: typeof ctx.get === 'function' ? ctx.get('modelDirectories') : ctx.modelDirectories,
|
|
1613
1683
|
}),
|
|
1614
1684
|
},
|
|
1615
1685
|
RoutePicker,
|