@seaveyon/harness-switch 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/README.md +5 -3
  2. package/dist/harness-switch.js +555 -93
  3. package/package.json +5 -3
  4. package/public/assets/1044.39aafe87.js +1 -0
  5. package/public/assets/1045.21280f56.js +1 -0
  6. package/public/assets/1050.46b86852.js +1 -0
  7. package/public/assets/1064.d2226313.js +1 -0
  8. package/public/assets/109.d185b844.js +1 -0
  9. package/public/assets/117.fbce1498.js +1 -0
  10. package/public/assets/1216.f58f116a.js +1 -0
  11. package/public/assets/1266.b0b77ece.js +1 -0
  12. package/public/assets/1274.36c97e4b.js +1 -0
  13. package/public/assets/1284.6d1b1fa9.js +1 -0
  14. package/public/assets/1297.5aa40a92.js +1 -0
  15. package/public/assets/1337.91282e33.js +1 -0
  16. package/public/assets/1348.3156645b.js +1 -0
  17. package/public/assets/1446.08d331b6.js +1 -0
  18. package/public/assets/1473.b0f70164.js +1 -0
  19. package/public/assets/1495.98d34a19.js +1 -0
  20. package/public/assets/1498.a7a38ca7.js +1 -0
  21. package/public/assets/1506.50339f62.js +1 -0
  22. package/public/assets/1541.3def363d.js +1 -0
  23. package/public/assets/1558.a7617461.js +1 -0
  24. package/public/assets/1565.2f21c8e1.js +1 -0
  25. package/public/assets/1680.4e882493.js +1 -0
  26. package/public/assets/1706.b445c403.js +1 -0
  27. package/public/assets/1811.132227bb.js +1 -0
  28. package/public/assets/1822.9d44e9b8.js +1 -0
  29. package/public/assets/1852.561dcf77.js +1 -0
  30. package/public/assets/1875.f9da64a1.js +1 -0
  31. package/public/assets/193.86e5680f.js +1 -0
  32. package/public/assets/1942.edb657de.js +1 -0
  33. package/public/assets/197.be0123ad.js +1 -0
  34. package/public/assets/1972.b1548051.js +1 -0
  35. package/public/assets/198.2702464a.js +1 -0
  36. package/public/assets/1981.4e7751ba.js +1 -0
  37. package/public/assets/2048.e0b5be0d.js +1 -0
  38. package/public/assets/2067.6433a4bd.js +1 -0
  39. package/public/assets/2082.b2643ed0.js +1 -0
  40. package/public/assets/2185.248c6b44.js +1 -0
  41. package/public/assets/2202.e80e4d18.js +1 -0
  42. package/public/assets/2227.cf7e7a88.js +1 -0
  43. package/public/assets/2234.f03ed50e.js +1 -0
  44. package/public/assets/2247.8cd63431.js +1 -0
  45. package/public/assets/2301.5b08aa31.js +1 -0
  46. package/public/assets/231.073ec786.js +1 -0
  47. package/public/assets/233.9eea8428.js +1 -0
  48. package/public/assets/2332.bec77738.js +1 -0
  49. package/public/assets/234.e1ec501c.js +1 -0
  50. package/public/assets/2368.6d60e76e.js +1 -0
  51. package/public/assets/2378.a09f27ac.js +1 -0
  52. package/public/assets/2411.1a1e84d8.js +1 -0
  53. package/public/assets/2426.12abe760.js +1 -0
  54. package/public/assets/2536.d03279a1.js +1 -0
  55. package/public/assets/2605.3ae8a730.js +1 -0
  56. package/public/assets/2645.52e9596b.js +1 -0
  57. package/public/assets/2707.6df3e122.js +1 -0
  58. package/public/assets/2725.9a21dc87.js +1 -0
  59. package/public/assets/2743.d8ff9d1a.js +1 -0
  60. package/public/assets/2748.a74a539c.js +1 -0
  61. package/public/assets/2751.3761b15d.js +1 -0
  62. package/public/assets/278.06c0a585.js +1 -0
  63. package/public/assets/2810.0805c8d3.js +1 -0
  64. package/public/assets/2816.52f328bf.js +1 -0
  65. package/public/assets/2872.712f11ad.js +1 -0
  66. package/public/assets/2881.812773b3.js +1 -0
  67. package/public/assets/2895.412a0fef.js +1 -0
  68. package/public/assets/2918.ca9f8ee6.js +1 -0
  69. package/public/assets/2948.812bfd61.js +1 -0
  70. package/public/assets/3008.0e0072bf.js +1 -0
  71. package/public/assets/3084.812f46dd.js +1 -0
  72. package/public/assets/311.ff658c78.js +1 -0
  73. package/public/assets/3115.de6d897d.js +1 -0
  74. package/public/assets/312.6893cc70.js +1 -0
  75. package/public/assets/3121.abf15015.js +1 -0
  76. package/public/assets/3123.bb6961b4.js +1 -0
  77. package/public/assets/3168.f70fdbe1.js +1 -0
  78. package/public/assets/3260.b9830b0a.js +1 -0
  79. package/public/assets/331.5979e79c.js +1 -0
  80. package/public/assets/3323.33607bff.js +1 -0
  81. package/public/assets/333.62f29c23.js +1 -0
  82. package/public/assets/3339.55ba3289.js +1 -0
  83. package/public/assets/3370.ac044cd4.js +1 -0
  84. package/public/assets/3381.ebf520a0.js +1 -0
  85. package/public/assets/3384.97088998.js +1 -0
  86. package/public/assets/3420.d26395e2.js +1 -0
  87. package/public/assets/3432.9a6cbc9d.js +1 -0
  88. package/public/assets/3474.c3b0a117.js +1 -0
  89. package/public/assets/3502.713d8997.js +1 -0
  90. package/public/assets/3520.8332b3b9.js +1 -0
  91. package/public/assets/3663.7e96a229.js +1 -0
  92. package/public/assets/3707.9a1cc57e.js +1 -0
  93. package/public/assets/3712.ccdacc8b.js +1 -0
  94. package/public/assets/3724.c7124c16.js +1 -0
  95. package/public/assets/379.3eba2174.js +1 -0
  96. package/public/assets/3793.2f8f8fa2.js +1 -0
  97. package/public/assets/3808.61543a59.js +1 -0
  98. package/public/assets/3809.ea90d219.js +1 -0
  99. package/public/assets/382.df49ab73.js +1 -0
  100. package/public/assets/3844.ad345570.js +1 -0
  101. package/public/assets/3853.0041121c.js +1 -0
  102. package/public/assets/3886.4758be08.js +1 -0
  103. package/public/assets/3911.67d83e56.js +1 -0
  104. package/public/assets/3945.02b410f7.js +1 -0
  105. package/public/assets/4025.faefbdf9.js +1 -0
  106. package/public/assets/4049.274b3781.js +1 -0
  107. package/public/assets/4058.9bd8b6fd.js +1 -0
  108. package/public/assets/4087.f5f2aa77.js +1 -0
  109. package/public/assets/4145.591efba1.js +1 -0
  110. package/public/assets/4179.0e70c02d.js +1 -0
  111. package/public/assets/4261.24d2c946.js +1 -0
  112. package/public/assets/4301.d36b09ac.js +1 -0
  113. package/public/assets/438.c9ddabb1.js +1 -0
  114. package/public/assets/4405.195b8807.js +1 -0
  115. package/public/assets/4429.20a43aee.js +1 -0
  116. package/public/assets/4445.0593f53c.js +1 -0
  117. package/public/assets/4447.1f4c2594.js +1 -0
  118. package/public/assets/4458.b54836f5.js +1 -0
  119. package/public/assets/4489.e05c3f02.js +1 -0
  120. package/public/assets/4496.59f9e494.js +1 -0
  121. package/public/assets/4498.53895790.js +1 -0
  122. package/public/assets/452.bf34842d.js +1 -0
  123. package/public/assets/4525.202e71f0.js +1 -0
  124. package/public/assets/459.d0de752e.js +1 -0
  125. package/public/assets/4609.539adc7e.js +1 -0
  126. package/public/assets/4613.2c9412fc.js +1 -0
  127. package/public/assets/465.6d0c9900.js +1 -0
  128. package/public/assets/4655.817d8c16.js +1 -0
  129. package/public/assets/4704.5bd5cd1f.js +1 -0
  130. package/public/assets/4705.1b7400d1.js +1 -0
  131. package/public/assets/4785.2c122907.js +1 -0
  132. package/public/assets/4795.5b28b5a2.js +1 -0
  133. package/public/assets/4796.38fc127d.js +1 -0
  134. package/public/assets/4798.061be689.js +1 -0
  135. package/public/assets/4846.2f6655eb.js +1 -0
  136. package/public/assets/485.3fe4cb47.js +1 -0
  137. package/public/assets/4885.c0812b9f.js +1 -0
  138. package/public/assets/4952.5b132c3d.js +1 -0
  139. package/public/assets/4983.565b5198.js +1 -0
  140. package/public/assets/4992.abfa216e.js +1 -0
  141. package/public/assets/4994.5eac32c7.js +1 -0
  142. package/public/assets/4996.46cad67b.js +1 -0
  143. package/public/assets/5068.3fa2fa23.js +1 -0
  144. package/public/assets/5072.7adfff93.js +1 -0
  145. package/public/assets/5108.62165adf.js +1 -0
  146. package/public/assets/5280.bc09c97b.js +1 -0
  147. package/public/assets/5281.73e94011.js +1 -0
  148. package/public/assets/5294.b2f2f0bd.js +1 -0
  149. package/public/assets/5319.e6dcabf9.js +1 -0
  150. package/public/assets/5393.e6c80ec4.js +1 -0
  151. package/public/assets/5398.d0384b7e.js +1 -0
  152. package/public/assets/5415.c896e0e1.js +1 -0
  153. package/public/assets/544.64addbc4.js +1 -0
  154. package/public/assets/5453.08deb63c.js +1 -0
  155. package/public/assets/5458.0095414b.js +1 -0
  156. package/public/assets/5462.17536a21.js +1 -0
  157. package/public/assets/5466.7acd94a7.js +1 -0
  158. package/public/assets/5518.57996485.js +1 -0
  159. package/public/assets/5530.828452d4.js +1 -0
  160. package/public/assets/5542.9162530c.js +1 -0
  161. package/public/assets/5593.0776f2d3.js +1 -0
  162. package/public/assets/5596.8a7ddea5.js +1 -0
  163. package/public/assets/5631.f6c57eaf.js +1 -0
  164. package/public/assets/5646.a72b2c1e.js +1 -0
  165. package/public/assets/5661.164c0709.js +1 -0
  166. package/public/assets/5678.c096f6c9.js +1 -0
  167. package/public/assets/5687.587f0e75.js +1 -0
  168. package/public/assets/5703.5e666028.js +1 -0
  169. package/public/assets/5708.164057e0.js +1 -0
  170. package/public/assets/5712.cc503220.js +1 -0
  171. package/public/assets/575.e898fd86.js +1 -0
  172. package/public/assets/5752.e018032d.js +1 -0
  173. package/public/assets/5813.cc59df28.js +1 -0
  174. package/public/assets/5865.012fa536.js +1 -0
  175. package/public/assets/5879.47b8e3c2.js +1 -0
  176. package/public/assets/590.8c02fbf9.js +1 -0
  177. package/public/assets/5917.87e0acee.js +1 -0
  178. package/public/assets/5959.c0de70a1.js +1 -0
  179. package/public/assets/5970.31600f7b.js +1 -0
  180. package/public/assets/6005.fb7dbdae.js +1 -0
  181. package/public/assets/6024.c3f22f35.js +1 -0
  182. package/public/assets/6070.6f66b5fa.js +1 -0
  183. package/public/assets/6084.26b44499.js +1 -0
  184. package/public/assets/6085.cb855236.js +1 -0
  185. package/public/assets/6093.bebbe3da.js +1 -0
  186. package/public/assets/6106.39b87fca.js +1 -0
  187. package/public/assets/6122.f064356d.js +1 -0
  188. package/public/assets/6150.910aaed9.js +203 -0
  189. package/public/assets/6157.7eeb3515.js +1 -0
  190. package/public/assets/616.a5acd2aa.js +1 -0
  191. package/public/assets/6226.dd8f1fd9.js +1 -0
  192. package/public/assets/6231.c10ba8f9.js +1 -0
  193. package/public/assets/6254.69f98e64.js +1 -0
  194. package/public/assets/6308.9f7b0778.js +1 -0
  195. package/public/assets/6309.fd92f229.js +1 -0
  196. package/public/assets/6378.d0087d79.js +1 -0
  197. package/public/assets/6380.6a320a57.js +1 -0
  198. package/public/assets/6427.80120ca0.js +1 -0
  199. package/public/assets/6468.cd796686.js +1 -0
  200. package/public/assets/655.2424b6f0.js +1 -0
  201. package/public/assets/6551.1316a8b4.js +1 -0
  202. package/public/assets/6563.f0ab8ea9.js +1 -0
  203. package/public/assets/658.d1870bbc.js +1 -0
  204. package/public/assets/659.43d1bd18.js +1 -0
  205. package/public/assets/6629.d5835f7b.js +1 -0
  206. package/public/assets/670.cc579966.js +1 -0
  207. package/public/assets/6729.711b6a33.js +1 -0
  208. package/public/assets/6739.5df85504.js +1 -0
  209. package/public/assets/6766.b3b93d6b.js +1 -0
  210. package/public/assets/6781.8330074c.js +1 -0
  211. package/public/assets/6829.f83cf943.js +1 -0
  212. package/public/assets/6855.c3b857c6.js +1 -0
  213. package/public/assets/6883.55fcdbea.js +1 -0
  214. package/public/assets/6900.abab0925.js +1 -0
  215. package/public/assets/6956.8307b311.js +1 -0
  216. package/public/assets/6959.7c488de5.js +1 -0
  217. package/public/assets/698.ebc84dc0.js +1 -0
  218. package/public/assets/7015.a05d0b78.js +1 -0
  219. package/public/assets/702.98bd9103.js +1 -0
  220. package/public/assets/703.285f3139.js +1 -0
  221. package/public/assets/7091.027a641c.js +1 -0
  222. package/public/assets/7104.9c59e320.js +1 -0
  223. package/public/assets/7113.0dfbe544.js +1 -0
  224. package/public/assets/7135.e9ab3841.js +1 -0
  225. package/public/assets/7143.612c372b.js +1 -0
  226. package/public/assets/7198.dc23f6fa.js +1 -0
  227. package/public/assets/7228.5b31dd65.js +1 -0
  228. package/public/assets/7234.bec30557.js +1 -0
  229. package/public/assets/7330.b15282a7.js +1 -0
  230. package/public/assets/7342.6f18177c.js +1 -0
  231. package/public/assets/7350.e46146b3.js +1 -0
  232. package/public/assets/7372.863b3f51.js +1 -0
  233. package/public/assets/7387.78fae2d9.js +1 -0
  234. package/public/assets/7403.acdec0cd.js +1 -0
  235. package/public/assets/7404.c90b9555.js +1 -0
  236. package/public/assets/7454.61df5c53.js +1 -0
  237. package/public/assets/7459.91247a0c.js +1 -0
  238. package/public/assets/7620.1317e4da.js +1 -0
  239. package/public/assets/7655.a8e05941.js +1 -0
  240. package/public/assets/7662.5c5fd466.js +1 -0
  241. package/public/assets/7698.68eab02c.js +1 -0
  242. package/public/assets/7714.6a6656ee.js +1 -0
  243. package/public/assets/7774.b546561d.js +1 -0
  244. package/public/assets/7822.264595e9.js +1 -0
  245. package/public/assets/7827.9a988ed6.js +1 -0
  246. package/public/assets/7858.565180cd.js +1 -0
  247. package/public/assets/7880.23c4af6f.js +1 -0
  248. package/public/assets/7921.796cf6f2.js +1 -0
  249. package/public/assets/7950.9222be47.js +1 -0
  250. package/public/assets/7992.1bbe27a2.js +1 -0
  251. package/public/assets/7993.3e415bcd.js +1 -0
  252. package/public/assets/8012.1df6c7ba.js +1 -0
  253. package/public/assets/8014.1618a26d.js +1 -0
  254. package/public/assets/8095.3b776dc1.js +1 -0
  255. package/public/assets/8115.01697474.js +1 -0
  256. package/public/assets/8134.2dbefad3.js +1 -0
  257. package/public/assets/8173.98e9cda8.js +1 -0
  258. package/public/assets/8178.4448a8c8.js +1 -0
  259. package/public/assets/8189.726f5bba.js +1 -0
  260. package/public/assets/8250.6a31d3db.js +1 -0
  261. package/public/assets/8252.46abb10d.js +1 -0
  262. package/public/assets/826.55f3327b.js +1 -0
  263. package/public/assets/8286.7165c5ae.js +1 -0
  264. package/public/assets/829.57aaa21f.js +1 -0
  265. package/public/assets/8295.510e74b2.js +1 -0
  266. package/public/assets/8306.ffe7fef6.js +1 -0
  267. package/public/assets/8336.071bb524.js +1 -0
  268. package/public/assets/8346.cfd200d8.js +1 -0
  269. package/public/assets/8349.8746a8e4.js +1 -0
  270. package/public/assets/8375.0bf25482.js +1 -0
  271. package/public/assets/8387.7849a364.js +1 -0
  272. package/public/assets/8408.7b3b0706.js +1 -0
  273. package/public/assets/8423.da4adde4.js +1 -0
  274. package/public/assets/8437.67cbb62b.js +1 -0
  275. package/public/assets/8439.4ab411cf.js +1 -0
  276. package/public/assets/8447.805e1fbb.js +1 -0
  277. package/public/assets/8481.30bb3786.js +1 -0
  278. package/public/assets/8531.0e8a1bcd.js +1 -0
  279. package/public/assets/855.c45d80d8.js +1 -0
  280. package/public/assets/857.47395203.js +1 -0
  281. package/public/assets/8601.e90cd434.js +1 -0
  282. package/public/assets/8671.f9b853f6.js +1 -0
  283. package/public/assets/8696.2db4dd40.js +1 -0
  284. package/public/assets/8698.d8c25bfd.js +1 -0
  285. package/public/assets/8725.2a97b2e0.js +1 -0
  286. package/public/assets/8767.f7dbaf81.js +1 -0
  287. package/public/assets/877.0d1df971.js +1 -0
  288. package/public/assets/8799.b2bc36a0.js +1 -0
  289. package/public/assets/8805.e166d436.js +1 -0
  290. package/public/assets/8861.8e37cb89.js +1 -0
  291. package/public/assets/8943.d35181ef.js +1 -0
  292. package/public/assets/9020.b1614bfe.js +1 -0
  293. package/public/assets/9048.8a6be463.js +1 -0
  294. package/public/assets/9060.f88d7ff2.js +1 -0
  295. package/public/assets/9109.e2cef4ae.js +1 -0
  296. package/public/assets/9120.0baa1b3f.js +1 -0
  297. package/public/assets/9172.9b1d2d6a.js +1 -0
  298. package/public/assets/920.5f971a4e.js +1 -0
  299. package/public/assets/9279.7ff451d0.js +1 -0
  300. package/public/assets/9285.c26079c7.js +1 -0
  301. package/public/assets/9297.7162de0e.js +1 -0
  302. package/public/assets/9328.a33ba701.js +1 -0
  303. package/public/assets/940.5806c487.js +1 -0
  304. package/public/assets/9403.d4200316.js +1 -0
  305. package/public/assets/9412.5849ed28.js +1 -0
  306. package/public/assets/9420.c4e70fab.js +1 -0
  307. package/public/assets/9467.1a7a6c92.js +1 -0
  308. package/public/assets/9502.c84dc29b.js +1 -0
  309. package/public/assets/9556.97e5f142.js +1 -0
  310. package/public/assets/9557.b10d5e41.js +1 -0
  311. package/public/assets/9597.c517cbfd.js +1 -0
  312. package/public/assets/96.fdb82714.js +1 -0
  313. package/public/assets/9619.35683308.js +1 -0
  314. package/public/assets/9623.437474fc.js +1 -0
  315. package/public/assets/9663.1210b76e.js +1 -0
  316. package/public/assets/9671.40a11985.js +1 -0
  317. package/public/assets/969.ce9121b3.js +1 -0
  318. package/public/assets/9695.84356bbf.js +1 -0
  319. package/public/assets/9728.4f98e0ce.js +1 -0
  320. package/public/assets/9770.df634bdf.js +1 -0
  321. package/public/assets/9842.6faee06c.js +1 -0
  322. package/public/assets/9886.1c62a8ff.js +1 -0
  323. package/public/assets/9888.e3c97777.js +1 -0
  324. package/public/assets/9918.7ac5f09c.js +1 -0
  325. package/public/assets/9927.89711a15.js +1 -0
  326. package/public/assets/9940.70581af3.js +1 -0
  327. package/public/assets/9990.cf02a3de.js +1 -0
  328. package/public/assets/main.9128def8.css +2 -0
  329. package/public/assets/main.95434834.js +1 -0
  330. package/public/index.html +1 -1
  331. package/public/assets/main.2d5005c9.css +0 -2
  332. package/public/assets/main.7928dbbb.js +0 -1
