niceeval 0.13.3 → 0.13.4-canary.39

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 (487) hide show
  1. package/INDEX.md +5 -5
  2. package/dist/agents/index.cjs +2 -2
  3. package/dist/agents/index.cjs.map +1 -1
  4. package/dist/agents/project.json +6 -0
  5. package/dist/agents/streaming.cjs.map +1 -1
  6. package/dist/agents/types.cjs.map +1 -1
  7. package/dist/agents/types.d.cts +1 -1
  8. package/dist/agents/types.d.mts +1 -1
  9. package/dist/agents/types.d.ts +1 -1
  10. package/dist/analysis/bindings.d.cts +8 -8
  11. package/dist/analysis/bindings.d.mts +8 -8
  12. package/dist/analysis/bindings.d.ts +8 -8
  13. package/dist/analysis/contracts.cjs.map +1 -1
  14. package/dist/analysis/contracts.d.cts +8 -19
  15. package/dist/analysis/contracts.d.mts +8 -19
  16. package/dist/analysis/contracts.d.ts +8 -19
  17. package/dist/analysis/experiment-groups.cjs +7 -14
  18. package/dist/analysis/experiment-groups.cjs.map +1 -1
  19. package/dist/analysis/index.cjs.map +1 -1
  20. package/dist/analysis/index.d.cts +1 -1
  21. package/dist/analysis/index.d.mts +1 -1
  22. package/dist/analysis/index.d.ts +1 -1
  23. package/dist/cli/application.cjs +4 -13
  24. package/dist/cli/application.cjs.map +1 -1
  25. package/dist/cli/application.d.cts +62 -59
  26. package/dist/cli/application.d.mts +62 -59
  27. package/dist/cli/application.d.ts +62 -59
  28. package/dist/cli/application.js +6 -12
  29. package/dist/cli/bootstrap.cjs +28 -2
  30. package/dist/cli/bootstrap.cjs.map +1 -1
  31. package/dist/cli/contribution.cjs +185 -0
  32. package/dist/cli/contribution.cjs.map +1 -0
  33. package/dist/cli/contribution.d.cts +55 -0
  34. package/dist/cli/contribution.d.mts +55 -0
  35. package/dist/cli/contribution.d.ts +55 -0
  36. package/dist/cli/contribution.js +20 -0
  37. package/dist/cli/contribution.js.map +1 -0
  38. package/dist/cli/node-application.cjs +119 -87
  39. package/dist/cli/node-application.cjs.map +1 -1
  40. package/dist/cli/node-application.d.cts +2 -8
  41. package/dist/cli/node-application.d.mts +2 -8
  42. package/dist/cli/node-application.d.ts +2 -8
  43. package/dist/cli/node-application.js +12 -22
  44. package/dist/cli/program.cjs +87 -2756
  45. package/dist/cli/program.cjs.map +1 -1
  46. package/dist/cli/program.d.cts +11 -332
  47. package/dist/cli/program.d.mts +11 -332
  48. package/dist/cli/program.d.ts +11 -332
  49. package/dist/cli/program.js +4 -28
  50. package/dist/cli.cjs +0 -3
  51. package/dist/cli.cjs.map +1 -1
  52. package/dist/cli.d.cts +0 -1
  53. package/dist/cli.d.mts +0 -1
  54. package/dist/cli.d.ts +0 -1
  55. package/dist/cli.js +6 -14
  56. package/dist/define.cjs +1 -1
  57. package/dist/define.cjs.map +1 -1
  58. package/dist/docker/cache-administration.cjs +8 -0
  59. package/dist/docker/cache-administration.cjs.map +1 -0
  60. package/dist/docker/cache-administration.d.cts +33 -0
  61. package/dist/docker/cache-administration.d.mts +33 -0
  62. package/dist/docker/cache-administration.d.ts +33 -0
  63. package/dist/docker/cache-administration.js +6 -0
  64. package/dist/docker/cache-administration.js.map +1 -0
  65. package/dist/docker/cache-live.cjs +27 -0
  66. package/dist/docker/cache-live.cjs.map +1 -0
  67. package/dist/docker/cache-live.d.cts +3 -0
  68. package/dist/docker/cache-live.d.mts +3 -0
  69. package/dist/docker/cache-live.d.ts +3 -0
  70. package/dist/docker/cache-live.js +6 -0
  71. package/dist/docker/cache-live.js.map +1 -0
  72. package/dist/docker/cli/contribution.cjs +223 -0
  73. package/dist/docker/cli/contribution.cjs.map +1 -0
  74. package/dist/docker/cli/contribution.d.cts +48 -0
  75. package/dist/docker/cli/contribution.d.mts +48 -0
  76. package/dist/docker/cli/contribution.d.ts +48 -0
  77. package/dist/docker/cli/contribution.js +8 -0
  78. package/dist/docker/cli/contribution.js.map +1 -0
  79. package/dist/eval/cli/contribution.cjs +62 -0
  80. package/dist/eval/cli/contribution.cjs.map +1 -0
  81. package/dist/eval/cli/contribution.d.cts +21 -0
  82. package/dist/eval/cli/contribution.d.mts +21 -0
  83. package/dist/eval/cli/contribution.d.ts +21 -0
  84. package/dist/eval/cli/contribution.js +8 -0
  85. package/dist/eval/cli/contribution.js.map +1 -0
  86. package/dist/eval/host/index.cjs +23 -0
  87. package/dist/eval/host/index.cjs.map +1 -0
  88. package/dist/eval/host/index.d.cts +27 -0
  89. package/dist/eval/host/index.d.mts +27 -0
  90. package/dist/eval/host/index.d.ts +27 -0
  91. package/dist/eval/host/index.js +8 -0
  92. package/dist/eval/host/index.js.map +1 -0
  93. package/dist/eval/host/index.mjs +8 -0
  94. package/dist/eval/host/index.mjs.map +1 -0
  95. package/dist/experiment/host/cli/contribution.cjs +835 -0
  96. package/dist/experiment/host/cli/contribution.cjs.map +1 -0
  97. package/dist/experiment/host/cli/contribution.d.cts +329 -0
  98. package/dist/experiment/host/cli/contribution.d.mts +329 -0
  99. package/dist/experiment/host/cli/contribution.d.ts +329 -0
  100. package/dist/experiment/host/cli/contribution.js +22 -0
  101. package/dist/experiment/host/cli/contribution.js.map +1 -0
  102. package/dist/experiment/host/cli/index.cjs +9 -0
  103. package/dist/experiment/host/cli/index.cjs.map +1 -0
  104. package/dist/experiment/host/cli/index.d.cts +2 -0
  105. package/dist/experiment/host/cli/index.d.mts +2 -0
  106. package/dist/experiment/host/cli/index.d.ts +2 -0
  107. package/dist/experiment/host/cli/index.js +10 -0
  108. package/dist/experiment/host/cli/index.js.map +1 -0
  109. package/dist/experiment/host/cli/terminal.cjs +15 -0
  110. package/dist/experiment/host/cli/terminal.cjs.map +1 -0
  111. package/dist/experiment/host/cli/terminal.d.cts +14 -0
  112. package/dist/experiment/host/cli/terminal.d.mts +14 -0
  113. package/dist/experiment/host/cli/terminal.d.ts +14 -0
  114. package/dist/experiment/host/cli/terminal.js +8 -0
  115. package/dist/experiment/host/cli/terminal.js.map +1 -0
  116. package/dist/experiment/host/index.cjs +35 -58
  117. package/dist/experiment/host/index.cjs.map +1 -1
  118. package/dist/experiment/host/index.d.cts +5 -79
  119. package/dist/experiment/host/index.d.mts +5 -79
  120. package/dist/experiment/host/index.d.ts +5 -79
  121. package/dist/experiment/host/index.js +4 -2
  122. package/dist/experiment/host/index.mjs +4 -2
  123. package/dist/experiment/host/operations.cjs +678 -0
  124. package/dist/experiment/host/operations.cjs.map +1 -0
  125. package/dist/experiment/host/operations.d.cts +19 -0
  126. package/dist/experiment/host/operations.d.mts +19 -0
  127. package/dist/experiment/host/operations.d.ts +19 -0
  128. package/dist/experiment/host/operations.js +24 -0
  129. package/dist/experiment/host/operations.js.map +1 -0
  130. package/dist/experiment/host/presentation.cjs +81 -0
  131. package/dist/experiment/host/presentation.cjs.map +1 -0
  132. package/dist/experiment/host/presentation.d.cts +9 -0
  133. package/dist/experiment/host/presentation.d.mts +9 -0
  134. package/dist/experiment/host/presentation.d.ts +9 -0
  135. package/dist/experiment/host/presentation.js +8 -0
  136. package/dist/experiment/host/presentation.js.map +1 -0
  137. package/dist/experiment/host/teardown.cjs +394 -0
  138. package/dist/experiment/host/teardown.cjs.map +1 -0
  139. package/dist/experiment/host/teardown.d.cts +5 -0
  140. package/dist/experiment/host/teardown.d.mts +5 -0
  141. package/dist/experiment/host/teardown.d.ts +5 -0
  142. package/dist/experiment/host/teardown.js +8 -0
  143. package/dist/experiment/host/teardown.js.map +1 -0
  144. package/dist/experiment/host/types.cjs +9 -0
  145. package/dist/experiment/host/types.cjs.map +1 -0
  146. package/dist/experiment/host/types.d.cts +423 -0
  147. package/dist/experiment/host/types.d.mts +423 -0
  148. package/dist/experiment/host/types.d.ts +423 -0
  149. package/dist/experiment/host/types.js +6 -0
  150. package/dist/experiment/host/types.js.map +1 -0
  151. package/dist/i18n/en.cjs +8 -50
  152. package/dist/i18n/en.cjs.map +1 -1
  153. package/dist/i18n/en.d.cts +2 -6
  154. package/dist/i18n/en.d.mts +2 -6
  155. package/dist/i18n/en.d.ts +2 -6
  156. package/dist/o11y/project.json +6 -0
  157. package/dist/project/cli/contribution.cjs +66 -0
  158. package/dist/project/cli/contribution.cjs.map +1 -0
  159. package/dist/project/cli/contribution.d.cts +17 -0
  160. package/dist/project/cli/contribution.d.mts +17 -0
  161. package/dist/project/cli/contribution.d.ts +17 -0
  162. package/dist/project/cli/contribution.js +8 -0
  163. package/dist/project/cli/contribution.js.map +1 -0
  164. package/dist/project/cli/index.cjs +7 -0
  165. package/dist/project/cli/index.cjs.map +1 -0
  166. package/dist/project/cli/index.d.cts +1 -0
  167. package/dist/project/cli/index.d.mts +1 -0
  168. package/dist/project/cli/index.d.ts +1 -0
  169. package/dist/project/cli/index.js +8 -0
  170. package/dist/project/cli/index.js.map +1 -0
  171. package/dist/project/host/index.cjs +11 -0
  172. package/dist/project/host/index.cjs.map +1 -0
  173. package/dist/project/host/index.d.cts +4 -0
  174. package/dist/project/host/index.d.mts +4 -0
  175. package/dist/project/host/index.d.ts +4 -0
  176. package/dist/project/host/index.js +14 -0
  177. package/dist/project/host/index.js.map +1 -0
  178. package/dist/project/host/index.mjs +14 -0
  179. package/dist/project/host/index.mjs.map +1 -0
  180. package/dist/project/host.cjs +59 -0
  181. package/dist/project/host.cjs.map +1 -0
  182. package/dist/project/host.d.cts +17 -0
  183. package/dist/project/host.d.mts +17 -0
  184. package/dist/project/host.d.ts +17 -0
  185. package/dist/project/host.js +6 -0
  186. package/dist/project/host.js.map +1 -0
  187. package/dist/project/index.cjs +11 -0
  188. package/dist/project/index.cjs.map +1 -0
  189. package/dist/project/index.d.cts +4 -0
  190. package/dist/project/index.d.mts +4 -0
  191. package/dist/project/index.d.ts +4 -0
  192. package/dist/project/index.js +14 -0
  193. package/dist/project/index.js.map +1 -0
  194. package/dist/project/node.cjs +91 -0
  195. package/dist/project/node.cjs.map +1 -0
  196. package/dist/project/node.d.cts +6 -0
  197. package/dist/project/node.d.mts +6 -0
  198. package/dist/project/node.d.ts +6 -0
  199. package/dist/project/node.js +12 -0
  200. package/dist/project/node.js.map +1 -0
  201. package/dist/project/services.cjs +17 -0
  202. package/dist/project/services.cjs.map +1 -0
  203. package/dist/project/services.d.cts +47 -0
  204. package/dist/project/services.d.mts +47 -0
  205. package/dist/project/services.d.ts +47 -0
  206. package/dist/project/services.js +12 -0
  207. package/dist/project/services.js.map +1 -0
  208. package/dist/project/templates.cjs +28 -0
  209. package/dist/project/templates.cjs.map +1 -0
  210. package/dist/project/templates.d.cts +4 -0
  211. package/dist/project/templates.d.mts +4 -0
  212. package/dist/project/templates.d.ts +4 -0
  213. package/dist/project/templates.js +12 -0
  214. package/dist/project/templates.js.map +1 -0
  215. package/dist/project.json +6 -0
  216. package/dist/record/family/catalog.d.cts +10 -10
  217. package/dist/record/family/catalog.d.mts +10 -10
  218. package/dist/record/family/catalog.d.ts +10 -10
  219. package/dist/record/family/file-changes.d.cts +8 -8
  220. package/dist/record/family/file-changes.d.mts +8 -8
  221. package/dist/record/family/file-changes.d.ts +8 -8
  222. package/dist/record/host/cli/contribution.cjs +206 -0
  223. package/dist/record/host/cli/contribution.cjs.map +1 -0
  224. package/dist/record/host/cli/contribution.d.cts +32 -0
  225. package/dist/record/host/cli/contribution.d.mts +32 -0
  226. package/dist/record/host/cli/contribution.d.ts +32 -0
  227. package/dist/record/host/cli/contribution.js +10 -0
  228. package/dist/record/host/cli/contribution.js.map +1 -0
  229. package/dist/record/host/cli/index.cjs +8 -0
  230. package/dist/record/host/cli/index.cjs.map +1 -0
  231. package/dist/record/host/cli/index.d.cts +1 -0
  232. package/dist/record/host/cli/index.d.mts +1 -0
  233. package/dist/record/host/cli/index.d.ts +1 -0
  234. package/dist/record/host/cli/index.js +10 -0
  235. package/dist/record/host/cli/index.js.map +1 -0
  236. package/dist/record/host/cli/presentation.cjs +122 -0
  237. package/dist/record/host/cli/presentation.cjs.map +1 -0
  238. package/dist/record/host/cli/presentation.d.cts +7 -0
  239. package/dist/record/host/cli/presentation.d.mts +7 -0
  240. package/dist/record/host/cli/presentation.d.ts +7 -0
  241. package/dist/record/host/cli/presentation.js +12 -0
  242. package/dist/record/host/cli/presentation.js.map +1 -0
  243. package/dist/record/host/index.cjs.map +1 -1
  244. package/dist/record/host/index.d.cts +1 -1
  245. package/dist/record/host/index.d.mts +1 -1
  246. package/dist/record/host/index.d.ts +1 -1
  247. package/dist/record/host/runtime.cjs +184 -1
  248. package/dist/record/host/runtime.cjs.map +1 -1
  249. package/dist/record/host/types.cjs.map +1 -1
  250. package/dist/record/host/types.d.cts +120 -0
  251. package/dist/record/host/types.d.mts +120 -0
  252. package/dist/record/host/types.d.ts +120 -0
  253. package/dist/record/project.json +6 -0
  254. package/dist/report/assets/styles.css +80 -0
  255. package/dist/report/cli/contribution.cjs +325 -0
  256. package/dist/report/cli/contribution.cjs.map +1 -0
  257. package/dist/report/cli/contribution.d.cts +143 -0
  258. package/dist/report/cli/contribution.d.mts +143 -0
  259. package/dist/report/cli/contribution.d.ts +143 -0
  260. package/dist/report/cli/contribution.js +12 -0
  261. package/dist/report/cli/contribution.js.map +1 -0
  262. package/dist/report/client-dist/app.js +9 -9
  263. package/dist/report/components/attempt-detail/content.cjs +1 -1
  264. package/dist/report/components/attempt-detail/content.cjs.map +1 -1
  265. package/dist/report/components/entity-lists/compute.cjs +5 -0
  266. package/dist/report/components/entity-lists/compute.cjs.map +1 -1
  267. package/dist/report/components/entity-lists/compute.d.cts +2 -0
  268. package/dist/report/components/entity-lists/compute.d.mts +2 -0
  269. package/dist/report/components/entity-lists/compute.d.ts +2 -0
  270. package/dist/report/components/entity-lists/content.cjs +35 -12
  271. package/dist/report/components/entity-lists/content.cjs.map +1 -1
  272. package/dist/report/components/entity-lists/index.cjs +0 -3
  273. package/dist/report/components/entity-lists/index.cjs.map +1 -1
  274. package/dist/report/components/summaries/index.cjs +2 -4
  275. package/dist/report/components/summaries/index.cjs.map +1 -1
  276. package/dist/report/definition/cell.cjs +7 -2
  277. package/dist/report/definition/cell.cjs.map +1 -1
  278. package/dist/report/definition/cell.d.cts +2 -0
  279. package/dist/report/definition/cell.d.mts +2 -0
  280. package/dist/report/definition/cell.d.ts +2 -0
  281. package/dist/report/definition/primitives/assertion-evidence.cjs +190 -4
  282. package/dist/report/definition/primitives/assertion-evidence.cjs.map +1 -1
  283. package/dist/report/definition/primitives/assertion-evidence.d.cts +4 -0
  284. package/dist/report/definition/primitives/assertion-evidence.d.mts +4 -0
  285. package/dist/report/definition/primitives/assertion-evidence.d.ts +4 -0
  286. package/dist/report/execution/machine.cjs +2 -3
  287. package/dist/report/execution/machine.cjs.map +1 -1
  288. package/dist/report/execution/machine.d.cts +11 -8
  289. package/dist/report/execution/machine.d.mts +11 -8
  290. package/dist/report/execution/machine.d.ts +11 -8
  291. package/dist/report/host/from-record.cjs +13 -8
  292. package/dist/report/host/from-record.cjs.map +1 -1
  293. package/dist/report/host/index.cjs +5 -1
  294. package/dist/report/host/index.cjs.map +1 -1
  295. package/dist/report/host/index.d.cts +1 -0
  296. package/dist/report/host/index.d.mts +1 -0
  297. package/dist/report/host/index.d.ts +1 -0
  298. package/dist/report/host/index.js +8 -2
  299. package/dist/report/host/index.mjs +8 -2
  300. package/dist/report/host/machine.cjs +23 -22
  301. package/dist/report/host/machine.cjs.map +1 -1
  302. package/dist/report/host/machine.d.cts +1 -1
  303. package/dist/report/host/machine.d.mts +1 -1
  304. package/dist/report/host/machine.d.ts +1 -1
  305. package/dist/report/host/node/loader.cjs +4 -2
  306. package/dist/report/host/node/loader.cjs.map +1 -1
  307. package/dist/report/host/node/loader.d.cts +3 -1
  308. package/dist/report/host/node/loader.d.mts +3 -1
  309. package/dist/report/host/node/loader.d.ts +3 -1
  310. package/dist/report/host/node.cjs +44 -9
  311. package/dist/report/host/node.cjs.map +1 -1
  312. package/dist/report/host/node.d.cts +13 -3
  313. package/dist/report/host/node.d.mts +13 -3
  314. package/dist/report/host/node.d.ts +13 -3
  315. package/dist/report/host/node.js +44 -32
  316. package/dist/report/host/operations.cjs +14 -0
  317. package/dist/report/host/operations.cjs.map +1 -0
  318. package/dist/report/host/operations.d.cts +39 -0
  319. package/dist/report/host/operations.d.mts +39 -0
  320. package/dist/report/host/operations.d.ts +39 -0
  321. package/dist/report/host/operations.js +10 -0
  322. package/dist/report/host/operations.js.map +1 -0
  323. package/dist/report/model/chart/plot.cjs +1 -1
  324. package/dist/report/model/chart/plot.cjs.map +1 -1
  325. package/dist/report/model/locale.cjs +4 -0
  326. package/dist/report/model/locale.cjs.map +1 -1
  327. package/dist/report/model/locale.d.cts +3 -1
  328. package/dist/report/model/locale.d.mts +3 -1
  329. package/dist/report/model/locale.d.ts +3 -1
  330. package/dist/report/react/styles.css +80 -0
  331. package/dist/runner/build-preparation.cjs +5 -5
  332. package/dist/runner/build-preparation.cjs.map +1 -1
  333. package/dist/runner/build-preparation.d.cts +2 -3
  334. package/dist/runner/build-preparation.d.mts +2 -3
  335. package/dist/runner/build-preparation.d.ts +2 -3
  336. package/dist/runner/feedback/coordinator.cjs +18 -15
  337. package/dist/runner/feedback/coordinator.cjs.map +1 -1
  338. package/dist/runner/feedback/coordinator.d.cts +6 -0
  339. package/dist/runner/feedback/coordinator.d.mts +6 -0
  340. package/dist/runner/feedback/coordinator.d.ts +6 -0
  341. package/dist/runner/ledger.cjs +3 -13
  342. package/dist/runner/ledger.cjs.map +1 -1
  343. package/dist/runner/ledger.d.cts +1 -3
  344. package/dist/runner/ledger.d.mts +1 -3
  345. package/dist/runner/ledger.d.ts +1 -3
  346. package/dist/runner/run.cjs +63 -18
  347. package/dist/runner/run.cjs.map +1 -1
  348. package/dist/runner/session.cjs +10 -0
  349. package/dist/runner/session.cjs.map +1 -1
  350. package/dist/runner/session.d.cts +25 -0
  351. package/dist/runner/session.d.mts +25 -0
  352. package/dist/runner/session.d.ts +25 -0
  353. package/dist/runner/types.cjs.map +1 -1
  354. package/dist/runner/types.d.cts +1 -2
  355. package/dist/runner/types.d.mts +1 -2
  356. package/dist/runner/types.d.ts +1 -2
  357. package/dist/sandbox/build-coordinator.cjs +38 -19
  358. package/dist/sandbox/build-coordinator.cjs.map +1 -1
  359. package/dist/sandbox/build-coordinator.d.cts +47 -7
  360. package/dist/sandbox/build-coordinator.d.mts +47 -7
  361. package/dist/sandbox/build-coordinator.d.ts +47 -7
  362. package/dist/sandbox/build-coordinator.js +8 -4
  363. package/dist/sandbox/cli/contribution.cjs +128 -0
  364. package/dist/sandbox/cli/contribution.cjs.map +1 -0
  365. package/dist/sandbox/cli/contribution.d.cts +71 -0
  366. package/dist/sandbox/cli/contribution.d.mts +71 -0
  367. package/dist/sandbox/cli/contribution.d.ts +71 -0
  368. package/dist/sandbox/cli/contribution.js +8 -0
  369. package/dist/sandbox/cli/contribution.js.map +1 -0
  370. package/dist/sandbox/cli-commands.cjs +14 -21
  371. package/dist/sandbox/cli-commands.cjs.map +1 -1
  372. package/dist/sandbox/cli-commands.d.cts +12 -8
  373. package/dist/sandbox/cli-commands.d.mts +12 -8
  374. package/dist/sandbox/cli-commands.d.ts +12 -8
  375. package/dist/sandbox/compose.cjs +22 -2
  376. package/dist/sandbox/compose.cjs.map +1 -1
  377. package/dist/sandbox/compose.d.cts +1 -1
  378. package/dist/sandbox/compose.d.mts +1 -1
  379. package/dist/sandbox/compose.d.ts +1 -1
  380. package/dist/sandbox/docker-profile/cli.cjs +13 -9
  381. package/dist/sandbox/docker-profile/cli.cjs.map +1 -1
  382. package/dist/sandbox/docker-profile/cli.d.cts +2 -0
  383. package/dist/sandbox/docker-profile/cli.d.mts +2 -0
  384. package/dist/sandbox/docker-profile/cli.d.ts +2 -0
  385. package/dist/sandbox/docker-profile/runtime.cjs +68 -7
  386. package/dist/sandbox/docker-profile/runtime.cjs.map +1 -1
  387. package/dist/sandbox/docker-profile/runtime.d.cts +19 -1
  388. package/dist/sandbox/docker-profile/runtime.d.mts +19 -1
  389. package/dist/sandbox/docker-profile/runtime.d.ts +19 -1
  390. package/dist/sandbox/docker-profile/runtime.js +10 -8
  391. package/dist/sandbox/docker-profile/schema.cjs +68 -19
  392. package/dist/sandbox/docker-profile/schema.cjs.map +1 -1
  393. package/dist/sandbox/docker-profile/schema.d.cts +23 -9
  394. package/dist/sandbox/docker-profile/schema.d.mts +23 -9
  395. package/dist/sandbox/docker-profile/schema.d.ts +23 -9
  396. package/dist/sandbox/docker-task-build-cache.cjs +532 -0
  397. package/dist/sandbox/docker-task-build-cache.cjs.map +1 -0
  398. package/dist/sandbox/docker-task-build-cache.d.cts +68 -0
  399. package/dist/sandbox/docker-task-build-cache.d.mts +68 -0
  400. package/dist/sandbox/docker-task-build-cache.d.ts +68 -0
  401. package/dist/sandbox/docker-task-build-cache.js +20 -0
  402. package/dist/sandbox/docker-task-build-cache.js.map +1 -0
  403. package/dist/sandbox/docker.cjs +50 -0
  404. package/dist/sandbox/docker.cjs.map +1 -1
  405. package/dist/sandbox/docker.d.cts +15 -0
  406. package/dist/sandbox/docker.d.mts +15 -0
  407. package/dist/sandbox/docker.d.ts +15 -0
  408. package/dist/sandbox/dockerfile-build.cjs +55 -5
  409. package/dist/sandbox/dockerfile-build.cjs.map +1 -1
  410. package/dist/sandbox/dockerfile-build.d.cts +2 -2
  411. package/dist/sandbox/dockerfile-build.d.mts +2 -2
  412. package/dist/sandbox/dockerfile-build.d.ts +2 -2
  413. package/dist/sandbox/index.cjs +5 -3
  414. package/dist/sandbox/index.cjs.map +1 -1
  415. package/dist/sandbox/index.d.cts +4 -3
  416. package/dist/sandbox/index.d.mts +4 -3
  417. package/dist/sandbox/index.d.ts +4 -3
  418. package/dist/sandbox/index.js +16 -14
  419. package/dist/sandbox/index.mjs +16 -14
  420. package/dist/sandbox/keep.cjs +1 -3
  421. package/dist/sandbox/keep.cjs.map +1 -1
  422. package/dist/sandbox/layer.cjs +70 -79
  423. package/dist/sandbox/layer.cjs.map +1 -1
  424. package/dist/sandbox/layer.d.cts +6 -12
  425. package/dist/sandbox/layer.d.mts +6 -12
  426. package/dist/sandbox/layer.d.ts +6 -12
  427. package/dist/sandbox/layer.js +16 -18
  428. package/dist/sandbox/ledger-paths.cjs +4 -18
  429. package/dist/sandbox/ledger-paths.cjs.map +1 -1
  430. package/dist/sandbox/ledger-paths.d.cts +3 -13
  431. package/dist/sandbox/ledger-paths.d.mts +3 -13
  432. package/dist/sandbox/ledger-paths.d.ts +3 -13
  433. package/dist/sandbox/ledger-paths.js +4 -8
  434. package/dist/sandbox/registry.cjs +1 -1
  435. package/dist/sandbox/registry.cjs.map +1 -1
  436. package/dist/sandbox/runtime.cjs +27 -37
  437. package/dist/sandbox/runtime.cjs.map +1 -1
  438. package/dist/sandbox/runtime.d.cts +1 -2
  439. package/dist/sandbox/runtime.d.mts +1 -2
  440. package/dist/sandbox/runtime.d.ts +1 -2
  441. package/dist/sandbox/runtime.js +6 -8
  442. package/dist/sandbox/types.cjs.map +1 -1
  443. package/dist/sandbox/types.d.cts +3 -3
  444. package/dist/sandbox/types.d.mts +3 -3
  445. package/dist/sandbox/types.d.ts +3 -3
  446. package/dist/sources/project.json +6 -0
  447. package/dist/vendor/remark/remark-gfm.cjs +72 -72
  448. package/dist/vendor/remark/remark-gfm.cjs.map +1 -1
  449. package/dist/vendor/remark/remark-parse.cjs +54 -54
  450. package/dist/vendor/remark/remark-parse.cjs.map +1 -1
  451. package/dist/vendor/remark/remark.cjs +125 -125
  452. package/dist/vendor/remark/remark.cjs.map +2 -2
  453. package/docs-site/zh/README.md +1 -1
  454. package/docs-site/zh/explanation/assert.mdx +4 -0
  455. package/docs-site/zh/explanation/judge.mdx +40 -9
  456. package/docs-site/zh/reference/cli.mdx +67 -43
  457. package/docs-site/zh/reference/define-agent.mdx +2 -2
  458. package/docs-site/zh/reference/report-components.mdx +4 -3
  459. package/docs-site/zh/troubleshooting/debug-sandbox.mdx +6 -0
  460. package/docs-site/zh/troubleshooting/debugging.mdx +28 -1
  461. package/docs-site/zh/tutorials/agent-feedback-loop.mdx +4 -2
  462. package/docs-site/zh/tutorials/concurrency.mdx +2 -2
  463. package/docs-site/zh/tutorials/custom-reports.mdx +175 -9
  464. package/docs-site/zh/tutorials/docker-in-docker.mdx +52 -7
  465. package/docs-site/zh/tutorials/eval-groups.mdx +1 -2
  466. package/docs-site/zh/tutorials/evaluation-kinds.mdx +39 -6
  467. package/docs-site/zh/tutorials/nixos-managed-dind.mdx +14 -5
  468. package/docs-site/zh/tutorials/sandbox-providers.mdx +1 -28
  469. package/docs-site/zh/tutorials/sandbox-reuse.mdx +1 -1
  470. package/docs-site/zh/tutorials/viewing-results.mdx +2 -0
  471. package/package.json +24 -19
  472. package/README.md +0 -176
  473. package/README.zh.md +0 -176
  474. package/dist/cli/record.cjs +0 -246
  475. package/dist/cli/record.cjs.map +0 -1
  476. package/dist/cli/record.d.cts +0 -40
  477. package/dist/cli/record.d.mts +0 -40
  478. package/dist/cli/record.d.ts +0 -40
  479. package/dist/cli/record.js +0 -10
  480. package/dist/cli/record.js.map +0 -1
  481. package/dist/sandbox/local.cjs +0 -361
  482. package/dist/sandbox/local.cjs.map +0 -1
  483. package/dist/sandbox/local.d.cts +0 -80
  484. package/dist/sandbox/local.d.mts +0 -80
  485. package/dist/sandbox/local.d.ts +0 -80
  486. package/dist/sandbox/local.js +0 -6
  487. package/dist/sandbox/local.js.map +0 -1
