dsh-team-control 0.3.0 → 0.3.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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +108 -9
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ## 调用顺序写在哪(别让模型自己摸)
10
10
 
11
- - 14 个工具里**只有 `dsh_team_create` 标了 `START HERE`**:它的 description 直接给出 5 步顺序、`permissionPreset` 的语义、
11
+ - 14 个工具里**只有 `dsh_team_create` 标了 `START HERE`**:它的 description 直接给出两道前置闸口(先澄清需求、再调研代码)、5 步顺序、`permissionPreset` 的语义、
12
12
  以及 `teamId` 取自 `result.team.id`;`dsh_team_spawn` 写明返回的 `member.id` 就是后面 `assignee` 要的值;
13
13
  `dsh_team_task` 写明简报必须自包含(成员看不到 Lead 的对话)。模型只看工具面就能按序走。
14
14
  - 完整配方(字段陷阱、拆任务与并发、症状→修法表)在 skill **`dsh-agent-team`**:[`../skills/dsh-agent-team/SKILL.md`](../skills/dsh-agent-team/SKILL.md)。
package/index.js CHANGED
@@ -812,6 +812,41 @@ async function assertRouteEnabled(s, ctx, provider, model, effort = null) {
812
812
  }
813
813
  }
814
814
 
815
+ /**
816
+ * 归一化看板建卡入参的模型路由:接受 { provider?, model, reasoningEffort? } 或
817
+ * "provider/model"/"model" 字符串;缺 model 返回 null(由调用方决定报错还是丢弃)。
818
+ */
819
+ function normalizeBoardRoute(input) {
820
+ if (input == null) return null;
821
+ let provider = null;
822
+ let model = null;
823
+ let effort = null;
824
+ if (typeof input === 'string') {
825
+ const raw = input.trim();
826
+ const slash = raw.indexOf('/');
827
+ if (slash > 0) {
828
+ provider = raw.slice(0, slash).trim() || null;
829
+ model = raw.slice(slash + 1).trim() || null;
830
+ } else {
831
+ model = raw || null;
832
+ }
833
+ } else if (typeof input === 'object') {
834
+ provider = input.provider != null && String(input.provider).trim() ? String(input.provider).trim() : null;
835
+ model = input.model != null && String(input.model).trim() ? String(input.model).trim() : null;
836
+ effort = input.reasoningEffort != null && String(input.reasoningEffort).trim() ? String(input.reasoningEffort).trim() : null;
837
+ }
838
+ if (!model) return null;
839
+ return { provider, model, ...(effort ? { reasoningEffort: effort } : {}) };
840
+ }
841
+
842
+ /** 显式 route 入参:undefined/null = 未设置,其余必须带 model,否则提前报错。 */
843
+ function boardRouteParam(input, label) {
844
+ if (input == null) return null;
845
+ const route = normalizeBoardRoute(input);
846
+ if (!route) throw new Error(`${label} 需要 model:传 { provider?, model, reasoningEffort? } 或 "provider/model"`);
847
+ return route;
848
+ }
849
+
815
850
  function rememberMember(sessionId, teamId, memberId, cwd, permissionPreset = null, name = null) {
816
851
  if (sessionId == null) return;
817
852
  const key = String(sessionId);
@@ -2633,7 +2668,7 @@ function buildTools(s, ctx) {
2633
2668
 
2634
2669
  tools.push({
2635
2670
  name: 'dsh_team_create',
2636
- description: 'START HERE to build a working team of agents. Order: dsh_team_create({name, workspace, permissionPreset?}) → dsh_team_models() to see the enabled provider/model routes → dsh_team_spawn({teamId, name, prompt, agentProvider?, model?, reasoningEffort?, permissionPreset?}) once per member, choosing a cheap/fast route for mechanical work and a strong-reasoning route for architecture, debugging, or review → dsh_team_task({teamId, subject, assignee?, plan, acceptance}) per DAG node → each member finishes by calling dsh_team_report_task → inspect with dsh_team_status / dsh_team_report. Every member is a real DSH sub-agent session (own model, tools, context, message inbox). `permissionPreset` decides the member sandbox + approval policy (DSH permission presets, e.g. workspace-write or danger-full-access); the team value is the default and dsh_team_spawn can override it per member. When a member hits an operation its preset requires approval for, the approval is forwarded to the Lead, who decides with dsh_team_approve. `workspace` is an absolute directory shared by the members and becomes their cwd. Keep teamId from this response (result.team.id): every later call needs it. Spawn members by capability domain, not one per requirement item: one member can own several related dsh_team_task items, so keep the member count at the minimum needed. For the full recipe with per-field pitfalls, load the skill "dsh-agent-team".',
2671
+ description: 'START HERE to build a working team of agents — but only AFTER two gates: (1) CLARIFY: if the request is vague, grill the user in numbered rounds, each question with your recommended answer, until scope/acceptance are settled — facts are yours to look up (read code, run commands, or dispatch a throwaway subagent), decisions belong to the user; (2) RESEARCH: read the workspace AGENTS.md/CLAUDE.md and the relevant code so the brief names real files, current behavior and constraints. Do not dispatch on a one-line request. Then: dsh_team_create({name, workspace, permissionPreset?}) → dsh_team_models() to see the enabled provider/model routes → dsh_team_spawn({teamId, name, prompt, agentProvider?, model?, reasoningEffort?, permissionPreset?}) once per member, choosing a cheap/fast route for mechanical work and a strong-reasoning route for architecture, debugging, or review → dsh_team_task({teamId, subject, assignee?, plan, acceptance}) per DAG node → each member finishes by calling dsh_team_report_task → inspect with dsh_team_status / dsh_team_report. Every member is a real DSH sub-agent session (own model, tools, context, message inbox). `permissionPreset` decides the member sandbox + approval policy (DSH permission presets, e.g. workspace-write or danger-full-access); the team value is the default and dsh_team_spawn can override it per member. When a member hits an operation its preset requires approval for, the approval is forwarded to the Lead, who decides with dsh_team_approve. `workspace` is an absolute directory shared by the members and becomes their cwd. Keep teamId from this response (result.team.id): every later call needs it. Spawn members by capability domain, not one per requirement item: one member can own several related dsh_team_task items, so keep the member count at the minimum needed. For the full recipe with per-field pitfalls, load the skill "dsh-agent-team".',
2637
2672
  parameters: {
2638
2673
  type: 'object',
2639
2674
  additionalProperties: false,
@@ -2925,7 +2960,7 @@ function buildTools(s, ctx) {
2925
2960
 
2926
2961
  tools.push({
2927
2962
  name: 'dsh_team_status',
2928
- description: 'Read a live snapshot instead of guessing progress. detail=summary returns every member with status/step/seq/percent/next/blockers/stale and its permissionPreset; detail=dag returns the task DAG with dependencies, readiness, joins and the critical path. `asOf` marks the snapshot time.',
2963
+ description: 'Read a live snapshot instead of guessing progress. detail=summary returns every member with status/step/seq/percent/next/blockers/stale and its permissionPreset; detail=dag returns the task DAG with dependencies, readiness, joins and the critical path. `asOf` marks the snapshot time. Read it once when reporting to the user; do not call it repeatedly to watch a running member — a rising `seq` already proves it is working, and the host wakes the Lead when it finishes.',
2929
2964
  parameters: {
2930
2965
  type: 'object',
2931
2966
  additionalProperties: false,
@@ -3001,7 +3036,7 @@ function buildTools(s, ctx) {
3001
3036
 
3002
3037
  tools.push({
3003
3038
  name: 'dsh_team_task',
3004
- description: 'Only for decomposing the CURRENT task: declare one task (DAG node) and hand it to a member. When the user asks for a new, separate task card (own deliverable or acceptance, own branch/session), use dsh_team_board_task_create instead — dsh_team_task items never appear on the board. The plan is a BRIEF sent to the member’s own sub-agent session, which does the work with its own tools and calls dsh_team_report_task when finished — write it self-contained (the member does not see this conversation). `assignee` takes a member **id** from dsh_team_spawn, not its name; omit it to let the scheduler pick an idle member. `deps[].from` takes a **task** id returned by an earlier dsh_team_task (member ids are rejected). The scheduler satisfies dependencies itself — never poll. The task dispatches immediately to an idle member once dependencies are satisfied; pass dispatch:false to build the DAG first.',
3039
+ description: 'Only for decomposing the CURRENT task: declare one task (DAG node) and hand it to a member. When the user asks for a new, separate task card (own deliverable or acceptance, own branch/session), use dsh_team_board_task_create instead — dsh_team_task items never appear on the board. The plan is a BRIEF sent to the member’s own sub-agent session, which does the work with its own tools and calls dsh_team_report_task when finished — write it self-contained (the member does not see this conversation). `assignee` takes a member **id** from dsh_team_spawn, not its name; omit it to let the scheduler pick an idle member. `deps[].from` takes a **task** id returned by an earlier dsh_team_task (member ids are rejected). The scheduler satisfies dependencies itself — never poll. The task dispatches immediately to an idle member once dependencies are satisfied; pass dispatch:false to build the DAG first. Never create a duplicate task or re-send a brief just to nudge a member that is still running — wait for its dsh_team_report_task.',
3005
3040
  parameters: {
3006
3041
  type: 'object',
3007
3042
  additionalProperties: false,
@@ -3058,7 +3093,7 @@ function buildTools(s, ctx) {
3058
3093
 
3059
3094
  tools.push({
3060
3095
  name: 'dsh_team_send',
3061
- description: "Send a message that a member will actually read: the text is injected into the target sub-agent's message inbox. By default a running member's current turn is interrupted first, so the message immediately starts a fresh turn instead of waiting for the next step boundary; pass `interrupt: false` to keep the current turn and deliver at the next step boundary. An idle member is woken. `to` is a member NAME (member id also accepted) or '*' to broadcast; use to:'lead' to reply to the Lead. Every send is also recorded on the sidecar so the panel shows the conversation. Returns delivery status only, never the member's reply: the reply arrives asynchronously as a new message in a later turn. Never wait for it with sleep/Start-Sleep/delayed scripts, polling loops, or repeated dsh_team_status calls — after sending, continue independent work or end the turn.",
3096
+ description: "Send a message that a member will actually read: the text is injected into the target sub-agent's message inbox. By default a running member's current turn is interrupted first, so the message immediately starts a fresh turn instead of waiting for the next step boundary; pass `interrupt: false` to keep the current turn and deliver at the next step boundary. An idle member is woken. `to` is a member NAME (member id also accepted) or '*' to broadcast; use to:'lead' to reply to the Lead. Every send is also recorded on the sidecar so the panel shows the conversation. Returns delivery status only, never the member's reply: the reply arrives asynchronously as a new message in a later turn. Never wait for it with sleep/Start-Sleep/delayed scripts, polling loops, or repeated dsh_team_status calls — after sending, continue independent work or end the turn. This is a REDIRECTION tool, not a progress-nudge tool: while a member is still running do NOT use it to ask how it is going, whether it is done, or to re-send the brief — the default interrupt discards its in-flight step and pushes it to wrap up early just to answer. Send once only when the member is blocked, reported an error, or you must correct a wrong direction (prefer interrupt:false for that), then end the turn.",
3062
3097
  parameters: {
3063
3098
  type: 'object',
3064
3099
  additionalProperties: false,
@@ -3067,7 +3102,7 @@ function buildTools(s, ctx) {
3067
3102
  to: { type: 'string', description: "Member name (agent teams) or member id, or '*' for broadcast." },
3068
3103
  message: { type: 'string', description: 'Message body.' },
3069
3104
  correlationId: { type: 'string', description: 'Optional correlation id to pair a request with its response.' },
3070
- interrupt: { type: 'boolean', description: 'Default true: if the target member is running, interrupt its current turn before delivering so this message takes effect immediately. false = keep the current turn and deliver at the next step boundary; the message is still queued durably and will be read (a pending steer forces another turn, an idle member is woken), but it may land only after the member finished the current step, so it cannot be relied on to change this turn.' },
3105
+ interrupt: { type: 'boolean', description: 'Use true only when you must change an instruction mid-flight; never as a nudge. Default true: if the target member is running, interrupt its current turn before delivering so this message takes effect immediately. false = keep the current turn and deliver at the next step boundary; the message is still queued durably and will be read (a pending steer forces another turn, an idle member is woken), but it may land only after the member finished the current step, so it cannot be relied on to change this turn.' },
3071
3106
  },
3072
3107
  required: ['teamId', 'to', 'message'],
3073
3108
  },
@@ -3377,7 +3412,7 @@ function buildTools(s, ctx) {
3377
3412
 
3378
3413
  tools.push({
3379
3414
  name: 'dsh_team_dispatch',
3380
- description: 'Pump the agent-team dispatcher once: claim ready tasks for idle members and send each member its brief. Normally unnecessary — dsh_team_task dispatches automatically and dsh_team_report_task dispatches the next wave — but useful after dsh_team_control/resume, after approving a scope request, or when a member went idle without reporting. Safe to call repeatedly; it returns when no idle member or no ready task is left.',
3415
+ description: 'Pump the agent-team dispatcher once: claim ready tasks for idle members and send each member its brief. Normally unnecessary — dsh_team_task dispatches automatically and dsh_team_report_task dispatches the next wave — but useful after dsh_team_control/resume, after approving a scope request, or when a member went idle without reporting. Safe to call repeatedly; it returns when no idle member or no ready task is left. It is a recovery pump, not a heartbeat: do not call it in a loop to watch a running member.',
3381
3416
  parameters: {
3382
3417
  type: 'object',
3383
3418
  additionalProperties: false,
@@ -3746,7 +3781,7 @@ function buildTools(s, ctx) {
3746
3781
  }
3747
3782
  }
3748
3783
  if (rec) { rec.phase = 'execution'; rec.sawRunning = false; }
3749
- } else if (rec) {
3784
+ } else if (rec && task?.status !== 'done') {
3750
3785
  rec.phase = 'planned';
3751
3786
  }
3752
3787
  if (task?.executionMode === 'new' && rec) {
@@ -3787,7 +3822,7 @@ function buildTools(s, ctx) {
3787
3822
 
3788
3823
  tools.push({
3789
3824
  name: 'dsh_team_board_task_create',
3790
- description: 'Create a new workspace-board task card (the user-facing queue the board scheduler picks up) — use it when the user asks for a new task that is a separate deliverable or deserves its own session/branch (not a step of the current task, which is dsh_team_task). This is NOT a team DAG task: team_* tools stay inside the current team. workspaceId defaults to the caller own board task, then to the only registered workspace; pass it when either is ambiguous. Pass gitBranch to run the new task on a git branch ("" = auto `task/<id>`, omitted = no branch).',
3825
+ description: 'Create a new workspace-board task card (the user-facing queue the board scheduler picks up) — use it when the user asks for a new task that is a separate deliverable or deserves its own session/branch (not a step of the current task, which is dsh_team_task). This is NOT a team DAG task: team_* tools stay inside the current team. workspaceId defaults to the caller own board task, then to the only registered workspace; pass it when either is ambiguous. Pass gitBranch to run the new task on a git branch ("" = auto `task/<id>`, omitted = no branch). Pin models with planRoute/leadRoute/teamModels: call dsh_team_models first and pass { provider?, model, reasoningEffort? } (or "provider/model"); omitted routes follow the board settings, and the card displays the models it uses.',
3791
3826
  parameters: {
3792
3827
  type: 'object',
3793
3828
  additionalProperties: false,
@@ -3801,6 +3836,46 @@ function buildTools(s, ctx) {
3801
3836
  useTeam: { type: 'boolean', description: 'Let the Lead orchestrate a team (default true).' },
3802
3837
  executionMode: { type: 'string', enum: ['same', 'new'], description: 'same = plan and execute in one session; new = execute in a fresh session.' },
3803
3838
  gitBranch: { type: 'string', description: 'Git branch to switch to before spawning; "" auto-generates task/<id>.' },
3839
+ planRoute: {
3840
+ type: 'object',
3841
+ additionalProperties: false,
3842
+ description: 'Planning model; omit to follow the board workspace settings. Use dsh_team_models to pick provider/model/reasoningEffort.',
3843
+ properties: {
3844
+ provider: { type: 'string', description: 'Provider id from dsh_team_models; omit when the model id is unique.' },
3845
+ model: { type: 'string', description: 'Model id from dsh_team_models.' },
3846
+ reasoningEffort: { type: 'string', description: 'Optional reasoning effort id from team_models.' },
3847
+ },
3848
+ required: ['model'],
3849
+ },
3850
+ leadRoute: {
3851
+ type: 'object',
3852
+ additionalProperties: false,
3853
+ description: 'Execution (Lead) model; omit to follow the board workspace settings.',
3854
+ properties: {
3855
+ provider: { type: 'string', description: 'Provider id from dsh_team_models; omit when the model id is unique.' },
3856
+ model: { type: 'string', description: 'Model id from dsh_team_models.' },
3857
+ reasoningEffort: { type: 'string', description: 'Optional reasoning effort id from team_models.' },
3858
+ },
3859
+ required: ['model'],
3860
+ },
3861
+ teamModels: {
3862
+ type: 'array',
3863
+ description: 'Whitelist of models team members may use (dsh_team_spawn enforces it; empty/omitted = unrestricted). Each item is the same { provider?, model, reasoningEffort? } route.',
3864
+ items: {
3865
+ type: 'object',
3866
+ additionalProperties: false,
3867
+ properties: {
3868
+ provider: { type: 'string', description: 'Provider id from dsh_team_models; omit when the model id is unique.' },
3869
+ model: { type: 'string', description: 'Model id from dsh_team_models.' },
3870
+ reasoningEffort: { type: 'string', description: 'Optional reasoning effort id from team_models.' },
3871
+ },
3872
+ required: ['model'],
3873
+ },
3874
+ },
3875
+ prewalk: {
3876
+ type: 'boolean',
3877
+ description: 'Experimental: with executionMode="same", switch the same session to leadRoute after the plan first changes files (default false).',
3878
+ },
3804
3879
  },
3805
3880
  required: ['title'],
3806
3881
  },
@@ -3848,6 +3923,24 @@ function buildTools(s, ctx) {
3848
3923
  }
3849
3924
  }
3850
3925
  }
3926
+ // 模型路由:只在显式传入时下发(省略则跟随看板工作区设置),并提前校验可用性,
3927
+ // 避免建卡成功、真正开会话时才因为模型被禁用而失败。
3928
+ const planRoute = args.planRoute === undefined ? undefined : boardRouteParam(args.planRoute, 'planRoute');
3929
+ const leadRoute = args.leadRoute === undefined ? undefined : boardRouteParam(args.leadRoute, 'leadRoute');
3930
+ let teamModels;
3931
+ if (args.teamModels !== undefined) {
3932
+ if (args.teamModels === null) {
3933
+ teamModels = null; // 显式 null 等价于不限制
3934
+ } else if (!Array.isArray(args.teamModels)) {
3935
+ throw new Error('teamModels 需要数组,每项为 { provider?, model, reasoningEffort? } 或 "provider/model"');
3936
+ } else {
3937
+ teamModels = args.teamModels.map((m, i) => boardRouteParam(m, `teamModels[${i}]`)).filter(Boolean);
3938
+ if (!teamModels.length) teamModels = null; // 空数组等价于不限制
3939
+ }
3940
+ }
3941
+ for (const route of [planRoute, leadRoute, ...(teamModels || [])]) {
3942
+ if (route) await assertRouteEnabled(s, ctx, route.provider, route.model, route.reasoningEffort || null);
3943
+ }
3851
3944
  const task = await request(s, '/api/board/tasks', {
3852
3945
  method: 'POST',
3853
3946
  body: {
@@ -3860,6 +3953,10 @@ function buildTools(s, ctx) {
3860
3953
  ...(args.useTeam !== undefined ? { useTeam: args.useTeam } : {}),
3861
3954
  ...(args.executionMode !== undefined ? { executionMode: args.executionMode } : {}),
3862
3955
  ...(args.gitBranch !== undefined ? { gitBranch: args.gitBranch } : {}),
3956
+ ...(planRoute !== undefined ? { planRoute } : {}),
3957
+ ...(leadRoute !== undefined ? { leadRoute } : {}),
3958
+ ...(teamModels !== undefined ? { teamModels } : {}),
3959
+ ...(args.prewalk !== undefined ? { prewalk: args.prewalk } : {}),
3863
3960
  },
3864
3961
  });
3865
3962
  return { task };
@@ -3868,7 +3965,7 @@ function buildTools(s, ctx) {
3868
3965
 
3869
3966
  tools.push({
3870
3967
  name: 'dsh_team_board_task_get',
3871
- description: 'Read the current workspace-board task of this session (status/planSummary/lastError/gitBranch/sessions) when taskId is omitted, or any board card by taskId. Cheap and safe to call every turn: it returns the status snapshot, not the whole plan body. Use it to decide whether to keep working, wait, or report via dsh_team_board_task_status.',
3968
+ description: 'Read the current workspace-board task of this session (status/planSummary/lastError/gitBranch/planRoute/leadRoute/teamModels/sessions) when taskId is omitted, or any board card by taskId. Cheap and safe to call every turn: it returns the status snapshot, not the whole plan body. Use it to decide whether to keep working, wait, or report via dsh_team_board_task_status.',
3872
3969
  parameters: {
3873
3970
  type: 'object',
3874
3971
  additionalProperties: false,
@@ -3883,6 +3980,8 @@ function buildTools(s, ctx) {
3883
3980
  id: t.id, workspaceId: t.workspaceId, title: t.title, status: t.status,
3884
3981
  executionMode: t.executionMode, needPlan: t.needPlan, useTeam: t.useTeam,
3885
3982
  gitBranch: t.gitBranch || null,
3983
+ planRoute: t.planRoute || null, leadRoute: t.leadRoute || null,
3984
+ teamModels: t.teamModels || null, prewalk: !!t.prewalk,
3886
3985
  planSummary: t.planSummary || null, lastError: t.lastError || null,
3887
3986
  planningSessionId: t.planningSessionId || null, leadSessionId: t.leadSessionId || null,
3888
3987
  teams: t.teams || [], archivedAt: t.archivedAt || null, updatedAt: t.updatedAt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-team-control",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "Expose the local dsh-team sidecar as model-facing tools (dsh_team_create / dsh_team_spawn / dsh_team_status / dsh_team_task / dsh_team_send / dsh_team_report_task / dsh_team_dispatch / dsh_team_control / dsh_team_approve / dsh_team_report), spawn real DSH sub-agent members with per-member permission presets, forward member approvals to the Lead, and manage the sidecar lifecycle.",
6
6
  "icon": "./icon.svg",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "dsh-team-control-cli": "^0.3.0"
24
+ "dsh-team-control-cli": "^0.3.1"
25
25
  },
26
26
  "exports": {
27
27
  ".": "./index.js",