@@ -7015,7 +7015,7 @@ var require_public_api = __commonJS((exports) => {
7015
7015
 
7016
7016
  // src/app.ts
7017
7017
  import { existsSync as existsSync3 } from "fs";
7018
- import { join as join8 } from "path";
7018
+ import { join as join9 } from "path";
7019
7019
 
7020
7020
  // ../../node_modules/hono/dist/compose.js
7021
7021
  var compose = (middleware, onError, onNotFound) => {
@@ -9210,7 +9210,8 @@ class EnvironmentService {
9210
9210
  claude: join2(this.homeDir, ".claude"),
9211
9211
  codex: process.env.CODEX_HOME || join2(this.homeDir, ".codex"),
9212
9212
  kimiCode: process.env.KIMI_CODE_HOME || join2(this.homeDir, ".kimi-code"),
9213
- piAgent: process.env.PI_CODING_AGENT_DIR || join2(this.homeDir, ".omp", "agent")
9213
+ piAgent: process.env.PI_CODING_AGENT_DIR || join2(this.homeDir, ".pi", "agent"),
9214
+ dsh: process.env.DSH_HOME || join2(this.homeDir, ".dsh")
9214
9215
  };
9215
9216
  ensureDataDir() {
9216
9217
  mkdirSync(this.dataDir, { recursive: true, mode: 448 });
@@ -9573,23 +9574,42 @@ class BackupService {
9573
9574
  return id;
9574
9575
  }
9575
9576
  list() {
9576
- return this.readManifests().map((manifest) => ({
9577
+ const liveCache = new Map;
9578
+ const readLive = (path) => {
9579
+ if (!liveCache.has(path)) {
9580
+ liveCache.set(path, this.files.readOptional(path) ?? null);
9581
+ }
9582
+ return liveCache.get(path) ?? null;
9583
+ };
9584
+ return this.readManifests().map((manifest) => {
9585
+ const dir = join3(this.environment.backupsDir, manifest.id);
9586
+ return {
9587
+ id: manifest.id,
9588
+ createdAt: manifest.createdAt,
9589
+ harness: manifest.harness,
9590
+ profile: manifest.profile,
9591
+ files: manifest.files.map((file) => ({ path: file.path, existed: file.existed })),
9592
+ current: this.matchesLive(dir, manifest.files, readLive)
9593
+ };
9594
+ }).toSorted((left, right) => right.id.localeCompare(left.id));
9595
+ }
9596
+ detail(id) {
9597
+ const { dir, manifest } = this.requireManifest(id);
9598
+ return {
9577
9599
  id: manifest.id,
9578
9600
  createdAt: manifest.createdAt,
9579
9601
  harness: manifest.harness,
9580
9602
  profile: manifest.profile,
9581
- files: manifest.files.map((file) => ({ path: file.path, existed: file.existed }))
9582
- })).toSorted((left, right) => right.id.localeCompare(left.id));
9603
+ files: manifest.files.map((file) => ({
9604
+ path: file.path,
9605
+ existed: file.existed,
9606
+ content: this.storedContent(dir, file),
9607
+ currentContent: this.files.readOptional(file.path) ?? null
9608
+ }))
9609
+ };
9583
9610
  }
9584
9611
  restore(id) {
9585
- if (id.includes("/") || id.includes("\\") || id.includes("..")) {
9586
- throw new HttpError(400, "invalid backup id");
9587
- }
9588
- const dir = join3(this.environment.backupsDir, id);
9589
- const manifest = this.files.readJson(join3(dir, MANIFEST), null);
9590
- if (!manifest) {
9591
- throw new HttpError(404, "backup not found");
9592
- }
9612
+ const { dir, manifest } = this.requireManifest(id);
9593
9613
  for (const file of manifest.files) {
9594
9614
  if (!file.existed || !file.stored) {
9595
9615
  this.files.remove(file.path);
@@ -9602,6 +9622,30 @@ class BackupService {
9602
9622
  this.files.writeUserFile(file.path, content);
9603
9623
  }
9604
9624
  }
9625
+ requireManifest(id) {
9626
+ if (id.includes("/") || id.includes("\\") || id.includes("..")) {
9627
+ throw new HttpError(400, "invalid backup id");
9628
+ }
9629
+ const dir = join3(this.environment.backupsDir, id);
9630
+ const manifest = this.files.readJson(join3(dir, MANIFEST), null);
9631
+ if (!manifest) {
9632
+ throw new HttpError(404, "backup not found");
9633
+ }
9634
+ return { dir, manifest };
9635
+ }
9636
+ matchesLive(dir, files, readLive) {
9637
+ return files.every((file) => this.storedContent(dir, file) === readLive(file.path));
9638
+ }
9639
+ storedContent(dir, file) {
9640
+ if (!file.existed || !file.stored) {
9641
+ return null;
9642
+ }
9643
+ const content = this.files.readOptional(join3(dir, file.stored));
9644
+ if (content === undefined) {
9645
+ throw new HttpError(500, `backup payload missing for ${file.path}`);
9646
+ }
9647
+ return content;
9648
+ }
9605
9649
  readManifests() {
9606
9650
  return this.files.listDirectories(this.environment.backupsDir).map((name) => this.files.readJson(join3(this.environment.backupsDir, name, MANIFEST), null)).filter((manifest) => manifest !== null);
9607
9651
  }
@@ -9635,6 +9679,7 @@ function createBackupRoutes(services) {
9635
9679
  const app = new Hono2;
9636
9680
  const backups = services.get(IBackupService);
9637
9681
  app.get("/", (c) => c.json({ items: backups.list() }));
9682
+ app.get("/:id", (c) => c.json(backups.detail(decodeURIComponent(c.req.param("id")))));
9638
9683
  app.post("/:id/restore", (c) => {
9639
9684
  backups.restore(decodeURIComponent(c.req.param("id")));
9640
9685
  return c.json({ ok: true });
@@ -10806,12 +10851,24 @@ var SETTINGS = "settings";
10806
10851
  var BASE_URL_VAR = "ANTHROPIC_BASE_URL";
10807
10852
  var MODEL_VAR = "ANTHROPIC_MODEL";
10808
10853
  var AUTH_VARS = ["ANTHROPIC_AUTH_TOKEN", "ANTHROPIC_API_KEY"];
10854
+ var MODEL_MAPPINGS = [
10855
+ ["haikuModel", "ANTHROPIC_DEFAULT_HAIKU_MODEL"],
10856
+ ["sonnetModel", "ANTHROPIC_DEFAULT_SONNET_MODEL"],
10857
+ ["opusModel", "ANTHROPIC_DEFAULT_OPUS_MODEL"],
10858
+ ["fableModel", "ANTHROPIC_DEFAULT_FABLE_MODEL"],
10859
+ ["subagentModel", "CLAUDE_CODE_SUBAGENT_MODEL"]
10860
+ ];
10809
10861
 
10810
10862
  class ClaudeAdapter {
10811
10863
  environment;
10812
10864
  id = "claude";
10813
10865
  mode = "replace";
10814
- envVarNames = [BASE_URL_VAR, ...AUTH_VARS, MODEL_VAR];
10866
+ envVarNames = [
10867
+ BASE_URL_VAR,
10868
+ ...AUTH_VARS,
10869
+ MODEL_VAR,
10870
+ ...MODEL_MAPPINGS.map(([, envVar]) => envVar)
10871
+ ];
10815
10872
  fields = [
10816
10873
  {
10817
10874
  key: "authVar",
@@ -10824,6 +10881,41 @@ class ClaudeAdapter {
10824
10881
  { value: "ANTHROPIC_API_KEY", label: "ANTHROPIC_API_KEY\uFF08\u5B98\u65B9\uFF09" }
10825
10882
  ]
10826
10883
  },
10884
+ {
10885
+ key: "haikuModel",
10886
+ label: "Haiku \u6A21\u578B\u6620\u5C04",
10887
+ kind: "text",
10888
+ placeholder: "\u4F8B\u5982\uFF1Aglm-5-air",
10889
+ help: "\u5199\u5165 ANTHROPIC_DEFAULT_HAIKU_MODEL\uFF1B\u7559\u7A7A\u4F7F\u7528\u56DE\u9000\u6A21\u578B\u6216 Claude Code \u9ED8\u8BA4\u503C\u3002"
10890
+ },
10891
+ {
10892
+ key: "sonnetModel",
10893
+ label: "Sonnet \u6A21\u578B\u6620\u5C04",
10894
+ kind: "text",
10895
+ placeholder: "\u4F8B\u5982\uFF1Aglm-5",
10896
+ help: "\u5199\u5165 ANTHROPIC_DEFAULT_SONNET_MODEL\u3002"
10897
+ },
10898
+ {
10899
+ key: "opusModel",
10900
+ label: "Opus \u6A21\u578B\u6620\u5C04",
10901
+ kind: "text",
10902
+ placeholder: "\u4F8B\u5982\uFF1Aglm-5",
10903
+ help: "\u5199\u5165 ANTHROPIC_DEFAULT_OPUS_MODEL\u3002"
10904
+ },
10905
+ {
10906
+ key: "fableModel",
10907
+ label: "Fable \u6A21\u578B\u6620\u5C04\uFF08\u53EF\u9009\uFF09",
10908
+ kind: "text",
10909
+ placeholder: "\u4F8B\u5982\uFF1Aglm-5",
10910
+ help: "\u5199\u5165 ANTHROPIC_DEFAULT_FABLE_MODEL\uFF1B\u7528\u4E8E\u652F\u6301 Fable \u6863\u4F4D\u7684\u65B0\u7248 Claude Code\u3002"
10911
+ },
10912
+ {
10913
+ key: "subagentModel",
10914
+ label: "\u5B50\u4EE3\u7406\u6A21\u578B\uFF08\u53EF\u9009\uFF09",
10915
+ kind: "text",
10916
+ placeholder: "\u4F8B\u5982\uFF1Aglm-5-air",
10917
+ help: "\u5199\u5165 CLAUDE_CODE_SUBAGENT_MODEL\uFF0C\u53EF\u8BA9\u5B50\u4EE3\u7406\u4F7F\u7528\u66F4\u5FEB\u6216\u6210\u672C\u66F4\u4F4E\u7684\u6A21\u578B\u3002"
10918
+ },
10827
10919
  {
10828
10920
  key: "extraEnv",
10829
10921
  label: "\u8FFD\u52A0\u73AF\u5883\u53D8\u91CF\uFF08\u53EF\u9009\uFF09",
@@ -10852,6 +10944,11 @@ API_TIMEOUT_MS=3000000`,
10852
10944
  if (profile.model) {
10853
10945
  vars[MODEL_VAR] = profile.model;
10854
10946
  }
10947
+ for (const [field, envVar] of MODEL_MAPPINGS) {
10948
+ if (profile.extras[field]) {
10949
+ vars[envVar] = profile.extras[field];
10950
+ }
10951
+ }
10855
10952
  return vars;
10856
10953
  }
10857
10954
  render(profile, current) {
@@ -10870,11 +10967,38 @@ API_TIMEOUT_MS=3000000`,
10870
10967
  } else {
10871
10968
  delete env[MODEL_VAR];
10872
10969
  }
10970
+ for (const [field, envVar] of MODEL_MAPPINGS) {
10971
+ const value = profile.extras[field]?.trim();
10972
+ if (value) {
10973
+ env[envVar] = value;
10974
+ } else {
10975
+ delete env[envVar];
10976
+ }
10977
+ }
10873
10978
  for (const [key, value] of parseEnvLines(profile.extras.extraEnv)) {
10874
10979
  env[key] = value;
10875
10980
  }
10876
10981
  return { [SETTINGS]: stringifyJson(settings) };
10877
10982
  }
10983
+ renderOfficial(profile, current) {
10984
+ const settings = parseJsonObject(current[SETTINGS]);
10985
+ const env = ensureObject(settings, "env");
10986
+ delete env[BASE_URL_VAR];
10987
+ delete env[MODEL_VAR];
10988
+ for (const authVar of AUTH_VARS) {
10989
+ delete env[authVar];
10990
+ }
10991
+ for (const [, envVar] of MODEL_MAPPINGS) {
10992
+ delete env[envVar];
10993
+ }
10994
+ for (const [key] of parseEnvLines(profile?.extras.extraEnv)) {
10995
+ delete env[key];
10996
+ }
10997
+ if (Object.keys(env).length === 0) {
10998
+ delete settings.env;
10999
+ }
11000
+ return { [SETTINGS]: stringifyJson(settings) };
11001
+ }
10878
11002
  backfill(profile, current) {
10879
11003
  const settings = safeParse(current[SETTINGS]);
10880
11004
  const env = settings.env;
@@ -10883,7 +11007,11 @@ API_TIMEOUT_MS=3000000`,
10883
11007
  return {
10884
11008
  baseUrl: readString(env, BASE_URL_VAR) || profile.baseUrl,
10885
11009
  model: readString(env, MODEL_VAR),
10886
- apiKey: apiKey || profile.apiKey
11010
+ apiKey: apiKey || profile.apiKey,
11011
+ extras: {
11012
+ ...profile.extras,
11013
+ ...Object.fromEntries(MODEL_MAPPINGS.map(([field, envVar]) => [field, readString(env, envVar)]))
11014
+ }
10887
11015
  };
10888
11016
  }
10889
11017
  authVar(profile) {
@@ -11038,6 +11166,31 @@ class CodexAdapter {
11038
11166
  }
11039
11167
  return rendered;
11040
11168
  }
11169
+ renderOfficial(profile, current) {
11170
+ const config = parseTomlObject(current[CONFIG]);
11171
+ const activeProviderId = readString(config, "model_provider");
11172
+ delete config.model_provider;
11173
+ delete config.model;
11174
+ delete config.model_reasoning_effort;
11175
+ if (isPlainObject(config.model_providers)) {
11176
+ if (profile) {
11177
+ delete config.model_providers[this.providerId(profile)];
11178
+ }
11179
+ if (activeProviderId) {
11180
+ delete config.model_providers[activeProviderId];
11181
+ }
11182
+ if (Object.keys(config.model_providers).length === 0) {
11183
+ delete config.model_providers;
11184
+ }
11185
+ }
11186
+ const rendered = { [CONFIG]: stringifyToml(config) };
11187
+ if (profile && this.authMode(profile) === "openai_auth") {
11188
+ const auth = parseJsonObject(current[AUTH]);
11189
+ delete auth[DEFAULT_ENV_KEY];
11190
+ rendered[AUTH] = stringifyJson(auth);
11191
+ }
11192
+ return rendered;
11193
+ }
11041
11194
  backfill(profile, current) {
11042
11195
  let config = {};
11043
11196
  try {
@@ -11075,10 +11228,218 @@ function safeJson(text) {
11075
11228
  }
11076
11229
  }
11077
11230
 
11078
- // src/services/adapters/kimi.ts
11231
+ // src/services/adapters/dsh.ts
11079
11232
  import { join as join6 } from "path";
11080
- var CONFIG2 = "config";
11233
+ var SETTINGS2 = "settings";
11234
+ var CREDENTIALS = "credentials";
11081
11235
  var DEFAULT_CONTEXT = 262144;
11236
+ var DEFAULT_MAX_TOKENS = 32768;
11237
+
11238
+ class DshAdapter {
11239
+ environment;
11240
+ id = "dsh";
11241
+ mode = "additive";
11242
+ envVarNames = [];
11243
+ envNote = "API key \u5B89\u5168\u5199\u5165 DSH \u7684 .credentials.yaml\uFF0C\u5E76\u7531 settings.yaml \u5F15\u7528\u3002";
11244
+ fields = [
11245
+ {
11246
+ key: "providerId",
11247
+ label: "Provider ID\uFF08\u53EF\u9009\uFF09",
11248
+ kind: "text",
11249
+ placeholder: "\u9ED8\u8BA4\u53D6\u914D\u7F6E\u540D\u79F0",
11250
+ help: "DSH \u7684\u6A21\u578B\u8DEF\u7531\u6807\u8BC6\uFF1B\u5FC5\u987B\u4EE5\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\u3002"
11251
+ },
11252
+ {
11253
+ key: "api",
11254
+ label: "API \u534F\u8BAE",
11255
+ kind: "select",
11256
+ defaultValue: "openai-responses",
11257
+ options: [
11258
+ { value: "openai-responses", label: "openai-responses" },
11259
+ { value: "openai-completions", label: "openai-completions" },
11260
+ { value: "anthropic-messages", label: "anthropic-messages" }
11261
+ ]
11262
+ },
11263
+ {
11264
+ key: "contextWindow",
11265
+ label: "\u4E0A\u4E0B\u6587\u957F\u5EA6",
11266
+ kind: "text",
11267
+ defaultValue: String(DEFAULT_CONTEXT)
11268
+ },
11269
+ {
11270
+ key: "maxTokens",
11271
+ label: "\u6700\u5927\u8F93\u51FA tokens",
11272
+ kind: "text",
11273
+ defaultValue: String(DEFAULT_MAX_TOKENS)
11274
+ },
11275
+ {
11276
+ key: "reasoningEfforts",
11277
+ label: "\u652F\u6301\u7684\u601D\u8003\u7A0B\u5EA6",
11278
+ kind: "select",
11279
+ defaultValue: "",
11280
+ help: "DSH \u53EA\u4F1A\u663E\u793A\u8FD9\u91CC\u58F0\u660E\u4E14\u4E0A\u6E38\u6A21\u578B\u5B9E\u9645\u652F\u6301\u7684\u6863\u4F4D\u3002",
11281
+ options: [
11282
+ { value: "", label: "\u4E0D\u58F0\u660E\uFF08\u63D0\u4F9B\u65B9\u9ED8\u8BA4\uFF09" },
11283
+ { value: "low,medium,high,xhigh,max", label: "Low / Medium / High / XHigh / Max" },
11284
+ { value: "low,medium,high,xhigh", label: "Low / Medium / High / XHigh" },
11285
+ { value: "minimal,low,medium,high", label: "Minimal / Low / Medium / High" },
11286
+ { value: "false", label: "\u6A21\u578B\u4E0D\u652F\u6301\u601D\u8003\u7A0B\u5EA6" }
11287
+ ]
11288
+ }
11289
+ ];
11290
+ constructor(environment) {
11291
+ this.environment = environment;
11292
+ }
11293
+ targets() {
11294
+ return [
11295
+ {
11296
+ key: SETTINGS2,
11297
+ label: "settings.yaml",
11298
+ path: join6(this.environment.harnessHomes.dsh, "settings.yaml"),
11299
+ format: "yaml"
11300
+ },
11301
+ {
11302
+ key: CREDENTIALS,
11303
+ label: ".credentials.yaml",
11304
+ path: join6(this.environment.harnessHomes.dsh, ".credentials.yaml"),
11305
+ format: "yaml"
11306
+ }
11307
+ ];
11308
+ }
11309
+ envVars() {
11310
+ return {};
11311
+ }
11312
+ validate(profile) {
11313
+ if (!profile.model.trim()) {
11314
+ throw new HttpError(400, "DeepSeek Harness \u9700\u8981\u586B\u5199\u6A21\u578B\u540D\u79F0");
11315
+ }
11316
+ if (!profile.apiKey.trim()) {
11317
+ throw new HttpError(400, "DeepSeek Harness \u9700\u8981\u586B\u5199 API key");
11318
+ }
11319
+ }
11320
+ render(profile, current) {
11321
+ this.validate(profile);
11322
+ const providerId = this.providerId(profile);
11323
+ const credentialRef = this.credentialRef(providerId);
11324
+ const settings = parseYamlDocument(current[SETTINGS2]);
11325
+ const model = {
11326
+ id: profile.model,
11327
+ name: profile.model,
11328
+ contextWindow: this.numeric(profile.extras.contextWindow, DEFAULT_CONTEXT),
11329
+ maxTokens: this.numeric(profile.extras.maxTokens, DEFAULT_MAX_TOKENS)
11330
+ };
11331
+ const reasoningEfforts = this.reasoningEfforts(profile.extras.reasoningEfforts);
11332
+ if (reasoningEfforts !== undefined) {
11333
+ model.reasoningEfforts = reasoningEfforts;
11334
+ }
11335
+ settings.setIn(["llm-pi-ai", "providers", providerId], {
11336
+ displayName: profile.name,
11337
+ apiKeyEnv: credentialRef,
11338
+ api: profile.extras.api || "openai-responses",
11339
+ baseURL: profile.baseUrl,
11340
+ models: [model]
11341
+ });
11342
+ settings.setIn(["agent-default-model", "provider"], providerId);
11343
+ settings.setIn(["agent-default-model", "model"], profile.model);
11344
+ settings.deleteIn(["agent-default-model", "reasoningEffort"]);
11345
+ const credentials = parseYamlDocument(current[CREDENTIALS]);
11346
+ credentials.setIn([credentialRef], profile.apiKey);
11347
+ return {
11348
+ [SETTINGS2]: settings.toString(),
11349
+ [CREDENTIALS]: credentials.toString()
11350
+ };
11351
+ }
11352
+ revoke(profile, current) {
11353
+ const providerId = this.providerId(profile);
11354
+ const rendered = {};
11355
+ if (current[SETTINGS2] !== undefined) {
11356
+ try {
11357
+ const settings = parseYamlDocument(current[SETTINGS2]);
11358
+ settings.deleteIn(["llm-pi-ai", "providers", providerId]);
11359
+ if (settings.getIn(["agent-default-model", "provider"]) === providerId) {
11360
+ settings.deleteIn(["agent-default-model"]);
11361
+ }
11362
+ rendered[SETTINGS2] = settings.toString();
11363
+ } catch {}
11364
+ }
11365
+ if (current[CREDENTIALS] !== undefined) {
11366
+ try {
11367
+ const credentials = parseYamlDocument(current[CREDENTIALS]);
11368
+ credentials.deleteIn([this.credentialRef(providerId)]);
11369
+ rendered[CREDENTIALS] = credentials.toString();
11370
+ } catch {}
11371
+ }
11372
+ return rendered;
11373
+ }
11374
+ backfill(profile, current) {
11375
+ try {
11376
+ const providerId = this.providerId(profile);
11377
+ const settings = parseYamlDocument(current[SETTINGS2]);
11378
+ const credentials = parseYamlDocument(current[CREDENTIALS]);
11379
+ const route = toPlain(settings.getIn(["llm-pi-ai", "providers", providerId]));
11380
+ const models = Array.isArray(route?.models) ? route.models : [];
11381
+ const firstModel = toPlain(models[0]);
11382
+ const apiKey = credentials.getIn([this.credentialRef(providerId)]);
11383
+ return {
11384
+ baseUrl: typeof route?.baseURL === "string" ? route.baseURL : profile.baseUrl,
11385
+ apiKey: typeof apiKey === "string" && apiKey ? apiKey : profile.apiKey,
11386
+ model: typeof firstModel?.id === "string" ? firstModel.id : profile.model,
11387
+ extras: {
11388
+ ...profile.extras,
11389
+ api: typeof route?.api === "string" ? route.api : profile.extras.api || "",
11390
+ contextWindow: valueString(firstModel?.contextWindow, profile.extras.contextWindow),
11391
+ maxTokens: valueString(firstModel?.maxTokens, profile.extras.maxTokens),
11392
+ reasoningEfforts: reasoningEffortsString(firstModel?.reasoningEfforts, profile.extras.reasoningEfforts)
11393
+ }
11394
+ };
11395
+ } catch {
11396
+ return {};
11397
+ }
11398
+ }
11399
+ providerId(profile) {
11400
+ const id = slugify(profile.extras.providerId || profile.name, "provider");
11401
+ return /^[a-z]/.test(id) ? id : `provider-${id}`;
11402
+ }
11403
+ credentialRef(providerId) {
11404
+ return `${providerId.toUpperCase().replace(/[^A-Z0-9_]/g, "_")}_API_KEY`;
11405
+ }
11406
+ numeric(raw2, fallback) {
11407
+ const parsed = Number(raw2);
11408
+ return Number.isFinite(parsed) && parsed > 0 ? Math.trunc(parsed) : fallback;
11409
+ }
11410
+ reasoningEfforts(raw2) {
11411
+ if (!raw2) {
11412
+ return;
11413
+ }
11414
+ if (raw2 === "false") {
11415
+ return false;
11416
+ }
11417
+ const levels = raw2.split(",").map((entry) => entry.trim()).filter(Boolean);
11418
+ return levels.length > 0 ? Object.fromEntries(levels.map((level) => [level, level])) : undefined;
11419
+ }
11420
+ }
11421
+ function toPlain(value) {
11422
+ const plain = isYamlNode(value) ? value.toJSON() : value;
11423
+ return typeof plain === "object" && plain !== null && !Array.isArray(plain) ? plain : undefined;
11424
+ }
11425
+ function isYamlNode(value) {
11426
+ return typeof value === "object" && value !== null && "toJSON" in value;
11427
+ }
11428
+ function valueString(value, fallback) {
11429
+ return typeof value === "number" && Number.isFinite(value) ? String(value) : fallback || "";
11430
+ }
11431
+ function reasoningEffortsString(value, fallback) {
11432
+ if (value === false) {
11433
+ return "false";
11434
+ }
11435
+ const plain = toPlain(value);
11436
+ return plain ? Object.keys(plain).join(",") : fallback || "";
11437
+ }
11438
+
11439
+ // src/services/adapters/kimi.ts
11440
+ import { join as join7 } from "path";
11441
+ var CONFIG2 = "config";
11442
+ var DEFAULT_CONTEXT2 = 262144;
11082
11443
 
11083
11444
  class KimiAdapter {
11084
11445
  environment;
@@ -11110,7 +11471,7 @@ class KimiAdapter {
11110
11471
  key: "maxContextSize",
11111
11472
  label: "\u4E0A\u4E0B\u6587\u957F\u5EA6",
11112
11473
  kind: "text",
11113
- defaultValue: String(DEFAULT_CONTEXT),
11474
+ defaultValue: String(DEFAULT_CONTEXT2),
11114
11475
  help: "Kimi Code \u8981\u6C42 models \u6761\u76EE\u5FC5\u987B\u58F0\u660E max_context_size\u3002"
11115
11476
  }
11116
11477
  ];
@@ -11122,7 +11483,7 @@ class KimiAdapter {
11122
11483
  {
11123
11484
  key: CONFIG2,
11124
11485
  label: "config.toml",
11125
- path: join6(this.environment.harnessHomes.kimiCode, "config.toml"),
11486
+ path: join7(this.environment.harnessHomes.kimiCode, "config.toml"),
11126
11487
  format: "toml"
11127
11488
  }
11128
11489
  ];
@@ -11203,23 +11564,23 @@ class KimiAdapter {
11203
11564
  }
11204
11565
  contextSize(profile) {
11205
11566
  const parsed = Number(profile.extras.maxContextSize);
11206
- return Number.isFinite(parsed) && parsed > 0 ? Math.trunc(parsed) : DEFAULT_CONTEXT;
11567
+ return Number.isFinite(parsed) && parsed > 0 ? Math.trunc(parsed) : DEFAULT_CONTEXT2;
11207
11568
  }
11208
11569
  }
11209
11570
 
11210
11571
  // src/services/adapters/pi.ts
11211
- import { join as join7 } from "path";
11572
+ import { join as join8 } from "path";
11212
11573
  var MODELS = "models";
11213
- var CONFIG3 = "config";
11214
- var DEFAULT_CONTEXT2 = 200000;
11215
- var DEFAULT_MAX_TOKENS = 8192;
11574
+ var SETTINGS3 = "settings";
11575
+ var DEFAULT_CONTEXT3 = 200000;
11576
+ var DEFAULT_MAX_TOKENS2 = 8192;
11216
11577
 
11217
11578
  class PiAdapter {
11218
11579
  environment;
11219
11580
  id = "pi";
11220
11581
  mode = "additive";
11221
11582
  envVarNames = [];
11222
- envNote = "API key \u76F4\u63A5\u5199\u5165 models.yml\uFF0C\u65E0\u9700\u73AF\u5883\u53D8\u91CF\uFF1B\u8FD0\u884C\u65F6\u4ECD\u53EF\u7528 --model \u8986\u76D6\u3002";
11583
+ envNote = "API key \u76F4\u63A5\u5199\u5165 models.json\uFF0C\u65E0\u9700\u73AF\u5883\u53D8\u91CF\uFF1B\u8FD0\u884C\u65F6\u4ECD\u53EF\u7528 --model \u8986\u76D6\u3002";
11223
11584
  fields = [
11224
11585
  {
11225
11586
  key: "providerId",
@@ -11235,7 +11596,8 @@ class PiAdapter {
11235
11596
  defaultValue: "openai-completions",
11236
11597
  options: [
11237
11598
  { value: "openai-completions", label: "openai-completions" },
11238
- { value: "openai-responses", label: "openai-responses" }
11599
+ { value: "openai-responses", label: "openai-responses" },
11600
+ { value: "anthropic-messages", label: "anthropic-messages" }
11239
11601
  ]
11240
11602
  },
11241
11603
  {
@@ -11253,13 +11615,24 @@ class PiAdapter {
11253
11615
  key: "contextWindow",
11254
11616
  label: "\u4E0A\u4E0B\u6587\u957F\u5EA6",
11255
11617
  kind: "text",
11256
- defaultValue: String(DEFAULT_CONTEXT2)
11618
+ defaultValue: String(DEFAULT_CONTEXT3)
11257
11619
  },
11258
11620
  {
11259
11621
  key: "maxTokens",
11260
11622
  label: "\u6700\u5927\u8F93\u51FA tokens",
11261
11623
  kind: "text",
11262
- defaultValue: String(DEFAULT_MAX_TOKENS)
11624
+ defaultValue: String(DEFAULT_MAX_TOKENS2)
11625
+ },
11626
+ {
11627
+ key: "reasoning",
11628
+ label: "\u63A8\u7406\u80FD\u529B",
11629
+ kind: "select",
11630
+ defaultValue: "false",
11631
+ help: "\u5BF9\u5E94 models.json \u7684 reasoning\u3002GPT / Claude \u601D\u8003\u6A21\u578B\u9700\u8981\u5F00\u542F\u3002",
11632
+ options: [
11633
+ { value: "false", label: "\u5173\u95ED" },
11634
+ { value: "true", label: "\u5F00\u542F" }
11635
+ ]
11263
11636
  }
11264
11637
  ];
11265
11638
  constructor(environment) {
@@ -11269,15 +11642,15 @@ class PiAdapter {
11269
11642
  return [
11270
11643
  {
11271
11644
  key: MODELS,
11272
- label: "models.yml",
11273
- path: join7(this.environment.harnessHomes.piAgent, "models.yml"),
11274
- format: "yaml"
11645
+ label: "models.json",
11646
+ path: join8(this.environment.harnessHomes.piAgent, "models.json"),
11647
+ format: "json"
11275
11648
  },
11276
11649
  {
11277
- key: CONFIG3,
11278
- label: "config.yml",
11279
- path: join7(this.environment.harnessHomes.piAgent, "config.yml"),
11280
- format: "yaml"
11650
+ key: SETTINGS3,
11651
+ label: "settings.json",
11652
+ path: join8(this.environment.harnessHomes.piAgent, "settings.json"),
11653
+ format: "json"
11281
11654
  }
11282
11655
  ];
11283
11656
  }
@@ -11286,30 +11659,37 @@ class PiAdapter {
11286
11659
  }
11287
11660
  validate(profile) {
11288
11661
  if (!profile.model.trim()) {
11289
- throw new HttpError(400, "oh-my-pi \u9700\u8981\u586B\u5199\u6A21\u578B\u540D\u79F0\uFF0C\u5426\u5219\u65E0\u6CD5\u751F\u6210 models \u6761\u76EE");
11662
+ throw new HttpError(400, "Pi \u9700\u8981\u586B\u5199\u6A21\u578B\u540D\u79F0\uFF0C\u5426\u5219\u65E0\u6CD5\u751F\u6210 models \u6761\u76EE");
11663
+ }
11664
+ if (!profile.apiKey.trim()) {
11665
+ throw new HttpError(400, "Pi \u9700\u8981\u586B\u5199 API key\uFF0C\u5426\u5219\u6A21\u578B\u4E0D\u4F1A\u51FA\u73B0\u5728 /model \u5217\u8868\u91CC");
11290
11666
  }
11291
11667
  }
11292
11668
  render(profile, current) {
11293
11669
  this.validate(profile);
11294
11670
  const id = this.providerId(profile);
11295
- const models = parseYamlDocument(current[MODELS]);
11296
- models.setIn(["providers", id, "baseUrl"], profile.baseUrl);
11297
- models.setIn(["providers", id, "apiKey"], profile.apiKey);
11298
- models.setIn(["providers", id, "api"], profile.extras.api || "openai-completions");
11299
- models.setIn(["providers", id, "authHeader"], profile.extras.authHeader !== "false");
11300
- models.setIn(["providers", id, "models"], [
11301
- {
11302
- id: profile.model,
11303
- name: profile.model,
11304
- contextWindow: this.numeric(profile.extras.contextWindow, DEFAULT_CONTEXT2),
11305
- maxTokens: this.numeric(profile.extras.maxTokens, DEFAULT_MAX_TOKENS)
11306
- }
11307
- ]);
11308
- const config = parseYamlDocument(current[CONFIG3]);
11309
- config.setIn(["modelProviderOrder"], this.promote(config.getIn(["modelProviderOrder"]), id));
11671
+ const models = parseJsonObject(current[MODELS]);
11672
+ const provider = ensureObject(ensureObject(models, "providers"), id);
11673
+ const model = {
11674
+ id: profile.model,
11675
+ name: profile.model,
11676
+ contextWindow: this.numeric(profile.extras.contextWindow, DEFAULT_CONTEXT3),
11677
+ maxTokens: this.numeric(profile.extras.maxTokens, DEFAULT_MAX_TOKENS2)
11678
+ };
11679
+ if (profile.extras.reasoning === "true") {
11680
+ model.reasoning = true;
11681
+ }
11682
+ provider.baseUrl = profile.baseUrl;
11683
+ provider.apiKey = profile.apiKey;
11684
+ provider.api = profile.extras.api || "openai-completions";
11685
+ provider.authHeader = profile.extras.authHeader !== "false";
11686
+ provider.models = [model];
11687
+ const settings = parseJsonObject(current[SETTINGS3]);
11688
+ settings.defaultProvider = id;
11689
+ settings.defaultModel = profile.model;
11310
11690
  return {
11311
- [MODELS]: models.toString(),
11312
- [CONFIG3]: config.toString()
11691
+ [MODELS]: stringifyJson(models),
11692
+ [SETTINGS3]: stringifyJson(settings)
11313
11693
  };
11314
11694
  }
11315
11695
  revoke(profile, current) {
@@ -11317,34 +11697,48 @@ class PiAdapter {
11317
11697
  const rendered = {};
11318
11698
  if (current[MODELS] !== undefined) {
11319
11699
  try {
11320
- const models = parseYamlDocument(current[MODELS]);
11321
- models.deleteIn(["providers", id]);
11322
- rendered[MODELS] = models.toString();
11700
+ const models = parseJsonObject(current[MODELS]);
11701
+ const providers = models.providers;
11702
+ if (isPlainObject(providers)) {
11703
+ delete providers[id];
11704
+ }
11705
+ rendered[MODELS] = stringifyJson(models);
11323
11706
  } catch {}
11324
11707
  }
11325
- if (current[CONFIG3] !== undefined) {
11708
+ if (current[SETTINGS3] !== undefined) {
11326
11709
  try {
11327
- const config = parseYamlDocument(current[CONFIG3]);
11328
- const order = this.toStringArray(config.getIn(["modelProviderOrder"])).filter((entry) => entry !== id);
11329
- if (order.length > 0) {
11330
- config.setIn(["modelProviderOrder"], order);
11331
- } else {
11332
- config.deleteIn(["modelProviderOrder"]);
11710
+ const settings = parseJsonObject(current[SETTINGS3]);
11711
+ if (settings.defaultProvider === id) {
11712
+ delete settings.defaultProvider;
11713
+ delete settings.defaultModel;
11333
11714
  }
11334
- rendered[CONFIG3] = config.toString();
11715
+ rendered[SETTINGS3] = stringifyJson(settings);
11335
11716
  } catch {}
11336
11717
  }
11337
11718
  return rendered;
11338
11719
  }
11339
11720
  backfill(profile, current) {
11340
11721
  try {
11341
- const models = parseYamlDocument(current[MODELS]);
11722
+ const models = parseJsonObject(current[MODELS]);
11342
11723
  const id = this.providerId(profile);
11343
- const baseUrl = models.getIn(["providers", id, "baseUrl"]);
11344
- const apiKey = models.getIn(["providers", id, "apiKey"]);
11724
+ const providers = models.providers;
11725
+ const provider = isPlainObject(providers) ? providers[id] : undefined;
11726
+ if (!isPlainObject(provider)) {
11727
+ return {};
11728
+ }
11729
+ const firstModel = Array.isArray(provider.models) ? provider.models.find((entry) => isPlainObject(entry)) : undefined;
11730
+ const apiKey = readString(provider, "apiKey");
11345
11731
  return {
11346
- baseUrl: typeof baseUrl === "string" ? baseUrl : profile.baseUrl,
11347
- apiKey: typeof apiKey === "string" && apiKey ? apiKey : profile.apiKey
11732
+ baseUrl: readString(provider, "baseUrl") || profile.baseUrl,
11733
+ apiKey: apiKey || profile.apiKey,
11734
+ model: readString(firstModel, "id") || profile.model,
11735
+ extras: {
11736
+ ...profile.extras,
11737
+ api: readString(provider, "api") || profile.extras.api || "",
11738
+ contextWindow: valueString2(firstModel?.contextWindow, profile.extras.contextWindow),
11739
+ maxTokens: valueString2(firstModel?.maxTokens, profile.extras.maxTokens),
11740
+ reasoning: firstModel?.reasoning === true ? "true" : profile.extras.reasoning || "false"
11741
+ }
11348
11742
  };
11349
11743
  } catch {
11350
11744
  return {};
@@ -11353,20 +11747,13 @@ class PiAdapter {
11353
11747
  providerId(profile) {
11354
11748
  return slugify(profile.extras.providerId || profile.name, "provider");
11355
11749
  }
11356
- promote(existing, id) {
11357
- return [id, ...this.toStringArray(existing).filter((entry) => entry !== id)];
11358
- }
11359
- toStringArray(value) {
11360
- const plain = isYamlNode(value) ? value.toJSON() : value;
11361
- return Array.isArray(plain) ? plain.filter((entry) => typeof entry === "string") : [];
11362
- }
11363
11750
  numeric(raw2, fallback) {
11364
11751
  const parsed = Number(raw2);
11365
11752
  return Number.isFinite(parsed) && parsed > 0 ? Math.trunc(parsed) : fallback;
11366
11753
  }
11367
11754
  }
11368
- function isYamlNode(value) {
11369
- return typeof value === "object" && value !== null && "toJSON" in value;
11755
+ function valueString2(value, fallback) {
11756
+ return typeof value === "number" && Number.isFinite(value) ? String(value) : fallback || "";
11370
11757
  }
11371
11758
 
11372
11759
  // src/services/adapters/index.ts
@@ -11383,7 +11770,8 @@ class AdapterRegistry {
11383
11770
  new ClaudeAdapter(environment),
11384
11771
  new CodexAdapter(environment),
11385
11772
  new KimiAdapter(environment),
11386
- new PiAdapter(environment)
11773
+ new PiAdapter(environment),
11774
+ new DshAdapter(environment)
11387
11775
  ];
11388
11776
  this.adapters = new Map(adapters.map((adapter) => [adapter.id, adapter]));
11389
11777
  }
@@ -11462,12 +11850,13 @@ __decoratorMetadata(_init, LiveWriteService);
11462
11850
  let _LiveWriteService = LiveWriteService;
11463
11851
 
11464
11852
  // ../../packages/shared/src/harnesses.ts
11465
- var HARNESS_IDS = ["claude", "codex", "kimi", "pi"];
11853
+ var HARNESS_IDS = ["claude", "codex", "kimi", "pi", "dsh"];
11466
11854
  var HARNESS_LABELS = {
11467
11855
  claude: "Claude Code",
11468
11856
  codex: "Codex",
11469
11857
  kimi: "Kimi Code",
11470
- pi: "oh-my-pi"
11858
+ pi: "Pi",
11859
+ dsh: "DeepSeek Harness"
11471
11860
  };
11472
11861
  function isHarnessId(value) {
11473
11862
  return HARNESS_IDS.includes(value);
@@ -11524,16 +11913,21 @@ class ProfileService {
11524
11913
  upsert(harness, input, isCreate) {
11525
11914
  this.harnesses.require(harness);
11526
11915
  const name = input.name.trim();
11916
+ const sourceName = isCreate ? name : input.sourceName?.trim() || name;
11527
11917
  this.assertName(name);
11918
+ this.assertName(sourceName);
11528
11919
  const store = this.read();
11529
11920
  store[harness] ||= {};
11530
- const prior = store[harness][name];
11921
+ const prior = store[harness][sourceName];
11531
11922
  if (isCreate && prior) {
11532
11923
  throw new HttpError(409, "profile already exists");
11533
11924
  }
11534
11925
  if (!isCreate && !prior) {
11535
11926
  throw new HttpError(404, "profile not found");
11536
11927
  }
11928
+ if (!isCreate && sourceName !== name && store[harness][name]) {
11929
+ throw new HttpError(409, "profile already exists");
11930
+ }
11537
11931
  const apiKey = input.apiKey || (prior ? this.crypto.decrypt(prior.api_key) : "");
11538
11932
  if (isCreate && !apiKey) {
11539
11933
  throw new HttpError(400, "apiKey is required");
@@ -11555,6 +11949,9 @@ class ProfileService {
11555
11949
  extras: next.extras ?? {}
11556
11950
  });
11557
11951
  store[harness][name] = next;
11952
+ if (sourceName !== name) {
11953
+ delete store[harness][sourceName];
11954
+ }
11558
11955
  this.files.writeJson(this.environment.files.profiles, store);
11559
11956
  return this.toPublic(harness, name, next);
11560
11957
  }
@@ -11595,6 +11992,9 @@ class ProfileService {
11595
11992
  if (values.apiKey) {
11596
11993
  stored.api_key = this.crypto.encrypt(values.apiKey);
11597
11994
  }
11995
+ if (values.extras !== undefined) {
11996
+ stored.extras = { ...stored.extras, ...values.extras };
11997
+ }
11598
11998
  this.files.writeJson(this.environment.files.profiles, store);
11599
11999
  }
11600
12000
  read() {
@@ -11661,7 +12061,8 @@ class ActivationService {
11661
12061
  return {
11662
12062
  name: stored.name,
11663
12063
  baseUrl: stored.base_url || "",
11664
- model: stored.model || ""
12064
+ model: stored.model || "",
12065
+ official: stored.official === true
11665
12066
  };
11666
12067
  }
11667
12068
  activate(harness, name) {
@@ -11678,7 +12079,8 @@ class ActivationService {
11678
12079
  base_url: profile.baseUrl,
11679
12080
  api_key: profile.apiKey,
11680
12081
  model: profile.model,
11681
- extras: profile.extras
12082
+ extras: profile.extras,
12083
+ official: false
11682
12084
  };
11683
12085
  this.files.writeJson(this.environment.files.active, active);
11684
12086
  try {
@@ -11689,6 +12091,45 @@ class ActivationService {
11689
12091
  }
11690
12092
  return { envFile: this.environment.files.env, warnings };
11691
12093
  }
12094
+ activateOfficial(harness) {
12095
+ const adapter = this.adapters.get(harness);
12096
+ if (!adapter.renderOfficial) {
12097
+ throw new HttpError(400, `${this.harnesses.label(harness)} \u4E0D\u652F\u6301\u5B98\u65B9\u8D26\u53F7\u767B\u5F55\u6A21\u5F0F`);
12098
+ }
12099
+ const warnings = [];
12100
+ const active = this.read();
12101
+ const previous = active[harness];
12102
+ const alreadyOfficial = previous?.official === true;
12103
+ if (!alreadyOfficial) {
12104
+ this.backfillPrevious(adapter, previous, "__official__", warnings);
12105
+ }
12106
+ const profile = previous && !alreadyOfficial ? {
12107
+ name: previous.name,
12108
+ baseUrl: previous.base_url,
12109
+ apiKey: previous.api_key,
12110
+ model: previous.model,
12111
+ extras: previous.extras ?? {}
12112
+ } : undefined;
12113
+ const targets = adapter.targets();
12114
+ const rendered = adapter.renderOfficial(profile, this.readCurrent(targets));
12115
+ this.liveWrite.apply(harness, "\u5B98\u65B9\u767B\u5F55", this.toWrites(targets, rendered));
12116
+ active[harness] = {
12117
+ name: "\u5B98\u65B9\u767B\u5F55",
12118
+ base_url: "",
12119
+ api_key: "",
12120
+ model: "",
12121
+ extras: {},
12122
+ official: true
12123
+ };
12124
+ this.files.writeJson(this.environment.files.active, active);
12125
+ try {
12126
+ this.writeEnv(active);
12127
+ } catch (error) {
12128
+ this.log.error("failed to rebuild env file", error);
12129
+ warnings.push("\u5DF2\u6062\u590D\u5B98\u65B9\u767B\u5F55\uFF0C\u4F46\u91CD\u5EFA env.sh \u5931\u8D25");
12130
+ }
12131
+ return { envFile: this.environment.files.env, warnings };
12132
+ }
11692
12133
  preview(harness, name) {
11693
12134
  const adapter = this.adapters.get(harness);
11694
12135
  const profile = this.profiles.decrypt(harness, name);
@@ -11708,11 +12149,19 @@ class ActivationService {
11708
12149
  };
11709
12150
  });
11710
12151
  }
11711
- reapplyIfActive(harness, name) {
11712
- if (this.read()[harness]?.name !== name) {
12152
+ reconcileProfileUpdate(harness, previousName, nextName) {
12153
+ const adapter = this.adapters.get(harness);
12154
+ if (previousName !== nextName && adapter.revoke) {
12155
+ const profile = this.profiles.decrypt(harness, nextName);
12156
+ const previousProfile = { ...profile, name: previousName };
12157
+ const targets = adapter.targets();
12158
+ const rendered = adapter.revoke(previousProfile, this.readCurrent(targets));
12159
+ this.liveWrite.apply(harness, previousName, this.toWrites(targets, rendered));
12160
+ }
12161
+ if (this.read()[harness]?.name !== previousName) {
11713
12162
  return;
11714
12163
  }
11715
- this.activate(harness, name);
12164
+ this.activate(harness, nextName);
11716
12165
  }
11717
12166
  prepareDelete(harness, name) {
11718
12167
  if (this.read()[harness]?.name === name) {
@@ -11732,7 +12181,7 @@ class ActivationService {
11732
12181
  }
11733
12182
  }
11734
12183
  backfillPrevious(adapter, previous, nextName, warnings) {
11735
- if (!adapter.backfill || !previous || previous.name === nextName) {
12184
+ if (!adapter.backfill || !previous || previous.official || previous.name === nextName) {
11736
12185
  return;
11737
12186
  }
11738
12187
  try {
@@ -11795,6 +12244,11 @@ class ActivationService {
11795
12244
  if (!entry) {
11796
12245
  continue;
11797
12246
  }
12247
+ if (entry.official) {
12248
+ lines.push("", `# ${this.harnesses.label(adapter.id)} / \u5B98\u65B9\u767B\u5F55`);
12249
+ lines.push("# \u4F7F\u7528\u5DE5\u5177\u81EA\u8EAB\u7684\u5B98\u65B9\u8D26\u53F7\u767B\u5F55\uFF0C\u4E0D\u6CE8\u5165\u73AF\u5883\u53D8\u91CF\u3002");
12250
+ continue;
12251
+ }
11798
12252
  const profile = {
11799
12253
  name: entry.name,
11800
12254
  baseUrl: entry.base_url,
@@ -11846,7 +12300,8 @@ function createHarnessRoutes(services) {
11846
12300
  fields: adapter.fields,
11847
12301
  targets: adapter.targets(),
11848
12302
  envVars: adapter.envVarNames,
11849
- envNote: adapter.envNote
12303
+ envNote: adapter.envNote,
12304
+ supportsOfficialAuth: adapter.renderOfficial !== undefined
11850
12305
  };
11851
12306
  }
11852
12307
  app.get("/", (c) => c.json({
@@ -11873,7 +12328,8 @@ function createHarnessRoutes(services) {
11873
12328
  const name = decodeURIComponent(c.req.param("name"));
11874
12329
  const body = await readBody(c.req.json.bind(c.req));
11875
12330
  const profile = profiles.upsert(harnessId, {
11876
- name,
12331
+ name: String(body.name ?? name),
12332
+ sourceName: name,
11877
12333
  baseUrl: body.baseUrl,
11878
12334
  apiKey: body.apiKey,
11879
12335
  model: body.model,
@@ -11881,7 +12337,7 @@ function createHarnessRoutes(services) {
11881
12337
  extras: body.extras,
11882
12338
  overrides: body.overrides
11883
12339
  }, false);
11884
- activation.reapplyIfActive(harnessId, name);
12340
+ activation.reconcileProfileUpdate(harnessId, name, profile.name);
11885
12341
  return c.json(profile);
11886
12342
  });
11887
12343
  app.delete("/:harnessId/profiles/:name", (c) => {
@@ -11902,6 +12358,11 @@ function createHarnessRoutes(services) {
11902
12358
  const result = activation.activate(harnessId, name);
11903
12359
  return c.json({ ok: true, envFile: result.envFile, warnings: result.warnings });
11904
12360
  });
12361
+ app.post("/:harnessId/official/activate", (c) => {
12362
+ const harnessId = harnesses.require(c.req.param("harnessId"));
12363
+ const result = activation.activateOfficial(harnessId);
12364
+ return c.json({ ok: true, envFile: result.envFile, warnings: result.warnings });
12365
+ });
11905
12366
  return app;
11906
12367
  }
11907
12368
  async function readBody(read) {
@@ -11934,12 +12395,13 @@ function createApp(services) {
11934
12395
  if (c.req.path.startsWith("/api") || c.req.path === "/healthz") {
11935
12396
  return next();
11936
12397
  }
11937
- const assetPath = join8(publicDir, c.req.path.replace(/^\//, ""));
12398
+ const assetPath = join9(publicDir, c.req.path.replace(/^\//, ""));
11938
12399
  if (c.req.path !== "/" && existsSync3(assetPath)) {
11939
12400
  return serveStatic2({ root: publicDir })(c, next);
11940
12401
  }
11941
- const index = join8(publicDir, "index.html");
12402
+ const index = join9(publicDir, "index.html");
11942
12403
  if (existsSync3(index)) {
12404
+ c.header("Cache-Control", "no-store");
11943
12405
  return c.html(await Bun.file(index).text());
11944
12406
  }
11945
12407
  return c.text("frontend not built", 503);