dsh-baton-mcp 0.6.17 → 0.6.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -211,7 +211,7 @@ Working alone, Astra rated its own work 23/23; the independent check found 17/23
211
211
  - **Claude Code** waits for a run in the background (the `wait_command` that `dsh_send` returns) and is woken once, when the run ends.
212
212
  - **Codex** waits inside `dsh_wait`. The plugin sets Codex's tool timeout for dsh-baton to an hour (`tool_timeout_sec = 3600`), so one call waits up to 59 minutes: a run that ends within the hour costs one model request to wait for, however long it takes, and the result comes back as an ordinary tool result in the chat. A longer run returns `timed_out` with just the state after 59 minutes, and Codex calls again without summarising. Pressing Stop ends the wait at once. Codex gets no `wait_command`: its terminal cannot wake it, so it would poll. A conversation without that setting waits 270 s per call. Measured in the Codex desktop app: a 28-minute run took one `dsh_wait` call; a 62-minute run took two, the first returning `timed_out` after 59 minutes and the second getting the result 3 minutes later, with no `dsh_status` calls in between.
213
213
  - **Several runs at once.** When a task is split across sessions (say docs, front end and back end, each in its own worktree), the client sends them all, then waits for them together: Claude Code runs one `wait_command` per run in the background, and Codex calls `dsh_wait` with `run_ids`. That call returns as soon as any of the runs ends or stops to ask a person, with every run that has (`ended`) and the ones still going (`still_running`); the client reviews those, sends fixes right away, and waits again with the rest plus the fixes. Measured on a three-part task: waiting for one run at a time, the back end that ended first was read 2 min 53 s late; waiting with `run_ids`, each result was read within a second of its run ending.
