dsh-baton-mcp 0.6.18 → 0.6.19
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 +1 -1
- package/README.zh-CN.md +1 -1
- package/host/lib/index.js +42 -4
- package/host/package.json +2 -2
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/cli.mjs +2 -0
- package/src/core.mjs +3 -1
- package/src/evidence.mjs +16 -3
package/README.md
CHANGED
|
@@ -251,7 +251,7 @@ The server's MCP instructions are a single sentence; how to hand over, wait and
|
|
|
251
251
|
| `dsh_list_models` | The models Harness can run (provider, id, name, reasoning efforts) and its default model |
|
|
252
252
|
| `dsh_read_session` | Recent prompts and replies of one session (with tool names); `archived: true` for an archived session |
|
|
253
253
|
| `dsh_send` | Send a message: `session_id` continues that session. Without it, a task for a folder where this conversation already has an idle session continues that session, so Harness keeps the earlier context (`continued_session` says so; `new_session` `true` starts a fresh one); a busy session is never reused, so parts sent in parallel get a session each. Otherwise a new one starts in `cwd` or `workspace_id`, or, with neither, in the folder the conversation works in (a `cwd` that is not a workspace yet is registered first; a `cwd` outside the conversation's folder is allowed and noted in `folder_note`). A `cwd` inside the conversation's folder joins that folder's workspace instead of getting one of its own: the session opens in the conversation's folder and the message names the subfolder (`work_folder`), where `checks` run. Folders a client makes per conversation share one workspace each: Codex chats without a project (Codex chats), Claude scratch folders (Claude scratch), Codex worktrees (Codex worktrees) and a project's Claude worktrees (Claude worktrees). A folder that is a workspace already, or a Git worktree, keeps its own. `checks`: test commands dsh-baton runs itself when the run ends (see [How a hand-over is checked](#how-a-hand-over-is-checked)). Returns a `run_id` at once. In Harness the message is marked "Sent by Claude / ChatGPT from another chat". An archived session is refused: unarchive it in Harness, or start a new session. To a busy session, `mode` `followup` queues the message after the current turn and `steer` adds it to the running turn; left out, it does what Harness's own setting says (Settings → sending while busy: queue or steer), and `followup` when that cannot be read. `mode_source` says which applied. `model` only when the user names one ("DeepSeek-V4 Pro", "v4-pro"; `reasoning_effort` likewise): it is matched against Harness's own model list, ignoring case, spaces, hyphens and a leading DeepSeek, so a model Harness adds later (V4.1 Pro) works as soon as Harness lists it; a name that matches nothing or several fails the send, before anything is created, with the list (`provider/model` picks one). It is set on that session before the message goes in, and Harness's default model is put back as it was (Harness saves a session's pick as the default too). Left out, a continued session keeps its own model and a new one uses the hand-over default from the plugin page, else Harness's default. The reply says which in `model` and `model_source` (`requested`, `handover_default`, `default` or `session`), and `model_note` says when a hand-over default was skipped or Harness's default changed since the last new hand-over. `team` (Harness 0.2.2-rc.2 or later): `true` turns Agent Teams on for the session before the message goes in, `false` turns them off; refused, with nothing sent, on an older Harness or on a sub-agent's session |
|
|
254
|
-
| `dsh_status` | Run progress: state, recent text and tool calls, final reply; `waiting_on` when the turn is over but sub-agents or jobs still run; `human_interjections` when someone typed in the Harness UI mid-run; state `interrupted` for a run cut short by a Harness restart; `model` the run was sent with. With `session_id` instead of `run_id`: what the session is doing, its Harness goal and its last turn's reply |
|
|
254
|
+
| `dsh_status` | Run progress: state, recent text and tool calls, final reply; `waiting_on` when the turn is over but sub-agents or jobs still run (sub-agents are waited for until they end; background jobs and reminders for at most 5 minutes after the turn, then the run completes with `left_running` naming what still runs); `human_interjections` when someone typed in the Harness UI mid-run; state `interrupted` for a run cut short by a Harness restart; `model` the run was sent with. With `session_id` instead of `run_id`: what the session is doing, its Harness goal and its last turn's reply |
|
|
255
255
|
| `dsh_wait` | Wait for the run to end; a finished run carries `evidence` (files changed, check results) when the message was sent with `checks` (or until it stops to ask a person, see `dsh_answer`): up to 3540 s per call for Codex (its tool timeout for dsh-baton less 60 s; 270 s when that is not set), 50 s for other clients. Still going: returns `timed_out` with just the state; call it again. Clients that can wait in the background use `dsh_send`'s `wait_command` instead; for a run a background `wait_command` already waits for, `dsh_wait` returns at once (`waiting_in_background`) rather than waiting a second time. `dsh_status` is a one-off look, not a way to wait. A run in a session with a Harness goal is waited for until the goal stops (`until` `turn` and `every_minutes` for progress reports). With `session_id` instead of `run_id` it follows the session's Harness goal without sending anything (`until`, `cursor`, `every_minutes`; see How each client waits). With `run_ids` it waits for several runs and returns as soon as any ends or asks (`ended`, `still_running`) |
|
|
256
256
|
| `dsh_answer` | Send your answer to the questions a run stopped to ask (Harness's ask_user_question): per question, an option number or label, free text, or skip; on a single choice, free text replaces the option. `dsh_wait` and `wait_command` return as soon as a run asks, with the questions (`needs_input`, `question`; the option Harness's model would pick is in `harness_suggested`); the main agent asks you and sends your answer. You can also answer in the Harness window: whoever answers first wins |
|
|
257
257
|
| `dsh_session_activity` | Codex: through `dsh_call`. What a session is doing now: running turn, sub-agents (any depth), background jobs; `archived: true` for an archived session |
|
package/README.zh-CN.md
CHANGED
|
@@ -251,7 +251,7 @@ Codex 占 ChatGPT Plus 5 小时额度的比例,以及主 Agent 自己的花费
|
|
|
251
251
|
| `dsh_list_models` | 列出 Harness 能用的模型(provider、id、名称、推理强度)和它的默认模型 |
|
|
252
252
|
| `dsh_read_session` | 读某个对话最近的消息和回复(含用到的工具名);已归档的对话会带 `archived: true` |
|
|
253
253
|
| `dsh_send` | 发消息。带 `session_id` 续接那个对话。不带时,如果当前对话在这个文件夹里已经有一个空闲的对话,就续接它,Harness 保留之前的上下文(结果里的 `continued_session` 会说明;`new_session` 为 `true` 时新开一个);正忙的对话不会被续接,所以并行发出的几部分仍各开一个对话。其余情况新开对话,建在 `cwd` 或 `workspace_id` 指定的位置,都不带时建在当前对话所在的文件夹(`cwd` 还不是工作区时会先登记;指定的 `cwd` 在当前对话文件夹之外也可以,结果里的 `folder_note` 会提醒)。`cwd` 在当前对话文件夹里面时,不再单独建工作区,而是进当前对话文件夹的工作区:对话开在那个文件夹,消息里写明要在哪个子文件夹工作(`work_folder`),`checks` 也在子文件夹里跑。客户端给每个对话单独建的文件夹各自共用一个工作区:Codex 没选项目的对话(Codex chats)、Claude 的 scratch 文件夹(Claude scratch)、Codex 的 worktree(Codex worktrees)、同一项目的 Claude worktree(Claude worktrees)。本来就是工作区的文件夹,或者 Git worktree,仍用它自己的工作区。`checks`:运行结束后 dsh-baton 自己跑的测试命令(见[转交之后怎么验收](#转交之后怎么验收))。立即返回 `run_id`。Harness 里这条消息会标注「由 Claude / ChatGPT 从另一个聊天发送」。已归档的对话会被拒绝:先在 Harness 里取消归档,或新开对话。对话正忙时,`mode` 为 `followup` 会排在当前回合之后,`steer` 会插进正在跑的回合;不传时跟随 Harness 自己的设置(设置 → 繁忙时的发送行为:排队发送或插话发送),读不到设置时按 `followup`。返回里的 `mode_source` 说明用的是哪种。`model` 只在用户点名模型时传(如“DeepSeek-V4 Pro”“v4-pro”;`reasoning_effort` 同理):按 Harness 自己的模型列表匹配,不分大小写,忽略空格、连字符和开头的 DeepSeek,所以 Harness 以后上线的模型(如 V4.1 Pro)一出现在列表里就能用;匹配不到或匹配到多个时,发送直接失败、什么都不创建,并列出可用模型(用 `provider/model` 指定其一)。模型在消息发出前设到该对话上,Harness 的默认模型会恢复原样(Harness 会把对话里选的模型同时存成默认)。不传时,续接的对话沿用它自己的模型,新对话用插件页的转交默认模型,没设就用 Harness 默认模型。返回值的 `model` 和 `model_source`(`requested`、`handover_default`、`default` 或 `session`)写明用的是哪个;转交默认模型用不上,或 Harness 的默认模型和上一次新开转交时不一样时,`model_note` 会说明。`team`(需要 Harness 0.2.2-rc.2 及以上):`true` 在消息发出前为该对话打开智能体团队协作,`false` 关闭;Harness 版本太旧或传的是子智能体的对话时,直接拒绝、什么都不发 |
|
|
254
|
-
| `dsh_status` | 查看运行进度:状态、最近的文字和工具调用、最终回复;回合结束但子智能体/后台任务还在跑时给出 `waiting_on
|
|
254
|
+
| `dsh_status` | 查看运行进度:状态、最近的文字和工具调用、最终回复;回合结束但子智能体/后台任务还在跑时给出 `waiting_on`(子智能体会一直等到结束;后台任务和提醒在回合结束后最多再等 5 分钟,之后运行算完成,并用 `left_running` 列出还在跑的任务);中途有人在 Harness 界面里发消息时给出 `human_interjections`;被 Harness 重启打断的任务状态为 `interrupted`;以及这次运行发送时用的 `model`。用 `session_id` 代替 `run_id` 时:会话正在做什么、它的 Harness 目标,以及上一回合的回复 |
|
|
255
255
|
| `dsh_wait` | 等运行结束;发消息时带了 `checks` 的,结束后会附上 `evidence`(改了哪些文件、测试结果)(或者等到它停下来问人,见 `dsh_answer`):Codex 每次最多等 3540 秒(它对 dsh-baton 的工具超时减 60 秒;没设时 270 秒),其他客户端 50 秒。没做完会带 `timed_out`,只返回状态,再调用一次即可。能在后台等待的客户端改用 `dsh_send` 返回的 `wait_command`;某个任务已经有后台 `wait_command` 在等时,`dsh_wait` 会立即返回(`waiting_in_background`),不再重复等待。`dsh_status` 只用来看一眼,不用来等待。发到带 Harness 目标的会话的任务会一直等到目标停下(要汇报进度时用 `until` 为 `turn` 和 `every_minutes`)。用 `session_id` 代替 `run_id` 时,不发任何消息,跟进这个会话的 Harness 目标(`until`、`cursor`、`every_minutes`;见“各客户端怎么等待”)。用 `run_ids` 时同时等多个任务,任何一个做完或提问就返回(`ended`、`still_running`) |
|
|
256
256
|
| `dsh_answer` | 把你对运行中途提问的回答发回去(Harness 的 ask_user_question):每道题可以填选项编号或选项文字、自由填写,或者跳过;单选题填了文字就以文字为准。运行一提问,`dsh_wait` 和 `wait_command` 就立刻返回,带上题目(`needs_input`、`question`;Harness 模型推荐的选项在 `harness_suggested`),由主 Agent 问你并把你的回答发回去。你也可以直接在 Harness 窗口里回答,谁先答就算谁的 |
|
|
257
257
|
| `dsh_session_activity` | Codex 里经 `dsh_call` 调用。对话此刻在做什么:正在跑的回合、子智能体(任意层级)、后台任务;已归档的对话会带 `archived: true` |
|
package/host/lib/index.js
CHANGED
|
@@ -28,6 +28,10 @@ const ACTIVITY_MAX_ERRORS = 10
|
|
|
28
28
|
// A run taken up after a plugin reload whose message Harness had not admitted yet.
|
|
29
29
|
const TAKE_UP_RETRY_MS = 3000
|
|
30
30
|
const takeUpAdmitMs = () => Number(process.env.DSH_BATON_TAKE_UP_ADMIT_MS) || 5 * 60_000
|
|
31
|
+
// How long a run whose own turn ended waits for background jobs or reminders (not sub-agents,
|
|
32
|
+
// which are part of the task) before it completes anyway, saying what is left (left_running).
|
|
33
|
+
// A search over the whole home folder held a reply back for 15 minutes (Mac, 2026-11-22).
|
|
34
|
+
const jobWaitMs = () => Number(process.env.DSH_BATON_JOB_WAIT_MS) || 5 * 60_000
|
|
31
35
|
const MAX_REQUEST_BYTES = 4 * 1024 * 1024
|
|
32
36
|
const MAX_WAIT_S = 24 * 3600
|
|
33
37
|
const MAX_HUMAN_INPUTS = 10
|
|
@@ -257,6 +261,7 @@ export function apply(ctx) {
|
|
|
257
261
|
...(run.sender ? { sender: run.sender } : {}),
|
|
258
262
|
...(run.model ? { model: run.model } : {}),
|
|
259
263
|
...(run.waitingOn ? { waiting_on: run.waitingOn } : {}),
|
|
264
|
+
...(run.leftRunning ? { left_running: run.leftRunning } : {}),
|
|
260
265
|
...(run.supersededBy ? { superseded_by: run.supersededBy } : {}),
|
|
261
266
|
...(run.humanInputs?.length ? { human_interjections: run.humanInputs } : {}),
|
|
262
267
|
...(run.approvalsAllowed?.length ? { approvals_allowed: run.approvalsAllowed } : {}),
|
|
@@ -547,7 +552,12 @@ export function apply(ctx) {
|
|
|
547
552
|
// completed one ends it only once the session is quiet (no sub-agents or jobs
|
|
548
553
|
// left), because Harness wakes the agent again when those report back.
|
|
549
554
|
const reason = data.reason ?? null
|
|
550
|
-
for (const run of receivers) {
|
|
555
|
+
for (const run of receivers) {
|
|
556
|
+
// The reply of the run's own turn, kept apart from what later wake-up turns say.
|
|
557
|
+
if (!run.turnEnd && (!reason?.kind || reason.kind === 'completed')) run.turnText = run.finalText ?? null
|
|
558
|
+
run.turnEnd = reason
|
|
559
|
+
persist(run)
|
|
560
|
+
}
|
|
551
561
|
if (reason?.kind && reason.kind !== 'completed') for (const run of receivers) settle(run, 'failed')
|
|
552
562
|
else scheduleQuietCheck(session.id, 1000)
|
|
553
563
|
turns.delete(session.id)
|
|
@@ -597,8 +607,16 @@ export function apply(ctx) {
|
|
|
597
607
|
// Closed runs: the running turn belongs to a newer run, so only their
|
|
598
608
|
// background work (sub-agents, jobs, reminders) keeps them open.
|
|
599
609
|
const background = items.filter((g) => g.kind !== 'turn')
|
|
610
|
+
// Only jobs or reminders left, past the limit since the run's own turn ended: done anyway.
|
|
611
|
+
const outlasted = (run) => {
|
|
612
|
+
if (!background.length || items.some((g) => g.kind === 'turn' || g.kind === 'subagent')) { delete run.jobsSince; return false }
|
|
613
|
+
run.jobsSince ??= Date.now()
|
|
614
|
+
return Date.now() - run.jobsSince >= jobWaitMs()
|
|
615
|
+
}
|
|
600
616
|
for (const run of receivers.filter((r) => r.outputClosed)) {
|
|
601
|
-
|
|
617
|
+
noteWaited(run, background)
|
|
618
|
+
if (background.length === 0) finishQuiet(run)
|
|
619
|
+
else if (outlasted(run)) finishQuiet(run, { leftRunning: summary(background) })
|
|
602
620
|
else { run.waitingOn = summary(background); persist(run) }
|
|
603
621
|
}
|
|
604
622
|
// A run whose own turn has not ended (and that has not seen the agent idle) is not done yet.
|
|
@@ -615,14 +633,34 @@ export function apply(ctx) {
|
|
|
615
633
|
return
|
|
616
634
|
}
|
|
617
635
|
quietSinceBySession.delete(sessionId)
|
|
618
|
-
for (const run of open)
|
|
636
|
+
for (const run of open) finishQuiet(run)
|
|
619
637
|
return
|
|
620
638
|
}
|
|
621
639
|
quietSinceBySession.delete(sessionId)
|
|
622
|
-
for (const run of open) run
|
|
640
|
+
for (const run of open) noteWaited(run, items)
|
|
641
|
+
const late = open.filter((r) => r.turnEnd && outlasted(r))
|
|
642
|
+
for (const run of late) finishQuiet(run, { leftRunning: summary(background) })
|
|
643
|
+
for (const run of open.filter((r) => !late.includes(r))) run.waitingOn = items.length ? summary(items) : run.waitingOn
|
|
623
644
|
if (receiversFor(sessionId).length) scheduleQuietCheck(sessionId, 3000)
|
|
624
645
|
}
|
|
625
646
|
|
|
647
|
+
// The kinds of background work a run has waited for, to tell what its later turns are about.
|
|
648
|
+
function noteWaited(run, list) {
|
|
649
|
+
const kinds = list.map((g) => g.kind).filter((k) => k !== 'turn' && !(run.waitedKinds ?? []).includes(k))
|
|
650
|
+
if (kinds.length) run.waitedKinds = [...(run.waitedKinds ?? []), ...kinds]
|
|
651
|
+
}
|
|
652
|
+
// A run that waited for sub-agents ends with their summary turn as its reply. One that waited
|
|
653
|
+
// only for jobs or reminders keeps its own turn's reply, with what the later turns said after it:
|
|
654
|
+
// a turn woken by a job is about that job, and replacing the reply with it lost a whole
|
|
655
|
+
// review (Antigravity, 2026-11-22).
|
|
656
|
+
function finishQuiet(run, extra = {}) {
|
|
657
|
+
const reply = run.turnText
|
|
658
|
+
const later = run.finalText
|
|
659
|
+
const kinds = run.waitedKinds ?? []
|
|
660
|
+
const keep = reply && later && later !== reply && kinds.length && !kinds.includes('subagent')
|
|
661
|
+
settle(run, 'completed', { waitingOn: null, error: null, ...(keep ? { finalText: `${reply}\n\n${later}` } : {}), ...extra })
|
|
662
|
+
}
|
|
663
|
+
|
|
626
664
|
ctx.effect(() => () => { for (const t of quietTimers.values()) clearTimeout(t) }, 'dsh-baton-host quiet timers')
|
|
627
665
|
|
|
628
666
|
ctx.on('agent/status', guard('agent/status', ({ agent, status }) => {
|
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.19",
|
|
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.
|
|
27
|
+
"dsh-baton-mcp": "0.6.19"
|
|
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.
|
|
3
|
+
"version": "0.6.19",
|
|
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.19",
|
|
11
11
|
"packages": [
|
|
12
12
|
{
|
|
13
13
|
"registryType": "npm",
|
|
14
14
|
"identifier": "dsh-baton-mcp",
|
|
15
|
-
"version": "0.6.
|
|
15
|
+
"version": "0.6.19",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
}
|
package/src/cli.mjs
CHANGED
|
@@ -124,6 +124,8 @@ async function main() {
|
|
|
124
124
|
...(st.evidence ? { evidence: st.evidence } : {}),
|
|
125
125
|
// Approvals this plugin allowed during the run (the plugin page's default): the client says what was let through.
|
|
126
126
|
...(st.approvals_allowed?.length ? { approvals_allowed: st.approvals_allowed } : {}),
|
|
127
|
+
// Background work still running when the run completed past the host's limit: the hint names it.
|
|
128
|
+
...(st.left_running?.length ? { left_running: st.left_running } : {}),
|
|
127
129
|
...(st.state === 'completed' ? { hint: core.endedHint(st) } : {}),
|
|
128
130
|
// Stopped by the user, cancelled, or cut off by a Harness restart: say so, or the client
|
|
129
131
|
// takes it for a failure in the work and sends it again.
|
package/src/core.mjs
CHANGED
|
@@ -573,9 +573,11 @@ const APPROVALS_HINT = (list) => ` dsh-baton allowed ${list.length} approval(s)
|
|
|
573
573
|
const WORKTREE_HINT = (trees) => (trees.every((w) => w.changes_in === 'changes')
|
|
574
574
|
? ` The session works in a Git worktree (${trees.map((w) => `${w.path}${w.branch ? `, branch ${w.branch}` : ''}`).join('; ')}): evidence.changes and the checks are from that worktree. Merging that branch is the user's call.`
|
|
575
575
|
: ` The session worked in a new Git worktree (${trees.map((w) => `${w.path}${w.branch ? `, branch ${w.branch}` : ''}`).join('; ')}): its changes are in evidence.worktrees, not evidence.changes, and checks ran in the last one. Merging that branch is the user's call.${trees.some((w) => w.incomplete) ? ' git could not list every change in a worktree marked incomplete: a file missing from its list proves nothing.' : ''}`)
|
|
576
|
+
// A run that completed while a background job of its session still ran (past the host's limit).
|
|
577
|
+
const LEFT_RUNNING_HINT = (left) => ` The run completed while background work it started was still running (left_running: ${left.flatMap((g) => g.labels ?? []).slice(0, 3).join('; ')}): its output is not in final_text. Go on with the reply; only if the task needs that output, look at the session later with dsh_status session_id.`
|
|
576
578
|
export function endedHint(st) {
|
|
577
579
|
const checks = st?.evidence?.checks
|
|
578
|
-
const shared = (st?.evidence?.same_folder_runs?.length ? SHARED_HINT(st.evidence.same_folder_runs) : '') + (st?.evidence?.changes?.truncated ? TRUNCATED_HINT : '') + (st?.evidence?.worktrees?.length ? WORKTREE_HINT(st.evidence.worktrees) : '') + (st?.approvals_allowed?.length ? APPROVALS_HINT(st.approvals_allowed) : '')
|
|
580
|
+
const shared = (st?.left_running?.length ? LEFT_RUNNING_HINT(st.left_running) : '') + (st?.evidence?.same_folder_runs?.length ? SHARED_HINT(st.evidence.same_folder_runs) : '') + (st?.evidence?.changes?.truncated ? TRUNCATED_HINT : '') + (st?.evidence?.worktrees?.length ? WORKTREE_HINT(st.evidence.worktrees) : '') + (st?.approvals_allowed?.length ? APPROVALS_HINT(st.approvals_allowed) : '')
|
|
579
581
|
const hint = !checks?.length ? NO_CHECKS_HINT + shared : ENDED_HINT + (checks.some((c) => !c.passed && MISSING_TOOL.test(c.output_tail ?? '')) ? ENV_HINT : '') + shared
|
|
580
582
|
return st?.goal ? `${goalHint(st.goal, st.session_id)} ${hint}` : hint
|
|
581
583
|
}
|
package/src/evidence.mjs
CHANGED
|
@@ -17,6 +17,14 @@ const SKIP_FILES = new Set(['.DS_Store', 'Thumbs.db'])
|
|
|
17
17
|
const MAX_ENTRIES = 100_000
|
|
18
18
|
const MAX_READ = 3000
|
|
19
19
|
const MAX_TEXT = 512 * 1024
|
|
20
|
+
// Reading is also cut off by time: dsh_send waits for the snapshot, and a slow disk or network
|
|
21
|
+
// folder must not hold it up (the rest keep size and time only).
|
|
22
|
+
const READ_BUDGET_MS = 5000
|
|
23
|
+
// A file whose content is not on this disk: an iCloud Drive (or other cloud) placeholder, with a
|
|
24
|
+
// size but no blocks. Reading it downloads it first, seconds per file: a Desktop folder synced
|
|
25
|
+
// with iCloud held dsh_send for minutes (Mac, 2026-11-22) and pulled the files back down. Such a
|
|
26
|
+
// file is compared by size and time only. Windows reports no blocks, so it is never marked there.
|
|
27
|
+
const notOnDisk = (st) => process.platform !== 'win32' && st.size > 0 && st.blocks === 0
|
|
20
28
|
const CHECK_TIMEOUT_MS = 120_000
|
|
21
29
|
const CHECKS_TOTAL_MS = 180_000
|
|
22
30
|
const TAIL_LINES = 15
|
|
@@ -112,7 +120,7 @@ function walk(dir) {
|
|
|
112
120
|
if (!e.isFile() || SKIP_FILES.has(e.name)) continue
|
|
113
121
|
try {
|
|
114
122
|
const st = fs.statSync(abs)
|
|
115
|
-
out.push({ rel: path.relative(dir, abs).split(path.sep).join('/'), abs, m: st.mtimeMs, s: st.size })
|
|
123
|
+
out.push({ rel: path.relative(dir, abs).split(path.sep).join('/'), abs, m: st.mtimeMs, s: st.size, ...(notOnDisk(st) ? { cloud: true } : {}) })
|
|
116
124
|
} catch { /* gone or unreadable: left out */ }
|
|
117
125
|
}
|
|
118
126
|
}
|
|
@@ -139,7 +147,11 @@ function snapshot(dir) {
|
|
|
139
147
|
const { list, truncated } = walk(dir)
|
|
140
148
|
const files = {}
|
|
141
149
|
for (const f of list) files[f.rel] = { m: f.m, s: f.s }
|
|
142
|
-
|
|
150
|
+
const deadline = Date.now() + READ_BUDGET_MS
|
|
151
|
+
for (const f of [...list].filter((x) => !x.cloud).sort((a, b) => b.m - a.m).slice(0, MAX_READ)) {
|
|
152
|
+
if (Date.now() > deadline) break
|
|
153
|
+
Object.assign(files[f.rel], readFile(f.abs, f.s) ?? {})
|
|
154
|
+
}
|
|
143
155
|
return { files, truncated }
|
|
144
156
|
}
|
|
145
157
|
|
|
@@ -239,7 +251,8 @@ export function collect(home, runId) {
|
|
|
239
251
|
// At most MAX_READ files are read here too (a run that writes thousands of files gets their
|
|
240
252
|
// paths, not their line counts).
|
|
241
253
|
let reads = 0
|
|
242
|
-
const
|
|
254
|
+
const readUntil = Date.now() + READ_BUDGET_MS
|
|
255
|
+
const read = (f, whole = false) => (!f.cloud && reads++ < MAX_READ && Date.now() <= readUntil ? readFile(f.abs, whole ? 0 : f.s) : null)
|
|
243
256
|
for (const f of after.list) {
|
|
244
257
|
seen.add(f.rel)
|
|
245
258
|
const b = before[f.rel]
|