dsh-baton-host 0.6.14 → 0.6.15
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 +5 -23
- package/docs/DETAIL.md +1 -0
- package/docs/DETAIL.zh.md +1 -0
- package/docs/preview.svg +31 -0
- package/docs/preview.zh.svg +31 -0
- package/icon.svg +27 -0
- package/lib/client.js +271 -8
- package/lib/index.js +481 -19
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -1,29 +1,11 @@
|
|
|
1
1
|
# dsh-baton-host
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**English** · [中文](#中文)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Install / 安装
|
|
8
|
-
|
|
9
|
-
**Install / 安装**: Plugins / 插件 → Add plugin / 添加插件 → `dsh-baton-host` → Install / 安装 → Enable now / 立即启用. That registers dsh-baton for Claude Code, Codex and Antigravity. / 启用后会为 Claude Code、Codex 和 Antigravity 注册 dsh-baton。
|
|
10
|
-
|
|
11
|
-
**Check / 验证**:
|
|
12
|
-
1. Open a new chat in Claude Code or Codex (restart Antigravity once); Codex asks once to approve the dsh-baton tools. / 在 Claude Code 或 Codex 里新开对话(Antigravity 要重启一次),Codex 第一次会请你批准 dsh-baton 的工具。
|
|
13
|
-
2. Ask it to call `dsh_list_workspaces`; it lists your Harness workspaces. / 让它调用 `dsh_list_workspaces`,会列出你的 Harness 工作区。
|
|
14
|
-
|
|
15
|
-
Not registered? / 没能注册?Run `npx -y dsh-baton-mcp setup`.
|
|
16
|
-
|
|
17
|
-
## Update / 更新
|
|
18
|
-
|
|
19
|
-
Version → **Update to x.y.z** (press **Recheck** first if it says up to date). On Harness 0.2.1: uninstall, then add `dsh-baton-host@x.y.z`.
|
|
20
|
-
|
|
21
|
-
版本一栏 → **更新到 x.y.z**(显示已是最新时先点 **重新检查**)。Harness 0.2.1:先卸载,再添加 `dsh-baton-host@x.y.z`。
|
|
22
|
-
|
|
23
|
-
## Remove / 卸载
|
|
24
|
-
|
|
25
|
-
Uninstall, then run `npx -y dsh-baton-mcp setup --remove`. / 卸载插件后运行 `npx -y dsh-baton-mcp setup --remove`。
|
|
5
|
+
Claude Code, Codex and Antigravity hand coding tasks to DeepSeek Harness here. Each runs live in this window and comes back with the changed files and test results. Below you can choose the default model for hand-overs, and how approvals in hand-over sessions are answered. [Full guide](https://github.com/JialaoLiu/dsh-baton#readme)
|
|
26
6
|
|
|
27
7
|
---
|
|
28
8
|
|
|
29
|
-
|
|
9
|
+
## 中文
|
|
10
|
+
|
|
11
|
+
Claude Code、Codex 和 Antigravity 在这里把编码任务交给 DeepSeek Harness,任务在这个窗口里实时跑,做完带着改动文件和测试结果交回。下面可以设转交默认模型,以及转交会话里的审批怎么处理。[完整说明](https://github.com/JialaoLiu/dsh-baton/blob/main/README.zh-CN.md)
|
package/docs/DETAIL.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+

|
|
@@ -0,0 +1 @@
|
|
|
1
|
+

|
package/docs/preview.svg
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="640" height="300" viewBox="0 0 640 300">
|
|
2
|
+
<rect width="640" height="300" rx="12" fill="#F5F6FC"/>
|
|
3
|
+
<text x="32" y="52" font-family=""Songti SC", "Noto Serif SC", "Source Han Serif SC", "SimSun", Georgia, serif" font-size="25" font-weight="400" fill="#253047">Hand tasks to DeepSeek Harness</text>
|
|
4
|
+
<text x="32" y="80" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="12.5" font-weight="400" fill="#66738B">From Claude Code, Codex or Antigravity · runs live here · comes back checked</text>
|
|
5
|
+
<rect x="32" y="100" width="206" height="168" rx="12" fill="#FFFFFF" stroke="#DFE4EF"/>
|
|
6
|
+
<text x="48" y="126" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="11.5" font-weight="400" fill="#7A859E">Your conversation</text>
|
|
7
|
+
<rect x="48" y="140" width="174" height="30" rx="8" fill="#EEF1FF"/>
|
|
8
|
+
<svg x="58" y="147" width="16" height="16" viewBox="0 0 248 248"><path d="M52.4285 162.873L98.7844 136.879L99.5485 134.602L98.7844 133.334H96.4921L88.7237 132.862L62.2346 132.153L39.3113 131.207L17.0249 130.026L11.4214 128.844L6.2 121.873L6.7094 118.447L11.4214 115.257L18.171 115.847L33.0711 116.911L55.485 118.447L71.6586 119.392L95.728 121.873H99.5485L100.058 120.337L98.7844 119.392L97.7656 118.447L74.5877 102.732L49.4995 86.1905L36.3823 76.62L29.3779 71.7757L25.8121 67.2858L24.2839 57.3608L30.6515 50.2716L39.3113 50.8623L41.4763 51.4531L50.2636 58.1879L68.9842 72.7209L93.4357 90.6804L97.0015 93.6343L98.4374 92.6652L98.6571 91.9801L97.0015 89.2625L83.757 65.2772L69.621 40.8192L63.2534 30.6579L61.5978 24.632C60.9565 22.1032 60.579 20.0111 60.579 17.4246L67.8381 7.49965L71.9133 6.19995L81.7193 7.49965L85.7946 11.0443L91.9074 24.9865L101.714 46.8451L116.996 76.62L121.453 85.4816L123.873 93.6343L124.764 96.1155H126.292V94.6976L127.566 77.9197L129.858 57.3608L132.15 30.8942L132.915 23.4505L136.608 14.4708L143.994 9.62643L149.725 12.344L154.437 19.0788L153.8 23.4505L150.998 41.6463L145.522 70.1215L141.957 89.2625H143.994L146.414 86.7813L156.093 74.0206L172.266 53.698L179.398 45.6635L187.803 36.802L193.152 32.5484H203.34L210.726 43.6549L207.415 55.1159L196.972 68.3492L188.312 79.5739L175.896 96.2095L168.191 109.585L168.882 110.689L170.738 110.53L198.755 104.504L213.91 101.787L231.994 98.7149L240.144 102.496L241.036 106.395L237.852 114.311L218.495 119.037L195.826 123.645L162.07 131.592L161.696 131.893L162.137 132.547L177.36 133.925L183.855 134.279H199.774L229.447 136.524L237.215 141.605L241.8 147.867L241.036 152.711L229.065 158.737L213.019 154.956L175.45 145.977L162.587 142.787H160.805V143.85L171.502 154.366L191.242 172.089L215.82 195.011L217.094 200.682L213.91 205.172L210.599 204.699L188.949 188.394L180.544 181.069L161.696 165.118H160.422V166.772L164.752 173.152L187.803 207.771L188.949 218.405L187.294 221.832L181.308 223.959L174.813 222.777L161.187 203.754L147.305 182.486L136.098 163.345L134.745 164.2L128.075 235.42L125.019 239.082L117.887 241.8L111.902 237.31L108.718 229.984L111.902 215.452L115.722 196.547L118.779 181.541L121.58 162.873L123.291 156.636L123.14 156.219L121.773 156.449L107.699 175.752L86.304 204.699L69.3663 222.777L65.291 224.431L58.2867 220.768L58.9235 214.27L62.8713 208.48L86.304 178.705L100.44 160.155L109.551 149.507L109.462 147.967L108.959 147.924L46.6977 188.512L35.6182 189.93L30.7788 185.44L31.4156 178.115L33.7079 175.752L52.4285 162.873Z" fill="#4655B3"/></svg>
|
|
9
|
+
<text x="84" y="160" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="13" font-weight="600" fill="#4655B3">Claude Code</text>
|
|
10
|
+
<rect x="48" y="178" width="174" height="30" rx="8" fill="#F3F5FA"/>
|
|
11
|
+
<svg x="58" y="185" width="16" height="16" viewBox="0 0 24 24"><path d="M9.20509 8.76514V6.50548C9.20509 6.31517 9.27649 6.17237 9.44293 6.07733L13.9861 3.46091C14.6046 3.10416 15.342 2.93772 16.103 2.93772C18.9573 2.93772 20.7651 5.14986 20.7651 7.50457C20.7651 7.67101 20.7651 7.86132 20.7412 8.05164L16.0316 5.29243C15.7462 5.12599 15.4607 5.12599 15.1753 5.29243L9.20509 8.76514ZM19.8136 17.566V12.1665C19.8136 11.8334 19.6708 11.5955 19.3854 11.4291L13.4152 7.95637L15.3656 6.83836C15.5321 6.74332 15.6749 6.74332 15.8413 6.83836L20.3845 9.45477C21.6928 10.216 22.5728 11.8334 22.5728 13.4032C22.5728 15.2108 21.5025 16.8759 19.8136 17.5657V17.566ZM7.80173 12.8088L5.8513 11.6671C5.68486 11.5721 5.61346 11.4293 5.61346 11.239V6.00616C5.61346 3.46114 7.56389 1.53436 10.2042 1.53436C11.2033 1.53436 12.1307 1.86746 12.9159 2.46205L8.2301 5.17374C7.94475 5.34018 7.80196 5.57801 7.80196 5.91112V12.809L7.80173 12.8088ZM12 15.2349L9.20509 13.6651V10.3352L12 8.76537L14.7947 10.3352V13.6651L12 15.2349ZM13.7958 22.4659C12.7967 22.4659 11.8693 22.1328 11.0841 21.5382L15.7699 18.8265C16.0553 18.6601 16.198 18.4223 16.198 18.0892V11.1912L18.1723 12.3329C18.3388 12.4279 18.4102 12.5707 18.4102 12.7611V17.9939C18.4102 20.5389 16.4359 22.4657 13.7958 22.4657V22.4659ZM8.15848 17.1617L3.61528 14.5453C2.30696 13.784 1.42701 12.1667 1.42701 10.5969C1.42701 8.76537 2.52115 7.12417 4.20987 6.43431V11.8575C4.20987 12.1906 4.35266 12.4284 4.63802 12.5948L10.5846 16.0437L8.63415 17.1617C8.46771 17.2567 8.32492 17.2567 8.15848 17.1617ZM7.897 21.0626C5.20919 21.0626 3.23488 19.0407 3.23488 16.5432C3.23488 16.3529 3.25875 16.1626 3.2824 15.9723L7.96817 18.684C8.25352 18.8504 8.53911 18.8504 8.82447 18.684L14.7947 15.2351V17.4948C14.7947 17.6851 14.7233 17.8279 14.5568 17.9229L10.0136 20.5394C9.39518 20.8961 8.6578 21.0626 7.89677 21.0626H7.897ZM13.7958 23.8929C16.6739 23.8929 19.0762 21.8475 19.6235 19.1358C22.2874 18.4459 24 15.9484 24 13.4034C24 11.7383 23.2865 10.121 22.002 8.95546C22.121 8.45591 22.1924 7.95637 22.1924 7.45705C22.1924 4.05573 19.4331 1.51048 16.2458 1.51048C15.6037 1.51048 14.9852 1.60553 14.3668 1.81971C13.2963 0.773101 11.8215 0.107117 10.2042 0.107117C7.32606 0.107117 4.92383 2.15259 4.37653 4.86428C1.7126 5.55414 0 8.05164 0 10.5967C0 12.2617 0.713506 13.8791 1.99795 15.0446C1.87904 15.5441 1.80764 16.0437 1.80764 16.543C1.80764 19.9443 4.56685 22.4896 7.75421 22.4896C8.39632 22.4896 9.01478 22.3945 9.63324 22.1803C10.7035 23.2269 12.1783 23.8929 13.7958 23.8929Z" fill="#253047"/></svg>
|
|
12
|
+
<text x="84" y="198" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="13" font-weight="500" fill="#253047">Codex</text>
|
|
13
|
+
<rect x="48" y="216" width="174" height="30" rx="8" fill="#F3F5FA"/>
|
|
14
|
+
<svg x="58" y="223" width="16" height="16" viewBox="0 0 24 24"><path d="M21.751 22.607c1.34 1.005 3.35.335 1.508-1.508C17.73 15.74 18.904 1 12.037 1 5.17 1 6.342 15.74.815 21.1c-2.01 2.009.167 2.511 1.507 1.506 5.192-3.517 4.857-9.714 9.715-9.714 4.857 0 4.522 6.197 9.714 9.715z" fill="#253047"/></svg>
|
|
15
|
+
<text x="84" y="236" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="13" font-weight="500" fill="#253047">Antigravity</text>
|
|
16
|
+
<path d="M244 184 H 260" stroke="#9CA9CC" stroke-width="1.5" fill="none"/>
|
|
17
|
+
<path d="M255 179 L 261 184 L 255 189" stroke="#9CA9CC" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
18
|
+
<rect x="266" y="100" width="342" height="168" rx="12" fill="#FFFFFF" stroke="#DFE4EF"/>
|
|
19
|
+
<svg x="284" y="116" width="12" height="12" viewBox="0 0 248 248"><path d="M52.4285 162.873L98.7844 136.879L99.5485 134.602L98.7844 133.334H96.4921L88.7237 132.862L62.2346 132.153L39.3113 131.207L17.0249 130.026L11.4214 128.844L6.2 121.873L6.7094 118.447L11.4214 115.257L18.171 115.847L33.0711 116.911L55.485 118.447L71.6586 119.392L95.728 121.873H99.5485L100.058 120.337L98.7844 119.392L97.7656 118.447L74.5877 102.732L49.4995 86.1905L36.3823 76.62L29.3779 71.7757L25.8121 67.2858L24.2839 57.3608L30.6515 50.2716L39.3113 50.8623L41.4763 51.4531L50.2636 58.1879L68.9842 72.7209L93.4357 90.6804L97.0015 93.6343L98.4374 92.6652L98.6571 91.9801L97.0015 89.2625L83.757 65.2772L69.621 40.8192L63.2534 30.6579L61.5978 24.632C60.9565 22.1032 60.579 20.0111 60.579 17.4246L67.8381 7.49965L71.9133 6.19995L81.7193 7.49965L85.7946 11.0443L91.9074 24.9865L101.714 46.8451L116.996 76.62L121.453 85.4816L123.873 93.6343L124.764 96.1155H126.292V94.6976L127.566 77.9197L129.858 57.3608L132.15 30.8942L132.915 23.4505L136.608 14.4708L143.994 9.62643L149.725 12.344L154.437 19.0788L153.8 23.4505L150.998 41.6463L145.522 70.1215L141.957 89.2625H143.994L146.414 86.7813L156.093 74.0206L172.266 53.698L179.398 45.6635L187.803 36.802L193.152 32.5484H203.34L210.726 43.6549L207.415 55.1159L196.972 68.3492L188.312 79.5739L175.896 96.2095L168.191 109.585L168.882 110.689L170.738 110.53L198.755 104.504L213.91 101.787L231.994 98.7149L240.144 102.496L241.036 106.395L237.852 114.311L218.495 119.037L195.826 123.645L162.07 131.592L161.696 131.893L162.137 132.547L177.36 133.925L183.855 134.279H199.774L229.447 136.524L237.215 141.605L241.8 147.867L241.036 152.711L229.065 158.737L213.019 154.956L175.45 145.977L162.587 142.787H160.805V143.85L171.502 154.366L191.242 172.089L215.82 195.011L217.094 200.682L213.91 205.172L210.599 204.699L188.949 188.394L180.544 181.069L161.696 165.118H160.422V166.772L164.752 173.152L187.803 207.771L188.949 218.405L187.294 221.832L181.308 223.959L174.813 222.777L161.187 203.754L147.305 182.486L136.098 163.345L134.745 164.2L128.075 235.42L125.019 239.082L117.887 241.8L111.902 237.31L108.718 229.984L111.902 215.452L115.722 196.547L118.779 181.541L121.58 162.873L123.291 156.636L123.14 156.219L121.773 156.449L107.699 175.752L86.304 204.699L69.3663 222.777L65.291 224.431L58.2867 220.768L58.9235 214.27L62.8713 208.48L86.304 178.705L100.44 160.155L109.551 149.507L109.462 147.967L108.959 147.924L46.6977 188.512L35.6182 189.93L30.7788 185.44L31.4156 178.115L33.7079 175.752L52.4285 162.873Z" fill="#7A859E"/></svg>
|
|
20
|
+
<text x="302" y="126" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="11.5" font-weight="400" fill="#7A859E">Sent by Claude from another chat</text>
|
|
21
|
+
<text x="284" y="154" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="15" font-weight="600" fill="#253047">Fix the login retry</text>
|
|
22
|
+
<circle cx="290" cy="174" r="3.5" fill="#428466"/>
|
|
23
|
+
<text x="300" y="178" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="12" font-weight="400" fill="#397359">Done</text>
|
|
24
|
+
<text x="400" y="178" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="12" font-weight="400" fill="#515F7B">3 files changed</text>
|
|
25
|
+
<line x1="278" y1="192" x2="596" y2="192" stroke="#E6EAF2"/>
|
|
26
|
+
<rect x="278" y="202" width="318" height="26" rx="6" fill="#EAF5EF"/>
|
|
27
|
+
<path d="M290 215 l3.5 3.5 l6.5 -7" stroke="#428466" stroke-width="1.6" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
28
|
+
<text x="308" y="219" font-family="ui-monospace, Menlo, Consolas, monospace" font-size="12" font-weight="400" fill="#253047">npm test</text>
|
|
29
|
+
<text x="586" y="219" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="12" font-weight="400" fill="#397359" text-anchor="end">passed</text>
|
|
30
|
+
<text x="284" y="252" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="11.5" font-weight="400" fill="#66738B">Reply, files and test results go back to Claude Code</text>
|
|
31
|
+
</svg>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="640" height="300" viewBox="0 0 640 300">
|
|
2
|
+
<rect width="640" height="300" rx="12" fill="#F5F6FC"/>
|
|
3
|
+
<text x="32" y="52" font-family=""Songti SC", "Noto Serif SC", "Source Han Serif SC", "SimSun", Georgia, serif" font-size="25" font-weight="400" fill="#253047">把编码任务交给 DeepSeek Harness</text>
|
|
4
|
+
<text x="32" y="80" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="12.5" font-weight="400" fill="#66738B">从 Claude Code、Codex、Antigravity 转交 · 在这里实时跑 · 带着结果交回</text>
|
|
5
|
+
<rect x="32" y="100" width="206" height="168" rx="12" fill="#FFFFFF" stroke="#DFE4EF"/>
|
|
6
|
+
<text x="48" y="126" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="11.5" font-weight="400" fill="#7A859E">你的对话</text>
|
|
7
|
+
<rect x="48" y="140" width="174" height="30" rx="8" fill="#EEF1FF"/>
|
|
8
|
+
<svg x="58" y="147" width="16" height="16" viewBox="0 0 248 248"><path d="M52.4285 162.873L98.7844 136.879L99.5485 134.602L98.7844 133.334H96.4921L88.7237 132.862L62.2346 132.153L39.3113 131.207L17.0249 130.026L11.4214 128.844L6.2 121.873L6.7094 118.447L11.4214 115.257L18.171 115.847L33.0711 116.911L55.485 118.447L71.6586 119.392L95.728 121.873H99.5485L100.058 120.337L98.7844 119.392L97.7656 118.447L74.5877 102.732L49.4995 86.1905L36.3823 76.62L29.3779 71.7757L25.8121 67.2858L24.2839 57.3608L30.6515 50.2716L39.3113 50.8623L41.4763 51.4531L50.2636 58.1879L68.9842 72.7209L93.4357 90.6804L97.0015 93.6343L98.4374 92.6652L98.6571 91.9801L97.0015 89.2625L83.757 65.2772L69.621 40.8192L63.2534 30.6579L61.5978 24.632C60.9565 22.1032 60.579 20.0111 60.579 17.4246L67.8381 7.49965L71.9133 6.19995L81.7193 7.49965L85.7946 11.0443L91.9074 24.9865L101.714 46.8451L116.996 76.62L121.453 85.4816L123.873 93.6343L124.764 96.1155H126.292V94.6976L127.566 77.9197L129.858 57.3608L132.15 30.8942L132.915 23.4505L136.608 14.4708L143.994 9.62643L149.725 12.344L154.437 19.0788L153.8 23.4505L150.998 41.6463L145.522 70.1215L141.957 89.2625H143.994L146.414 86.7813L156.093 74.0206L172.266 53.698L179.398 45.6635L187.803 36.802L193.152 32.5484H203.34L210.726 43.6549L207.415 55.1159L196.972 68.3492L188.312 79.5739L175.896 96.2095L168.191 109.585L168.882 110.689L170.738 110.53L198.755 104.504L213.91 101.787L231.994 98.7149L240.144 102.496L241.036 106.395L237.852 114.311L218.495 119.037L195.826 123.645L162.07 131.592L161.696 131.893L162.137 132.547L177.36 133.925L183.855 134.279H199.774L229.447 136.524L237.215 141.605L241.8 147.867L241.036 152.711L229.065 158.737L213.019 154.956L175.45 145.977L162.587 142.787H160.805V143.85L171.502 154.366L191.242 172.089L215.82 195.011L217.094 200.682L213.91 205.172L210.599 204.699L188.949 188.394L180.544 181.069L161.696 165.118H160.422V166.772L164.752 173.152L187.803 207.771L188.949 218.405L187.294 221.832L181.308 223.959L174.813 222.777L161.187 203.754L147.305 182.486L136.098 163.345L134.745 164.2L128.075 235.42L125.019 239.082L117.887 241.8L111.902 237.31L108.718 229.984L111.902 215.452L115.722 196.547L118.779 181.541L121.58 162.873L123.291 156.636L123.14 156.219L121.773 156.449L107.699 175.752L86.304 204.699L69.3663 222.777L65.291 224.431L58.2867 220.768L58.9235 214.27L62.8713 208.48L86.304 178.705L100.44 160.155L109.551 149.507L109.462 147.967L108.959 147.924L46.6977 188.512L35.6182 189.93L30.7788 185.44L31.4156 178.115L33.7079 175.752L52.4285 162.873Z" fill="#4655B3"/></svg>
|
|
9
|
+
<text x="84" y="160" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="13" font-weight="600" fill="#4655B3">Claude Code</text>
|
|
10
|
+
<rect x="48" y="178" width="174" height="30" rx="8" fill="#F3F5FA"/>
|
|
11
|
+
<svg x="58" y="185" width="16" height="16" viewBox="0 0 24 24"><path d="M9.20509 8.76514V6.50548C9.20509 6.31517 9.27649 6.17237 9.44293 6.07733L13.9861 3.46091C14.6046 3.10416 15.342 2.93772 16.103 2.93772C18.9573 2.93772 20.7651 5.14986 20.7651 7.50457C20.7651 7.67101 20.7651 7.86132 20.7412 8.05164L16.0316 5.29243C15.7462 5.12599 15.4607 5.12599 15.1753 5.29243L9.20509 8.76514ZM19.8136 17.566V12.1665C19.8136 11.8334 19.6708 11.5955 19.3854 11.4291L13.4152 7.95637L15.3656 6.83836C15.5321 6.74332 15.6749 6.74332 15.8413 6.83836L20.3845 9.45477C21.6928 10.216 22.5728 11.8334 22.5728 13.4032C22.5728 15.2108 21.5025 16.8759 19.8136 17.5657V17.566ZM7.80173 12.8088L5.8513 11.6671C5.68486 11.5721 5.61346 11.4293 5.61346 11.239V6.00616C5.61346 3.46114 7.56389 1.53436 10.2042 1.53436C11.2033 1.53436 12.1307 1.86746 12.9159 2.46205L8.2301 5.17374C7.94475 5.34018 7.80196 5.57801 7.80196 5.91112V12.809L7.80173 12.8088ZM12 15.2349L9.20509 13.6651V10.3352L12 8.76537L14.7947 10.3352V13.6651L12 15.2349ZM13.7958 22.4659C12.7967 22.4659 11.8693 22.1328 11.0841 21.5382L15.7699 18.8265C16.0553 18.6601 16.198 18.4223 16.198 18.0892V11.1912L18.1723 12.3329C18.3388 12.4279 18.4102 12.5707 18.4102 12.7611V17.9939C18.4102 20.5389 16.4359 22.4657 13.7958 22.4657V22.4659ZM8.15848 17.1617L3.61528 14.5453C2.30696 13.784 1.42701 12.1667 1.42701 10.5969C1.42701 8.76537 2.52115 7.12417 4.20987 6.43431V11.8575C4.20987 12.1906 4.35266 12.4284 4.63802 12.5948L10.5846 16.0437L8.63415 17.1617C8.46771 17.2567 8.32492 17.2567 8.15848 17.1617ZM7.897 21.0626C5.20919 21.0626 3.23488 19.0407 3.23488 16.5432C3.23488 16.3529 3.25875 16.1626 3.2824 15.9723L7.96817 18.684C8.25352 18.8504 8.53911 18.8504 8.82447 18.684L14.7947 15.2351V17.4948C14.7947 17.6851 14.7233 17.8279 14.5568 17.9229L10.0136 20.5394C9.39518 20.8961 8.6578 21.0626 7.89677 21.0626H7.897ZM13.7958 23.8929C16.6739 23.8929 19.0762 21.8475 19.6235 19.1358C22.2874 18.4459 24 15.9484 24 13.4034C24 11.7383 23.2865 10.121 22.002 8.95546C22.121 8.45591 22.1924 7.95637 22.1924 7.45705C22.1924 4.05573 19.4331 1.51048 16.2458 1.51048C15.6037 1.51048 14.9852 1.60553 14.3668 1.81971C13.2963 0.773101 11.8215 0.107117 10.2042 0.107117C7.32606 0.107117 4.92383 2.15259 4.37653 4.86428C1.7126 5.55414 0 8.05164 0 10.5967C0 12.2617 0.713506 13.8791 1.99795 15.0446C1.87904 15.5441 1.80764 16.0437 1.80764 16.543C1.80764 19.9443 4.56685 22.4896 7.75421 22.4896C8.39632 22.4896 9.01478 22.3945 9.63324 22.1803C10.7035 23.2269 12.1783 23.8929 13.7958 23.8929Z" fill="#253047"/></svg>
|
|
12
|
+
<text x="84" y="198" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="13" font-weight="500" fill="#253047">Codex</text>
|
|
13
|
+
<rect x="48" y="216" width="174" height="30" rx="8" fill="#F3F5FA"/>
|
|
14
|
+
<svg x="58" y="223" width="16" height="16" viewBox="0 0 24 24"><path d="M21.751 22.607c1.34 1.005 3.35.335 1.508-1.508C17.73 15.74 18.904 1 12.037 1 5.17 1 6.342 15.74.815 21.1c-2.01 2.009.167 2.511 1.507 1.506 5.192-3.517 4.857-9.714 9.715-9.714 4.857 0 4.522 6.197 9.714 9.715z" fill="#253047"/></svg>
|
|
15
|
+
<text x="84" y="236" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="13" font-weight="500" fill="#253047">Antigravity</text>
|
|
16
|
+
<path d="M244 184 H 260" stroke="#9CA9CC" stroke-width="1.5" fill="none"/>
|
|
17
|
+
<path d="M255 179 L 261 184 L 255 189" stroke="#9CA9CC" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
18
|
+
<rect x="266" y="100" width="342" height="168" rx="12" fill="#FFFFFF" stroke="#DFE4EF"/>
|
|
19
|
+
<svg x="284" y="116" width="12" height="12" viewBox="0 0 248 248"><path d="M52.4285 162.873L98.7844 136.879L99.5485 134.602L98.7844 133.334H96.4921L88.7237 132.862L62.2346 132.153L39.3113 131.207L17.0249 130.026L11.4214 128.844L6.2 121.873L6.7094 118.447L11.4214 115.257L18.171 115.847L33.0711 116.911L55.485 118.447L71.6586 119.392L95.728 121.873H99.5485L100.058 120.337L98.7844 119.392L97.7656 118.447L74.5877 102.732L49.4995 86.1905L36.3823 76.62L29.3779 71.7757L25.8121 67.2858L24.2839 57.3608L30.6515 50.2716L39.3113 50.8623L41.4763 51.4531L50.2636 58.1879L68.9842 72.7209L93.4357 90.6804L97.0015 93.6343L98.4374 92.6652L98.6571 91.9801L97.0015 89.2625L83.757 65.2772L69.621 40.8192L63.2534 30.6579L61.5978 24.632C60.9565 22.1032 60.579 20.0111 60.579 17.4246L67.8381 7.49965L71.9133 6.19995L81.7193 7.49965L85.7946 11.0443L91.9074 24.9865L101.714 46.8451L116.996 76.62L121.453 85.4816L123.873 93.6343L124.764 96.1155H126.292V94.6976L127.566 77.9197L129.858 57.3608L132.15 30.8942L132.915 23.4505L136.608 14.4708L143.994 9.62643L149.725 12.344L154.437 19.0788L153.8 23.4505L150.998 41.6463L145.522 70.1215L141.957 89.2625H143.994L146.414 86.7813L156.093 74.0206L172.266 53.698L179.398 45.6635L187.803 36.802L193.152 32.5484H203.34L210.726 43.6549L207.415 55.1159L196.972 68.3492L188.312 79.5739L175.896 96.2095L168.191 109.585L168.882 110.689L170.738 110.53L198.755 104.504L213.91 101.787L231.994 98.7149L240.144 102.496L241.036 106.395L237.852 114.311L218.495 119.037L195.826 123.645L162.07 131.592L161.696 131.893L162.137 132.547L177.36 133.925L183.855 134.279H199.774L229.447 136.524L237.215 141.605L241.8 147.867L241.036 152.711L229.065 158.737L213.019 154.956L175.45 145.977L162.587 142.787H160.805V143.85L171.502 154.366L191.242 172.089L215.82 195.011L217.094 200.682L213.91 205.172L210.599 204.699L188.949 188.394L180.544 181.069L161.696 165.118H160.422V166.772L164.752 173.152L187.803 207.771L188.949 218.405L187.294 221.832L181.308 223.959L174.813 222.777L161.187 203.754L147.305 182.486L136.098 163.345L134.745 164.2L128.075 235.42L125.019 239.082L117.887 241.8L111.902 237.31L108.718 229.984L111.902 215.452L115.722 196.547L118.779 181.541L121.58 162.873L123.291 156.636L123.14 156.219L121.773 156.449L107.699 175.752L86.304 204.699L69.3663 222.777L65.291 224.431L58.2867 220.768L58.9235 214.27L62.8713 208.48L86.304 178.705L100.44 160.155L109.551 149.507L109.462 147.967L108.959 147.924L46.6977 188.512L35.6182 189.93L30.7788 185.44L31.4156 178.115L33.7079 175.752L52.4285 162.873Z" fill="#7A859E"/></svg>
|
|
20
|
+
<text x="302" y="126" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="11.5" font-weight="400" fill="#7A859E">由 Claude 从另一个聊天发送</text>
|
|
21
|
+
<text x="284" y="154" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="15" font-weight="600" fill="#253047">修复登录重试</text>
|
|
22
|
+
<circle cx="290" cy="174" r="3.5" fill="#428466"/>
|
|
23
|
+
<text x="300" y="178" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="12" font-weight="400" fill="#397359">已完成</text>
|
|
24
|
+
<text x="400" y="178" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="12" font-weight="400" fill="#515F7B">改动 3 个文件</text>
|
|
25
|
+
<line x1="278" y1="192" x2="596" y2="192" stroke="#E6EAF2"/>
|
|
26
|
+
<rect x="278" y="202" width="318" height="26" rx="6" fill="#EAF5EF"/>
|
|
27
|
+
<path d="M290 215 l3.5 3.5 l6.5 -7" stroke="#428466" stroke-width="1.6" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
28
|
+
<text x="308" y="219" font-family="ui-monospace, Menlo, Consolas, monospace" font-size="12" font-weight="400" fill="#253047">npm test</text>
|
|
29
|
+
<text x="586" y="219" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="12" font-weight="400" fill="#397359" text-anchor="end">通过</text>
|
|
30
|
+
<text x="284" y="252" font-family="-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif" font-size="11.5" font-weight="400" fill="#66738B">回复、改动文件和测试结果交回 Claude Code</text>
|
|
31
|
+
</svg>
|
package/icon.svg
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="180" height="180" viewBox="10 9 180 180" role="img" aria-labelledby="t">
|
|
2
|
+
<title id="t">dsh-baton</title>
|
|
3
|
+
<style>
|
|
4
|
+
.front { stroke: #2D2F33; }
|
|
5
|
+
.back { stroke: #9A9DA4; }
|
|
6
|
+
@media (prefers-color-scheme: dark) {
|
|
7
|
+
.front { stroke: #F4F4F5; }
|
|
8
|
+
.back { stroke: #6B6E75; }
|
|
9
|
+
}
|
|
10
|
+
</style>
|
|
11
|
+
<defs>
|
|
12
|
+
<!-- the back window hides behind the front one, and both frames open where the baton passes -->
|
|
13
|
+
<mask id="behind" maskUnits="userSpaceOnUse" x="0" y="0" width="200" height="200">
|
|
14
|
+
<rect width="200" height="200" fill="#fff"/>
|
|
15
|
+
<rect x="20" y="46" width="102" height="84" rx="19" fill="#000"/>
|
|
16
|
+
<rect x="62.5" y="92.5" width="79" height="24" rx="12" fill="#000"/>
|
|
17
|
+
</mask>
|
|
18
|
+
<mask id="cut" maskUnits="userSpaceOnUse" x="0" y="0" width="200" height="200">
|
|
19
|
+
<rect width="200" height="200" fill="#fff"/>
|
|
20
|
+
<rect x="62.5" y="92.5" width="79" height="24" rx="12" fill="#000"/>
|
|
21
|
+
</mask>
|
|
22
|
+
</defs>
|
|
23
|
+
<rect class="back" x="92" y="80" width="84" height="68" rx="15" fill="none" stroke-width="8" mask="url(#behind)"/>
|
|
24
|
+
<rect class="front" x="24" y="50" width="94" height="76" rx="15" fill="none" stroke-width="8" mask="url(#cut)"/>
|
|
25
|
+
<path class="front" d="M42 76 L56 90 L42 104" fill="none" stroke-width="8" stroke-linecap="round" stroke-linejoin="round"/>
|
|
26
|
+
<rect x="66" y="96" width="72" height="17" rx="8.5" fill="#FF8A3D"/>
|
|
27
|
+
</svg>
|
package/lib/client.js
CHANGED
|
@@ -18,7 +18,7 @@ window.__ModuleLoader__.load({
|
|
|
18
18
|
id: 'dsh-baton-host',
|
|
19
19
|
factory: (require) => {
|
|
20
20
|
const module = { exports: {} }
|
|
21
|
-
const { createElement: h, useState, useEffect } = require('react')
|
|
21
|
+
const { createElement: h, useState, useEffect, useRef } = require('react')
|
|
22
22
|
// Harness's dialog and button; without them (an older or newer Harness), plain elements.
|
|
23
23
|
let ui = null
|
|
24
24
|
try { ui = require('@deepseek-ai/dsh-client-ui-primitives') } catch { /* fall back */ }
|
|
@@ -57,6 +57,28 @@ window.__ModuleLoader__.load({
|
|
|
57
57
|
notRegistered: '未注册',
|
|
58
58
|
and: '和',
|
|
59
59
|
comma: '、',
|
|
60
|
+
handoverTitle: '转交默认模型',
|
|
61
|
+
handoverModel: '模型',
|
|
62
|
+
handoverEffort: '推理强度',
|
|
63
|
+
approvalsLabel: '转交会话里的审批',
|
|
64
|
+
approvalsAllow: '自动允许',
|
|
65
|
+
approvalsAsk: '交给我在 Harness 里处理',
|
|
66
|
+
followDefaultPlain: '跟随默认',
|
|
67
|
+
effortDefault: '跟随模型默认',
|
|
68
|
+
missingOption: '{model}(已不在 Harness 里)',
|
|
69
|
+
searchModels: '搜索模型…',
|
|
70
|
+
noMatch: '没有匹配的模型',
|
|
71
|
+
handoverMissing: '{model} 已不在 Harness 的模型列表里,转交会改用 Harness 默认。',
|
|
72
|
+
handoverUnsupported: '这个版本的 Harness 不能按会话选模型,这里没法设置。',
|
|
73
|
+
handoverLoadFailed: '没能读取模型列表。',
|
|
74
|
+
handoverUnreadable: '设置文件读不出来({error}),转交暂时不用这里的设置。重新选一次就会写好。',
|
|
75
|
+
saved: '已保存',
|
|
76
|
+
saveFailed: '没能保存:{error}',
|
|
77
|
+
effortOff: '关',
|
|
78
|
+
effortLow: '低',
|
|
79
|
+
effortMedium: '中',
|
|
80
|
+
effortHigh: '高',
|
|
81
|
+
effortMax: '最高',
|
|
60
82
|
}
|
|
61
83
|
const en = {
|
|
62
84
|
sentFrom: 'Sent by {name} from another chat',
|
|
@@ -80,6 +102,28 @@ window.__ModuleLoader__.load({
|
|
|
80
102
|
notRegistered: 'not registered',
|
|
81
103
|
and: 'and',
|
|
82
104
|
comma: ', ',
|
|
105
|
+
handoverTitle: 'Default model for hand-overs',
|
|
106
|
+
handoverModel: 'Model',
|
|
107
|
+
handoverEffort: 'Reasoning effort',
|
|
108
|
+
approvalsLabel: 'Hand-over approvals',
|
|
109
|
+
approvalsAllow: 'Allow automatically',
|
|
110
|
+
approvalsAsk: 'Leave them to me in Harness',
|
|
111
|
+
followDefaultPlain: 'Harness default',
|
|
112
|
+
effortDefault: "The model's default",
|
|
113
|
+
missingOption: '{model} (no longer in Harness)',
|
|
114
|
+
searchModels: 'Search models…',
|
|
115
|
+
noMatch: 'No model matches',
|
|
116
|
+
handoverMissing: "{model} is no longer in Harness's model list, so hand-overs use Harness's default.",
|
|
117
|
+
handoverUnsupported: 'This Harness cannot choose a model per session, so this cannot be set here.',
|
|
118
|
+
handoverLoadFailed: 'The model list could not be read.',
|
|
119
|
+
handoverUnreadable: 'The settings file could not be read ({error}), so hand-overs do not use these settings for now. Choosing again writes it afresh.',
|
|
120
|
+
saved: 'Saved',
|
|
121
|
+
saveFailed: 'Not saved: {error}',
|
|
122
|
+
effortOff: 'Off',
|
|
123
|
+
effortLow: 'Low',
|
|
124
|
+
effortMedium: 'Medium',
|
|
125
|
+
effortHigh: 'High',
|
|
126
|
+
effortMax: 'Max',
|
|
83
127
|
}
|
|
84
128
|
|
|
85
129
|
// --- Plugins page ------------------------------------------------------------
|
|
@@ -150,18 +194,237 @@ window.__ModuleLoader__.load({
|
|
|
150
194
|
}
|
|
151
195
|
}
|
|
152
196
|
|
|
153
|
-
// The
|
|
197
|
+
// The model and reasoning effort new hand-over sessions start on (host: /dsh-baton/handover).
|
|
198
|
+
// A change is saved at once; the host checks it against Harness's model list.
|
|
199
|
+
const handoverUrl = () => new URL('dsh-baton/handover', document.baseURI).pathname
|
|
200
|
+
const EFFORT_KEYS = { off: 'effortOff', low: 'effortLow', medium: 'effortMedium', high: 'effortHigh', max: 'effortMax' }
|
|
201
|
+
const FIELD = { display: 'flex', flexDirection: 'column', gap: 6, maxWidth: 420 }
|
|
202
|
+
// The detail page's sections as Harness's own settings cards: rows with the name on the
|
|
203
|
+
// left and the value or control on the right, so nothing stretches across the page.
|
|
204
|
+
const STROKE = 'var(--dsw-alias-settings-card-stroke, var(--dsw-alias-border-l2))'
|
|
205
|
+
const CARD = { display: 'flex', flexDirection: 'column', maxWidth: 560, borderRadius: 'var(--dsw-radius-lg, 10px)', border: `0.5px solid ${STROKE}`, background: 'var(--dsw-alias-settings-card-fill, transparent)' }
|
|
206
|
+
// A row of a card; an optional first child that is a plain style object adjusts the row.
|
|
207
|
+
const cardRow = (key, first, ...children) => {
|
|
208
|
+
const own = children[0] && typeof children[0] === 'object' && !children[0].$$typeof && !Array.isArray(children[0]) && children[0] !== null && !('props' in children[0]) ? children.shift() : {}
|
|
209
|
+
return h('div', { key, style: { display: 'flex', alignItems: 'center', gap: 12, minHeight: 48, padding: '8px 14px', boxSizing: 'border-box', ...(first ? {} : { borderTop: `0.5px solid ${STROKE}` }), ...own } }, ...children)
|
|
210
|
+
}
|
|
211
|
+
const SECTION = { display: 'flex', flexDirection: 'column', gap: 8, maxWidth: 560 }
|
|
212
|
+
const HEADING = { color: 'var(--dsw-alias-label-primary)', fontWeight: 600 }
|
|
213
|
+
const ROW_NAME = { flex: '1 1 auto', minWidth: 0, color: 'var(--dsw-alias-label-primary)', fontSize: 13 }
|
|
214
|
+
// A dropdown in the style of Harness's own model menu (its theme tokens): a quiet trigger,
|
|
215
|
+
// an elevated card with group headings, a search box for long lists, a check on the choice
|
|
216
|
+
// and the detail (a price multiplier, a provider) muted on the right. Keyboard: arrows, Enter, Escape.
|
|
217
|
+
const CHEVRON = h('svg', { width: 12, height: 12, viewBox: '0 0 12 12', 'aria-hidden': true, style: { flex: '0 0 auto', color: 'var(--dsw-alias-label-caption)' } },
|
|
218
|
+
h('path', { d: 'M3 4.5 6 7.5 9 4.5', fill: 'none', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' }))
|
|
219
|
+
const CHECK = h('svg', { width: 14, height: 14, viewBox: '0 0 14 14', 'aria-hidden': true, style: { flex: '0 0 auto', color: 'var(--dsw-alias-state-business-primary)' } },
|
|
220
|
+
h('path', { d: 'M3 7.2 5.8 10 11 4.5', fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round', strokeLinejoin: 'round' }))
|
|
221
|
+
const MUTED = { color: 'var(--dsw-alias-label-caption)', whiteSpace: 'nowrap', flex: '0 0 auto' }
|
|
222
|
+
const CLIP = { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }
|
|
223
|
+
function Picker({ label, value, items, disabled, onPick, searchable, placeholder, empty, chosenDetail }) {
|
|
224
|
+
const [open, setOpen] = useState(false)
|
|
225
|
+
const [query, setQuery] = useState('')
|
|
226
|
+
const [active, setActive] = useState(-1)
|
|
227
|
+
const root = useRef(null)
|
|
228
|
+
const chosen = items.find((i) => i.value === value) ?? items[0]
|
|
229
|
+
const q = query.trim().toLowerCase()
|
|
230
|
+
const shown = items.filter((i) => !q || `${i.label} ${i.detail ?? ''} ${i.group ?? ''}`.toLowerCase().includes(q))
|
|
231
|
+
const pickable = shown.filter((i) => !i.disabled)
|
|
232
|
+
useEffect(() => {
|
|
233
|
+
if (!open) return
|
|
234
|
+
const away = (e) => { if (root.current && !root.current.contains(e.target)) setOpen(false) }
|
|
235
|
+
document.addEventListener('mousedown', away)
|
|
236
|
+
return () => document.removeEventListener('mousedown', away)
|
|
237
|
+
}, [open])
|
|
238
|
+
useEffect(() => { if (!open) { setQuery(''); setActive(-1) } }, [open])
|
|
239
|
+
const pick = (i) => { setOpen(false); if (!i.disabled && i.value !== value) onPick(i.value) }
|
|
240
|
+
const onKey = (e) => {
|
|
241
|
+
if (e.key === 'Escape') { if (open) { e.preventDefault(); setOpen(false) } return }
|
|
242
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
243
|
+
e.preventDefault()
|
|
244
|
+
if (!open) return setOpen(true)
|
|
245
|
+
const n = pickable.length
|
|
246
|
+
if (n) setActive((a) => (e.key === 'ArrowDown' ? (a + 1) % n : (a - 1 + n) % n))
|
|
247
|
+
return
|
|
248
|
+
}
|
|
249
|
+
if (e.key === 'Enter' && open && pickable[active]) { e.preventDefault(); pick(pickable[active]) }
|
|
250
|
+
}
|
|
251
|
+
const trigger = h('button', {
|
|
252
|
+
type: 'button', disabled, 'aria-haspopup': 'listbox', 'aria-expanded': open, 'aria-label': label,
|
|
253
|
+
onClick: () => setOpen((o) => !o), onKeyDown: onKey,
|
|
254
|
+
style: {
|
|
255
|
+
display: 'flex', alignItems: 'center', gap: 8, width: '100%', minHeight: 34, padding: '0 10px', boxSizing: 'border-box',
|
|
256
|
+
border: '0.5px solid var(--dsw-alias-border-l3)', borderRadius: 'var(--dsw-radius-md, 8px)',
|
|
257
|
+
background: open ? 'var(--dsw-alias-interactive-bg-hover)' : 'transparent', color: disabled ? 'var(--dsw-alias-label-dimmed)' : 'var(--dsw-alias-label-primary)',
|
|
258
|
+
font: 'inherit', fontSize: 13, textAlign: 'left', cursor: disabled ? 'default' : 'pointer',
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
h('span', { style: { ...CLIP, flex: '1 1 auto' } }, chosen?.label ?? ''),
|
|
262
|
+
(chosenDetail ?? chosen?.detail) ? h('span', { style: { ...MUTED, fontSize: 12 } }, chosenDetail ?? chosen.detail) : null,
|
|
263
|
+
CHEVRON)
|
|
264
|
+
let lastGroup
|
|
265
|
+
const rows = []
|
|
266
|
+
for (const i of shown) {
|
|
267
|
+
if (i.group && i.group !== lastGroup) {
|
|
268
|
+
lastGroup = i.group
|
|
269
|
+
rows.push(h('div', { key: `g:${i.group}`, role: 'presentation', style: { padding: '8px 8px 4px', fontSize: 12, color: 'var(--dsw-alias-label-tertiary)' } }, i.group))
|
|
270
|
+
}
|
|
271
|
+
const on = i.value === value
|
|
272
|
+
const hot = pickable[active] === i
|
|
273
|
+
rows.push(h('div', {
|
|
274
|
+
key: `o:${i.value}`, role: 'option', 'aria-selected': on, 'aria-disabled': i.disabled || undefined,
|
|
275
|
+
onMouseDown: (e) => e.preventDefault(), onClick: () => pick(i), onMouseEnter: () => setActive(pickable.indexOf(i)),
|
|
276
|
+
style: {
|
|
277
|
+
display: 'flex', alignItems: 'center', gap: 8, minHeight: 32, padding: '5px 8px', borderRadius: 'var(--dsw-radius-md, 8px)',
|
|
278
|
+
background: hot ? 'var(--dsw-alias-interactive-bg-hover)' : 'transparent', cursor: i.disabled ? 'default' : 'pointer', fontSize: 13,
|
|
279
|
+
color: i.disabled ? 'var(--dsw-alias-label-dimmed)' : 'var(--dsw-alias-label-primary)',
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
h('span', { style: { ...CLIP, flex: '1 1 auto', fontWeight: on ? 600 : 400 } }, i.label),
|
|
283
|
+
i.detail ? h('span', { style: { ...MUTED, fontSize: 12 } }, i.detail) : null,
|
|
284
|
+
h('span', { style: { width: 14, display: 'inline-flex' } }, on ? CHECK : null)))
|
|
285
|
+
}
|
|
286
|
+
const card = open ? h('div', {
|
|
287
|
+
role: 'listbox', 'aria-label': label,
|
|
288
|
+
style: {
|
|
289
|
+
position: 'absolute', top: 'calc(100% + 4px)', right: 0, minWidth: '100%', width: 'max-content', maxWidth: 360, zIndex: 1100, display: 'flex', flexDirection: 'column',
|
|
290
|
+
maxHeight: 360, padding: 4, boxSizing: 'border-box', borderRadius: 'var(--dsw-radius-lg, 10px)',
|
|
291
|
+
background: 'var(--dsw-alias-bg-layer-3, var(--dsw-alias-bg-base))', boxShadow: 'var(--dsw-elevation-prominent, 0 8px 24px rgba(0,0,0,.25))',
|
|
292
|
+
border: '0.5px solid var(--dsw-alias-border-l2)', color: 'var(--dsw-alias-label-primary)',
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
searchable ? h('input', {
|
|
296
|
+
autoFocus: true, value: query, placeholder, onKeyDown: onKey,
|
|
297
|
+
onChange: (e) => { setQuery(e.target.value); setActive(0) },
|
|
298
|
+
style: { margin: '2px 0 4px', padding: '6px 8px', border: 'none', borderBottom: '0.5px solid var(--dsw-alias-border-l2)', outline: 'none', background: 'transparent', color: 'inherit', font: 'inherit', fontSize: 12 },
|
|
299
|
+
}) : null,
|
|
300
|
+
h('div', { style: { overflowY: 'auto', minHeight: 0 } },
|
|
301
|
+
...(rows.length ? rows : [h('div', { key: 'none', style: { padding: 8, fontSize: 12, color: 'var(--dsw-alias-label-tertiary)' } }, empty)]))) : null
|
|
302
|
+
return h('div', { ref: root, style: { position: 'relative' } }, trigger, card)
|
|
303
|
+
}
|
|
304
|
+
// "Fast · x0.34" (a WorkBuddy plugin puts the price in the name): the name, and the price apart.
|
|
305
|
+
const splitName = (name) => { const m = /^(.*\S)\s+·\s+(x\d+(?:\.\d+)?)$/.exec(String(name ?? '')); return m ? [m[1], m[2]] : [String(name ?? ''), null] }
|
|
306
|
+
function HandoverSettings({ t }) {
|
|
307
|
+
const [view, setView] = useState(null)
|
|
308
|
+
const [note, setNote] = useState(null)
|
|
309
|
+
const [busy, setBusy] = useState(false)
|
|
310
|
+
// Right after "Enable now" the host may not serve the route yet: ask again for a while.
|
|
311
|
+
useEffect(() => {
|
|
312
|
+
let stopped = false
|
|
313
|
+
let tries = 0
|
|
314
|
+
const load = async () => {
|
|
315
|
+
let next = null
|
|
316
|
+
try {
|
|
317
|
+
const res = await fetch(handoverUrl(), { cache: 'no-store' })
|
|
318
|
+
if (res.ok) next = await res.json()
|
|
319
|
+
} catch { /* not served yet */ }
|
|
320
|
+
if (stopped) return
|
|
321
|
+
if (next) return setView(next)
|
|
322
|
+
if (++tries >= 15) return setView({ failed: true })
|
|
323
|
+
setTimeout(load, 700)
|
|
324
|
+
}
|
|
325
|
+
load()
|
|
326
|
+
return () => { stopped = true }
|
|
327
|
+
}, [])
|
|
328
|
+
const title = h('span', { style: HEADING }, t('handoverTitle'))
|
|
329
|
+
if (!view) return null
|
|
330
|
+
if (view.failed) return h('div', { style: FIELD }, title, h('span', null, t('handoverLoadFailed')))
|
|
331
|
+
// A Harness that cannot choose a model per session still has the approvals choice.
|
|
332
|
+
const modelsOk = view.supported !== false
|
|
333
|
+
const key = (m) => `${m.provider}/${m.model}`
|
|
334
|
+
const models = view.models ?? []
|
|
335
|
+
const current = models.find((m) => key(m) === view.model)
|
|
336
|
+
const def = view.default ? models.find((m) => m.provider === view.default.provider && m.model === view.default.model) : null
|
|
337
|
+
// Efforts come as { id, name }; ours are translated, any other shows Harness's name.
|
|
338
|
+
const effortList = (m) => (m ? m.reasoning_efforts ?? [] : def?.reasoning_efforts ?? []).map((e) => (typeof e === 'string' ? { id: e, name: e } : e))
|
|
339
|
+
const effortsOf = (m) => effortList(m).map((e) => e.id)
|
|
340
|
+
const efforts = effortsOf(current)
|
|
341
|
+
const effortName = (id) => (EFFORT_KEYS[id] ? t(EFFORT_KEYS[id]) : effortList(current).find((e) => e.id === id)?.name ?? id)
|
|
342
|
+
async function save(next) {
|
|
343
|
+
setBusy(true)
|
|
344
|
+
setNote(null)
|
|
345
|
+
try {
|
|
346
|
+
const res = await fetch(handoverUrl(), { method: 'POST', headers: { 'content-type': 'application/json', 'x-dsh-baton': 'handover' }, body: JSON.stringify(next) })
|
|
347
|
+
const body = await res.json().catch(() => ({}))
|
|
348
|
+
if (!res.ok) throw new Error(body.error ?? `HTTP ${res.status}`)
|
|
349
|
+
setView(body)
|
|
350
|
+
setNote(t('saved'))
|
|
351
|
+
} catch (error) {
|
|
352
|
+
setNote(t('saveFailed', { error: error?.message ?? String(error) }))
|
|
353
|
+
} finally {
|
|
354
|
+
setBusy(false)
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function pickModel(value) {
|
|
358
|
+
const m = models.find((x) => key(x) === value)
|
|
359
|
+
// An effort the new model does not have goes back to the model's own default.
|
|
360
|
+
const keep = view.reasoning_effort && effortsOf(m).includes(view.reasoning_effort) ? view.reasoning_effort : null
|
|
361
|
+
save({ model: value || null, reasoning_effort: keep })
|
|
362
|
+
}
|
|
363
|
+
const providerName = (p) => models.find((m) => m.provider === p)?.provider_name ?? p
|
|
364
|
+
const modelItems = [
|
|
365
|
+
// Short in the narrow trigger: the model Harness defaults to now goes on the right, muted.
|
|
366
|
+
{ value: '', label: t('followDefaultPlain'), ...(def ? { detail: def.name } : {}) },
|
|
367
|
+
...(view.model && !current ? [{ value: view.model, label: t('missingOption', { model: view.model }), disabled: true }] : []),
|
|
368
|
+
// One group per provider, in Harness's order, as in Harness's own model menu.
|
|
369
|
+
...models.map((m) => { const [name, price] = splitName(m.name); return { value: key(m), label: name, detail: price, group: providerName(m.provider) } }),
|
|
370
|
+
]
|
|
371
|
+
// The closed trigger shows the provider too: names repeat across providers.
|
|
372
|
+
const chosenItem = modelItems.find((i) => i.value === (view.model ?? ''))
|
|
373
|
+
const chosenDetail = chosenItem?.group ? [chosenItem.detail, chosenItem.group].filter(Boolean).join(' · ') : undefined
|
|
374
|
+
const effortItems = [
|
|
375
|
+
{ value: '', label: t('effortDefault') },
|
|
376
|
+
...(view.reasoning_effort && !efforts.includes(view.reasoning_effort) ? [{ value: view.reasoning_effort, label: effortName(view.reasoning_effort), disabled: true }] : []),
|
|
377
|
+
...efforts.map((e) => ({ value: e, label: effortName(e) })),
|
|
378
|
+
]
|
|
379
|
+
const row = (key, label, control, first = false) => cardRow(key, first, h('span', { style: ROW_NAME }, label), h('div', { style: { flex: '0 0 260px', width: 260 } }, control))
|
|
380
|
+
return h('div', { style: { ...SECTION, maxWidth: 440 }, 'data-dsh-baton-handover': '' },
|
|
381
|
+
title,
|
|
382
|
+
modelsOk ? null : h('span', { style: { fontSize: 12 } }, t('handoverUnsupported')),
|
|
383
|
+
h('div', { style: { ...CARD, maxWidth: 440 } },
|
|
384
|
+
modelsOk && row('model', t('handoverModel'), h(Picker, {
|
|
385
|
+
label: t('handoverModel'), value: view.model ?? '', items: modelItems, chosenDetail, disabled: busy, onPick: pickModel,
|
|
386
|
+
searchable: models.length > 8, placeholder: t('searchModels'), empty: t('noMatch'),
|
|
387
|
+
}), true),
|
|
388
|
+
modelsOk && row('effort', t('handoverEffort'), h(Picker, {
|
|
389
|
+
label: t('handoverEffort'), value: view.reasoning_effort ?? '', items: effortItems, disabled: busy || (!efforts.length && !view.reasoning_effort),
|
|
390
|
+
onPick: (v) => save({ model: view.model ?? null, reasoning_effort: v || null }), empty: t('noMatch'),
|
|
391
|
+
})),
|
|
392
|
+
row('approvals', t('approvalsLabel'), h(Picker, {
|
|
393
|
+
label: t('approvalsLabel'), value: view.approvals ?? 'allow', disabled: busy,
|
|
394
|
+
items: [{ value: 'allow', label: t('approvalsAllow') }, { value: 'ask', label: t('approvalsAsk') }],
|
|
395
|
+
onPick: (v) => save({ approvals: v }), empty: t('noMatch'),
|
|
396
|
+
}), !modelsOk)),
|
|
397
|
+
view.missing ? h('span', null, t('handoverMissing', { model: view.model })) : null,
|
|
398
|
+
view.unreadable ? h('span', null, t('handoverUnreadable', { error: view.unreadable })) : null,
|
|
399
|
+
note ? h('span', { role: 'status', style: { fontSize: 12 } }, note) : null)
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// The plugin's detail page: one line per client, then the hand-over defaults.
|
|
154
403
|
function wrapDetails(t) {
|
|
155
404
|
return function DshBatonStatus({ view }) {
|
|
156
405
|
const reg = useRegistration()
|
|
157
406
|
if (view === 'summary') return null
|
|
158
407
|
const [, text] = describe(reg, t)
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
408
|
+
// One row per client: its mark and name, and its state as a dot and a word on the right.
|
|
409
|
+
const state = (s) => (REGISTERED.includes(s)
|
|
410
|
+
? [t('registered'), 'var(--dsw-alias-state-success-primary, #2ea44f)']
|
|
411
|
+
: s === 'not-installed' ? [t('notInstalled'), 'var(--dsw-alias-label-dimmed, #8b949e)'] : [t('notRegistered'), 'var(--dsw-alias-state-warn-primary, #d29922)'])
|
|
412
|
+
const clients = reg?.clients ?? []
|
|
413
|
+
const clientRow = (c, i) => {
|
|
414
|
+
const [word, colour] = state(c.state)
|
|
415
|
+
const mark = MARKS[c.id]
|
|
416
|
+
return cardRow(c.id, i === 0, { minHeight: 40 },
|
|
417
|
+
mark ? h('svg', { width: 18, height: 18, viewBox: mark.viewBox, 'aria-hidden': true, style: { flex: '0 0 auto', color: 'var(--dsw-alias-label-primary)' } }, h('path', { d: mark.d, fill: 'currentColor' })) : null,
|
|
418
|
+
h('span', { style: { ...ROW_NAME, fontWeight: 500 } }, c.label),
|
|
419
|
+
h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } },
|
|
420
|
+
h('span', { 'aria-hidden': true, style: { width: 7, height: 7, borderRadius: '50%', background: colour } }), word))
|
|
421
|
+
}
|
|
422
|
+
return h('div', { style: { display: 'flex', flexDirection: 'column', gap: 20, color: 'var(--dsw-alias-label-secondary)' } },
|
|
423
|
+
h('div', { style: { ...SECTION, maxWidth: 380 } },
|
|
424
|
+
h('span', { style: HEADING }, t('status')),
|
|
425
|
+
clients.length ? h('div', { style: { ...CARD, maxWidth: 380 } }, ...clients.map(clientRow)) : null,
|
|
426
|
+
h('span', { style: { fontSize: 12 } }, text)),
|
|
427
|
+
h(HandoverSettings, { t }))
|
|
165
428
|
}
|
|
166
429
|
}
|
|
167
430
|
|
package/lib/index.js
CHANGED
|
@@ -56,6 +56,57 @@ function normalizePath(p) {
|
|
|
56
56
|
try { return fs.realpathSync.native(abs) } catch { return abs }
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
// Where a new session goes. Harness keeps every session of a workspace in the workspace's own
|
|
60
|
+
// folder, so a hand-over to a folder that is not a workspace would get a workspace of its own,
|
|
61
|
+
// one more in the sidebar for each subfolder or throw-away folder. Instead it joins:
|
|
62
|
+
// - the conversation's own folder (base), when the target is inside it: a Claude Code chat in
|
|
63
|
+
// Coding handing over Coding/app joins the Coding workspace;
|
|
64
|
+
// - for folders clients make per conversation, one shared folder: Codex chats without a project
|
|
65
|
+
// (Documents/Codex/<date>/<chat>), Claude scratch folders (…/scratch-workspaces/…), Claude
|
|
66
|
+
// worktrees (<project>/.claude/worktrees/<name>, joined to the project) and Codex worktrees
|
|
67
|
+
// (~/.codex/worktrees/…).
|
|
68
|
+
// The session then starts in that folder and the message names the target folder.
|
|
69
|
+
const CASELESS = process.platform === 'win32' || process.platform === 'darwin'
|
|
70
|
+
const same = (a, b) => (CASELESS ? a.toLowerCase() === b.toLowerCase() : a === b)
|
|
71
|
+
function isInside(dir, parent) {
|
|
72
|
+
const r = path.relative(CASELESS ? parent.toLowerCase() : parent, CASELESS ? dir.toLowerCase() : dir)
|
|
73
|
+
return r !== '' && !r.startsWith('..') && !path.isAbsolute(r)
|
|
74
|
+
}
|
|
75
|
+
const DAY = /^\d{4}-\d{2}-\d{2}$/
|
|
76
|
+
function sharedFolder(dir) {
|
|
77
|
+
const parts = dir.split(path.sep)
|
|
78
|
+
const upto = (i) => parts.slice(0, i).join(path.sep) || path.sep
|
|
79
|
+
for (let i = parts.length - 2; i >= 1; i--) {
|
|
80
|
+
const at = parts[i]
|
|
81
|
+
// Claude Code worktrees share the folder that holds them, never the project's main checkout.
|
|
82
|
+
if (same(at, 'worktrees') && i >= 2 && same(parts[i - 1], '.claude')) return { path: upto(i + 1), title: 'Claude worktrees' }
|
|
83
|
+
if (same(at, 'worktrees') && same(parts[i - 1], '.codex')) return { path: upto(i + 1), title: 'Codex worktrees' }
|
|
84
|
+
if (same(at, 'scratch-workspaces')) return { path: upto(i + 1), title: 'Claude scratch' }
|
|
85
|
+
if (same(at, 'Codex') && same(parts[i - 1], 'Documents') && DAY.test(parts[i + 1] ?? '')) return { path: upto(i + 1), title: 'Codex chats' }
|
|
86
|
+
}
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
// A Git worktree (its .git is a file pointing into another repository's worktrees): a checkout
|
|
90
|
+
// of its own, so a session for it must not open in the folder around it, which may be the main checkout.
|
|
91
|
+
function isLinkedWorktree(dir) {
|
|
92
|
+
try {
|
|
93
|
+
const text = fs.readFileSync(path.join(dir, '.git'), 'utf8')
|
|
94
|
+
return text.startsWith('gitdir:') && /[\\/]worktrees[\\/]/.test(text)
|
|
95
|
+
} catch { return false }
|
|
96
|
+
}
|
|
97
|
+
function sessionHome(target, base) {
|
|
98
|
+
const usable = (dir) => dir && !same(dir, os.homedir()) && dir !== path.parse(dir).root && isDirectory(dir)
|
|
99
|
+
if (base && !isLinkedWorktree(target)) {
|
|
100
|
+
let b = normalizePath(base)
|
|
101
|
+
const shared = sharedFolder(b)
|
|
102
|
+
if (shared && isDirectory(shared.path)) b = shared.path
|
|
103
|
+
if (usable(b) && isInside(target, b)) return { path: b, ...(shared && same(b, shared.path) && shared.title ? { title: shared.title } : {}) }
|
|
104
|
+
}
|
|
105
|
+
const shared = sharedFolder(target)
|
|
106
|
+
if (shared && usable(shared.path)) return shared
|
|
107
|
+
return { path: target }
|
|
108
|
+
}
|
|
109
|
+
|
|
59
110
|
// Prepare the socket path without touching anything that is not ours: only our
|
|
60
111
|
// own directory gets 0700, only a stale socket is removed, and a live host that
|
|
61
112
|
// already answers there is left alone.
|
|
@@ -180,6 +231,7 @@ export function apply(ctx) {
|
|
|
180
231
|
...(run.waitingOn ? { waiting_on: run.waitingOn } : {}),
|
|
181
232
|
...(run.supersededBy ? { superseded_by: run.supersededBy } : {}),
|
|
182
233
|
...(run.humanInputs?.length ? { human_interjections: run.humanInputs } : {}),
|
|
234
|
+
...(run.approvalsAllowed?.length ? { approvals_allowed: run.approvalsAllowed } : {}),
|
|
183
235
|
...(run.question ? { question: run.question } : {}),
|
|
184
236
|
...(tail ? { recent_events: run.events.slice(-tail) } : {}),
|
|
185
237
|
})
|
|
@@ -314,9 +366,45 @@ export function apply(ctx) {
|
|
|
314
366
|
// followup, or someone typing in the Harness UI); one after it is a steer.
|
|
315
367
|
const turns = new Map() // sessionId -> { hasOutput }
|
|
316
368
|
|
|
369
|
+
// An approval asked inside a tool call (the run_code of Harness's PTC mode, for one) leaves the
|
|
370
|
+
// agent "running", so its status never says "waiting". The session log's approval/asked and
|
|
371
|
+
// approval/decided pair does: the run waits for the Harness UI from the first open approval
|
|
372
|
+
// to the last decision.
|
|
373
|
+
const openApprovals = new Map() // sessionId -> Map(approval id -> whether it waits for a person)
|
|
374
|
+
let approvalSeq = 0
|
|
375
|
+
const personApproval = (sessionId) => [...(openApprovals.get(sessionId)?.values() ?? [])].some(Boolean)
|
|
376
|
+
// What Harness's Auto review puts in the approval it asks for after turning a call down.
|
|
377
|
+
const AUTO_REVIEW_DENIAL = /^Auto review denied tool/
|
|
378
|
+
function onApproval(sessionId, type, data) {
|
|
379
|
+
const open = openApprovals.get(sessionId) ?? new Map()
|
|
380
|
+
if (type === 'approval/asked') {
|
|
381
|
+
// One this plugin answers itself (onApprovalRequest) is decided at once: no person to wait for.
|
|
382
|
+
const forPerson = !(approvalsMode() === 'allow' && outputReceiversFor(sessionId).length && !AUTO_REVIEW_DENIAL.test(String(data.reason ?? '')))
|
|
383
|
+
open.set(data.id ?? `asked-${++approvalSeq}`, forPerson)
|
|
384
|
+
} else if (data.id) open.delete(data.id)
|
|
385
|
+
else { const oldest = open.keys().next(); if (!oldest.done) open.delete(oldest.value) } // no id: the oldest one
|
|
386
|
+
if (open.size) openApprovals.set(sessionId, open)
|
|
387
|
+
else openApprovals.delete(sessionId)
|
|
388
|
+
// Any open approval that waits for a person, whatever else is open, puts the run in waiting.
|
|
389
|
+
if (personApproval(sessionId)) {
|
|
390
|
+
if (!waitingSessions.has(sessionId)) { uiEpisodes.set(sessionId, (uiEpisodes.get(sessionId) ?? 0) + 1); waitingSince.set(sessionId, Date.now()) }
|
|
391
|
+
waitingSessions.add(sessionId)
|
|
392
|
+
for (const run of outputReceiversFor(sessionId)) if (run.state !== 'waiting') needsPerson(run, 500)
|
|
393
|
+
} else if (type === 'approval/decided') {
|
|
394
|
+
waitingSessions.delete(sessionId)
|
|
395
|
+
waitingSince.delete(sessionId)
|
|
396
|
+
for (const run of outputReceiversFor(sessionId)) if (run.state === 'waiting' && !questions.has(sessionId)) { run.state = 'running'; persist(run) }
|
|
397
|
+
}
|
|
398
|
+
wakeFollowers(sessionId)
|
|
399
|
+
}
|
|
400
|
+
|
|
317
401
|
ctx.on('session/event', guard('session/event', (session, event) => {
|
|
318
402
|
const data = event.data ?? {}
|
|
319
403
|
if (FOLLOW_EVENTS.has(event.type)) wakeFollowers(session.id)
|
|
404
|
+
if (event.type === 'approval/asked' || event.type === 'approval/decided') onApproval(session.id, event.type, data)
|
|
405
|
+
// Harness asks for approvals only inside a turn, so none is open after it: one whose
|
|
406
|
+
// decision never came is not left to hold the session's waiting state.
|
|
407
|
+
if (event.type === 'turn/end' && openApprovals.has(session.id)) { openApprovals.delete(session.id); onApproval(session.id, 'approval/decided', { id: null }) }
|
|
320
408
|
// Turn state is kept only for a turn in progress and dropped at its end.
|
|
321
409
|
if (event.type === 'turn/start') turns.set(session.id, { hasOutput: false })
|
|
322
410
|
else if (event.type === 'assistant/message' && turns.has(session.id)) turns.get(session.id).hasOutput = true
|
|
@@ -471,13 +559,15 @@ export function apply(ctx) {
|
|
|
471
559
|
|
|
472
560
|
ctx.on('agent/status', guard('agent/status', ({ agent, status }) => {
|
|
473
561
|
if (!agent) return
|
|
562
|
+
// An approval asked inside a tool call keeps the run waiting though the agent says "running".
|
|
563
|
+
const approvalOpen = personApproval(agent.id)
|
|
474
564
|
if (status === 'waiting') { if (!waitingSessions.has(agent.id)) { uiEpisodes.set(agent.id, (uiEpisodes.get(agent.id) ?? 0) + 1); waitingSince.set(agent.id, Date.now()) } waitingSessions.add(agent.id) }
|
|
475
|
-
else { waitingSessions.delete(agent.id); waitingSince.delete(agent.id) }
|
|
565
|
+
else if (!approvalOpen) { waitingSessions.delete(agent.id); waitingSince.delete(agent.id) }
|
|
476
566
|
wakeFollowers(agent.id)
|
|
477
567
|
const receivers = receiversFor(agent.id)
|
|
478
568
|
if (status === 'running' && receivers.length) lastRunningAt.set(agent.id, Date.now())
|
|
479
569
|
for (const run of outputReceiversFor(agent.id)) {
|
|
480
|
-
if (status === 'running') run.state = 'running'
|
|
570
|
+
if (status === 'running') { if (!approvalOpen) run.state = 'running' }
|
|
481
571
|
// Needs a person: a question (see user-questions/request) or an approval in the
|
|
482
572
|
// Harness UI. Waiters wake a moment later, so a question that comes with it is on the run.
|
|
483
573
|
else if (status === 'waiting') { if (run.state !== 'waiting') needsPerson(run, 500) }
|
|
@@ -694,6 +784,28 @@ export function apply(ctx) {
|
|
|
694
784
|
|
|
695
785
|
ctx.on('user-questions/request', guardWaterfall(onQuestion), { global: true, prepend: true })
|
|
696
786
|
|
|
787
|
+
// Approvals in a hand-over run: allowed once here unless the plugin page says to leave them
|
|
788
|
+
// to the Harness UI (the user's choice, 2026-11-17: a hand-over must not stall on one). Only
|
|
789
|
+
// sessions with a run of this plugin in progress; every other approval goes on to Harness.
|
|
790
|
+
// Each one is listed on the run (approvals_allowed), so the client sees what was let through.
|
|
791
|
+
const MAX_ALLOWED = 20
|
|
792
|
+
function onApprovalRequest(request, next) {
|
|
793
|
+
const sessionId = request?.agent?.id
|
|
794
|
+
const runs = sessionId ? outputReceiversFor(sessionId) : []
|
|
795
|
+
if (!runs.length || approvalsMode() !== 'allow' || request?.signal?.aborted) return next()
|
|
796
|
+
// A call Harness's own Auto review model turned down (it never lets a high-risk one, such as
|
|
797
|
+
// sending secrets out, through) stays with the user: allowing it here would undo that review.
|
|
798
|
+
if (AUTO_REVIEW_DENIAL.test(String(request.reason ?? ''))) return next()
|
|
799
|
+
const entry = { time: new Date().toISOString(), tool: String(request.toolName ?? 'tool'), ...(request.reason ? { reason: String(request.reason).slice(0, 300) } : {}) }
|
|
800
|
+
for (const run of runs) {
|
|
801
|
+
run.approvalsAllowed = [...(run.approvalsAllowed ?? []), entry].slice(-MAX_ALLOWED)
|
|
802
|
+
pushEvent(run, { type: 'approval_allowed', tool: entry.tool })
|
|
803
|
+
persist(run)
|
|
804
|
+
}
|
|
805
|
+
return 'allowed-once'
|
|
806
|
+
}
|
|
807
|
+
ctx.on('approval/request', guardWaterfall(onApprovalRequest), { global: true, prepend: true })
|
|
808
|
+
|
|
697
809
|
// Harness's own "busy send" setting (Settings → sending while busy: queue or steer),
|
|
698
810
|
// as a dsh-baton mode, or null when this Harness has no such setting to read.
|
|
699
811
|
function harnessBusyMode() {
|
|
@@ -1072,13 +1184,17 @@ export function apply(ctx) {
|
|
|
1072
1184
|
|
|
1073
1185
|
// One model, or an error naming what is there: never a near miss in its place.
|
|
1074
1186
|
// "provider/model" picks between providers that offer the same model.
|
|
1075
|
-
function
|
|
1187
|
+
function modelHits(c, asked) {
|
|
1076
1188
|
const slash = String(asked).lastIndexOf('/')
|
|
1077
1189
|
const provider = slash > 0 ? modelKey(String(asked).slice(0, slash)) : null
|
|
1078
1190
|
const want = modelKey(slash > 0 ? String(asked).slice(slash + 1) : asked)
|
|
1079
|
-
const hits = c.groups.flatMap((g) => (provider && modelKey(g.id) !== provider ? [] : g.models
|
|
1191
|
+
const hits = want ? c.groups.flatMap((g) => (provider && modelKey(g.id) !== provider ? [] : g.models
|
|
1080
1192
|
.filter((m) => modelKey(m.id) === want || modelKey(m.name) === want)
|
|
1081
|
-
.map((m) => ({ provider: g.id, entry: m }))))
|
|
1193
|
+
.map((m) => ({ provider: g.id, entry: m })))) : []
|
|
1194
|
+
return { want, hits }
|
|
1195
|
+
}
|
|
1196
|
+
function matchModel(c, asked) {
|
|
1197
|
+
const { want, hits } = modelHits(c, asked)
|
|
1082
1198
|
if (!want || !hits.length) throw new Error(`No model in Harness matches ${JSON.stringify(asked)}. Available: ${listed(c)}.`)
|
|
1083
1199
|
if (hits.length > 1) throw new Error(`${JSON.stringify(asked)} matches several models: ${hits.map((h) => `${h.provider}/${h.entry.id}`).join(', ')}. Pass one of them as provider/model.`)
|
|
1084
1200
|
return hits[0]
|
|
@@ -1127,15 +1243,40 @@ export function apply(ctx) {
|
|
|
1127
1243
|
|
|
1128
1244
|
// Work out the model a send asks for before anything is created, so a name that
|
|
1129
1245
|
// matches nothing (or several) fails the send with the list of what is there.
|
|
1130
|
-
|
|
1131
|
-
|
|
1246
|
+
// `hit` is a catalog entry already found exactly (a hand-over default): it is used as it
|
|
1247
|
+
// is, never matched again by name.
|
|
1248
|
+
async function planModel(sessionId, { model, reasoning_effort, hit: exact }) {
|
|
1249
|
+
if (model == null && reasoning_effort == null && !exact) return null
|
|
1132
1250
|
if (!canSelect()) throw new Error(MODELS_UNSUPPORTED)
|
|
1133
1251
|
const c = await catalog()
|
|
1134
1252
|
let hit
|
|
1135
|
-
if (
|
|
1136
|
-
else {
|
|
1137
|
-
|
|
1138
|
-
|
|
1253
|
+
if (exact) hit = exact
|
|
1254
|
+
else if (model != null) {
|
|
1255
|
+
hit = exactModel(c, String(model))
|
|
1256
|
+
if (!hit) {
|
|
1257
|
+
// A name several providers share: the hand-over default on the plugin page decides
|
|
1258
|
+
// when it is one of them (issue #1, "DeepSeek-V4.1-Flash" from three providers).
|
|
1259
|
+
const { hits } = modelHits(c, model)
|
|
1260
|
+
const pin = hits.length > 1 ? handoverDefaults() : null
|
|
1261
|
+
const pinned = pin?.model && !pin.unreadable ? exactModel(c, pin.model) : null
|
|
1262
|
+
const chosen = pinned && hits.find((h) => h.provider === pinned.provider && h.entry.id === pinned.entry.id)
|
|
1263
|
+
if (chosen) {
|
|
1264
|
+
const plan = { provider: chosen.provider, model: chosen.entry.id, ...(reasoning_effort != null ? { reasoningEffort: matchEffort(chosen, reasoning_effort) } : {}) }
|
|
1265
|
+
return { ...plan, note: `${JSON.stringify(model)} matches several models (${hits.map((h) => `${h.provider}/${h.entry.id}`).join(', ')}); it ran on ${chosen.provider}/${chosen.entry.id}, the hand-over default set on ${PAGE}.` }
|
|
1266
|
+
}
|
|
1267
|
+
hit = matchModel(c, model)
|
|
1268
|
+
}
|
|
1269
|
+
} else if (!sessionId) {
|
|
1270
|
+
// Effort alone on a new session: Harness's default model, read inside the pick queue
|
|
1271
|
+
// (applyModel), so a pick running for another send cannot stand in for it. Checked
|
|
1272
|
+
// here against the default as it is now, so a wrong effort fails before anything is made.
|
|
1273
|
+
const entry = defaultHit(c)
|
|
1274
|
+
if (!entry) throw new Error(`The model ${c.default?.provider}/${c.default?.model} is not in Harness's catalog now; pass model too. Available: ${listed(c)}.`)
|
|
1275
|
+
matchEffort({ provider: c.default.provider, entry }, reasoning_effort)
|
|
1276
|
+
return { followDefault: true, reasoningEffort: reasoning_effort, catalog: c }
|
|
1277
|
+
} else {
|
|
1278
|
+
// Effort alone: the model the session runs with now.
|
|
1279
|
+
const current = (await sessionModel(sessionId)) || c.default
|
|
1139
1280
|
const entry = c.groups.find((g) => g.id === current?.provider)?.models.find((m) => m.id === current?.model)
|
|
1140
1281
|
if (!entry) throw new Error(`The model ${current?.provider}/${current?.model} is not in Harness's catalog now; pass model too. Available: ${listed(c)}.`)
|
|
1141
1282
|
hit = { provider: current.provider, entry }
|
|
@@ -1143,13 +1284,209 @@ export function apply(ctx) {
|
|
|
1143
1284
|
return { provider: hit.provider, model: hit.entry.id, ...(reasoning_effort != null ? { reasoningEffort: matchEffort(hit, reasoning_effort) } : {}) }
|
|
1144
1285
|
}
|
|
1145
1286
|
|
|
1287
|
+
// --- hand-over defaults (Plugins page) ------------------------------------------
|
|
1288
|
+
// The model and reasoning effort a new hand-over session starts on when the send names
|
|
1289
|
+
// none, chosen on the plugin's page. Unset, a new session follows Harness's default model,
|
|
1290
|
+
// and that default moves whenever a model is picked in Harness's model menu. Kept in
|
|
1291
|
+
// settings.json in the dsh-baton home, with the last Harness default a hand-over followed,
|
|
1292
|
+
// so a change of that default is said in the reply instead of passing unnoticed.
|
|
1293
|
+
// A setting never fails a send: one that cannot be used is skipped and said in model_note.
|
|
1294
|
+
const SETTINGS_FILE = path.join(batonHome(), 'settings.json')
|
|
1295
|
+
const pause = (ms) => { try { Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms) } catch { /* no wait */ } }
|
|
1296
|
+
// { data } or { data: {}, error, corrupt? }. A missing file is no settings; a file another
|
|
1297
|
+
// process holds (Windows antivirus or indexer) is read again once; one that is not JSON
|
|
1298
|
+
// is reported, never taken for "nothing set".
|
|
1299
|
+
function loadSettings() {
|
|
1300
|
+
let text
|
|
1301
|
+
for (let attempt = 0; ; attempt++) {
|
|
1302
|
+
try { text = fs.readFileSync(SETTINGS_FILE, 'utf8'); break } catch (error) {
|
|
1303
|
+
if (error?.code === 'ENOENT') return { data: {} }
|
|
1304
|
+
if (attempt >= 1) return { data: {}, error: error?.code ?? String(error?.message ?? error) }
|
|
1305
|
+
pause(50)
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
try {
|
|
1309
|
+
const s = JSON.parse(text.replace(/^/, ''))
|
|
1310
|
+
if (s && typeof s === 'object' && !Array.isArray(s)) return { data: s }
|
|
1311
|
+
} catch { /* below */ }
|
|
1312
|
+
return { data: {}, error: 'not valid JSON', corrupt: true }
|
|
1313
|
+
}
|
|
1314
|
+
// Merge a change into the file. An unreadable file is never overwritten from scratch:
|
|
1315
|
+
// only a save from the page replaces a broken one, after keeping it as settings.json.bad-<time>.
|
|
1316
|
+
function writeSettings(change, { replaceBroken = false } = {}) {
|
|
1317
|
+
const now = loadSettings()
|
|
1318
|
+
if (now.error && !(replaceBroken && now.corrupt)) throw new Error(`${SETTINGS_FILE} could not be read (${now.error}), so it was left as it is`)
|
|
1319
|
+
if (now.corrupt) fs.renameSync(SETTINGS_FILE, `${SETTINGS_FILE}.bad-${Date.now()}`)
|
|
1320
|
+
const next = { ...now.data, ...change }
|
|
1321
|
+
const body = JSON.stringify(next, null, 2) + '\n'
|
|
1322
|
+
fs.mkdirSync(path.dirname(SETTINGS_FILE), { recursive: true })
|
|
1323
|
+
const tmp = `${SETTINGS_FILE}.${process.pid}.tmp`
|
|
1324
|
+
fs.writeFileSync(tmp, body)
|
|
1325
|
+
// Windows refuses the rename while another process has the file open: try again shortly.
|
|
1326
|
+
for (let attempt = 0; ; attempt++) {
|
|
1327
|
+
try { fs.renameSync(tmp, SETTINGS_FILE); return next } catch (error) {
|
|
1328
|
+
if (attempt >= 5) { fs.rmSync(tmp, { force: true }); throw error }
|
|
1329
|
+
pause(40)
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
const filled = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null)
|
|
1334
|
+
// How approvals in a hand-over run are answered: 'allow' (the default) or 'ask' (the Harness UI).
|
|
1335
|
+
// Fails closed: a settings file that cannot be read, or a value other than the two, is 'ask'.
|
|
1336
|
+
function approvalsMode() {
|
|
1337
|
+
const { data, error } = loadSettings()
|
|
1338
|
+
if (error) return 'ask'
|
|
1339
|
+
return data.approvals == null || data.approvals === 'allow' ? 'allow' : 'ask'
|
|
1340
|
+
}
|
|
1341
|
+
function handoverDefaults() {
|
|
1342
|
+
const { data, error } = loadSettings()
|
|
1343
|
+
const h = data.handover && typeof data.handover === 'object' ? data.handover : {}
|
|
1344
|
+
return { model: filled(h.model), reasoning_effort: filled(h.reasoning_effort), ...(error ? { unreadable: error } : {}) }
|
|
1345
|
+
}
|
|
1346
|
+
// A saved "provider/model" names one catalog entry exactly; nothing else stands in for it.
|
|
1347
|
+
// Model ids may hold slashes themselves (openrouter/deepseek/deepseek-v4-pro).
|
|
1348
|
+
function exactModel(c, saved) {
|
|
1349
|
+
for (const g of c.groups) {
|
|
1350
|
+
if (!saved.startsWith(`${g.id}/`)) continue
|
|
1351
|
+
const entry = g.models.find((m) => m.id === saved.slice(g.id.length + 1))
|
|
1352
|
+
if (entry) return { provider: g.id, entry }
|
|
1353
|
+
}
|
|
1354
|
+
return null
|
|
1355
|
+
}
|
|
1356
|
+
const efforts = (hit) => (hit?.entry.reasoning?.efforts ?? []).map((e) => e.id)
|
|
1357
|
+
const hasEffort = (hit, asked) => { try { matchEffort(hit, asked); return true } catch { return false } }
|
|
1358
|
+
const defaultHit = (c) => c.groups.find((g) => g.id === c.default?.provider)?.models.find((m) => m.id === c.default?.model)
|
|
1359
|
+
// Choosing a model for a session needs Harness's default-model service as well, to put
|
|
1360
|
+
// the default back after the pick (keepingDefault).
|
|
1361
|
+
const canKeepDefault = () => {
|
|
1362
|
+
const dm = defaultModel()
|
|
1363
|
+
return typeof dm?.currentSelection === 'function' && typeof dm?.saveSelection === 'function'
|
|
1364
|
+
}
|
|
1365
|
+
const PAGE = 'the dsh-baton plugin page in Harness'
|
|
1366
|
+
|
|
1367
|
+
// What a new session's send asks for once the hand-over defaults fill in what it left out.
|
|
1368
|
+
async function withHandoverDefaults({ model, reasoning_effort }) {
|
|
1369
|
+
const out = { model, reasoning_effort, hit: null, used: { model: false, reasoning_effort: false }, notes: [] }
|
|
1370
|
+
const pin = handoverDefaults()
|
|
1371
|
+
if (pin.unreadable) {
|
|
1372
|
+
out.notes.push(`The hand-over defaults on ${PAGE} could not be read (${pin.unreadable}), so they were not used. Choose them on that page again if this goes on.`)
|
|
1373
|
+
return out
|
|
1374
|
+
}
|
|
1375
|
+
const wantModel = model == null && pin.model
|
|
1376
|
+
const wantEffort = reasoning_effort == null && pin.reasoning_effort
|
|
1377
|
+
if (!wantModel && !wantEffort) return out
|
|
1378
|
+
if (!canSelect() || !canKeepDefault()) {
|
|
1379
|
+
out.notes.push(`The hand-over defaults on ${PAGE} were not used: this DeepSeek Harness cannot choose a model per session.`)
|
|
1380
|
+
return out
|
|
1381
|
+
}
|
|
1382
|
+
let c
|
|
1383
|
+
try { c = await catalog() } catch (error) {
|
|
1384
|
+
out.notes.push(`Harness's model list could not be read (${error?.message ?? error}), so the hand-over defaults on ${PAGE} were not used.`)
|
|
1385
|
+
return out
|
|
1386
|
+
}
|
|
1387
|
+
let target = null
|
|
1388
|
+
if (wantModel) {
|
|
1389
|
+
const hit = exactModel(c, pin.model)
|
|
1390
|
+
if (!hit) out.notes.push(`The hand-over default model ${pin.model} (set on ${PAGE}) is not in Harness's model list now, so this session uses Harness's default model instead.`)
|
|
1391
|
+
else if (reasoning_effort != null && !hasEffort(hit, reasoning_effort)) out.notes.push(`The hand-over default model ${pin.model} (set on ${PAGE}) has no reasoning effort ${reasoning_effort}, so this session uses Harness's default model with that effort.`)
|
|
1392
|
+
else { out.hit = hit; out.used.model = true; target = hit }
|
|
1393
|
+
}
|
|
1394
|
+
if (wantEffort) {
|
|
1395
|
+
if (!target && model != null) { try { target = exactModel(c, String(model)) ?? matchModel(c, model) } catch { target = null } }
|
|
1396
|
+
if (!target && model == null) { const entry = defaultHit(c); target = entry ? { provider: c.default.provider, entry } : null }
|
|
1397
|
+
if (target && efforts(target).includes(pin.reasoning_effort)) { out.reasoning_effort = pin.reasoning_effort; out.used.reasoning_effort = true }
|
|
1398
|
+
else if (target) out.notes.push(`${target.provider}/${target.entry.id} has no reasoning effort ${pin.reasoning_effort} (the hand-over default on ${PAGE}), so it runs with its own default effort.`)
|
|
1399
|
+
}
|
|
1400
|
+
return out
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
// A new session that followed Harness's default: if that default is not the one the last
|
|
1404
|
+
// such hand-over ran on, say so, since nothing else shows it moved. The new default is
|
|
1405
|
+
// recorded only once the message is in (rememberDefault), so a refused send does not use
|
|
1406
|
+
// up the note.
|
|
1407
|
+
function defaultDrift(selected) {
|
|
1408
|
+
const now = selected ? `${selected.provider}/${selected.model}` : null
|
|
1409
|
+
if (!now) return null
|
|
1410
|
+
const saved = loadSettings()
|
|
1411
|
+
if (saved.error) return null
|
|
1412
|
+
const before = filled(saved.data.lastDefaultModel)
|
|
1413
|
+
if (before === now) return null
|
|
1414
|
+
return { now, note: before ? `Harness's default model changed since the last new hand-over (${before} then, ${now} now), so this session runs on ${now}. Picking a model in Harness's model menu changes that default. To keep new hand-overs on one model, choose a hand-over default model on ${PAGE}.` : null }
|
|
1415
|
+
}
|
|
1416
|
+
function rememberDefault(now) {
|
|
1417
|
+
try { writeSettings({ lastDefaultModel: now }) } catch (error) { logError('save last default model', error) }
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
// The plugin page reads and saves the defaults through these.
|
|
1421
|
+
async function handoverView() {
|
|
1422
|
+
const pin = handoverDefaults()
|
|
1423
|
+
const view = { model: pin.model, reasoning_effort: pin.reasoning_effort, approvals: approvalsMode(), ...(pin.unreadable ? { unreadable: pin.unreadable } : {}) }
|
|
1424
|
+
if (!canSelect() || !canKeepDefault()) return { ...view, supported: false }
|
|
1425
|
+
const c = await catalog()
|
|
1426
|
+
return {
|
|
1427
|
+
...view,
|
|
1428
|
+
supported: true,
|
|
1429
|
+
default: shownModel(c.default),
|
|
1430
|
+
models: c.groups.flatMap((g) => g.models.map((m) => ({
|
|
1431
|
+
provider: g.id, provider_name: g.name ?? g.id, model: m.id, name: m.name ?? m.id,
|
|
1432
|
+
reasoning_efforts: (m.reasoning?.efforts ?? []).map((e) => ({ id: e.id, name: e.name ?? e.id })),
|
|
1433
|
+
}))),
|
|
1434
|
+
...(pin.model && !exactModel(c, pin.model) ? { missing: true } : {}),
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
// A field left out of the body keeps its saved value; null clears it. A saved model that
|
|
1438
|
+
// left Harness's list may be kept as it is (the provider may come back), but not chosen anew.
|
|
1439
|
+
async function saveHandover(body) {
|
|
1440
|
+
if ('approvals' in body && !['allow', 'ask'].includes(body.approvals)) throw new Error(`approvals is "allow" or "ask", not ${JSON.stringify(body.approvals)}.`)
|
|
1441
|
+
const touchesModel = 'model' in body || 'reasoning_effort' in body
|
|
1442
|
+
let model = null
|
|
1443
|
+
let reasoning_effort = null
|
|
1444
|
+
if (touchesModel) {
|
|
1445
|
+
const pin = handoverDefaults()
|
|
1446
|
+
model = 'model' in body ? filled(body.model) : pin.model
|
|
1447
|
+
reasoning_effort = 'reasoning_effort' in body ? filled(body.reasoning_effort) : pin.reasoning_effort
|
|
1448
|
+
if (model != null || reasoning_effort != null) {
|
|
1449
|
+
if (!canSelect() || !canKeepDefault()) throw new Error(MODELS_UNSUPPORTED)
|
|
1450
|
+
const c = await catalog()
|
|
1451
|
+
const hit = model != null ? exactModel(c, model) : null
|
|
1452
|
+
if (model != null && !hit && model !== pin.model) throw new Error(`No model ${model} in Harness's model list.`)
|
|
1453
|
+
const allowed = hit ? efforts(hit) : [...new Set(c.groups.flatMap((g) => g.models.flatMap((m) => efforts({ entry: m }))))]
|
|
1454
|
+
if (reasoning_effort != null && !allowed.includes(reasoning_effort)) throw new Error(`No reasoning effort ${reasoning_effort}${hit ? ` for ${model}` : ''}; there is ${allowed.join(', ') || 'none'}.`)
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
// Only what this save names is written. A field it left out is read again now, after the
|
|
1458
|
+
// catalogue wait, so a save from another page in the meantime is not undone.
|
|
1459
|
+
const change = {}
|
|
1460
|
+
if (touchesModel) {
|
|
1461
|
+
const latest = handoverDefaults()
|
|
1462
|
+
change.handover = { model: 'model' in body ? model : latest.model, reasoning_effort: 'reasoning_effort' in body ? reasoning_effort : latest.reasoning_effort }
|
|
1463
|
+
}
|
|
1464
|
+
if ('approvals' in body) change.approvals = body.approvals
|
|
1465
|
+
// A broken file that is replaced: the approvals choice in it is unknown, so the safe one.
|
|
1466
|
+
else if (loadSettings().corrupt) change.approvals = 'ask'
|
|
1467
|
+
writeSettings(change, { replaceBroken: true })
|
|
1468
|
+
return handoverView()
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1146
1471
|
// Put the session on its model before the prompt goes in. Without a plan, a new session
|
|
1147
1472
|
// is pinned to the default as it stands, so a pick running for another send cannot leak
|
|
1148
1473
|
// into it (Harness reads the default only when the first request is built); an existing
|
|
1149
1474
|
// one keeps its own. The pin is best effort: if it fails, the session just uses the default.
|
|
1150
1475
|
async function applyModel(sessionId, plan, isNew) {
|
|
1476
|
+
if (plan?.followDefault) {
|
|
1477
|
+
// Effort alone on a new session: the default as it stands inside the queue, with that effort if it has it.
|
|
1478
|
+
let dropped = null
|
|
1479
|
+
const { selected } = await keepingDefault((kept) => {
|
|
1480
|
+
const entry = plan.catalog.groups.find((g) => g.id === kept?.provider)?.models.find((m) => m.id === kept?.model)
|
|
1481
|
+
const effort = entry && hasEffort({ provider: kept.provider, entry }, plan.reasoningEffort) ? matchEffort({ provider: kept.provider, entry }, plan.reasoningEffort) : null
|
|
1482
|
+
if (!effort) dropped = plan.reasoningEffort
|
|
1483
|
+
return controller.selectModel({ sessionId, ...kept, ...(effort ? { reasoningEffort: effort } : {}) })
|
|
1484
|
+
})
|
|
1485
|
+
return { model: shownModel(selected), source: 'requested', ...(dropped ? { droppedEffort: dropped } : {}) }
|
|
1486
|
+
}
|
|
1151
1487
|
if (plan) {
|
|
1152
|
-
const {
|
|
1488
|
+
const { note: _note, ...pick } = plan // the note is for the reply, not for Harness
|
|
1489
|
+
const { selected } = await keepingDefault(() => controller.selectModel({ sessionId, ...pick }))
|
|
1153
1490
|
return { model: shownModel(selected), source: 'requested' }
|
|
1154
1491
|
}
|
|
1155
1492
|
if (isNew && canSelect() && defaultModel()) {
|
|
@@ -1205,7 +1542,7 @@ export function apply(ctx) {
|
|
|
1205
1542
|
await teamsService.setEnabled(agent, enabled)
|
|
1206
1543
|
}
|
|
1207
1544
|
|
|
1208
|
-
async function send({ message, session_id, cwd, workspace_id, mode: asked, sender, model, reasoning_effort, team }) {
|
|
1545
|
+
async function send({ message, session_id, cwd, workspace_id, conversation_folder, mode: asked, sender, model, reasoning_effort, team }) {
|
|
1209
1546
|
if (!message || !message.trim()) throw new Error('message is required')
|
|
1210
1547
|
if (asked != null && asked !== 'followup' && asked !== 'steer') throw new Error('mode must be followup or steer')
|
|
1211
1548
|
if (team != null && typeof team !== 'boolean') throw new Error('team must be true or false')
|
|
@@ -1218,6 +1555,7 @@ export function apply(ctx) {
|
|
|
1218
1555
|
if (sender != null && !SENDER_RE.test(sender)) throw new Error('sender must be 1-32 characters of a-z, 0-9 or -')
|
|
1219
1556
|
let sessionId = session_id
|
|
1220
1557
|
let workspace = null
|
|
1558
|
+
let workFolder = null
|
|
1221
1559
|
// Harness never runs a prompt sent to an archived session: the run would stay queued forever.
|
|
1222
1560
|
if (sessionId && isArchived(sessionId)) {
|
|
1223
1561
|
throw new Error(`Session ${sessionId} is archived. Unarchive it in Harness, or start a new session with cwd or workspace_id.`)
|
|
@@ -1238,17 +1576,69 @@ export function apply(ctx) {
|
|
|
1238
1576
|
const busy = activeRunsFor(sessionId).length > 0 || (await sessionActivity(sessionId).catch(() => [])).length > 0
|
|
1239
1577
|
if (busy) throw new Error(`No message was sent: the session is busy, and Agent Teams apply to the whole session, so turning them ${team ? 'on' : 'off'} now would change the running turn too. Send it again once the session is idle, or without team.`)
|
|
1240
1578
|
}
|
|
1241
|
-
const plan = await planModel(sessionId, { model, reasoning_effort })
|
|
1242
1579
|
const isNew = !sessionId
|
|
1580
|
+
// A new session takes the plugin page's hand-over defaults for what the send leaves out;
|
|
1581
|
+
// a session that exists keeps its own model.
|
|
1582
|
+
const want = isNew ? await withHandoverDefaults({ model, reasoning_effort }) : { model, reasoning_effort, hit: null, used: {}, notes: [] }
|
|
1583
|
+
const fromPage = () => want.used.model || want.used.reasoning_effort
|
|
1584
|
+
// A send fails only over what it asked for itself: if the plan fails because of a
|
|
1585
|
+
// hand-over default, the send is planned again without the defaults.
|
|
1586
|
+
const dropDefaults = (error, what) => {
|
|
1587
|
+
want.notes.push(`The hand-over defaults on ${PAGE} could not be used (${what}: ${error?.message ?? error}), so this session uses ${model != null ? 'the model asked for' : "Harness's default model"}.`)
|
|
1588
|
+
want.used = { model: false, reasoning_effort: false }
|
|
1589
|
+
want.hit = null
|
|
1590
|
+
}
|
|
1591
|
+
let plan
|
|
1592
|
+
try { plan = await planModel(sessionId, want) } catch (error) {
|
|
1593
|
+
if (!fromPage()) throw error
|
|
1594
|
+
dropDefaults(error, 'planning')
|
|
1595
|
+
plan = await planModel(sessionId, { model, reasoning_effort })
|
|
1596
|
+
}
|
|
1243
1597
|
if (isNew) {
|
|
1244
1598
|
// A folder that is not a workspace yet is registered first, so the new session shows in the sidebar.
|
|
1245
|
-
workspace =
|
|
1599
|
+
if (workspace_id) workspace = { id: workspace_id }
|
|
1600
|
+
else {
|
|
1601
|
+
const target = normalizePath(cwd)
|
|
1602
|
+
// A folder that is a workspace already (sessions from before 0.6.15) keeps it.
|
|
1603
|
+
const own = await registry.resolveByPath(target).catch(() => undefined)
|
|
1604
|
+
const home = own ? { path: target } : sessionHome(target, conversation_folder)
|
|
1605
|
+
workspace = await createWorkspace({ path: home.path, title: home.title, create_dir: false })
|
|
1606
|
+
if (!same(home.path, target)) {
|
|
1607
|
+
workFolder = target
|
|
1608
|
+
// First, not last: a message saying "the current directory" otherwise ran in the parent
|
|
1609
|
+
// (Windows, 2 of 3 runs). A leading /command (/goal) stays first.
|
|
1610
|
+
const note = `(Working folder for this task: ${target}. Run every command there: set each shell command's working directory to ${target}, or cd into it first. "The current directory", "here" and relative paths below all mean ${target}; this session opened in ${home.path}, a folder that contains it.)`
|
|
1611
|
+
// A command such as /goal, not a path such as /Users/me/app/x.js.
|
|
1612
|
+
const slash = /^(\/[A-Za-z][\w-]*)(\s+|$)/.exec(message)
|
|
1613
|
+
message = slash ? `${slash[1]} ${note}\n\n${message.slice(slash[0].length)}` : `${note}\n\n${message}`
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1246
1616
|
sessionId = (await controller.create({ workspaceId: workspace.id })).sessionId
|
|
1247
1617
|
}
|
|
1248
1618
|
// A model that cannot be set fails the send before the prompt goes in.
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1251
|
-
})
|
|
1619
|
+
const notSet = (error) => new Error(`${isNew ? `Session ${sessionId} was created, but no message was sent: ` : 'No message was sent: '}the model could not be set (${error?.message ?? error})`)
|
|
1620
|
+
let chosen
|
|
1621
|
+
try { chosen = await applyModel(sessionId, plan, isNew) } catch (error) {
|
|
1622
|
+
if (!fromPage()) throw notSet(error)
|
|
1623
|
+
// A default Harness would not take (a provider signed out since): the send's own request instead.
|
|
1624
|
+
logError('apply hand-over default', error)
|
|
1625
|
+
dropDefaults(error, 'setting the model')
|
|
1626
|
+
try { chosen = await applyModel(sessionId, await planModel(sessionId, { model, reasoning_effort }), isNew) } catch (again) { throw notSet(again) }
|
|
1627
|
+
}
|
|
1628
|
+
let modelSource = chosen.source
|
|
1629
|
+
if (want.used.model) modelSource = 'handover_default'
|
|
1630
|
+
else if (want.used.reasoning_effort && model == null) modelSource = 'default' // Harness's default model, the effort set on the page
|
|
1631
|
+
const modelNotes = [...want.notes]
|
|
1632
|
+
if (plan?.note) modelNotes.push(plan.note)
|
|
1633
|
+
if (chosen.droppedEffort) modelNotes.push(`${chosen.model?.provider}/${chosen.model?.model} has no reasoning effort ${chosen.droppedEffort}, so it runs with its own default effort.`)
|
|
1634
|
+
let drift = null
|
|
1635
|
+
if (isNew && modelSource === 'default') {
|
|
1636
|
+
let followed = chosen.model
|
|
1637
|
+
if (!followed) try { followed = shownModel(defaultModel()?.currentSelection?.()) } catch { /* unknown */ }
|
|
1638
|
+
drift = defaultDrift(followed)
|
|
1639
|
+
if (drift?.note) modelNotes.push(drift.note)
|
|
1640
|
+
}
|
|
1641
|
+
const pagePart = [...(want.used.model ? ['model'] : []), ...(want.used.reasoning_effort ? ['reasoning_effort'] : [])]
|
|
1252
1642
|
// A session that never picked a model runs on Harness's default.
|
|
1253
1643
|
let provider = chosen.model?.provider
|
|
1254
1644
|
if (!provider) try { provider = defaultModel()?.currentSelection?.()?.provider } catch { /* unknown: no check */ }
|
|
@@ -1278,6 +1668,7 @@ export function apply(ctx) {
|
|
|
1278
1668
|
try {
|
|
1279
1669
|
await controller.prompt({ sessionId, requestId: run.requestId, content: [{ type: 'text', text: message }], mode }, signal())
|
|
1280
1670
|
run.admitted = true // in Harness's queue (or conversation) now
|
|
1671
|
+
if (drift) rememberDefault(drift.now)
|
|
1281
1672
|
} catch (error) {
|
|
1282
1673
|
settle(run, 'failed', { error: String(error?.message ?? error) })
|
|
1283
1674
|
}
|
|
@@ -1286,11 +1677,14 @@ export function apply(ctx) {
|
|
|
1286
1677
|
mode,
|
|
1287
1678
|
mode_source: modeSource,
|
|
1288
1679
|
model: chosen.model,
|
|
1289
|
-
model_source:
|
|
1680
|
+
model_source: modelSource,
|
|
1681
|
+
...(pagePart.length ? { handover_default: pagePart } : {}),
|
|
1682
|
+
...(modelNotes.length ? { model_note: modelNotes.join(' ') } : {}),
|
|
1290
1683
|
...(team != null ? { team } : {}),
|
|
1291
1684
|
...(ahead.length ? { other_active_runs: ahead } : {}),
|
|
1292
1685
|
...(queuedBehind ? { queued_behind: true } : {}),
|
|
1293
1686
|
...(workspace ? { workspace } : {}),
|
|
1687
|
+
...(workFolder ? { work_folder: workFolder } : {}),
|
|
1294
1688
|
}
|
|
1295
1689
|
}
|
|
1296
1690
|
|
|
@@ -1479,6 +1873,65 @@ export function apply(ctx) {
|
|
|
1479
1873
|
}
|
|
1480
1874
|
|
|
1481
1875
|
|
|
1876
|
+
// --- hand-over defaults route -----------------------------------------------
|
|
1877
|
+
// GET /dsh-baton/handover: the saved defaults and Harness's model list, for the plugin page.
|
|
1878
|
+
// POST (JSON): save new ones. Only the plugin page itself may save. Its request carries the
|
|
1879
|
+
// header x-dsh-baton: handover and a JSON body, which a page on another site can only send
|
|
1880
|
+
// after a CORS preflight that this route never answers. The Host must be an address or a
|
|
1881
|
+
// localhost name, never another name, so a site that rebinds its own name to this machine
|
|
1882
|
+
// is refused too. The desktop app's window (dsh-app://app) reaches the web server through a
|
|
1883
|
+
// proxy that drops Origin, so a missing Origin is allowed; one that is there must be the
|
|
1884
|
+
// app's own or match the Host (dsh web in a browser).
|
|
1885
|
+
function localHost(hostname) {
|
|
1886
|
+
const bare = hostname.replace(/^\[|\]$/g, '')
|
|
1887
|
+
return bare === 'localhost' || bare.endsWith('.localhost') || net.isIP(bare) !== 0
|
|
1888
|
+
}
|
|
1889
|
+
// The peer of the connection: on this computer only, whatever the Host says (a Harness web
|
|
1890
|
+
// server bound to the network would otherwise take a save from another machine).
|
|
1891
|
+
const LOOPBACK = /^(?:127\.\d+\.\d+\.\d+|::1|::ffff:127\.\d+\.\d+\.\d+)$/
|
|
1892
|
+
function fromHarnessPage(request) {
|
|
1893
|
+
const headers = request.headers ?? {}
|
|
1894
|
+
const peer = request.socket?.remoteAddress
|
|
1895
|
+
if (peer != null && !LOOPBACK.test(peer)) return false
|
|
1896
|
+
if (headers['x-dsh-baton'] !== 'handover') return false
|
|
1897
|
+
if (!String(headers['content-type'] ?? '').toLowerCase().startsWith('application/json')) return false
|
|
1898
|
+
let host
|
|
1899
|
+
try { host = new URL(`http://${headers.host}`) } catch { return false }
|
|
1900
|
+
if (!localHost(host.hostname)) return false
|
|
1901
|
+
if (headers.origin == null) return true
|
|
1902
|
+
let origin
|
|
1903
|
+
try { origin = new URL(headers.origin) } catch { return false }
|
|
1904
|
+
return origin.protocol === 'dsh-app:' || origin.host === host.host
|
|
1905
|
+
}
|
|
1906
|
+
function readBody(request, limit = 16 * 1024) {
|
|
1907
|
+
return new Promise((resolve, reject) => {
|
|
1908
|
+
const chunks = []
|
|
1909
|
+
let size = 0
|
|
1910
|
+
request.on('data', (chunk) => {
|
|
1911
|
+
size += chunk.length
|
|
1912
|
+
if (size > limit) { reject(new Error('request body too large')); request.destroy() } else chunks.push(chunk)
|
|
1913
|
+
})
|
|
1914
|
+
request.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')))
|
|
1915
|
+
request.on('error', reject)
|
|
1916
|
+
})
|
|
1917
|
+
}
|
|
1918
|
+
function replyJson(response, code, body) {
|
|
1919
|
+
response.writeHead(code, { 'content-type': 'application/json', 'cache-control': 'no-store' })
|
|
1920
|
+
response.end(JSON.stringify(body))
|
|
1921
|
+
}
|
|
1922
|
+
async function serveHandover(request, response) {
|
|
1923
|
+
try {
|
|
1924
|
+
if (request.method === 'GET') return replyJson(response, 200, await handoverView())
|
|
1925
|
+
if (request.method !== 'POST') return replyJson(response, 405, { error: 'GET or POST only' })
|
|
1926
|
+
if (!fromHarnessPage(request)) return replyJson(response, 403, { error: 'These settings can only be saved from the Harness window on this computer.' })
|
|
1927
|
+
const raw = await readBody(request)
|
|
1928
|
+
const body = raw.trim() ? JSON.parse(raw) : {}
|
|
1929
|
+
replyJson(response, 200, await saveHandover(body && typeof body === 'object' && !Array.isArray(body) ? body : {}))
|
|
1930
|
+
} catch (error) {
|
|
1931
|
+
replyJson(response, 400, { error: String(error?.message ?? error) })
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1482
1935
|
// --- MCP registration -----------------------------------------------------
|
|
1483
1936
|
// Switching the plugin on registers the dsh-baton MCP server for Claude Code, Codex and Antigravity,
|
|
1484
1937
|
// the same entries `dsh-baton setup` writes, so adding the plugin is the whole install.
|
|
@@ -1536,6 +1989,15 @@ export function apply(ctx) {
|
|
|
1536
1989
|
response.end(JSON.stringify({ version: VERSION, registration: { state, ok, error, version, runtime, clients: clients.map(({ id, label, state, error, file }) => ({ id, label, state, ...(error === 'bad-json' ? { error, file } : {}) })) } }))
|
|
1537
1990
|
},
|
|
1538
1991
|
}), 'dsh-baton-host status route')
|
|
1992
|
+
web.effect(() => web.webServer.register({
|
|
1993
|
+
kind: 'exact',
|
|
1994
|
+
path: '/dsh-baton/handover',
|
|
1995
|
+
// The promise goes back to the web server, and nothing in the last resort can throw.
|
|
1996
|
+
handler: (request, response) => serveHandover(request, response).catch((error) => {
|
|
1997
|
+
logError('hand-over route', error)
|
|
1998
|
+
try { replyJson(response, 500, { error: String(error?.message ?? error) }) } catch { try { response.destroy() } catch { /* gone */ } }
|
|
1999
|
+
}),
|
|
2000
|
+
}), 'dsh-baton-host hand-over route')
|
|
1539
2001
|
})
|
|
1540
2002
|
}
|
|
1541
2003
|
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-baton-host",
|
|
3
|
-
"version": "0.6.
|
|
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.",
|
|
3
|
+
"version": "0.6.15",
|
|
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",
|
|
7
|
+
"icon": "./icon.svg",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
9
10
|
"default": "./lib/index.js"
|
|
@@ -15,12 +16,15 @@
|
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
17
18
|
"lib",
|
|
19
|
+
"icon.svg",
|
|
18
20
|
"cordis.patch.yml",
|
|
19
21
|
"README.md",
|
|
20
|
-
"LICENSE"
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"locale/*.json",
|
|
24
|
+
"docs"
|
|
21
25
|
],
|
|
22
26
|
"dependencies": {
|
|
23
|
-
"dsh-baton-mcp": "0.6.
|
|
27
|
+
"dsh-baton-mcp": "0.6.15"
|
|
24
28
|
},
|
|
25
29
|
"license": "MIT",
|
|
26
30
|
"dsh": {
|