214
- - **Sessions with a Harness goal.** A goal (a message starting with `/goal` sets one) makes Harness start the next round by itself as soon as a turn ends. A run sent to such a session is waited for until the goal stops, not just its first round, so "hand this to Harness" brings back the finished work; sessions without a goal are waited for as before. When the user asks for progress reports ("report every 10 minutes"), the client passes `until` `turn`: it then reports at the end of a round once 10 minutes (`every_minutes`) have passed since the last report, with every round since. To follow a session without sending anything, the client calls `dsh_wait` with `session_id` (Claude Code runs the `follow_command` in the background instead). Each report carries every round since the last one (the latest round's closing reply (up to 1500 characters), each earlier round as a one-line digest with its tools; any round in full through `dsh_read_session`), the files changed in the folder since the last report (since the run began, for the first), and the goal's state (phase, rounds started of the most allowed, whether Harness goes on with it), plus a `cursor` that the next call passes back, so switching between the two modes neither repeats nor misses a round. Both return at once when Harness asks a question (answer it with `dsh_answer` and `session_id`) or waits for an approval, when the goal is complete, paused, blocked or cleared, or when Harness will not go on with it by itself (for example after a Harness restart, until you press Continue). In Codex one call follows a goal for at most 15 minutes and Codex then calls again, so a message you type reaches it within that time; such an in-between return carries only the goal's state and how many rounds wait, not their texts.
214
+ - **Sessions with a Harness goal.** A goal (a message starting with `/goal` sets one) makes Harness start the next round by itself as soon as a turn ends. A `dsh_send` message `/goal <objective>` sets the goal through Harness's own goal service, as typing it in Harness does, and the objective goes in as the run's message; `/goal edit <objective>` replaces the objective of the goal there is. `/goal pause`, `resume` and `clear` work only in the Harness window; sent through dsh-baton they are refused, and so is a new `/goal` for a session whose goal is still active. A run sent to such a session is waited for until the goal stops, not just its first round, so "hand this to Harness" brings back the finished work; sessions without a goal are waited for as before. When the user asks for progress reports ("report every 10 minutes"), the client passes `until` `turn`: it then reports at the end of a round once 10 minutes (`every_minutes`) have passed since the last report, with every round since. To follow a session without sending anything, the client calls `dsh_wait` with `session_id` (Claude Code runs the `follow_command` in the background instead). Each report carries every round since the last one (the latest round's closing reply (up to 1500 characters), each earlier round as a one-line digest with its tools; any round in full through `dsh_read_session`), the files changed in the folder since the last report (since the run began, for the first), and the goal's state (phase, rounds started of the most allowed, whether Harness goes on with it), plus a `cursor` that the next call passes back, so switching between the two modes neither repeats nor misses a round. Both return at once when Harness asks a question (answer it with `dsh_answer` and `session_id`) or waits for an approval, when the goal is complete, paused, blocked or cleared, or when Harness will not go on with it by itself (for example after a Harness restart, until you press Continue). In Codex one call follows a goal for at most 15 minutes and Codex then calls again, so a message you type reaches it within that time; such an in-between return carries only the goal's state and how many rounds wait, not their texts.
215
215
  - **Changing the request while it waits.** In Codex, send the change with **Steer**: Codex stops waiting at once, steers it into the same Harness session (`dsh_send` with `mode` `steer`) and waits on the new run; Harness does both in the same turn. Sent with **Queue**, Codex sees it only when the run ends; you can also press Stop first and then send it. In Claude Code, just send it: it waits in the background, so it steers the change in right away. A steered run ends together with the original and they share one result; a queued run comes back on its own. Runs working in the same folder at the same time are named in each other's results, so neither removes the other's files.
216
216
 
217
217
  </details>
package/README.zh-CN.md CHANGED
@@ -211,7 +211,7 @@ Codex 占 ChatGPT Plus 5 小时额度的比例,以及主 Agent 自己的花费
211
211
  - **Claude Code** 在后台等待任务(`dsh_send` 返回的 `wait_command`),任务结束时只被唤醒一次。
212
212
  - **Codex** 在 `dsh_wait` 里等待。插件把 Codex 对 dsh-baton 的工具超时设为一小时(`tool_timeout_sec = 3600`),所以一次调用最多能等 59 分钟:一小时以内跑完的任务,不管跑多久,等待只花一次模型请求,结果作为普通的工具结果回到对话里。超过 59 分钟会返回 `timed_out`,只带状态,Codex 直接再调用一次,不会去总结进度。等待中按停止会立刻停下。Codex 不会收到 `wait_command`:它的终端无法在命令结束时唤醒它,只能轮询。没有这项设置的对话每次最多等 270 秒。实测(Codex 桌面端):28 分钟的任务只调了 1 次 `dsh_wait`;62 分钟的任务调了 2 次,第一次等满 59 分钟返回 `timed_out`,接着再等 3 分钟拿到结果;期间没有调用 `dsh_status`。
213
213
  - **同时等多个任务**。一个任务拆给几个会话做时(比如接口文档、前端、后端,各在自己的 worktree 里),客户端先全部发出去,再一起等:Claude Code 给每个任务在后台各开一个 `wait_command`,Codex 调一次带 `run_ids` 的 `dsh_wait`。只要其中任何一个做完或停下来问人,这次调用就立刻返回,带上所有已经做完的(`ended`)和还在跑的(`still_running`);客户端检查这些结果、马上发返修,再带着剩下的和返修的一起接着等。实测一个分三部分的任务:一次只等一个时,最先做完的后端晚了 2 分 53 秒才被看到;用 `run_ids` 一起等时,每个结果都在做完 1 秒内拿到。
214
- - **带 Harness 目标的会话**。有了目标(以 `/goal` 开头的消息会设置目标),Harness 在一个回合结束后会自己开始下一轮。发给这种会话的任务会一直等到目标停下,而不只是第一轮,所以一句“交给 Harness”就能拿回做完的结果;没有目标的会话照旧等待。用户要求汇报进度时(“每 10 分钟汇报一次”),客户端传 `until` 为 `turn`:距上次报告满 10 分钟(`every_minutes`)后的第一个回合结束时报告,带上这期间的每一轮。想不发消息只跟进某个会话,客户端用 `session_id` 调 `dsh_wait`(Claude Code 则在后台运行 `follow_command`)。每份报告带着自上次报告以来的每一轮(最新一轮的结尾回复(最多 1500 字),之前每一轮一行摘要和用过的工具;任何一轮的全文可以用 `dsh_read_session` 看)、文件夹里自上次报告以来改动的文件(第一份从任务开始算起)、目标状态(阶段、已开始的轮数和上限、Harness 会不会自己接着做),以及下次调用要传回的 `cursor`,所以两种方式之间切换既不会重复也不会漏掉哪一轮。两种方式在这些情况下都会立刻返回:Harness 提问(用 `dsh_answer` 加 `session_id` 回答)或等待审批;目标完成、暂停、受阻或被清除;Harness 不会自己接着做(比如 Harness 重启后,要等你按“继续”)。在 Codex 里,一次调用最多跟进 15 分钟,然后 Codex 再接着调用,所以你打的新消息最晚 15 分钟内就能被看到;这种中途返回只带目标状态和还有几轮没报告,不带各轮全文。
214
+ - **带 Harness 目标的会话**。有了目标(以 `/goal` 开头的消息会设置目标),Harness 在一个回合结束后会自己开始下一轮。通过 `dsh_send` 发 `/goal 目标内容`,会用 Harness 自己的目标服务设置目标,和在 Harness 里直接输入一样,目标内容作为这次任务的消息发过去;`/goal edit 新内容` 改掉现有目标的内容。`/goal pause`、`resume`、`clear` 只能在 Harness 窗口里用,通过 dsh-baton 发会被拒绝;会话里已有未完成的目标时再发新的 `/goal` 也会被拒绝。发给这种会话的任务会一直等到目标停下,而不只是第一轮,所以一句“交给 Harness”就能拿回做完的结果;没有目标的会话照旧等待。用户要求汇报进度时(“每 10 分钟汇报一次”),客户端传 `until` 为 `turn`:距上次报告满 10 分钟(`every_minutes`)后的第一个回合结束时报告,带上这期间的每一轮。想不发消息只跟进某个会话,客户端用 `session_id` 调 `dsh_wait`(Claude Code 则在后台运行 `follow_command`)。每份报告带着自上次报告以来的每一轮(最新一轮的结尾回复(最多 1500 字),之前每一轮一行摘要和用过的工具;任何一轮的全文可以用 `dsh_read_session` 看)、文件夹里自上次报告以来改动的文件(第一份从任务开始算起)、目标状态(阶段、已开始的轮数和上限、Harness 会不会自己接着做),以及下次调用要传回的 `cursor`,所以两种方式之间切换既不会重复也不会漏掉哪一轮。两种方式在这些情况下都会立刻返回:Harness 提问(用 `dsh_answer` 加 `session_id` 回答)或等待审批;目标完成、暂停、受阻或被清除;Harness 不会自己接着做(比如 Harness 重启后,要等你按“继续”)。在 Codex 里,一次调用最多跟进 15 分钟,然后 Codex 再接着调用,所以你打的新消息最晚 15 分钟内就能被看到;这种中途返回只带目标状态和还有几轮没报告,不带各轮全文。
215
215
  - **等待中想改需求**。Codex:在输入框里用**引导**发出新要求,Codex 会立刻停止等待,用 `dsh_send`(`mode` 为 `steer`)把它插进同一个 Harness 对话,改等新的任务,Harness 在同一轮里把新要求一起做完;用**排队**发的话,要等这次任务做完才会被看到。也可以先按停止再发。Claude Code:随时发就行,它在后台等待,马上就能把新要求插队转给 Harness。插队的任务和原任务同时结束,共用一份结果;排队的任务单独返回。同一个文件夹里同时跑多个任务时,结果里会标出其他任务,不会删掉别人的文件。
216
216
 
217
217
  </details>
package/host/lib/index.js CHANGED
@@ -65,8 +65,11 @@ function normalizePath(p) {
65
65
  // one more in the sidebar for each subfolder or throw-away folder. Instead it joins:
66
66
  // - the conversation's own folder (base), when the target is inside it: a Claude Code chat in
67
67
  // Coding handing over Coding/app joins the Coding workspace;
68
+ // - for a target outside it, the nearest workspace around the target, else the conversation's
69
+ // own folder: a chat in Coding handing over a folder on another disk joins the Coding workspace;
68
70
  // - for folders clients make per conversation, one shared folder: Codex chats without a project
69
- // (Documents/Codex/<date>/<chat>), Claude scratch folders (…/scratch-workspaces/…), Claude
71
+ // (Documents/Codex/<date>/<chat>), Claude scratch folders (…/scratch-workspaces/…, Claude
72
+ // Code's <tmp>/claude-<uid>/…/scratchpad), Antigravity's scratch and brain folders, Claude
70
73
  // worktrees (<project>/.claude/worktrees/<name>, joined to the project) and Codex worktrees
71
74
  // (~/.codex/worktrees/…).
72
75
  // The session then starts in that folder and the message names the target folder.
@@ -86,8 +89,16 @@ function sharedFolder(dir) {
86
89
  if (same(at, 'worktrees') && i >= 2 && same(parts[i - 1], '.claude')) return { path: upto(i + 1), title: 'Claude worktrees' }
87
90
  if (same(at, 'worktrees') && same(parts[i - 1], '.codex')) return { path: upto(i + 1), title: 'Codex worktrees' }
88
91
  if (same(at, 'scratch-workspaces')) return { path: upto(i + 1), title: 'Claude scratch' }
92
+ // Antigravity: chats outside a project work in <data>/scratch, artifacts sit in <data>/brain/<id>.
93
+ if ((same(at, 'scratch') || same(at, 'brain')) && /^antigravity/i.test(parts[i - 1] ?? '') && same(parts[i - 2] ?? '', '.gemini')) return { path: upto(i + 1), title: 'Antigravity scratch' }
89
94
  if (same(at, 'Codex') && same(parts[i - 1], 'Documents') && DAY.test(parts[i + 1] ?? '')) return { path: upto(i + 1), title: 'Codex chats' }
90
95
  }
96
+ // Claude Code's per-conversation scratchpad: <tmp>/claude[-<uid>]/<project>/<session>/scratchpad;
97
+ // every conversation's goes to the claude[-<uid>] folder (2026-11-20: a paper review gave each
98
+ // reviewer its own scratchpad subfolder, five workspaces).
99
+ for (let s = parts.length - 1; s >= 3; s--) {
100
+ if (same(parts[s], 'scratchpad') && /^claude(-\d+)?$/i.test(parts[s - 3])) return { path: upto(s - 2), title: 'Claude scratch' }
101
+ }
91
102
  return null
92
103
  }
93
104
  // A Git worktree (its .git is a file pointing into another repository's worktrees): a checkout
@@ -98,16 +109,29 @@ function isLinkedWorktree(dir) {
98
109
  return text.startsWith('gitdir:') && /[\\/]worktrees[\\/]/.test(text)
99
110
  } catch { return false }
100
111
  }
101
- function sessionHome(target, base) {
112
+ // known: the folders that are workspaces already.
113
+ function sessionHome(target, base, known = []) {
102
114
  const usable = (dir) => dir && !same(dir, os.homedir()) && dir !== path.parse(dir).root && isDirectory(dir)
103
- if (base && !isLinkedWorktree(target)) {
104
- let b = normalizePath(base)
105
- const shared = sharedFolder(b)
106
- if (shared && isDirectory(shared.path)) b = shared.path
107
- if (usable(b) && isInside(target, b)) return { path: b, ...(shared && same(b, shared.path) && shared.title ? { title: shared.title } : {}) }
115
+ const linked = isLinkedWorktree(target)
116
+ let b
117
+ let baseShared = null
118
+ if (base && !linked) {
119
+ b = normalizePath(base)
120
+ baseShared = sharedFolder(b)
121
+ if (baseShared && isDirectory(baseShared.path)) b = baseShared.path
122
+ if (usable(b) && isInside(target, b)) return { path: b, ...(baseShared && same(b, baseShared.path) && baseShared.title ? { title: baseShared.title } : {}) }
108
123
  }
109
124
  const shared = sharedFolder(target)
110
125
  if (shared && usable(shared.path)) return shared
126
+ if (b) {
127
+ // A folder outside the conversation's folder (2026-11-20: a chat in Coding gave each reviewer
128
+ // a folder of its own on another disk, one workspace each): the nearest workspace around it,
129
+ // else the conversation's own folder. Not a chat's throw-away folder (a Codex chat without
130
+ // a project): a project handed over from there keeps a workspace of its own.
131
+ const around = known.filter((dir) => dir && usable(dir) && isInside(target, dir)).sort((x, y) => y.length - x.length)[0]
132
+ if (around) return { path: around }
133
+ if (b && !baseShared && usable(b)) return { path: b }
134
+ }
111
135
  return { path: target }
112
136
  }
113
137
 
@@ -1600,17 +1624,58 @@ export function apply(ctx) {
1600
1624
  const TEAMS_UNSUPPORTED = 'this DeepSeek Harness cannot turn Agent Teams on per session; that needs Harness 0.2.2-rc.2 or later: update Harness, or send without team'
1601
1625
  async function setTeam(sessionId, enabled) {
1602
1626
  if (typeof teamsService?.setEnabled !== 'function') throw new Error(TEAMS_UNSUPPORTED)
1603
- // The exact live Agent from Harness's registry, as its own UI lookup takes it: Team rejects
1604
- // any other object ("subagent tree access requires the exact live caller"). A session not
1605
- // loaded yet is loaded first.
1627
+ const agent = await liveAgent(sessionId)
1628
+ // A finished sub-agent's session is never loaded again: name the likely cause.
1629
+ if (!agent) throw new Error(`session ${sessionId} is not loaded in Harness; if it is a sub-agent's (teammate's) session, change Team mode on its root session instead`)
1630
+ await teamsService.setEnabled(agent, enabled)
1631
+ }
1632
+
1633
+ // The exact live Agent from Harness's registry, as its own UI lookup takes it: Team and goals
1634
+ // reject any other object ("subagent tree access requires the exact live caller"). A session
1635
+ // not loaded yet is loaded first. undefined when it cannot be loaded.
1636
+ async function liveAgent(sessionId) {
1606
1637
  let agent = agentsService?.get?.(sessionId)
1607
1638
  if (!agent && typeof controller.resolveAgent === 'function') {
1608
1639
  await controller.resolveAgent(sessionId)
1609
1640
  agent = agentsService?.get?.(sessionId)
1610
1641
  }
1611
- // A finished sub-agent's session is never loaded again: name the likely cause.
1612
- if (!agent) throw new Error(`session ${sessionId} is not loaded in Harness; if it is a sub-agent's (teammate's) session, change Team mode on its root session instead`)
1613
- await teamsService.setEnabled(agent, enabled)
1642
+ return agent
1643
+ }
1644
+
1645
+ // --- /goal ------------------------------------------------------------------------
1646
+ // Harness runs /goal as a composer command (commands.execute), not as text for the model:
1647
+ // sent as a prompt it set no goal (Windows rc.2 on 11-17, Mac rc.5 on 11-21). So a leading
1648
+ // "/goal <objective>" sets the goal through Harness's goals service, as the command does, and
1649
+ // the objective goes in as the run's message. The goal is set once Harness has taken that
1650
+ // message in, so its round driver sees a queued prompt and waits: the run's own turn comes
1651
+ // first, then Harness goes on with the goal's rounds by itself.
1652
+ const GOAL_UNSUPPORTED = 'this DeepSeek Harness cannot set a goal from a plugin (no goals service); type /goal in the Harness window, or update Harness'
1653
+ function goalCommand(message) {
1654
+ const m = /^\/goal(?:\s+([^]*))?$/i.exec(message.trim())
1655
+ if (!m) return null
1656
+ const rest = (m[1] ?? '').trim()
1657
+ const word = rest.toLowerCase()
1658
+ if (!rest || ['clear', 'pause', 'resume', 'edit'].includes(word)) return { kind: 'control', word: word || 'show' }
1659
+ if (/^edit\s/i.test(rest)) return { kind: 'edit', objective: rest.slice(4).trim() }
1660
+ return { kind: 'create', objective: rest }
1661
+ }
1662
+ const GOAL_NOTE = '(This message also set a Harness goal for this session, with the text above as its objective. When all of it is done and verified, mark the goal complete; if work remains, leave it active and Harness starts the next goal round after this turn.)'
1663
+
1664
+ async function setGoal(run, cmd, objective) {
1665
+ try {
1666
+ const agent = await liveAgent(run.sessionId)
1667
+ if (!agent) throw new Error(`session ${run.sessionId} is not loaded in Harness`)
1668
+ const current = goalsService.get(agent)
1669
+ const view = cmd.kind === 'edit' && current && current.phase !== 'complete'
1670
+ ? goalsService.edit(agent, { id: current.id, revision: current.revision }, { objective })
1671
+ : goalsService.create(agent, { objective })
1672
+ run.goalSet = { id: view.id, phase: view.phase, max_rounds: view.maxGoalRounds ?? null }
1673
+ pushEvent(run, { type: 'goal_set', goal_id: view.id, edited: cmd.kind === 'edit' && view.revision > 1 })
1674
+ } catch (error) {
1675
+ run.goalError = String(error?.message ?? error)
1676
+ pushEvent(run, { type: 'goal_failed', error: run.goalError })
1677
+ logError('set goal', error)
1678
+ }
1614
1679
  }
1615
1680
 
1616
1681
  async function send({ message, session_id, cwd, workspace_id, conversation_folder, mode: asked, sender, model, reasoning_effort, team }) {
@@ -1632,6 +1697,14 @@ export function apply(ctx) {
1632
1697
  throw new Error(`Session ${sessionId} is archived. Unarchive it in Harness, or start a new session with cwd or workspace_id.`)
1633
1698
  }
1634
1699
  if (!sessionId && !cwd && !workspace_id) throw new Error('A new session needs cwd or workspace_id. Pass session_id to continue an existing one.')
1700
+ const goalCmd = goalCommand(message)
1701
+ if (goalCmd?.kind === 'control') throw new Error(`Nothing was sent: dsh_send takes "/goal <objective>" or "/goal edit <objective>"; /goal ${goalCmd.word === 'show' ? '' : goalCmd.word} works only in the Harness window. dsh_status with session_id shows a session's goal.`)
1702
+ if (goalCmd && (typeof goalsService?.create !== 'function' || typeof agentsService?.get !== 'function')) throw new Error(`Nothing was sent: ${GOAL_UNSUPPORTED}`)
1703
+ if (goalCmd?.kind === 'create' && sessionId) {
1704
+ const current = await goalOf(sessionId)
1705
+ if (current && current.phase !== 'complete') throw new Error(`No message was sent: session ${sessionId} already has a goal (${current.phase}: ${current.objective}). Send "/goal edit <objective>" to replace its objective, or clear it in the Harness window first.`)
1706
+ }
1707
+ if (goalCmd) message = goalCmd.objective
1635
1708
  // A missing folder is not created: a mistyped path, or a project on a drive that is not
1636
1709
  // connected, would get an empty folder (under /Volumes, even). Checked before the registry,
1637
1710
  // which answers a bare ENOENT, or nothing at all for a folder registered while it was there.
@@ -1672,7 +1745,7 @@ export function apply(ctx) {
1672
1745
  const target = normalizePath(cwd)
1673
1746
  // A folder that is a workspace already (sessions from before 0.6.15) keeps it.
1674
1747
  const own = await registry.resolveByPath(target).catch(() => undefined)
1675
- const home = own ? { path: target } : sessionHome(target, conversation_folder)
1748
+ const home = own ? { path: target } : sessionHome(target, conversation_folder, registry.list().map((w) => w.path))
1676
1749
  workspace = await createWorkspace({ path: home.path, title: home.title, create_dir: false })
1677
1750
  if (!same(home.path, target)) {
1678
1751
  workFolder = target
@@ -1740,9 +1813,10 @@ export function apply(ctx) {
1740
1813
  // session after a restart) that took 2 min 35 s, and the client sat in dsh_send all along
1741
1814
  // (Mac, 2026-11-18). So the reply waits at most admitWaitMs() (10 s); Harness's answer still settles
1742
1815
  // the run when it comes (a refusal fails it, and dsh_wait says so).
1743
- const admitted = controller.prompt({ sessionId, requestId: run.requestId, content: [{ type: 'text', text: message }], mode }, signal())
1744
- .then(() => {
1816
+ const admitted = controller.prompt({ sessionId, requestId: run.requestId, content: [{ type: 'text', text: goalCmd ? `${message}\n\n${GOAL_NOTE}` : message }], mode }, signal())
1817
+ .then(async () => {
1745
1818
  run.admitted = true // in Harness's queue (or conversation) now
1819
+ if (goalCmd) await setGoal(run, goalCmd, message)
1746
1820
  if (drift) rememberDefault(drift.now)
1747
1821
  return true
1748
1822
  }, (error) => {
@@ -1763,6 +1837,7 @@ export function apply(ctx) {
1763
1837
  ...(pagePart.length ? { handover_default: pagePart } : {}),
1764
1838
  ...(modelNotes.length ? { model_note: modelNotes.join(' ') } : {}),
1765
1839
  ...(team != null ? { team } : {}),
1840
+ ...(goalCmd && answered ? (run.goalSet ? { goal_set: run.goalSet } : { goal_error: run.goalError ?? 'not set' }) : {}),
1766
1841
  ...(ahead.length ? { other_active_runs: ahead } : {}),
1767
1842
  ...(queuedBehind ? { queued_behind: true } : {}),
1768
1843
  ...(workspace ? { workspace } : {}),
package/host/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-baton-host",
3
- "version": "0.6.17",
3
+ "version": "0.6.18",
4
4
  "description": "Hand coding tasks from Claude Code, Codex or Antigravity to DeepSeek Harness: they run live in the Harness window and come back with the changed files and test results. 让 Claude Code、Codex 和 Antigravity 把编码任务交给 DeepSeek Harness:在 Harness 窗口里实时跑,做完带着改动文件和测试结果交回。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -24,7 +24,7 @@
24
24
  "docs"
25
25
  ],
26
26
  "dependencies": {
27
- "dsh-baton-mcp": "0.6.17"
27
+ "dsh-baton-mcp": "0.6.18"
28
28
  },
29
29
  "license": "MIT",
30
30
  "dsh": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-baton-mcp",
3
- "version": "0.6.17",
3
+ "version": "0.6.18",
4
4
  "mcpName": "io.github.JialaoLiu/dsh-baton",
5
5
  "description": "Pass the baton from Claude Code, Codex or any MCP client to a local DeepSeek Harness: an MCP server that hands off tasks, continues a specific session, shows the run live in Harness and hands the result back when it is done.",
6
6
  "type": "module",
package/server.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "url": "https://github.com/JialaoLiu/dsh-baton",
8
8
  "source": "github"
9
9
  },
10
- "version": "0.6.17",
10
+ "version": "0.6.18",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "dsh-baton-mcp",
15
- "version": "0.6.17",
15
+ "version": "0.6.18",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  }
package/src/mcp.mjs CHANGED
@@ -33,6 +33,8 @@ const listsHidden = () => ['claude', 'antigravity'].includes(core.senderOf(clien
33
33
  // Codex (no wake-on-exit), and not Antigravity on Windows: its terminal is sandboxed there and
34
34
  // may not open Harness's named pipe (EPERM), while this server, started outside it, can.
35
35
  const backgroundWaits = () => !isCodex() && !(process.platform === 'win32' && core.senderOf(clientName) === 'antigravity')
36
+ // Claude Code itself (not the Claude desktop chat, claude-ai, which has no shell).
37
+ const isClaudeCode = () => /^claude-code/i.test(String(clientName ?? ''))
36
38
  let codexTimeout = { mtime: null, value: null }
37
39
  function codexToolTimeout() {
38
40
  try {
@@ -349,7 +351,7 @@ const TOOLS = [
349
351
  {
350
352
  name: 'dsh_send',
351
353
  annotations: annotations('Send message', hints(false, false, false)),
352
- description: 'Hand a task to DeepSeek Harness, or continue a session: returns at once with a run_id and a hint saying how to wait for the reply; follow it. Call it directly, no need to list anything first. A new session starts in the folder this conversation works in, or in cwd or workspace_id (a new cwd is registered first); session_id continues that session. Without session_id, a task for a folder where this conversation already has an idle Harness session continues that session, so it keeps the earlier context (continued_session in the result says so; new_session: true starts a fresh one); a busy session is never reused, so parts sent in parallel still get a session each. message arrives verbatim as a user message, and Harness does not see this conversation: make it self-contained, in the user\'s language, the full, explicit spec, asking for tests that cover each requirement. Keep a leading /goal (it sets a Harness goal) and the user\'s goal text as written. For a large task, write a concrete spec (goal, modules and the files each owns, level of detail, acceptance criteria) rather than passing the user\'s words on, and send independent parts to separate sessions in parallel, each owning its own files; wait for them together (dsh_wait run_ids), review each as it returns and send its fixes at once. With checks, a short request for a sub-agent review table is appended. To a busy session, mode followup queues the message and steer adds it to the running turn; left out, the Harness setting decides.',
354
+ description: 'Hand a task to DeepSeek Harness, or continue a session: returns at once with a run_id and a hint saying how to wait for the reply; follow it. Call it directly, no need to list anything first. A new session starts in the folder this conversation works in, or in cwd or workspace_id (a new cwd is registered first); session_id continues that session. Without session_id, a task for a folder where this conversation already has an idle Harness session continues that session, so it keeps the earlier context (continued_session in the result says so; new_session: true starts a fresh one); a busy session is never reused, so parts sent in parallel still get a session each. message arrives verbatim as a user message, and Harness does not see this conversation: make it self-contained, in the user\'s language, the full, explicit spec, asking for tests that cover each requirement. Keep a leading /goal (it sets a Harness goal) and the user\'s goal text as written. For a large task, write a concrete spec (goal, modules and the files each owns, level of detail, acceptance criteria) rather than passing the user\'s words on, and send independent parts to separate sessions in parallel, each owning its own files; wait for them together as each send\'s hint says, review each as it returns and send its fixes at once. With checks, a short request for a sub-agent review table is appended. To a busy session, mode followup queues the message and steer adds it to the running turn; left out, the Harness setting decides.',
353
355
  inputSchema: { type: 'object', required: ['message'], properties: { message: str('The task or reply to send'), session_id: str('Existing session to continue'), new_session: { type: 'boolean', description: 'Start a new session even though this conversation has an idle session in that folder: only for an unrelated task, or one that must not see the earlier work' }, cwd: str('Workspace folder for a new session; leave out to use the folder this conversation works in'), workspace_id: str('Harness workspace for a new session (from dsh_list_workspaces)'), mode: { type: 'string', enum: ['followup', 'steer'], description: "followup queues after the current turn; steer injects into a running turn. Omit to follow Harness's busy-send setting" }, model: str('Only when the user names a model for this run (e.g. "DeepSeek-V4 Pro"); else the session keeps its own; a new one takes the plugin page\'s default. Matched ignoring case, spaces, hyphens and a leading DeepSeek; no match or several fails the send with the list (provider/model picks one). Sets this session only'), team: { type: 'boolean', description: 'Only when the user asks for Agent Teams: true turns them on for this session, false off' }, reasoning_effort: str('Only when the user names a reasoning effort, e.g. high; one of the efforts dsh_list_models shows for the model'), checks: { type: 'array', items: { type: 'string' }, description: 'The project\'s own test commands, e.g. npm test, or python -m pytest (a bare pytest is often not on PATH, on Windows especially); never check scripts you write yourself. dsh-baton runs them in the folder when the run ends and returns exit codes and the last output lines as evidence.' } } },
354
356
  run: async (a, { meta } = {}) => {
355
357
  // A new session goes to this conversation's folder unless the call names another one;
@@ -366,7 +368,7 @@ const TOOLS = [
366
368
  }
367
369
  const filled = here && !a.cwd && !a.workspace_id
368
370
  const folder = here && a.cwd && !within(a.cwd, here)
369
- ? { folder_note: `This conversation works in ${here}; the new session was started in ${a.cwd} as asked. If that was not intended, cancel it and send again without cwd.` }
371
+ ? { folder_note: `This conversation works in ${here}; the task runs in ${a.cwd} as asked. If that was not intended, cancel it and send again without cwd.` }
370
372
  : filled ? { cwd: here } : {}
371
373
  // The conversation's folder goes along, so a hand-over to a folder inside it joins its workspace.
372
374
  const { new_session: fresh, ...given } = a
@@ -401,6 +403,16 @@ const TOOLS = [
401
403
  hint: `Run started. Run wait_command now as a background terminal command and end your turn: Antigravity wakes you when it exits, which is when the run ends or stops to ask the user something; it prints the reply or the questions, with no polling and no turns spent meanwhile. Do not call dsh_wait for it. Several runs: one background wait_command each, so whichever ends first wakes you. ${GOAL_WAIT_HINT('--until turn --every 10m on wait_command')}`,
402
404
  }
403
405
  }
406
+ // Claude Code: told plainly as well. Offered "otherwise dsh_wait", a conversation that sent
407
+ // 12 runs at once took one dsh_wait for all of them, timing out and calling again every
408
+ // 50 s (2026-11-21), where a background wait costs nothing until a run ends.
409
+ if (isClaudeCode()) {
410
+ return {
411
+ ...st,
412
+ wait_command: waitCommand(st.run_id),
413
+ hint: `Run started. Run wait_command now with Bash run_in_background: true, then go on with other work, or end your turn if there is none: Claude Code wakes you when it exits, which is when the run ends or stops to ask the user something; it prints the reply or the questions, with no polling and no turns spent meanwhile. Do not call dsh_wait for it. Several runs: one background wait_command each, never one dsh_wait for all, so whichever ends first wakes you. ${GOAL_WAIT_HINT('--until turn --every 10m on wait_command')}`,
414
+ }
415
+ }
404
416
  return {
405
417
  ...st,
406
418
  wait_command: waitCommand(st.run_id),