dsh-baton-mcp 0.6.9 → 0.6.10
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/host/package.json +2 -2
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/cli.mjs +9 -3
- package/src/core.mjs +62 -12
- package/src/mcp.mjs +5 -3
package/host/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-baton-host",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "DeepSeek Harness plugin for dsh-baton: hand coding tasks from Claude Code or Codex to DeepSeek Harness on your machine. Adding it is the whole install: it registers the dsh-baton MCP server for Claude Code and Codex, runs each task live in the Harness window, wakes the main agent when the run ends and hands back the changed files, the project's own test results and a requirement-by-requirement checklist.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"LICENSE"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"dsh-baton-mcp": "0.6.
|
|
23
|
+
"dsh-baton-mcp": "0.6.10"
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dsh": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-baton-mcp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
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.
|
|
10
|
+
"version": "0.6.10",
|
|
11
11
|
"packages": [
|
|
12
12
|
{
|
|
13
13
|
"registryType": "npm",
|
|
14
14
|
"identifier": "dsh-baton-mcp",
|
|
15
|
-
"version": "0.6.
|
|
15
|
+
"version": "0.6.10",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
}
|
package/src/cli.mjs
CHANGED
|
@@ -106,8 +106,14 @@ async function main() {
|
|
|
106
106
|
process.exitCode = f.state === 'needs_input' ? 3 : 0
|
|
107
107
|
return
|
|
108
108
|
}
|
|
109
|
+
if (st.needs_input && st.question) {
|
|
110
|
+
const { run_id, state, session_id, needs_input, question } = st
|
|
111
|
+
print(core.asking({ run_id, state, session_id, needs_input, question }, core.askHint(question.count ?? question.questions?.length ?? 1, 'dsh_answer (or dsh-baton answer)', 'wait again')))
|
|
112
|
+
process.exitCode = 3
|
|
113
|
+
return
|
|
114
|
+
}
|
|
109
115
|
print({
|
|
110
|
-
...(st.decided_for_user ? { hint:
|
|
116
|
+
...(st.decided_for_user ? { hint: `${core.DECIDED_HINT} ${core.endedHint(st)}`, decided_for_user: st.decided_for_user } : {}),
|
|
111
117
|
run_id: st.run_id, state: st.state, session_id: st.session_id, timed_out: !!st.timed_out, error: st.error, final_text: st.final_text,
|
|
112
118
|
// A goal goes on after this run: the hint says so and how to follow it.
|
|
113
119
|
...(st.goal ? { goal: st.goal, ...(st.goal.phase === 'active' ? { follow_command: self(`follow ${st.session_id}`) } : {}) } : {}),
|
|
@@ -116,9 +122,9 @@ async function main() {
|
|
|
116
122
|
...(st.state === 'completed' && !st.decided_for_user ? { hint: core.endedHint(st) } : {}),
|
|
117
123
|
// Stopped by the user, cancelled, or cut off by a Harness restart: say so, or the client
|
|
118
124
|
// takes it for a failure in the work and sends it again.
|
|
119
|
-
...(st.harness_down ? { harness_down: true, hint: core.
|
|
125
|
+
...(st.harness_down ? { harness_down: true, hint: core.harnessDownHint('run this same wait command again') } : {}),
|
|
120
126
|
...(stop ? { ...(st.turn_end ? { turn_end: st.turn_end } : {}), ...stop } : {}),
|
|
121
|
-
...(st.needs_input ? { needs_input: st.needs_input,
|
|
127
|
+
...(st.needs_input ? { needs_input: st.needs_input, hint: 'The run waits for a person in the Harness UI. Tell the user, then wait again.' } : {}) })
|
|
122
128
|
process.exitCode = st.state === 'completed' ? 0 : st.needs_input ? 3 : 1
|
|
123
129
|
return
|
|
124
130
|
}
|
package/src/core.mjs
CHANGED
|
@@ -604,7 +604,7 @@ export function followResult(st) {
|
|
|
604
604
|
case 'following': return { ...st, hint: `No report is due yet: ${AGAIN}, with no progress note in between. ${QUIET}` }
|
|
605
605
|
case 'goal_ended': return { ...st, hint: `The goal stopped (${st.ended_because}${st.goal?.blocked_reason ? `: ${st.goal.blocked_reason.message}` : ''}), so following is over. ${report}${st.ended_because === 'blocked' || st.ended_because === 'paused' ? ' It needs the user before it goes on: say so.' : ''}` }
|
|
606
606
|
case 'needs_input': return st.question
|
|
607
|
-
?
|
|
607
|
+
? asking(st, askHint(st.question.count, `dsh_answer and session_id ${st.session_id} (no run_id)`, AGAIN))
|
|
608
608
|
: { ...st, hint: `Harness waits for something only a person can do in its window (an approval, for example). Tell the user, then ${AGAIN}.` }
|
|
609
609
|
case 'needs_resume': return { ...st, hint: 'The goal is still active, but Harness will not go on with it by itself (for example after a Harness restart). Tell the user to press Continue in Harness, and stop following until they have.' }
|
|
610
610
|
case 'goal_stalled': return { ...st, hint: 'The goal is active, yet no new round has started for 5 minutes: Harness may have stopped going on with it (for example after a restart). Tell the user; they can press Continue in Harness. Stop following until they have.' }
|
|
@@ -618,11 +618,28 @@ export const QUOTA_HINT = 'The run stopped because the DeepSeek account has no b
|
|
|
618
618
|
const outOfBalance = (st) => st.state === 'failed' && (['ACCOUNT_QUOTA', 'QUOTA'].includes(st.turn_end?.error?.code) || st.turn_end?.error?.status === 402 || /insufficient balance/i.test(st.error ?? ''))
|
|
619
619
|
|
|
620
620
|
// What to do when a run stops to ask a person (dsh_wait, wait_command and the instructions say it).
|
|
621
|
-
|
|
622
|
-
|
|
621
|
+
// The options are the asking model's guesses, not the limit of the answer: every question also
|
|
622
|
+
// takes free text (on a single-choice question it replaces the option, Harness's own rule).
|
|
623
|
+
// The user wants the client to decide as the owner of the task, not pick the least bad option.
|
|
624
|
+
export const OWN_WORDS = 'On a single choice, text replaces the option.'
|
|
625
|
+
export const ASKED = `If the user told you to decide such questions yourself, decide as the task's owner: an option only if it fits as is, else your own words. ${OWN_WORDS} Call dsh_answer with a one-sentence reason, then tell the user what you answered and why. Otherwise relay the questions, starting with your advice on its own line: "My recommendation: <an option, or your own answer>, because <reason>", from your own judgment, even outside the options (harness_suggested is only the asker's pick, never a reason). List the options (the user may also answer in words) and submit their decision with dsh_answer. Never answer on the user's behalf without that permission.`
|
|
626
|
+
export const DECIDED_HINT = 'Required in your reply: you answered for the user during this run, so start your reply by telling the user, in their language, what you answered (an option or your own words) and why (decided_for_user: answers and reason), then give the result. Passing on only final_text is not enough.'
|
|
627
|
+
// What to do when a run asks the user, in one short hint that goes first in the result.
|
|
628
|
+
// Codex relays through its own question tool (request_user_input: a title and plain option
|
|
629
|
+
// strings); the message before that call is folded away in the Codex app, so a recommendation
|
|
630
|
+
// written only there is lost (Mac, 2026-11-08), and longer hints did not change that. The
|
|
631
|
+
// result therefore carries question_tool, the call laid out with the recommendation as its first
|
|
632
|
+
// option, as relay is the message laid out with it as its first line: clients copy a layout
|
|
633
|
+
// more reliably than they follow rules.
|
|
634
|
+
export const askHint = (n, answerWith, then) => `Harness asks the user ${n} question(s). If the user let you decide such questions, answer as the task's owner: an option only if it fits as is, else your own words (text; ${OWN_WORDS.toLowerCase().replace(/\.$/, '')}). An option that needs a note, a fix or an explanation to work for this task does not fit: write the answer it should have been instead. Answer with ${answerWith} and a one-sentence reason, then tell the user what you answered and why. Otherwise ask the user, your own recommendation first: fill the first line of relay (in a message) or the first option of question_tool (in a question tool such as request_user_input) with the answer that best fits this task, checked against its file names and requirements (an option, or your own answer when none fits), and why. Never "your choice", nor the asker's pick (harness_suggested) unchecked. If they pick your recommendation, submit the answer alone, without "Recommended" or the reason. Submit their answer with ${answerWith}, then ${then}.`
|
|
623
635
|
const NEEDS_INPUT_HINT = (st) => st.question
|
|
624
|
-
?
|
|
636
|
+
? askHint(st.question.count, 'dsh_answer', 'wait for the run again')
|
|
625
637
|
: 'The run waits for something only a person can do in the Harness UI (an approval, for example). Tell the user, then wait for the run again.'
|
|
638
|
+
// The hint first, then the question laid out two ways, then the rest of the status.
|
|
639
|
+
export function asking(st, hint) {
|
|
640
|
+
const { hint: _old, relay: _r, question_tool: _q, ...rest } = st
|
|
641
|
+
return { hint, ...(st.question ? { relay: relayText(st.question), question_tool: questionTool(st.question) } : {}), ...rest }
|
|
642
|
+
}
|
|
626
643
|
|
|
627
644
|
// A run the user stopped in the Harness UI: its turn ended aborted, by the user. With the usual
|
|
628
645
|
// hint, Codex took that for a failure and sent the task again each time the user stopped it
|
|
@@ -636,12 +653,16 @@ export const USER_STOPPED_HINT = 'The user stopped this run in Harness (stopped_
|
|
|
636
653
|
export const INTERRUPTED_HINT = 'Harness restarted or quit while this run was going, and its turn was stopped (interrupted). It is not a failure in the work: do not send it again or continue it on your own. Tell the user Harness was restarted and what evidence shows the run got done, then ask whether to run it again or continue in the same session.'
|
|
637
654
|
export const CANCELLED_HINT = 'This run was cancelled before it finished: with dsh_cancel, or in Harness, where the user stopped the session or removed the queued message. If you did not cancel it yourself, the user did: do not send it again. Tell the user it was cancelled and ask what to do next.'
|
|
638
655
|
// The hint for a run that did not end by its own work, or null for one that did.
|
|
656
|
+
// A run that answered a question for the user before it stopped keeps the sentence telling the
|
|
657
|
+
// client to say so.
|
|
639
658
|
export function stopHint(st) {
|
|
640
|
-
|
|
641
|
-
if (st
|
|
642
|
-
if (st?.state === '
|
|
659
|
+
const told = (hint) => (st?.decided_for_user ? `${DECIDED_STOPPED} ${hint}` : hint)
|
|
660
|
+
if (stoppedByUser(st)) return { stopped_by_user: true, hint: told(USER_STOPPED_HINT) }
|
|
661
|
+
if (st?.state === 'interrupted') return { hint: told(INTERRUPTED_HINT) }
|
|
662
|
+
if (st?.state === 'cancelled') return { hint: told(CANCELLED_HINT) }
|
|
643
663
|
return null
|
|
644
664
|
}
|
|
665
|
+
const DECIDED_STOPPED = 'You answered a question for the user during this run: tell the user, in their language, what you answered and why (decided_for_user: answers and reason).'
|
|
645
666
|
|
|
646
667
|
// The result of a run that ended, kept short: the client already knows what it sent, and a
|
|
647
668
|
// completed run's event log is only the work behind final_text (dsh_status still has it).
|
|
@@ -659,9 +680,7 @@ function ended({ recent_events, message_preview, backend, ...st }) {
|
|
|
659
680
|
|
|
660
681
|
|
|
661
682
|
// What dsh_wait returns for a run that ended or stopped to ask (the Codex Stop hook returns the same).
|
|
662
|
-
export const waitResult = (st) => (st.needs_input
|
|
663
|
-
? { ...st, ...(st.question ? { relay: relayText(st.question) } : {}), hint: NEEDS_INPUT_HINT(st) }
|
|
664
|
-
: ended(st))
|
|
683
|
+
export const waitResult = (st) => (st.needs_input ? asking(st, NEEDS_INPUT_HINT(st)) : ended(st))
|
|
665
684
|
|
|
666
685
|
// The asking model marks its favourite option in the label ("(Recommended)", "(推荐)").
|
|
667
686
|
// Clients relaying the question tended to repeat that mark as their own advice, so the
|
|
@@ -696,7 +715,17 @@ export function relayText(question) {
|
|
|
696
715
|
const asker = q.harness_suggested ? [` (The model in Harness that asked would pick: ${q.harness_suggested.label})`] : []
|
|
697
716
|
return [head, ...options, ...asker].join('\n')
|
|
698
717
|
})
|
|
699
|
-
return ['
|
|
718
|
+
return [RECOMMEND_LINE, '', ...blocks, '', 'You can also answer in your own words.'].join('\n')
|
|
719
|
+
}
|
|
720
|
+
const RECOMMEND_LINE = 'My recommendation: <an option, or your own answer>, because <your own reason>'
|
|
721
|
+
// The same questions as a question tool takes them (a title, plain option strings), the first
|
|
722
|
+
// option left for the client's recommendation; the user can still type their own answer there.
|
|
723
|
+
export function questionTool(question) {
|
|
724
|
+
if (!Array.isArray(question?.questions)) return undefined
|
|
725
|
+
return question.questions.map((q) => ({
|
|
726
|
+
title: `${q.question}${q.multi_select ? ' (several can be chosen)' : ''}`,
|
|
727
|
+
options: ['Recommended: <an option, or your own answer>, because <your own reason>', ...(q.options ?? []).map((o) => o.label)],
|
|
728
|
+
}))
|
|
700
729
|
}
|
|
701
730
|
|
|
702
731
|
// When the client chose for the user (dsh_answer with reason), the choice and reason are
|
|
@@ -705,6 +734,23 @@ export function relayText(question) {
|
|
|
705
734
|
// from another process (wait_command).
|
|
706
735
|
const reasonsFile = () => path.join(config.batonHome, 'answer-reasons.json')
|
|
707
736
|
const readReasons = () => { try { return JSON.parse(fs.readFileSync(reasonsFile(), 'utf8')) } catch { return {} } }
|
|
737
|
+
// A client deciding for the user picked the least bad option and patched it with a note
|
|
738
|
+
// (".doc, but keep it plain text"; "XV:00, with a line saying it means 3 pm"), however the hint
|
|
739
|
+
// put it (Codex, Mac, 2026-11-09). So an option chosen for the user is not sent at once: the
|
|
740
|
+
// first call asks for a second look, and the same answers sent again go through. Own words
|
|
741
|
+
// (text) go through at once, as do answers the user gave (no reason).
|
|
742
|
+
export const OPTION_CHECK_HINT = 'Not sent yet, because you chose an option for the user. First, without looking at the options, write down the answer this user would want for this task, as if Harness had asked with no options at all. Send the option (dsh_answer again with the same answers) only if it says the same as that answer. If it does not, answer with text: your answer. An option you can argue for, or make work with a note or an explanation, is not the answer this user would want.'
|
|
743
|
+
const checked = new Map()
|
|
744
|
+
export function optionCheck(a, reason) {
|
|
745
|
+
if (!(typeof reason === 'string' && reason.trim())) return null
|
|
746
|
+
const picks = (a.answers ?? []).filter((x) => x.choose?.length && !(typeof x.text === 'string' && x.text.trim()))
|
|
747
|
+
if (!picks.length) return null
|
|
748
|
+
const key = JSON.stringify([a.run_id ?? a.session_id, picks.map((x) => [x.id ?? null, x.choose.map(String)])])
|
|
749
|
+
for (const [k, at] of checked) if (Date.now() - at > 30 * 60_000) checked.delete(k)
|
|
750
|
+
if (checked.delete(key)) return null
|
|
751
|
+
checked.set(key, Date.now())
|
|
752
|
+
return { submitted: false, check: picks.map((x) => ({ ...(x.id ? { id: x.id } : {}), choose: x.choose })), hint: OPTION_CHECK_HINT }
|
|
753
|
+
}
|
|
708
754
|
function rememberReason(runId, answers, reason) {
|
|
709
755
|
try {
|
|
710
756
|
const all = readReasons()
|
|
@@ -781,7 +827,9 @@ export async function followThrough(params, { total_s, chunk_s = 300, onChunk, s
|
|
|
781
827
|
|
|
782
828
|
// How often a wait looks for Harness again while it is not running.
|
|
783
829
|
const HOST_RETRY_MS = Number(process.env.DSH_BATON_HOST_RETRY_MS) || 2000
|
|
784
|
-
|
|
830
|
+
// again: how to wait once Harness is back (dsh_wait for one run or several, or the CLI command).
|
|
831
|
+
export const harnessDownHint = (again = 'call dsh_wait again with the same run_id') => `DeepSeek Harness is not running (closed, or restarting), so the run cannot be followed right now; Harness ends a running turn when it quits. Do not send the task again. Tell the user Harness is closed and to open it; then ${again}: it reports how the run ended (interrupted, if Harness quit while it ran).`
|
|
832
|
+
export const HARNESS_DOWN_HINT = harnessDownHint()
|
|
785
833
|
|
|
786
834
|
export const api = {
|
|
787
835
|
async workspaces() {
|
|
@@ -898,6 +946,8 @@ export const api = {
|
|
|
898
946
|
// user, not for Harness.
|
|
899
947
|
async answer({ reason, ...a }) {
|
|
900
948
|
if (!(await useHost())) throw new Error('Answering a question needs the dsh-baton-host plugin running inside DeepSeek Harness.')
|
|
949
|
+
const check = optionCheck(a, reason)
|
|
950
|
+
if (check) return check
|
|
901
951
|
try {
|
|
902
952
|
const result = shaped(await hostCall('answer', a))
|
|
903
953
|
if (!(typeof reason === 'string' && reason.trim())) return result
|
package/src/mcp.mjs
CHANGED
|
@@ -183,7 +183,7 @@ async function waitAnyInChunks(run_ids, progress, signal, meta) {
|
|
|
183
183
|
if (Date.now() - t0 < 500) await new Promise((r) => setTimeout(r, 500))
|
|
184
184
|
if (Date.now() >= deadline) {
|
|
185
185
|
const asking = running.filter((r) => r.state === 'waiting').map((r) => r.run_id)
|
|
186
|
-
if ([...answers.values()].some((st) => st.harness_down)) return { run_ids, timed_out: true, harness_down: true, still_running: running, hint:
|
|
186
|
+
if ([...answers.values()].some((st) => st.harness_down)) return { run_ids, timed_out: true, harness_down: true, still_running: running, hint: core.harnessDownHint('call dsh_wait again with the same run_ids') }
|
|
187
187
|
return {
|
|
188
188
|
run_ids, timed_out: true, still_running: running,
|
|
189
189
|
hint: `None of these runs has ended yet. Call dsh_wait again with the same run_ids, with no progress check or progress note in between (work the user asked you to do meanwhile is fine).${asking.length ? ` ${asking.join(', ')} still wait${asking.length === 1 ? 's' : ''} for a person (see dsh_status for the question): answer with dsh_answer if you may, or tell the user.` : ''}`,
|
|
@@ -369,7 +369,7 @@ const TOOLS = [
|
|
|
369
369
|
{
|
|
370
370
|
name: 'dsh_answer',
|
|
371
371
|
annotations: annotations('Answer question', hints(false, false, false)),
|
|
372
|
-
description: `Answer the questions a waiting run asked (needs_input
|
|
372
|
+
description: `Answer the questions a waiting run asked (needs_input in dsh_wait or dsh_status). ${core.ASKED} Per question: choose (option numbers or labels), text (your own answer, complete on its own), or skip. It reaches Harness once every question has an answer (submitted: true; remaining lists the rest); then wait again. If the user already answered in Harness, it says there is no open question.`,
|
|
373
373
|
inputSchema: {
|
|
374
374
|
type: 'object', required: ['answers'], properties: {
|
|
375
375
|
run_id: str('Run id that is waiting (needs_input: answer)'),
|
|
@@ -379,7 +379,7 @@ const TOOLS = [
|
|
|
379
379
|
type: 'object', properties: {
|
|
380
380
|
id: str('Question id from question.questions[].id; may be left out when there is one question'),
|
|
381
381
|
choose: { type: 'array', items: { type: ['integer', 'string'] }, description: 'Option numbers (1 = first) or labels; one for a single-choice question' },
|
|
382
|
-
text: str('
|
|
382
|
+
text: str('Your own answer in words'),
|
|
383
383
|
skip: { type: 'boolean', description: 'Skip this question' },
|
|
384
384
|
},
|
|
385
385
|
},
|
|
@@ -389,6 +389,8 @@ const TOOLS = [
|
|
|
389
389
|
},
|
|
390
390
|
run: async (a) => {
|
|
391
391
|
const st = await core.api.answer(a)
|
|
392
|
+
// The second look at an option chosen for the user: nothing was sent, its hint says what next.
|
|
393
|
+
if (st.check) return st
|
|
392
394
|
if (!a.run_id) return { ...st, hint: `${st.reason ? 'Tell the user what you chose and this reason. ' : ''}Then call dsh_wait again as before (the same run_id or session_id), with the same until and the last cursor.` }
|
|
393
395
|
return {
|
|
394
396
|
...st,
|