@@ -1,40 +0,0 @@
1
- import { Effect, Layer } from "effect";
2
- import type { RecordAttachmentMigrationTarget } from "../record/host/types.cjs";
3
- import { RecordAutoMigrationGitSaveRequired, RecordMigrationRequired } from "../record/reader/errors.cjs";
4
- import { RecordFileSystem } from "../record/platform/services.cjs";
5
- export type RecordCliCommand = "clean" | "migrate";
6
- export interface RunRecordCliCommandInput {
7
- readonly command: RecordCliCommand;
8
- readonly cwd: string;
9
- /** An actual Record root, never a `.niceeval` parent directory. */
10
- readonly record?: string;
11
- readonly yes: boolean;
12
- }
13
- /** The outer CLI owns process streams and exit; this value is its pure receipt. */
14
- export interface RecordCliCommandOutput {
15
- readonly exitCode: 0 | 1;
16
- readonly stdout: string;
17
- readonly stderr: string;
18
- }
19
- export declare const NodeRecordCliLive: Layer.Layer<import("../coordination/record-leases.cjs").RecordCoordination | RecordFileSystem | import("../record/platform/services.cjs").RecordEntropy | import("../record/platform/services.cjs").RecordGit, never, never>;
20
- export interface AutomaticRecordMigrationReceipt {
21
- readonly restoreCommit: string;
22
- readonly attachments: readonly RecordAttachmentMigrationTarget[];
23
- }
24
- /**
25
- * Preflight for ordinary CLI entry points. Every Scope is closed before the
26
- * next lease kind is acquired: read check -> exclusive maintenance -> caller's
27
- * fresh ordinary open.
28
- */
29
- export declare function ensureAutomaticRecordMigration(input: {
30
- readonly cwd: string;
31
- readonly record?: string;
32
- }): Effect.Effect<never, import("../record/index.cjs").RecordRootConstructionError, never> | Effect.Effect<Readonly<{
33
- restoreCommit: string;
34
- attachments: readonly RecordAttachmentMigrationTarget[];
35
- }> | null, import("../record/platform/errors.cjs").RecordMaintenanceBusy | import("../record/platform/errors.cjs").RecordGitCommandError | import("../record/platform/errors.cjs").RecordFileSystemError | import("../coordination/record-leases.cjs").RecordCoordinationIdentityMismatch | import("../record/reader/errors.cjs").RecordBootstrapInvalid | RecordMigrationRequired | import("../record/reader/errors.cjs").RecordFormatUnsupported | import("../record/reader/errors.cjs").RecordMigrationInterruptedState | import("../record/reader/errors.cjs").RecordMigrationPlanStale | import("../record/reader/errors.cjs").RecordMigrationGitRestoreRequired | RecordAutoMigrationGitSaveRequired | import("../record/reader/errors.cjs").RecordMigrationInvalid | import("../record/reader/errors.cjs").RecordMigrationRecoveryRequired, import("../coordination/record-leases.cjs").RecordCoordination | RecordFileSystem | import("../record/platform/services.cjs").RecordGit>;
36
- /**
37
- * Effect-native command handling for the Record maintenance surface. The
38
- * CLI owns the one Promise adaptation at its actual process boundary.
39
- */
40
- export declare function runRecordCliCommand(input: RunRecordCliCommandInput): Effect.Effect<RecordCliCommandOutput>;
@@ -1,40 +0,0 @@
1
- import { Effect, Layer } from "effect";
2
- import type { RecordAttachmentMigrationTarget } from "../record/host/types.mjs";
3
- import { RecordAutoMigrationGitSaveRequired, RecordMigrationRequired } from "../record/reader/errors.mjs";
4
- import { RecordFileSystem } from "../record/platform/services.mjs";
5
- export type RecordCliCommand = "clean" | "migrate";
6
- export interface RunRecordCliCommandInput {
7
- readonly command: RecordCliCommand;
8
- readonly cwd: string;
9
- /** An actual Record root, never a `.niceeval` parent directory. */
10
- readonly record?: string;
11
- readonly yes: boolean;
12
- }
13
- /** The outer CLI owns process streams and exit; this value is its pure receipt. */
14
- export interface RecordCliCommandOutput {
15
- readonly exitCode: 0 | 1;
16
- readonly stdout: string;
17
- readonly stderr: string;
18
- }
19
- export declare const NodeRecordCliLive: Layer.Layer<import("../coordination/record-leases.mjs").RecordCoordination | RecordFileSystem | import("../record/platform/services.mjs").RecordEntropy | import("../record/platform/services.mjs").RecordGit, never, never>;
20
- export interface AutomaticRecordMigrationReceipt {
21
- readonly restoreCommit: string;
22
- readonly attachments: readonly RecordAttachmentMigrationTarget[];
23
- }
24
- /**
25
- * Preflight for ordinary CLI entry points. Every Scope is closed before the
26
- * next lease kind is acquired: read check -> exclusive maintenance -> caller's
27
- * fresh ordinary open.
28
- */
29
- export declare function ensureAutomaticRecordMigration(input: {
30
- readonly cwd: string;
31
- readonly record?: string;
32
- }): Effect.Effect<never, import("../record/index.mjs").RecordRootConstructionError, never> | Effect.Effect<Readonly<{
33
- restoreCommit: string;
34
- attachments: readonly RecordAttachmentMigrationTarget[];
35
- }> | null, import("../record/platform/errors.mjs").RecordMaintenanceBusy | import("../record/platform/errors.mjs").RecordGitCommandError | import("../record/platform/errors.mjs").RecordFileSystemError | import("../coordination/record-leases.mjs").RecordCoordinationIdentityMismatch | import("../record/reader/errors.mjs").RecordBootstrapInvalid | RecordMigrationRequired | import("../record/reader/errors.mjs").RecordFormatUnsupported | import("../record/reader/errors.mjs").RecordMigrationInterruptedState | import("../record/reader/errors.mjs").RecordMigrationPlanStale | import("../record/reader/errors.mjs").RecordMigrationGitRestoreRequired | RecordAutoMigrationGitSaveRequired | import("../record/reader/errors.mjs").RecordMigrationInvalid | import("../record/reader/errors.mjs").RecordMigrationRecoveryRequired, import("../coordination/record-leases.mjs").RecordCoordination | RecordFileSystem | import("../record/platform/services.mjs").RecordGit>;
36
- /**
37
- * Effect-native command handling for the Record maintenance surface. The
38
- * CLI owns the one Promise adaptation at its actual process boundary.
39
- */
40
- export declare function runRecordCliCommand(input: RunRecordCliCommandInput): Effect.Effect<RecordCliCommandOutput>;
@@ -1,40 +0,0 @@
1
- import { Effect, Layer } from "effect";
2
- import type { RecordAttachmentMigrationTarget } from "../record/host/types.js";
3
- import { RecordAutoMigrationGitSaveRequired, RecordMigrationRequired } from "../record/reader/errors.js";
4
- import { RecordFileSystem } from "../record/platform/services.js";
5
- export type RecordCliCommand = "clean" | "migrate";
6
- export interface RunRecordCliCommandInput {
7
- readonly command: RecordCliCommand;
8
- readonly cwd: string;
9
- /** An actual Record root, never a `.niceeval` parent directory. */
10
- readonly record?: string;
11
- readonly yes: boolean;
12
- }
13
- /** The outer CLI owns process streams and exit; this value is its pure receipt. */
14
- export interface RecordCliCommandOutput {
15
- readonly exitCode: 0 | 1;
16
- readonly stdout: string;
17
- readonly stderr: string;
18
- }
19
- export declare const NodeRecordCliLive: Layer.Layer<import("../coordination/record-leases.js").RecordCoordination | RecordFileSystem | import("../record/platform/services.js").RecordEntropy | import("../record/platform/services.js").RecordGit, never, never>;
20
- export interface AutomaticRecordMigrationReceipt {
21
- readonly restoreCommit: string;
22
- readonly attachments: readonly RecordAttachmentMigrationTarget[];
23
- }
24
- /**
25
- * Preflight for ordinary CLI entry points. Every Scope is closed before the
26
- * next lease kind is acquired: read check -> exclusive maintenance -> caller's
27
- * fresh ordinary open.
28
- */
29
- export declare function ensureAutomaticRecordMigration(input: {
30
- readonly cwd: string;
31
- readonly record?: string;
32
- }): Effect.Effect<never, import("../record/index.js").RecordRootConstructionError, never> | Effect.Effect<Readonly<{
33
- restoreCommit: string;
34
- attachments: readonly RecordAttachmentMigrationTarget[];
35
- }> | null, import("../record/platform/errors.js").RecordMaintenanceBusy | import("../record/platform/errors.js").RecordGitCommandError | import("../record/platform/errors.js").RecordFileSystemError | import("../coordination/record-leases.js").RecordCoordinationIdentityMismatch | import("../record/reader/errors.js").RecordBootstrapInvalid | RecordMigrationRequired | import("../record/reader/errors.js").RecordFormatUnsupported | import("../record/reader/errors.js").RecordMigrationInterruptedState | import("../record/reader/errors.js").RecordMigrationPlanStale | import("../record/reader/errors.js").RecordMigrationGitRestoreRequired | RecordAutoMigrationGitSaveRequired | import("../record/reader/errors.js").RecordMigrationInvalid | import("../record/reader/errors.js").RecordMigrationRecoveryRequired, import("../coordination/record-leases.js").RecordCoordination | RecordFileSystem | import("../record/platform/services.js").RecordGit>;
36
- /**
37
- * Effect-native command handling for the Record maintenance surface. The
38
- * CLI owns the one Promise adaptation at its actual process boundary.
39
- */
40
- export declare function runRecordCliCommand(input: RunRecordCliCommandInput): Effect.Effect<RecordCliCommandOutput>;
@@ -1,10 +0,0 @@
1
- import { createRequire as __niceevalCreateRequire } from "node:module";
2
- const __niceevalRequire = __niceevalCreateRequire(import.meta.url);
3
- const __niceevalCanonical = __niceevalRequire("./record.cjs");
4
- const __niceevalExport0 = __niceevalCanonical["NodeRecordCliLive"];
5
- export { __niceevalExport0 as NodeRecordCliLive };
6
- const __niceevalExport1 = __niceevalCanonical["ensureAutomaticRecordMigration"];
7
- export { __niceevalExport1 as ensureAutomaticRecordMigration };
8
- const __niceevalExport2 = __niceevalCanonical["runRecordCliCommand"];
9
- export { __niceevalExport2 as runRecordCliCommand };
10
- //# sourceMappingURL=record.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"record.js","sources":[],"names":[],"mappings":""}
@@ -1,361 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocalSandbox = void 0;
4
- // Local 沙箱 provider:宿主机本地目录直接当 workdir 跑,零隔离、零仪式
5
- // (契约见 docs/feature/sandbox/local.md)。runCommand 按 argv 直接 spawn 宿主进程(不经 shell);
6
- // runShell 交给宿主 bash(与其它 provider 的 runShell 语义一致);文件 IO 走本地 fs——
7
- // 「沙箱」就是宿主文件系统本身,没有远端控制面、没有预制环境、没有留存。
8
- //
9
- // 变更分类账的 GIT_DIR 不能像其它 provider 那样固定在同一个宿主路径:多数 provider 每次创建都是
10
- // 全新隔离文件系统,固定路径天然不冲突;本地档的"沙箱"是宿主机本身,同机先后或并发跑的多个
11
- // attempt 共享同一个 /tmp,固定路径会在多次运行之间互相踩踏用户看不到的 git 索引。这里改用
12
- // mkdtemp 出的每实例私有目录,经 sandbox/ledger-paths.ts 登记给 runner/ledger.ts 消费——
13
- // ledger.ts 不需要认识"local"这个名字,只需要知道"这个 sandboxId 有没有登记覆盖路径"。
14
- const node_child_process_1 = require("node:child_process");
15
- const node_util_1 = require("node:util");
16
- const promises_1 = require("node:fs/promises");
17
- const node_fs_1 = require("node:fs");
18
- const node_os_1 = require("node:os");
19
- const node_path_1 = require("node:path");
20
- const node_crypto_1 = require("node:crypto");
21
- const paths_ts_1 = require("./paths.cjs");
22
- const deadline_ts_1 = require("./deadline.cjs");
23
- const local_files_ts_1 = require("./local-files.cjs");
24
- const download_directory_ts_1 = require("./download-directory.cjs");
25
- const operations_ts_1 = require("./operations.cjs");
26
- const backend_ts_1 = require("./backend.cjs");
27
- const ledger_paths_ts_1 = require("./ledger-paths.cjs");
28
- const index_ts_1 = require("../i18n/index.cjs");
29
- const managed_process_ts_1 = require("./managed-process.cjs");
30
- const execFileAsync = (0, node_util_1.promisify)(node_child_process_1.execFile);
31
- /** 从给定目录向上解析 git 仓库根;不在任何 git 仓库内时给出两条出路。 */
32
- async function resolveGitRoot(cwd) {
33
- try {
34
- const { stdout } = await execFileAsync("git", ["rev-parse", "--show-toplevel"], { cwd });
35
- return stdout.trim();
36
- }
37
- catch {
38
- throw new Error((0, index_ts_1.t)("local.notARepo"));
39
- }
40
- }
41
- /** 显式 dir:相对路径按 cwd 解析;必须已存在且可写(不自动创建)。 */
42
- async function resolveExplicitDir(dir, cwd) {
43
- const abs = (0, node_path_1.resolve)(cwd, dir);
44
- try {
45
- await (0, promises_1.access)(abs, node_fs_1.constants.W_OK);
46
- }
47
- catch (e) {
48
- const err = e;
49
- if (err.code === "ENOENT")
50
- throw new Error((0, index_ts_1.t)("local.dirMissing", { dir: abs }));
51
- throw new Error((0, index_ts_1.t)("local.dirNotWritable", { dir: abs, message: err.message }));
52
- }
53
- const info = await (0, promises_1.stat)(abs);
54
- if (!info.isDirectory())
55
- throw new Error((0, index_ts_1.t)("local.dirNotWritable", { dir: abs, message: "not a directory" }));
56
- return abs;
57
- }
58
- async function resolveWorkdir(dir, cwd) {
59
- return dir !== undefined ? resolveExplicitDir(dir, cwd) : resolveGitRoot(cwd);
60
- }
61
- /** argv 直接 spawn(不经 shell)与「bash -c script」共用的执行核心。 */
62
- function runSpawned(command, args, opts) {
63
- return new Promise((resolvePromise, reject) => {
64
- // detached(POSIX):超时时能杀掉整个进程组,不只是直接子进程——agent 命令常常自己再
65
- // 起子进程(npm 脚本、shell 管道),只杀顶层容易留下孤儿。Windows 没有进程组这个概念,
66
- // 退化成直接 kill 顶层进程。
67
- const posix = process.platform !== "win32";
68
- const child = (0, node_child_process_1.spawn)(command, args, { cwd: opts.cwd, env: opts.env, detached: posix });
69
- let stdout = "";
70
- let stderr = "";
71
- let callbackChain = Promise.resolve();
72
- let settled = false;
73
- const killTree = () => {
74
- if (posix && child.pid !== undefined) {
75
- try {
76
- process.kill(-child.pid, "SIGKILL");
77
- }
78
- catch {
79
- child.kill("SIGKILL");
80
- }
81
- }
82
- else {
83
- child.kill("SIGKILL");
84
- }
85
- };
86
- let termination;
87
- const timer = opts.timeout === undefined ? undefined : setTimeout(() => {
88
- termination = "timeout";
89
- killTree();
90
- }, opts.timeout);
91
- const onAbort = () => {
92
- termination = "abort";
93
- killTree();
94
- };
95
- opts.signal?.addEventListener("abort", onAbort, { once: true });
96
- if (opts.signal?.aborted)
97
- onAbort();
98
- child.stdout?.on("data", (chunk) => {
99
- const text = chunk.toString("utf-8");
100
- stdout += text;
101
- const onStdout = opts.onStdout;
102
- if (onStdout !== undefined)
103
- callbackChain = callbackChain.then(() => onStdout(text));
104
- });
105
- child.stderr?.on("data", (chunk) => {
106
- const text = chunk.toString("utf-8");
107
- stderr += text;
108
- const onStderr = opts.onStderr;
109
- if (onStderr !== undefined)
110
- callbackChain = callbackChain.then(() => onStderr(text));
111
- });
112
- child.on("error", (err) => {
113
- if (settled)
114
- return;
115
- settled = true;
116
- if (timer !== undefined)
117
- clearTimeout(timer);
118
- opts.signal?.removeEventListener("abort", onAbort);
119
- reject(err);
120
- });
121
- child.on("close", (code, signal) => {
122
- if (settled)
123
- return;
124
- settled = true;
125
- if (timer !== undefined)
126
- clearTimeout(timer);
127
- opts.signal?.removeEventListener("abort", onAbort);
128
- callbackChain
129
- .then(() => {
130
- if (termination === "abort") {
131
- reject(opts.signal?.reason ?? new DOMException("sandbox command aborted", "AbortError"));
132
- return;
133
- }
134
- if (termination === "timeout" && signal === "SIGKILL" && code === null && opts.timeout !== undefined) {
135
- reject(new deadline_ts_1.SandboxCommandTimeoutError((0, index_ts_1.t)("local.commandTimeout", { timeoutMs: opts.timeout }), opts.timeout, opts.explicitTimeout === true));
136
- return;
137
- }
138
- resolvePromise({ stdout, stderr, exitCode: code ?? 0 });
139
- })
140
- .catch(reject);
141
- });
142
- });
143
- }
144
- /**
145
- * Local 沙箱:宿主机的一个本地目录。实现 ../types.ts 的 Sandbox 接口。
146
- * 契约见 docs/feature/sandbox/local.md;实现要点见 docs/feature/sandbox/architecture.md
147
- * 「Local provider(宿主机,零隔离)」。
148
- */
149
- class LocalSandbox {
150
- workdir;
151
- otlpHost = "localhost";
152
- sandboxId;
153
- timeout;
154
- deadlineAt;
155
- ledgerBase;
156
- /** factory `pathPrepend`;按声明顺序前置到宿主 PATH,省略 = 空数组。 */
157
- pathPrepend;
158
- capabilities = {
159
- rootCommands: backend_ts_1.unsupportedBackendCapability,
160
- appendLog: backend_ts_1.unsupportedBackendCapability,
161
- suspend: backend_ts_1.unsupportedBackendCapability,
162
- ensureLifetime: backend_ts_1.unsupportedBackendCapability,
163
- setCommandDeadline: (0, backend_ts_1.supportedBackendCapability)((deadlineAt) => this.setCommandDeadline(deadlineAt)),
164
- managedProcess: (0, backend_ts_1.supportedBackendCapability)((input) => this.startManagedProcess(input)),
165
- };
166
- async startManagedProcess(input) {
167
- const [command, ...args] = input.argv;
168
- const output = new managed_process_ts_1.ManagedProcessOutput();
169
- const env = {
170
- ...process.env,
171
- ...input.env,
172
- ...(this.pathPrepend.length === 0
173
- ? {}
174
- : { PATH: `${this.pathPrepend.join(":")}:${process.env.PATH ?? ""}` }),
175
- };
176
- const posix = process.platform !== "win32";
177
- const child = (0, node_child_process_1.spawn)(command, args, {
178
- cwd: (0, paths_ts_1.resolveSandboxPath)(this.workdir, input.cwd),
179
- env,
180
- detached: posix,
181
- stdio: ["pipe", "pipe", "pipe"],
182
- });
183
- child.stdout.on("data", (bytes) => output.push({ _tag: "Stdout", bytes: new Uint8Array(bytes) }));
184
- child.stderr.on("data", (bytes) => output.push({ _tag: "Stderr", bytes: new Uint8Array(bytes) }));
185
- const exit = new Promise((resolve, reject) => {
186
- child.once("error", (error) => { output.end(); reject(error); });
187
- child.once("close", (exitCode, signal) => {
188
- output.end();
189
- resolve({ exitCode, ...(signal === null ? {} : { signal }) });
190
- });
191
- });
192
- const terminate = async () => {
193
- stdinState = "closing";
194
- if (child.exitCode !== null || child.signalCode !== null)
195
- return;
196
- if (posix && child.pid !== undefined) {
197
- try {
198
- process.kill(-child.pid, "SIGKILL");
199
- }
200
- catch {
201
- child.kill("SIGKILL");
202
- }
203
- }
204
- else
205
- child.kill("SIGKILL");
206
- await exit.catch(() => undefined);
207
- };
208
- let stdinState = "open";
209
- let closeReceipt;
210
- let terminateReceipt;
211
- return {
212
- output,
213
- writeStdin: (bytes) => new Promise((resolve, reject) => {
214
- if (stdinState !== "open") {
215
- reject(new Error("managed process stdin is closed"));
216
- return;
217
- }
218
- child.stdin.write(bytes, (error) => error ? reject(error) : resolve());
219
- }),
220
- closeStdin: () => closeReceipt ??= new Promise((resolve) => {
221
- stdinState = "closing";
222
- child.stdin.end(() => { stdinState = "closed"; resolve(); });
223
- }),
224
- wait: () => exit,
225
- terminate: () => terminateReceipt ??= terminate(),
226
- };
227
- }
228
- constructor(workdir, ledgerBase, pathPrepend, timeout, deadlineAt) {
229
- this.workdir = workdir;
230
- this.ledgerBase = ledgerBase;
231
- this.pathPrepend = pathPrepend;
232
- this.timeout = timeout;
233
- this.deadlineAt = deadlineAt;
234
- this.sandboxId = `local-${(0, node_crypto_1.randomUUID)().slice(0, 8)}`;
235
- }
236
- /** 解析 workdir + 备好变更分类账的私有临时目录;Local provider 不参与 provisioning 重试。 */
237
- static async create(options = {}) {
238
- const workdir = await resolveWorkdir(options.dir, options.cwd ?? process.cwd());
239
- const ledgerBase = await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), "niceeval-local-ledger-"));
240
- const sandbox = new LocalSandbox(workdir, ledgerBase, options.pathPrepend ?? [], options.timeout, options.deadlineAt);
241
- // runner/ledger.ts 按 sandboxId 读取这份登记——本地档的"沙箱"是宿主机本身,固定的宿主路径
242
- // 会在同机多次运行之间互相踩踏,每实例必须有自己的一份(见文件头注释)。
243
- (0, ledger_paths_ts_1.registerLedgerPaths)(sandbox.sandboxId, {
244
- gitDir: (0, node_path_1.join)(ledgerBase, "ledger.git"),
245
- exportDir: (0, node_path_1.join)(ledgerBase, "export"),
246
- });
247
- return sandbox;
248
- }
249
- /** 复用下由池在每次借出时换成承接者自己的 deadline(见 sandbox/deadline.ts)。 */
250
- setCommandDeadline(deadlineAt) {
251
- this.deadlineAt = deadlineAt;
252
- }
253
- /** 宿主 env:`process.env` 叠加 `pathPrepend` 前置后的 PATH,`opts.env` 仍可覆盖任意键(含 PATH)。 */
254
- hostEnv(opts) {
255
- const pathBase = this.pathPrepend.length > 0
256
- ? { PATH: [...this.pathPrepend, ...(process.env.PATH ?? "").split(":")].join(":") }
257
- : {};
258
- return { ...process.env, ...pathBase, ...opts.env };
259
- }
260
- async runCommand(cmd, args = [], opts = {}) {
261
- if (opts.user !== undefined)
262
- throw new Error((0, index_ts_1.t)("local.userUnsupported", { user: opts.user }));
263
- const limit = (0, deadline_ts_1.commandLimit)(opts, { commandTimeoutMs: this.timeout, deadlineAt: this.deadlineAt });
264
- return runSpawned(cmd, [...args], {
265
- cwd: (0, paths_ts_1.resolveSandboxPath)(this.workdir, opts.cwd),
266
- env: this.hostEnv(opts),
267
- ...(limit.timeoutMs !== undefined ? { timeout: limit.timeoutMs } : {}),
268
- explicitTimeout: limit.explicit,
269
- onStdout: opts.onStdout,
270
- onStderr: opts.onStderr,
271
- signal: opts.signal,
272
- });
273
- }
274
- async runShell(script, opts = {}) {
275
- if (opts.user !== undefined)
276
- throw new Error((0, index_ts_1.t)("local.userUnsupported", { user: opts.user }));
277
- const limit = (0, deadline_ts_1.commandLimit)(opts, { commandTimeoutMs: this.timeout, deadlineAt: this.deadlineAt });
278
- return runSpawned("bash", ["-c", script], {
279
- cwd: (0, paths_ts_1.resolveSandboxPath)(this.workdir, opts.cwd),
280
- env: this.hostEnv(opts),
281
- ...(limit.timeoutMs !== undefined ? { timeout: limit.timeoutMs } : {}),
282
- explicitTimeout: limit.explicit,
283
- onStdout: opts.onStdout,
284
- onStderr: opts.onStderr,
285
- signal: opts.signal,
286
- });
287
- }
288
- async runCommandOrThrow(cmd, args = [], opts = {}) {
289
- return (0, operations_ts_1.successfulCommandResult)(await this.runCommand(cmd, args, opts), opts.sensitiveValues);
290
- }
291
- async runShellOrThrow(script, opts = {}) {
292
- return (0, operations_ts_1.successfulCommandResult)(await this.runShell(script, opts), opts.sensitiveValues);
293
- }
294
- async readText(path) {
295
- return (0, promises_1.readFile)((0, paths_ts_1.resolveSandboxPath)(this.workdir, path), "utf-8");
296
- }
297
- async pathExists(path) {
298
- try {
299
- await (0, promises_1.access)((0, paths_ts_1.resolveSandboxPath)(this.workdir, path));
300
- return true;
301
- }
302
- catch {
303
- return false;
304
- }
305
- }
306
- async writeText(path, content) {
307
- await this.writeBytes(path, Buffer.from(content, "utf-8"));
308
- }
309
- async writeCollectedFiles(files, targetDir) {
310
- const target = (0, paths_ts_1.resolveSandboxPath)(this.workdir, targetDir);
311
- for (const file of files) {
312
- const dest = (0, paths_ts_1.resolveSandboxPath)(target, file.path);
313
- await (0, promises_1.mkdir)((0, node_path_1.dirname)(dest), { recursive: true });
314
- await (0, promises_1.writeFile)(dest, file.content);
315
- }
316
- }
317
- async readBytes(path) {
318
- return (0, promises_1.readFile)((0, paths_ts_1.resolveSandboxPath)(this.workdir, path));
319
- }
320
- async writeBytes(path, content) {
321
- const dest = (0, paths_ts_1.resolveSandboxPath)(this.workdir, path);
322
- await (0, promises_1.mkdir)((0, node_path_1.dirname)(dest), { recursive: true });
323
- await (0, promises_1.writeFile)(dest, content);
324
- }
325
- async uploadFile(source, targetPath) {
326
- await this.writeBytes(targetPath, await (0, promises_1.readFile)((0, paths_ts_1.resolveLocalPath)(undefined, source)));
327
- }
328
- async uploadDirectory(sourceDir, targetDir, opts = {}) {
329
- const files = await (0, local_files_ts_1.collectLocalFiles)((0, paths_ts_1.resolveLocalPath)(undefined, sourceDir), opts.ignore);
330
- await this.writeCollectedFiles(files, targetDir);
331
- }
332
- async downloadFile(sourcePath, target) {
333
- const destination = (0, paths_ts_1.resolveLocalPath)(undefined, target);
334
- await (0, promises_1.mkdir)((0, node_path_1.dirname)(destination), { recursive: true });
335
- await (0, promises_1.writeFile)(destination, await this.readBytes(sourcePath));
336
- }
337
- /**
338
- * 与 vercel/e2b 共用同一套「find 列路径 + 逐文件读取」模板(见 download-directory.ts):
339
- * 复用是为了让 ignore 的 basename 剪除语义与落盘行为在三个 provider 间保持逐字节一致,
340
- * 不是本地档做不了更直接的 fs 递归拷贝——用同一份实现,行为差异这个物种直接不存在。
341
- */
342
- async downloadDirectory(sourceDir, targetDir, opts = {}) {
343
- const remoteDir = (0, paths_ts_1.resolveSandboxPath)(this.workdir, sourceDir);
344
- await (0, download_directory_ts_1.downloadDirectoryByList)({
345
- localDir: (0, paths_ts_1.resolveLocalPath)(undefined, targetDir),
346
- ignore: opts.ignore ?? [],
347
- runShell: (script) => this.runShell(script, { cwd: remoteDir }),
348
- readOne: (relPath) => this.readBytes(`${remoteDir}/${relPath}`),
349
- });
350
- }
351
- /**
352
- * 只清 runner 私有资源(分类账的私有 GIT_DIR 临时目录),不动工作树任何文件——本地档从不
353
- * 销毁"沙箱",因为宿主机本身不是可销毁的资源(见 docs/feature/sandbox/local.md「只观察,不还原」)。
354
- */
355
- async stop() {
356
- (0, ledger_paths_ts_1.unregisterLedgerPaths)(this.sandboxId);
357
- await (0, promises_1.rm)(this.ledgerBase, { recursive: true, force: true }).catch(() => { });
358
- }
359
- }
360
- exports.LocalSandbox = LocalSandbox;
361
- //# sourceMappingURL=local.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"local.js","sourceRoot":"","sources":["local.ts"],"names":[],"mappings":";;;AAAA,iDAAiD;AACjD,iFAAiF;AACjF,kEAAkE;AAClE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,gDAAgD;AAChD,wDAAwD;AACxD,wEAAwE;AACxE,4DAA4D;AAC5D,2DAAqD;AACrD,yCAAsC;AACtC,+CAAsH;AACtH,qCAAmD;AACnD,qCAAiC;AACjC,yCAAkE;AAClE,6CAAyC;AAEzC,yCAAkE;AAClE,+CAAyE;AACzE,qDAA8E;AAC9E,mEAAkE;AAClE,mDAA0D;AAC1D,6CAAsH;AACtH,uDAA+E;AAC/E,+CAAqC;AACrC,6DAA4D;AAC5D,MAAM,aAAa,GAAG,IAAA,qBAAS,EAAC,6BAAQ,CAAC,CAAC;AAoB1C,6CAA6C;AAC7C,KAAK,UAAU,cAAc,CAAC,GAAW;IACrC,IAAI,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,iBAAiB,C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机本地目录直接当 workdir 跑,零隔离、零仪式\n// (契约见 docs/feature/sandbox/local.md)。runCommand 按 argv 直接 spawn 宿主进程(不经 shell);\n// runShell 交给宿主 bash(与其它 provider 的 runShell 语义一致);文件 IO 走本地 fs——\n// 「沙箱」就是宿主文件系统本身,没有远端控制面、没有预制环境、没有留存。\n//\n// 变更分类账的 GIT_DIR 不能像其它 provider 那样固定在同一个宿主路径:多数 provider 每次创建都是\n// 全新隔离文件系统,固定路径天然不冲突;本地档的\"沙箱\"是宿主机本身,同机先后或并发跑的多个\n// attempt 共享同一个 /tmp,固定路径会在多次运行之间互相踩踏用户看不到的 git 索引。这里改用\n// mkdtemp 出的每实例私有目录,经 sandbox/ledger-paths.ts 登记给 runner/ledger.ts 消费——\n// ledger.ts 不需要认识\"local\"这个名字,只需要知道\"这个 sandboxId 有没有登记覆盖路径\"。\nimport { spawn, execFile } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { mkdtemp, mkdir, rm, readFile as fsReadFile, writeFile as fsWriteFile, access, stat } from \"node:fs/promises\";\nimport { constants as fsConstants } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join, resolve as resolvePath } from \"node:path\";\nimport { randomUUID } from \"node:crypto\";\nimport type { CommandOptions, CommandResult, ManagedProcess, ManagedProcessStart, SuccessfulCommandResult } from \"../types.ts\";\nimport { resolveLocalPath, resolveSandboxPath } from \"./paths.ts\";\nimport { commandLimit, SandboxCommandTimeoutError } from \"./deadline.ts\";\nimport { collectLocalFiles, type CollectedLocalFile } from \"./local-files.ts\";\nimport { downloadDirectoryByList } from \"./download-directory.ts\";\nimport { successfulCommandResult } from \"./operations.ts\";\nimport { supportedBackendCapability, unsupportedBackendCapability, type SandboxProviderBackend, } from \"./backend.ts\";\nimport { registerLedgerPaths, unregisterLedgerPaths } from \"./ledger-paths.ts\";\nimport { t } from \"../i18n/index.ts\";\nimport { ManagedProcessOutput } from \"./managed-process.ts\";\nconst execFileAsync = promisify(execFile);\nexport interface LocalSandboxOptions {\n /** 显式 workdir;省略时从当前目录向上解析 git 仓库根。 */\n dir?: string;\n /** attempt 的超时上限(毫秒),单条命令未显式传 `timeout` 时的上限来源;省略 = 没有上限。 */\n timeout?: number;\n /** attempt deadline 的截止时刻(epoch ms);单条命令按剩余量取上限(见 deadline.ts)。 */\n deadlineAt?: number;\n /**\n * 按序前置到宿主 `PATH` 的目录;省略 = 不改 PATH(见 docs/feature/sandbox/library.md\n * 「PATH:受管变量与 pathPrepend」)。\n */\n pathPrepend?: readonly string[];\n /**\n * 内部测试用:覆盖「当前目录」的解析起点(省略 `dir` 时向上找 git 根、显式 `dir` 时的相对路径\n * 基准都从它算)。生产路径(runtime.ts 的 provider materializer)从不传这个字段,恒用\n * `process.cwd()`——不是公开 spec 的一部分,`localSandbox()` 工厂不暴露它。\n */\n cwd?: string;\n}\n/** 从给定目录向上解析 git 仓库根;不在任何 git 仓库内时给出两条出路。 */\nasync function resolveGitRoot(cwd: string): Promise<string> {\n try {\n const { stdout } = await execFileAsync(\"git\", [\"rev-parse\", \"--show-toplevel\"], { cwd });\n return stdout.trim();\n }\n catch {\n throw new Error(t(\"local.notARepo\"));\n }\n}\n/** 显式 dir:相对路径按 cwd 解析;必须已存在且可写(不自动创建)。 */\nasync function resolveExplicitDir(dir: string, cwd: string): Promise<string> {\n const abs = resolvePath(cwd, dir);\n try {\n await access(abs, fsConstants.W_OK);\n }\n catch (e) {\n const err = e as NodeJS.ErrnoException;\n if (err.code === \"ENOENT\")\n throw new Error(t(\"local.dirMissing\", { dir: abs }));\n throw new Error(t(\"local.dirNotWritable\", { dir: abs, message: err.message }));\n }\n const info = await stat(abs);\n if (!info.isDirectory())\n throw new Error(t(\"local.dirNotWritable\", { dir: abs, message: \"not a directory\" }));\n return abs;\n}\nasync function resolveWorkdir(dir: string | undefined, cwd: string): Promise<string> {\n return dir !== undefined ? resolveExplicitDir(dir, cwd) : resolveGitRoot(cwd);\n}\ninterface SpawnOpts {\n cwd: string;\n env: NodeJS.ProcessEnv;\n /** 缺席 = 这条命令没有上限(四层解析链一个都没声明)。 */\n timeout?: number;\n explicitTimeout?: boolean;\n onStdout?: CommandOptions[\"onStdout\"];\n onStderr?: CommandOptions[\"onStderr\"];\n signal?: AbortSignal;\n}\n/** argv 直接 spawn(不经 shell)与「bash -c script」共用的执行核心。 */\nfunction runSpawned(command: string, args: string[], opts: SpawnOpts): Promise<CommandResult> {\n return new Promise((resolvePromise, reject) => {\n // detached(POSIX):超时时能杀掉整个进程组,不只是直接子进程——agent 命令常常自己再\n // 起子进程(npm 脚本、shell 管道),只杀顶层容易留下孤儿。Windows 没有进程组这个概念,\n // 退化成直接 kill 顶层进程。\n const posix = process.platform !== \"win32\";\n const child = spawn(command, args, { cwd: opts.cwd, env: opts.env, detached: posix });\n let stdout = \"\";\n let stderr = \"\";\n let callbackChain = Promise.resolve();\n let settled = false;\n const killTree = (): void => {\n if (posix && child.pid !== undefined) {\n try {\n process.kill(-child.pid, \"SIGKILL\");\n }\n catch {\n child.kill(\"SIGKILL\");\n }\n }\n else {\n child.kill(\"SIGKILL\");\n }\n };\n let termination: \"timeout\" | \"abort\" | undefined;\n const timer = opts.timeout === undefined ? undefined : setTimeout(() => {\n termination = \"timeout\";\n killTree();\n }, opts.timeout);\n const onAbort = (): void => {\n termination = \"abort\";\n killTree();\n };\n opts.signal?.addEventListener(\"abort\", onAbort, { once: true });\n if (opts.signal?.aborted)\n onAbort();\n child.stdout?.on(\"data\", (chunk: Buffer) => {\n const text = chunk.toString(\"utf-8\");\n stdout += text;\n const onStdout = opts.onStdout;\n if (onStdout !== undefined)\n callbackChain = callbackChain.then(() => onStdout(text));\n });\n child.stderr?.on(\"data\", (chunk: Buffer) => {\n const text = chunk.toString(\"utf-8\");\n stderr += text;\n const onStderr = opts.onStderr;\n if (onStderr !== undefined)\n callbackChain = callbackChain.then(() => onStderr(text));\n });\n child.on(\"error\", (err) => {\n if (settled)\n return;\n settled = true;\n if (timer !== undefined)\n clearTimeout(timer);\n opts.signal?.removeEventListener(\"abort\", onAbort);\n reject(err);\n });\n child.on(\"close\", (code, signal) => {\n if (settled)\n return;\n settled = true;\n if (timer !== undefined)\n clearTimeout(timer);\n opts.signal?.removeEventListener(\"abort\", onAbort);\n callbackChain\n .then(() => {\n if (termination === \"abort\") {\n reject(opts.signal?.reason ?? new DOMException(\"sandbox command aborted\", \"AbortError\"));\n return;\n }\n if (termination === \"timeout\" && signal === \"SIGKILL\" && code === null && opts.timeout !== undefined) {\n reject(new SandboxCommandTimeoutError(t(\"local.commandTimeout\", { timeoutMs: opts.timeout }), opts.timeout, opts.explicitTimeout === true));\n return;\n }\n resolvePromise({ stdout, stderr, exitCode: code ?? 0 });\n })\n .catch(reject);\n });\n });\n}\n/**\n * Local 沙箱:宿主机的一个本地目录。实现 ../types.ts 的 Sandbox 接口。\n * 契约见 docs/feature/sandbox/local.md;实现要点见 docs/feature/sandbox/architecture.md\n * 「Local provider(宿主机,零隔离)」。\n */\nexport class LocalSandbox implements SandboxProviderBackend {\n readonly workdir: string;\n readonly otlpHost = \"localhost\";\n readonly sandboxId: string;\n private readonly timeout?: number;\n private deadlineAt?: number;\n private readonly ledgerBase: string;\n /** factory `pathPrepend`;按声明顺序前置到宿主 PATH,省略 = 空数组。 */\n private readonly pathPrepend: readonly string[];\n readonly capabilities = {\n rootCommands: unsupportedBackendCapability,\n appendLog: unsupportedBackendCapability,\n suspend: unsupportedBackendCapability,\n ensureLifetime: unsupportedBackendCapability,\n setCommandDeadline: supportedBackendCapability((deadlineAt?: number) => this.setCommandDeadline(deadlineAt)),\n managedProcess: supportedBackendCapability((input: ManagedProcessStart) => this.startManagedProcess(input)),\n };\n private async startManagedProcess(input: ManagedProcessStart): Promise<ManagedProcess> {\n const [command, ...args] = input.argv;\n const output = new ManagedProcessOutput();\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n ...input.env,\n ...(this.pathPrepend.length === 0\n ? {}\n : { PATH: `${this.pathPrepend.join(\":\")}:${process.env.PATH ?? \"\"}` }),\n };\n const posix = process.platform !== \"win32\";\n const child = spawn(command, args, {\n cwd: resolveSandboxPath(this.workdir, input.cwd),\n env,\n detached: posix,\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n child.stdout.on(\"data\", (bytes: Buffer) => output.push({ _tag: \"Stdout\", bytes: new Uint8Array(bytes) }));\n child.stderr.on(\"data\", (bytes: Buffer) => output.push({ _tag: \"Stderr\", bytes: new Uint8Array(bytes) }));\n const exit = new Promise<import(\"../types.ts\").ManagedProcessExit>((resolve, reject) => {\n child.once(\"error\", (error) => { output.end(); reject(error); });\n child.once(\"close\", (exitCode, signal) => {\n output.end();\n resolve({ exitCode, ...(signal === null ? {} : { signal }) });\n });\n });\n const terminate = async (): Promise<void> => {\n stdinState = \"closing\";\n if (child.exitCode !== null || child.signalCode !== null)\n return;\n if (posix && child.pid !== undefined) {\n try {\n process.kill(-child.pid, \"SIGKILL\");\n }\n catch {\n child.kill(\"SIGKILL\");\n }\n }\n else\n child.kill(\"SIGKILL\");\n await exit.catch(() => undefined);\n };\n let stdinState: \"open\" | \"closing\" | \"closed\" = \"open\";\n let closeReceipt: Promise<void> | undefined;\n let terminateReceipt: Promise<void> | undefined;\n return {\n output,\n writeStdin: (bytes) => new Promise<void>((resolve, reject) => {\n if (stdinState !== \"open\") {\n reject(new Error(\"managed process stdin is closed\"));\n return;\n }\n child.stdin.write(bytes, (error) => error ? reject(error) : resolve());\n }),\n closeStdin: () => closeReceipt ??= new Promise<void>((resolve) => {\n stdinState = \"closing\";\n child.stdin.end(() => { stdinState = \"closed\"; resolve(); });\n }),\n wait: () => exit,\n terminate: () => terminateReceipt ??= terminate(),\n };\n }\n private constructor(workdir: string, ledgerBase: string, pathPrepend: readonly string[], timeout?: number, deadlineAt?: number) {\n this.workdir = workdir;\n this.ledgerBase = ledgerBase;\n this.pathPrepend = pathPrepend;\n this.timeout = timeout;\n this.deadlineAt = deadlineAt;\n this.sandboxId = `local-${randomUUID().slice(0, 8)}`;\n }\n /** 解析 workdir + 备好变更分类账的私有临时目录;Local provider 不参与 provisioning 重试。 */\n static async create(options: LocalSandboxOptions = {}): Promise<LocalSandbox> {\n const workdir = await resolveWorkdir(options.dir, options.cwd ?? process.cwd());\n const ledgerBase = await mkdtemp(join(tmpdir(), \"niceeval-local-ledger-\"));\n const sandbox = new LocalSandbox(workdir, ledgerBase, options.pathPrepend ?? [], options.timeout, options.deadlineAt);\n // runner/ledger.ts 按 sandboxId 读取这份登记——本地档的\"沙箱\"是宿主机本身,固定的宿主路径\n // 会在同机多次运行之间互相踩踏,每实例必须有自己的一份(见文件头注释)。\n registerLedgerPaths(sandbox.sandboxId, {\n gitDir: join(ledgerBase, \"ledger.git\"),\n exportDir: join(ledgerBase, \"export\"),\n });\n return sandbox;\n }\n /** 复用下由池在每次借出时换成承接者自己的 deadline(见 sandbox/deadline.ts)。 */\n setCommandDeadline(deadlineAt?: number): void {\n this.deadlineAt = deadlineAt;\n }\n /** 宿主 env:`process.env` 叠加 `pathPrepend` 前置后的 PATH,`opts.env` 仍可覆盖任意键(含 PATH)。 */\n private hostEnv(opts: CommandOptions): NodeJS.ProcessEnv {\n const pathBase = this.pathPrepend.length > 0\n ? { PATH: [...this.pathPrepend, ...(process.env.PATH ?? \"\").split(\":\")].join(\":\") }\n : {};\n return { ...process.env, ...pathBase, ...opts.env };\n }\n async runCommand(cmd: string, args: readonly string[] = [], opts: CommandOptions = {}): Promise<CommandResult> {\n if (opts.user !== undefined)\n throw new Error(t(\"local.userUnsupported\", { user: opts.user }));\n const limit = commandLimit(opts, { commandTimeoutMs: this.timeout, deadlineAt: this.deadlineAt });\n return runSpawned(cmd, [...args], {\n cwd: resolveSandboxPath(this.workdir, opts.cwd),\n env: this.hostEnv(opts),\n ...(limit.timeoutMs !== undefined ? { timeout: limit.timeoutMs } : {}),\n explicitTimeout: limit.explicit,\n onStdout: opts.onStdout,\n onStderr: opts.onStderr,\n signal: opts.signal,\n });\n }\n async runShell(script: string, opts: CommandOptions = {}): Promise<CommandResult> {\n if (opts.user !== undefined)\n throw new Error(t(\"local.userUnsupported\", { user: opts.user }));\n const limit = commandLimit(opts, { commandTimeoutMs: this.timeout, deadlineAt: this.deadlineAt });\n return runSpawned(\"bash\", [\"-c\", script], {\n cwd: resolveSandboxPath(this.workdir, opts.cwd),\n env: this.hostEnv(opts),\n ...(limit.timeoutMs !== undefined ? { timeout: limit.timeoutMs } : {}),\n explicitTimeout: limit.explicit,\n onStdout: opts.onStdout,\n onStderr: opts.onStderr,\n signal: opts.signal,\n });\n }\n async runCommandOrThrow(cmd: string, args: readonly string[] = [], opts: CommandOptions = {}): Promise<SuccessfulCommandResult> {\n return successfulCommandResult(await this.runCommand(cmd, args, opts), opts.sensitiveValues);\n }\n async runShellOrThrow(script: string, opts: CommandOptions = {}): Promise<SuccessfulCommandResult> {\n return successfulCommandResult(await this.runShell(script, opts), opts.sensitiveValues);\n }\n async readText(path: string): Promise<string> {\n return fsReadFile(resolveSandboxPath(this.workdir, path), \"utf-8\");\n }\n async pathExists(path: string): Promise<boolean> {\n try {\n await access(resolveSandboxPath(this.workdir, path));\n return true;\n }\n catch {\n return false;\n }\n }\n async writeText(path: string, content: string): Promise<void> {\n await this.writeBytes(path, Buffer.from(content, \"utf-8\"));\n }\n private async writeCollectedFiles(files: readonly CollectedLocalFile[], targetDir?: string): Promise<void> {\n const target = resolveSandboxPath(this.workdir, targetDir);\n for (const file of files) {\n const dest = resolveSandboxPath(target, file.path);\n await mkdir(dirname(dest), { recursive: true });\n await fsWriteFile(dest, file.content);\n }\n }\n async readBytes(path: string): Promise<Uint8Array> {\n return fsReadFile(resolveSandboxPath(this.workdir, path));\n }\n async writeBytes(path: string, content: Uint8Array): Promise<void> {\n const dest = resolveSandboxPath(this.workdir, path);\n await mkdir(dirname(dest), { recursive: true });\n await fsWriteFile(dest, content);\n }\n async uploadFile(source: string | URL, targetPath: string): Promise<void> {\n await this.writeBytes(targetPath, await fsReadFile(resolveLocalPath(undefined, source)));\n }\n async uploadDirectory(sourceDir: string | URL, targetDir?: string, opts: {\n readonly ignore?: readonly string[];\n } = {}): Promise<void> {\n const files = await collectLocalFiles(resolveLocalPath(undefined, sourceDir), opts.ignore);\n await this.writeCollectedFiles(files, targetDir);\n }\n async downloadFile(sourcePath: string, target: string | URL): Promise<void> {\n const destination = resolveLocalPath(undefined, target);\n await mkdir(dirname(destination), { recursive: true });\n await fsWriteFile(destination, await this.readBytes(sourcePath));\n }\n /**\n * 与 vercel/e2b 共用同一套「find 列路径 + 逐文件读取」模板(见 download-directory.ts):\n * 复用是为了让 ignore 的 basename 剪除语义与落盘行为在三个 provider 间保持逐字节一致,\n * 不是本地档做不了更直接的 fs 递归拷贝——用同一份实现,行为差异这个物种直接不存在。\n */\n async downloadDirectory(sourceDir: string, targetDir: string | URL, opts: {\n readonly ignore?: readonly string[];\n } = {}): Promise<void> {\n const remoteDir = resolveSandboxPath(this.workdir, sourceDir);\n await downloadDirectoryByList({\n localDir: resolveLocalPath(undefined, targetDir),\n ignore: opts.ignore ?? [],\n runShell: (script) => this.runShell(script, { cwd: remoteDir }),\n readOne: (relPath) => this.readBytes(`${remoteDir}/${relPath}`),\n });\n }\n /**\n * 只清 runner 私有资源(分类账的私有 GIT_DIR 临时目录),不动工作树任何文件——本地档从不\n * 销毁\"沙箱\",因为宿主机本身不是可销毁的资源(见 docs/feature/sandbox/local.md「只观察,不还原」)。\n */\n async stop(): Promise<void> {\n unregisterLedgerPaths(this.sandboxId);\n await rm(this.ledgerBase, { recursive: true, force: true }).catch(() => { });\n }\n}\n"]}