@xrkseek/harness 0.4.0-rc.4 → 0.4.1

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 (625) hide show
  1. package/dist/index.d.ts +3 -2
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -2
  4. package/dist/index.js.map +1 -1
  5. package/node_modules/@xrkseek/checkpoint/README.md +88 -0
  6. package/node_modules/@xrkseek/checkpoint/dist/index.d.ts +5 -0
  7. package/node_modules/@xrkseek/checkpoint/dist/index.d.ts.map +1 -0
  8. package/node_modules/@xrkseek/checkpoint/dist/index.js +5 -0
  9. package/node_modules/@xrkseek/checkpoint/dist/index.js.map +1 -0
  10. package/node_modules/@xrkseek/checkpoint/dist/json-file.d.ts +5 -0
  11. package/node_modules/@xrkseek/checkpoint/dist/json-file.d.ts.map +1 -0
  12. package/node_modules/@xrkseek/checkpoint/dist/json-file.js +29 -0
  13. package/node_modules/@xrkseek/checkpoint/dist/json-file.js.map +1 -0
  14. package/node_modules/@xrkseek/checkpoint/dist/process-git.d.ts +8 -0
  15. package/node_modules/@xrkseek/checkpoint/dist/process-git.d.ts.map +1 -0
  16. package/node_modules/@xrkseek/checkpoint/dist/process-git.js +40 -0
  17. package/node_modules/@xrkseek/checkpoint/dist/process-git.js.map +1 -0
  18. package/node_modules/@xrkseek/checkpoint/dist/store.d.ts +101 -0
  19. package/node_modules/@xrkseek/checkpoint/dist/store.d.ts.map +1 -0
  20. package/node_modules/@xrkseek/checkpoint/dist/store.js +312 -0
  21. package/node_modules/@xrkseek/checkpoint/dist/store.js.map +1 -0
  22. package/node_modules/@xrkseek/checkpoint/dist/types.d.ts +65 -0
  23. package/node_modules/@xrkseek/checkpoint/dist/types.d.ts.map +1 -0
  24. package/node_modules/@xrkseek/checkpoint/dist/types.js +18 -0
  25. package/node_modules/@xrkseek/checkpoint/dist/types.js.map +1 -0
  26. package/node_modules/@xrkseek/checkpoint/package.json +23 -0
  27. package/node_modules/@xrkseek/code-runtime/README.md +11 -4
  28. package/node_modules/@xrkseek/code-runtime/dist/index.d.ts +43 -3
  29. package/node_modules/@xrkseek/code-runtime/dist/index.d.ts.map +1 -1
  30. package/node_modules/@xrkseek/code-runtime/dist/index.js +209 -7
  31. package/node_modules/@xrkseek/code-runtime/dist/index.js.map +1 -1
  32. package/node_modules/@xrkseek/context-fragments/README.md +28 -0
  33. package/node_modules/@xrkseek/context-fragments/dist/index.d.ts +104 -0
  34. package/node_modules/@xrkseek/context-fragments/dist/index.d.ts.map +1 -0
  35. package/node_modules/@xrkseek/context-fragments/dist/index.js +192 -0
  36. package/node_modules/@xrkseek/context-fragments/dist/index.js.map +1 -0
  37. package/node_modules/@xrkseek/context-fragments/package.json +27 -0
  38. package/node_modules/@xrkseek/core-agent-loop/dist/index.d.ts +1 -1
  39. package/node_modules/@xrkseek/core-agent-loop/dist/index.d.ts.map +1 -1
  40. package/node_modules/@xrkseek/core-agent-loop/dist/index.js +7 -4
  41. package/node_modules/@xrkseek/core-agent-loop/dist/index.js.map +1 -1
  42. package/node_modules/@xrkseek/core-agent-loop/dist/invariant.d.ts +11 -0
  43. package/node_modules/@xrkseek/core-agent-loop/dist/invariant.d.ts.map +1 -0
  44. package/node_modules/@xrkseek/core-agent-loop/dist/invariant.js +21 -0
  45. package/node_modules/@xrkseek/core-agent-loop/dist/invariant.js.map +1 -0
  46. package/node_modules/@xrkseek/core-agent-loop/dist/tool-result-bound.d.ts +7 -5
  47. package/node_modules/@xrkseek/core-agent-loop/dist/tool-result-bound.d.ts.map +1 -1
  48. package/node_modules/@xrkseek/core-agent-loop/dist/tool-result-bound.js +24 -109
  49. package/node_modules/@xrkseek/core-agent-loop/dist/tool-result-bound.js.map +1 -1
  50. package/node_modules/@xrkseek/core-agent-loop/package.json +7 -0
  51. package/node_modules/@xrkseek/core-session/README.md +3 -1
  52. package/node_modules/@xrkseek/core-session/dist/invariant.d.ts +18 -0
  53. package/node_modules/@xrkseek/core-session/dist/invariant.d.ts.map +1 -0
  54. package/node_modules/@xrkseek/core-session/dist/invariant.js +114 -0
  55. package/node_modules/@xrkseek/core-session/dist/invariant.js.map +1 -0
  56. package/node_modules/@xrkseek/core-session/dist/session-interchange.d.ts +2 -1
  57. package/node_modules/@xrkseek/core-session/dist/session-interchange.d.ts.map +1 -1
  58. package/node_modules/@xrkseek/core-session/dist/session-interchange.js +6 -1
  59. package/node_modules/@xrkseek/core-session/dist/session-interchange.js.map +1 -1
  60. package/node_modules/@xrkseek/core-session/dist/sqlite-store.d.ts.map +1 -1
  61. package/node_modules/@xrkseek/core-session/dist/sqlite-store.js +37 -23
  62. package/node_modules/@xrkseek/core-session/dist/sqlite-store.js.map +1 -1
  63. package/node_modules/@xrkseek/core-session/package.json +33 -26
  64. package/node_modules/@xrkseek/core-system-prompt/README.md +7 -7
  65. package/node_modules/@xrkseek/core-system-prompt/dist/index.d.ts +1 -1
  66. package/node_modules/@xrkseek/core-system-prompt/dist/index.d.ts.map +1 -1
  67. package/node_modules/@xrkseek/core-system-prompt/dist/index.js +1 -1
  68. package/node_modules/@xrkseek/core-system-prompt/dist/index.js.map +1 -1
  69. package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.d.ts +55 -3
  70. package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.d.ts.map +1 -1
  71. package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.js +107 -11
  72. package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.js.map +1 -1
  73. package/node_modules/@xrkseek/core-tools/dist/guards.d.ts +9 -1
  74. package/node_modules/@xrkseek/core-tools/dist/guards.d.ts.map +1 -1
  75. package/node_modules/@xrkseek/core-tools/dist/guards.js +53 -9
  76. package/node_modules/@xrkseek/core-tools/dist/guards.js.map +1 -1
  77. package/node_modules/@xrkseek/core-tools/dist/index.d.ts +2 -1
  78. package/node_modules/@xrkseek/core-tools/dist/index.d.ts.map +1 -1
  79. package/node_modules/@xrkseek/core-tools/dist/index.js +2 -1
  80. package/node_modules/@xrkseek/core-tools/dist/index.js.map +1 -1
  81. package/node_modules/@xrkseek/core-tools/dist/session-query-prompt.d.ts +5 -0
  82. package/node_modules/@xrkseek/core-tools/dist/session-query-prompt.d.ts.map +1 -0
  83. package/node_modules/@xrkseek/core-tools/dist/session-query-prompt.js +12 -0
  84. package/node_modules/@xrkseek/core-tools/dist/session-query-prompt.js.map +1 -0
  85. package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.d.ts.map +1 -1
  86. package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js +6 -2
  87. package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js.map +1 -1
  88. package/node_modules/@xrkseek/exec-computer-use/README.md +1 -1
  89. package/node_modules/@xrkseek/exec-computer-use/dist/format.d.ts.map +1 -1
  90. package/node_modules/@xrkseek/exec-computer-use/dist/format.js +7 -5
  91. package/node_modules/@xrkseek/exec-computer-use/dist/format.js.map +1 -1
  92. package/node_modules/@xrkseek/exec-computer-use/dist/index.d.ts +14 -3
  93. package/node_modules/@xrkseek/exec-computer-use/dist/index.d.ts.map +1 -1
  94. package/node_modules/@xrkseek/exec-computer-use/dist/index.js +22 -8
  95. package/node_modules/@xrkseek/exec-computer-use/dist/index.js.map +1 -1
  96. package/node_modules/@xrkseek/exec-computer-use/dist/keys.d.ts +10 -0
  97. package/node_modules/@xrkseek/exec-computer-use/dist/keys.d.ts.map +1 -0
  98. package/node_modules/@xrkseek/exec-computer-use/dist/keys.js +89 -0
  99. package/node_modules/@xrkseek/exec-computer-use/dist/keys.js.map +1 -0
  100. package/node_modules/@xrkseek/exec-computer-use/dist/tools.d.ts +3 -1
  101. package/node_modules/@xrkseek/exec-computer-use/dist/tools.d.ts.map +1 -1
  102. package/node_modules/@xrkseek/exec-computer-use/dist/tools.js +12 -8
  103. package/node_modules/@xrkseek/exec-computer-use/dist/tools.js.map +1 -1
  104. package/node_modules/@xrkseek/exec-computer-use/dist/windows-uia.d.ts.map +1 -1
  105. package/node_modules/@xrkseek/exec-computer-use/dist/windows-uia.js +138 -2
  106. package/node_modules/@xrkseek/exec-computer-use/dist/windows-uia.js.map +1 -1
  107. package/node_modules/@xrkseek/exec-fs/README.md +12 -9
  108. package/node_modules/@xrkseek/exec-fs/dist/apply-patch-apply.d.ts +32 -0
  109. package/node_modules/@xrkseek/exec-fs/dist/apply-patch-apply.d.ts.map +1 -0
  110. package/node_modules/@xrkseek/exec-fs/dist/apply-patch-apply.js +203 -0
  111. package/node_modules/@xrkseek/exec-fs/dist/apply-patch-apply.js.map +1 -0
  112. package/node_modules/@xrkseek/exec-fs/dist/apply-patch-parser.d.ts +52 -0
  113. package/node_modules/@xrkseek/exec-fs/dist/apply-patch-parser.d.ts.map +1 -0
  114. package/node_modules/@xrkseek/exec-fs/dist/apply-patch-parser.js +260 -0
  115. package/node_modules/@xrkseek/exec-fs/dist/apply-patch-parser.js.map +1 -0
  116. package/node_modules/@xrkseek/exec-fs/dist/apply-patch.d.ts +27 -0
  117. package/node_modules/@xrkseek/exec-fs/dist/apply-patch.d.ts.map +1 -0
  118. package/node_modules/@xrkseek/exec-fs/dist/apply-patch.js +69 -0
  119. package/node_modules/@xrkseek/exec-fs/dist/apply-patch.js.map +1 -0
  120. package/node_modules/@xrkseek/exec-fs/dist/index.d.ts +6 -1
  121. package/node_modules/@xrkseek/exec-fs/dist/index.d.ts.map +1 -1
  122. package/node_modules/@xrkseek/exec-fs/dist/index.js +72 -3
  123. package/node_modules/@xrkseek/exec-fs/dist/index.js.map +1 -1
  124. package/node_modules/@xrkseek/exec-fs/dist/present.d.ts +4 -0
  125. package/node_modules/@xrkseek/exec-fs/dist/present.d.ts.map +1 -1
  126. package/node_modules/@xrkseek/exec-fs/dist/present.js +25 -0
  127. package/node_modules/@xrkseek/exec-fs/dist/present.js.map +1 -1
  128. package/node_modules/@xrkseek/exec-fs/dist/routing-prompt.d.ts +1 -1
  129. package/node_modules/@xrkseek/exec-fs/dist/routing-prompt.d.ts.map +1 -1
  130. package/node_modules/@xrkseek/exec-fs/dist/routing-prompt.js +10 -6
  131. package/node_modules/@xrkseek/exec-fs/dist/routing-prompt.js.map +1 -1
  132. package/node_modules/@xrkseek/exec-image-gen/dist/index.d.ts +15 -2
  133. package/node_modules/@xrkseek/exec-image-gen/dist/index.d.ts.map +1 -1
  134. package/node_modules/@xrkseek/exec-image-gen/dist/index.js +14 -7
  135. package/node_modules/@xrkseek/exec-image-gen/dist/index.js.map +1 -1
  136. package/node_modules/@xrkseek/exec-image-gen/dist/tools.d.ts +6 -1
  137. package/node_modules/@xrkseek/exec-image-gen/dist/tools.d.ts.map +1 -1
  138. package/node_modules/@xrkseek/exec-image-gen/dist/tools.js +14 -8
  139. package/node_modules/@xrkseek/exec-image-gen/dist/tools.js.map +1 -1
  140. package/node_modules/@xrkseek/exec-memory/README.md +5 -3
  141. package/node_modules/@xrkseek/exec-memory/dist/http.d.ts +42 -0
  142. package/node_modules/@xrkseek/exec-memory/dist/http.d.ts.map +1 -0
  143. package/node_modules/@xrkseek/exec-memory/dist/http.js +232 -0
  144. package/node_modules/@xrkseek/exec-memory/dist/http.js.map +1 -0
  145. package/node_modules/@xrkseek/exec-memory/dist/index.d.ts +5 -2
  146. package/node_modules/@xrkseek/exec-memory/dist/index.d.ts.map +1 -1
  147. package/node_modules/@xrkseek/exec-memory/dist/index.js +3 -1
  148. package/node_modules/@xrkseek/exec-memory/dist/index.js.map +1 -1
  149. package/node_modules/@xrkseek/exec-memory/dist/provider.d.ts +19 -0
  150. package/node_modules/@xrkseek/exec-memory/dist/provider.d.ts.map +1 -0
  151. package/node_modules/@xrkseek/exec-memory/dist/provider.js +8 -0
  152. package/node_modules/@xrkseek/exec-memory/dist/provider.js.map +1 -0
  153. package/node_modules/@xrkseek/exec-memory/dist/resolve.d.ts +25 -0
  154. package/node_modules/@xrkseek/exec-memory/dist/resolve.d.ts.map +1 -0
  155. package/node_modules/@xrkseek/exec-memory/dist/resolve.js +46 -0
  156. package/node_modules/@xrkseek/exec-memory/dist/resolve.js.map +1 -0
  157. package/node_modules/@xrkseek/exec-memory/dist/store.d.ts +8 -4
  158. package/node_modules/@xrkseek/exec-memory/dist/store.d.ts.map +1 -1
  159. package/node_modules/@xrkseek/exec-memory/dist/store.js +6 -0
  160. package/node_modules/@xrkseek/exec-memory/dist/store.js.map +1 -1
  161. package/node_modules/@xrkseek/exec-memory/dist/tools.d.ts.map +1 -1
  162. package/node_modules/@xrkseek/exec-memory/dist/tools.js +12 -9
  163. package/node_modules/@xrkseek/exec-memory/dist/tools.js.map +1 -1
  164. package/node_modules/@xrkseek/exec-memory/dist/write-path.d.ts +17 -6
  165. package/node_modules/@xrkseek/exec-memory/dist/write-path.d.ts.map +1 -1
  166. package/node_modules/@xrkseek/exec-memory/dist/write-path.js +81 -20
  167. package/node_modules/@xrkseek/exec-memory/dist/write-path.js.map +1 -1
  168. package/node_modules/@xrkseek/exec-memory/package.json +1 -0
  169. package/node_modules/@xrkseek/exec-sandbox/dist/doctor.d.ts +24 -0
  170. package/node_modules/@xrkseek/exec-sandbox/dist/doctor.d.ts.map +1 -0
  171. package/node_modules/@xrkseek/exec-sandbox/dist/doctor.js +118 -0
  172. package/node_modules/@xrkseek/exec-sandbox/dist/doctor.js.map +1 -0
  173. package/node_modules/@xrkseek/exec-sandbox/dist/hardline.d.ts +24 -0
  174. package/node_modules/@xrkseek/exec-sandbox/dist/hardline.d.ts.map +1 -0
  175. package/node_modules/@xrkseek/exec-sandbox/dist/hardline.js +93 -0
  176. package/node_modules/@xrkseek/exec-sandbox/dist/hardline.js.map +1 -0
  177. package/node_modules/@xrkseek/exec-sandbox/dist/index.d.ts +3 -1
  178. package/node_modules/@xrkseek/exec-sandbox/dist/index.d.ts.map +1 -1
  179. package/node_modules/@xrkseek/exec-sandbox/dist/index.js +3 -1
  180. package/node_modules/@xrkseek/exec-sandbox/dist/index.js.map +1 -1
  181. package/node_modules/@xrkseek/exec-sandbox/dist/resolve.d.ts +17 -0
  182. package/node_modules/@xrkseek/exec-sandbox/dist/resolve.d.ts.map +1 -1
  183. package/node_modules/@xrkseek/exec-sandbox/dist/resolve.js +47 -5
  184. package/node_modules/@xrkseek/exec-sandbox/dist/resolve.js.map +1 -1
  185. package/node_modules/@xrkseek/exec-sandbox/dist/service.d.ts.map +1 -1
  186. package/node_modules/@xrkseek/exec-sandbox/dist/service.js +2 -5
  187. package/node_modules/@xrkseek/exec-sandbox/dist/service.js.map +1 -1
  188. package/node_modules/@xrkseek/exec-ssh/README.md +16 -16
  189. package/node_modules/@xrkseek/exec-ssh/dist/config.d.ts +10 -0
  190. package/node_modules/@xrkseek/exec-ssh/dist/config.d.ts.map +1 -1
  191. package/node_modules/@xrkseek/exec-ssh/dist/config.js +50 -0
  192. package/node_modules/@xrkseek/exec-ssh/dist/config.js.map +1 -1
  193. package/node_modules/@xrkseek/exec-ssh/dist/fs.d.ts +1 -1
  194. package/node_modules/@xrkseek/exec-ssh/dist/fs.d.ts.map +1 -1
  195. package/node_modules/@xrkseek/exec-ssh/dist/fs.js +18 -1
  196. package/node_modules/@xrkseek/exec-ssh/dist/fs.js.map +1 -1
  197. package/node_modules/@xrkseek/exec-ssh/dist/index.d.ts +1 -1
  198. package/node_modules/@xrkseek/exec-ssh/dist/index.d.ts.map +1 -1
  199. package/node_modules/@xrkseek/exec-ssh/dist/index.js +1 -1
  200. package/node_modules/@xrkseek/exec-ssh/dist/index.js.map +1 -1
  201. package/node_modules/@xrkseek/exec-video-gen/dist/index.d.ts +15 -2
  202. package/node_modules/@xrkseek/exec-video-gen/dist/index.d.ts.map +1 -1
  203. package/node_modules/@xrkseek/exec-video-gen/dist/index.js +14 -9
  204. package/node_modules/@xrkseek/exec-video-gen/dist/index.js.map +1 -1
  205. package/node_modules/@xrkseek/exec-video-gen/dist/tools.d.ts +6 -1
  206. package/node_modules/@xrkseek/exec-video-gen/dist/tools.d.ts.map +1 -1
  207. package/node_modules/@xrkseek/exec-video-gen/dist/tools.js +14 -10
  208. package/node_modules/@xrkseek/exec-video-gen/dist/tools.js.map +1 -1
  209. package/node_modules/@xrkseek/exec-voice/README.md +25 -25
  210. package/node_modules/@xrkseek/exec-voice/dist/index.d.ts +16 -3
  211. package/node_modules/@xrkseek/exec-voice/dist/index.d.ts.map +1 -1
  212. package/node_modules/@xrkseek/exec-voice/dist/index.js +14 -8
  213. package/node_modules/@xrkseek/exec-voice/dist/index.js.map +1 -1
  214. package/node_modules/@xrkseek/exec-voice/dist/readiness.d.ts +26 -0
  215. package/node_modules/@xrkseek/exec-voice/dist/readiness.d.ts.map +1 -0
  216. package/node_modules/@xrkseek/exec-voice/dist/readiness.js +69 -0
  217. package/node_modules/@xrkseek/exec-voice/dist/readiness.js.map +1 -0
  218. package/node_modules/@xrkseek/exec-voice/dist/tools.d.ts +4 -1
  219. package/node_modules/@xrkseek/exec-voice/dist/tools.d.ts.map +1 -1
  220. package/node_modules/@xrkseek/exec-voice/dist/tools.js +3 -14
  221. package/node_modules/@xrkseek/exec-voice/dist/tools.js.map +1 -1
  222. package/node_modules/@xrkseek/exec-web/README.md +11 -11
  223. package/node_modules/@xrkseek/exec-web/dist/browser-cdp.d.ts +22 -0
  224. package/node_modules/@xrkseek/exec-web/dist/browser-cdp.d.ts.map +1 -1
  225. package/node_modules/@xrkseek/exec-web/dist/browser-cdp.js +32 -1
  226. package/node_modules/@xrkseek/exec-web/dist/browser-cdp.js.map +1 -1
  227. package/node_modules/@xrkseek/exec-web/dist/browser-runtime-registry.d.ts +21 -0
  228. package/node_modules/@xrkseek/exec-web/dist/browser-runtime-registry.d.ts.map +1 -0
  229. package/node_modules/@xrkseek/exec-web/dist/browser-runtime-registry.js +52 -0
  230. package/node_modules/@xrkseek/exec-web/dist/browser-runtime-registry.js.map +1 -0
  231. package/node_modules/@xrkseek/exec-web/dist/browser-session.d.ts +2 -0
  232. package/node_modules/@xrkseek/exec-web/dist/browser-session.d.ts.map +1 -1
  233. package/node_modules/@xrkseek/exec-web/dist/browser-session.js +3 -0
  234. package/node_modules/@xrkseek/exec-web/dist/browser-session.js.map +1 -1
  235. package/node_modules/@xrkseek/exec-web/dist/browser-tools.d.ts +9 -0
  236. package/node_modules/@xrkseek/exec-web/dist/browser-tools.d.ts.map +1 -1
  237. package/node_modules/@xrkseek/exec-web/dist/browser-tools.js +34 -15
  238. package/node_modules/@xrkseek/exec-web/dist/browser-tools.js.map +1 -1
  239. package/node_modules/@xrkseek/exec-web/dist/fetch-http.d.ts +7 -0
  240. package/node_modules/@xrkseek/exec-web/dist/fetch-http.d.ts.map +1 -1
  241. package/node_modules/@xrkseek/exec-web/dist/fetch-http.js +8 -2
  242. package/node_modules/@xrkseek/exec-web/dist/fetch-http.js.map +1 -1
  243. package/node_modules/@xrkseek/exec-web/dist/format.d.ts.map +1 -1
  244. package/node_modules/@xrkseek/exec-web/dist/format.js +4 -3
  245. package/node_modules/@xrkseek/exec-web/dist/format.js.map +1 -1
  246. package/node_modules/@xrkseek/exec-web/dist/index.d.ts +4 -2
  247. package/node_modules/@xrkseek/exec-web/dist/index.d.ts.map +1 -1
  248. package/node_modules/@xrkseek/exec-web/dist/index.js +8 -3
  249. package/node_modules/@xrkseek/exec-web/dist/index.js.map +1 -1
  250. package/node_modules/@xrkseek/exec-web/dist/outbound-allowlist.d.ts +46 -0
  251. package/node_modules/@xrkseek/exec-web/dist/outbound-allowlist.d.ts.map +1 -0
  252. package/node_modules/@xrkseek/exec-web/dist/outbound-allowlist.js +144 -0
  253. package/node_modules/@xrkseek/exec-web/dist/outbound-allowlist.js.map +1 -0
  254. package/node_modules/@xrkseek/exec-web/dist/url-policy.d.ts +6 -1
  255. package/node_modules/@xrkseek/exec-web/dist/url-policy.d.ts.map +1 -1
  256. package/node_modules/@xrkseek/exec-web/dist/url-policy.js +5 -2
  257. package/node_modules/@xrkseek/exec-web/dist/url-policy.js.map +1 -1
  258. package/node_modules/@xrkseek/im-gateway-contract/README.md +50 -0
  259. package/node_modules/@xrkseek/im-gateway-contract/dist/index.d.ts +77 -0
  260. package/node_modules/@xrkseek/im-gateway-contract/dist/index.d.ts.map +1 -0
  261. package/node_modules/@xrkseek/im-gateway-contract/dist/index.js +120 -0
  262. package/node_modules/@xrkseek/im-gateway-contract/dist/index.js.map +1 -0
  263. package/node_modules/@xrkseek/im-gateway-contract/examples/mock-sidecar.mjs +124 -0
  264. package/node_modules/@xrkseek/im-gateway-contract/package.json +25 -0
  265. package/node_modules/@xrkseek/mcp/dist/index.d.ts +1 -0
  266. package/node_modules/@xrkseek/mcp/dist/index.d.ts.map +1 -1
  267. package/node_modules/@xrkseek/mcp/dist/index.js +1 -0
  268. package/node_modules/@xrkseek/mcp/dist/index.js.map +1 -1
  269. package/node_modules/@xrkseek/mcp/dist/oauth-product.d.ts +31 -0
  270. package/node_modules/@xrkseek/mcp/dist/oauth-product.d.ts.map +1 -0
  271. package/node_modules/@xrkseek/mcp/dist/oauth-product.js +72 -0
  272. package/node_modules/@xrkseek/mcp/dist/oauth-product.js.map +1 -0
  273. package/node_modules/@xrkseek/policy/README.md +18 -15
  274. package/node_modules/@xrkseek/policy/dist/index.d.ts +1 -0
  275. package/node_modules/@xrkseek/policy/dist/index.d.ts.map +1 -1
  276. package/node_modules/@xrkseek/policy/dist/index.js +1 -0
  277. package/node_modules/@xrkseek/policy/dist/index.js.map +1 -1
  278. package/node_modules/@xrkseek/policy/dist/permission-pre.d.ts.map +1 -1
  279. package/node_modules/@xrkseek/policy/dist/permission-pre.js +1 -0
  280. package/node_modules/@xrkseek/policy/dist/permission-pre.js.map +1 -1
  281. package/node_modules/@xrkseek/policy/dist/security-guidance.d.ts +50 -0
  282. package/node_modules/@xrkseek/policy/dist/security-guidance.d.ts.map +1 -0
  283. package/node_modules/@xrkseek/policy/dist/security-guidance.js +262 -0
  284. package/node_modules/@xrkseek/policy/dist/security-guidance.js.map +1 -0
  285. package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts +81 -7
  286. package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts.map +1 -1
  287. package/node_modules/@xrkseek/preset-harness/dist/preset.js +307 -63
  288. package/node_modules/@xrkseek/preset-harness/dist/preset.js.map +1 -1
  289. package/node_modules/@xrkseek/preset-harness/dist/tsconfig.tsbuildinfo +1 -1
  290. package/node_modules/@xrkseek/preset-harness/package.json +53 -52
  291. package/node_modules/@xrkseek/preset-minimal/dist/preset.d.ts.map +1 -1
  292. package/node_modules/@xrkseek/preset-minimal/dist/preset.js +7 -2
  293. package/node_modules/@xrkseek/preset-minimal/dist/preset.js.map +1 -1
  294. package/node_modules/@xrkseek/preset-minimal/dist/tsconfig.tsbuildinfo +1 -1
  295. package/node_modules/@xrkseek/preset-server/dist/preset.d.ts.map +1 -1
  296. package/node_modules/@xrkseek/preset-server/dist/preset.js +19 -1
  297. package/node_modules/@xrkseek/preset-server/dist/preset.js.map +1 -1
  298. package/node_modules/@xrkseek/preset-server/dist/tsconfig.tsbuildinfo +1 -1
  299. package/node_modules/@xrkseek/protocol/dist/json-schema.d.ts.map +1 -1
  300. package/node_modules/@xrkseek/protocol/dist/json-schema.js +3 -0
  301. package/node_modules/@xrkseek/protocol/dist/json-schema.js.map +1 -1
  302. package/node_modules/@xrkseek/protocol/dist/session-events.d.ts +18 -0
  303. package/node_modules/@xrkseek/protocol/dist/session-events.d.ts.map +1 -1
  304. package/node_modules/@xrkseek/protocol/dist/session-events.js.map +1 -1
  305. package/node_modules/@xrkseek/protocol/dist/validate.d.ts.map +1 -1
  306. package/node_modules/@xrkseek/protocol/dist/validate.js +30 -0
  307. package/node_modules/@xrkseek/protocol/dist/validate.js.map +1 -1
  308. package/node_modules/@xrkseek/runtime-invariants/README.md +28 -0
  309. package/node_modules/@xrkseek/runtime-invariants/dist/index.d.ts +94 -0
  310. package/node_modules/@xrkseek/runtime-invariants/dist/index.d.ts.map +1 -0
  311. package/node_modules/@xrkseek/runtime-invariants/dist/index.js +163 -0
  312. package/node_modules/@xrkseek/runtime-invariants/dist/index.js.map +1 -0
  313. package/node_modules/@xrkseek/runtime-invariants/package.json +27 -0
  314. package/node_modules/@xrkseek/secrets/README.md +28 -0
  315. package/node_modules/@xrkseek/secrets/dist/index.d.ts +11 -0
  316. package/node_modules/@xrkseek/secrets/dist/index.d.ts.map +1 -0
  317. package/node_modules/@xrkseek/secrets/dist/index.js +23 -0
  318. package/node_modules/@xrkseek/secrets/dist/index.js.map +1 -0
  319. package/node_modules/@xrkseek/secrets/dist/keyring.d.ts +10 -0
  320. package/node_modules/@xrkseek/secrets/dist/keyring.d.ts.map +1 -0
  321. package/node_modules/@xrkseek/secrets/dist/keyring.js +77 -0
  322. package/node_modules/@xrkseek/secrets/dist/keyring.js.map +1 -0
  323. package/node_modules/@xrkseek/secrets/dist/memory.d.ts +4 -0
  324. package/node_modules/@xrkseek/secrets/dist/memory.d.ts.map +1 -0
  325. package/node_modules/@xrkseek/secrets/dist/memory.js +21 -0
  326. package/node_modules/@xrkseek/secrets/dist/memory.js.map +1 -0
  327. package/node_modules/@xrkseek/secrets/dist/redact.d.ts +23 -0
  328. package/node_modules/@xrkseek/secrets/dist/redact.d.ts.map +1 -0
  329. package/node_modules/@xrkseek/secrets/dist/redact.js +38 -0
  330. package/node_modules/@xrkseek/secrets/dist/redact.js.map +1 -0
  331. package/node_modules/@xrkseek/secrets/dist/resolve.d.ts +10 -0
  332. package/node_modules/@xrkseek/secrets/dist/resolve.d.ts.map +1 -0
  333. package/node_modules/@xrkseek/secrets/dist/resolve.js +24 -0
  334. package/node_modules/@xrkseek/secrets/dist/resolve.js.map +1 -0
  335. package/node_modules/@xrkseek/secrets/dist/types.d.ts +27 -0
  336. package/node_modules/@xrkseek/secrets/dist/types.d.ts.map +1 -0
  337. package/node_modules/@xrkseek/secrets/dist/types.js +15 -0
  338. package/node_modules/@xrkseek/secrets/dist/types.js.map +1 -0
  339. package/node_modules/@xrkseek/secrets/package.json +29 -0
  340. package/node_modules/@xrkseek/server-config/dist/index.d.ts +6 -0
  341. package/node_modules/@xrkseek/server-config/dist/index.d.ts.map +1 -1
  342. package/node_modules/@xrkseek/server-config/dist/index.js +12 -0
  343. package/node_modules/@xrkseek/server-config/dist/index.js.map +1 -1
  344. package/node_modules/@xrkseek/server-cron/README.md +1 -1
  345. package/node_modules/@xrkseek/server-cron/dist/index.d.ts +10 -1
  346. package/node_modules/@xrkseek/server-cron/dist/index.d.ts.map +1 -1
  347. package/node_modules/@xrkseek/server-cron/dist/index.js +9 -2
  348. package/node_modules/@xrkseek/server-cron/dist/index.js.map +1 -1
  349. package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.d.ts.map +1 -1
  350. package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.js +6 -2
  351. package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.js.map +1 -1
  352. package/node_modules/@xrkseek/server-face/dist/agent-team-output.d.ts +34 -0
  353. package/node_modules/@xrkseek/server-face/dist/agent-team-output.d.ts.map +1 -0
  354. package/node_modules/@xrkseek/server-face/dist/agent-team-output.js +140 -0
  355. package/node_modules/@xrkseek/server-face/dist/agent-team-output.js.map +1 -0
  356. package/node_modules/@xrkseek/server-face/dist/agent-team-roles.d.ts +13 -0
  357. package/node_modules/@xrkseek/server-face/dist/agent-team-roles.d.ts.map +1 -0
  358. package/node_modules/@xrkseek/server-face/dist/agent-team-roles.js +67 -0
  359. package/node_modules/@xrkseek/server-face/dist/agent-team-roles.js.map +1 -0
  360. package/node_modules/@xrkseek/server-face/dist/agent-team-tasks.d.ts +79 -0
  361. package/node_modules/@xrkseek/server-face/dist/agent-team-tasks.d.ts.map +1 -0
  362. package/node_modules/@xrkseek/server-face/dist/agent-team-tasks.js +230 -0
  363. package/node_modules/@xrkseek/server-face/dist/agent-team-tasks.js.map +1 -0
  364. package/node_modules/@xrkseek/server-face/dist/approval-category.d.ts +25 -0
  365. package/node_modules/@xrkseek/server-face/dist/approval-category.d.ts.map +1 -0
  366. package/node_modules/@xrkseek/server-face/dist/approval-category.js +108 -0
  367. package/node_modules/@xrkseek/server-face/dist/approval-category.js.map +1 -0
  368. package/node_modules/@xrkseek/server-face/dist/approvals.d.ts +17 -0
  369. package/node_modules/@xrkseek/server-face/dist/approvals.d.ts.map +1 -1
  370. package/node_modules/@xrkseek/server-face/dist/approvals.js +50 -0
  371. package/node_modules/@xrkseek/server-face/dist/approvals.js.map +1 -1
  372. package/node_modules/@xrkseek/server-face/dist/context.d.ts +22 -0
  373. package/node_modules/@xrkseek/server-face/dist/context.d.ts.map +1 -1
  374. package/node_modules/@xrkseek/server-face/dist/cost-meter-store.d.ts.map +1 -1
  375. package/node_modules/@xrkseek/server-face/dist/cost-meter-store.js +22 -0
  376. package/node_modules/@xrkseek/server-face/dist/cost-meter-store.js.map +1 -1
  377. package/node_modules/@xrkseek/server-face/dist/dispatch.d.ts.map +1 -1
  378. package/node_modules/@xrkseek/server-face/dist/dispatch.js +14 -2
  379. package/node_modules/@xrkseek/server-face/dist/dispatch.js.map +1 -1
  380. package/node_modules/@xrkseek/server-face/dist/external-agent-runtime.d.ts +87 -2
  381. package/node_modules/@xrkseek/server-face/dist/external-agent-runtime.d.ts.map +1 -1
  382. package/node_modules/@xrkseek/server-face/dist/external-agent-runtime.js +456 -32
  383. package/node_modules/@xrkseek/server-face/dist/external-agent-runtime.js.map +1 -1
  384. package/node_modules/@xrkseek/server-face/dist/goal-round-driver.d.ts +48 -0
  385. package/node_modules/@xrkseek/server-face/dist/goal-round-driver.d.ts.map +1 -0
  386. package/node_modules/@xrkseek/server-face/dist/goal-round-driver.js +69 -0
  387. package/node_modules/@xrkseek/server-face/dist/goal-round-driver.js.map +1 -0
  388. package/node_modules/@xrkseek/server-face/dist/goal-store.d.ts +6 -1
  389. package/node_modules/@xrkseek/server-face/dist/goal-store.d.ts.map +1 -1
  390. package/node_modules/@xrkseek/server-face/dist/goal-store.js +45 -9
  391. package/node_modules/@xrkseek/server-face/dist/goal-store.js.map +1 -1
  392. package/node_modules/@xrkseek/server-face/dist/goal-tools.d.ts +13 -0
  393. package/node_modules/@xrkseek/server-face/dist/goal-tools.d.ts.map +1 -0
  394. package/node_modules/@xrkseek/server-face/dist/goal-tools.js +131 -0
  395. package/node_modules/@xrkseek/server-face/dist/goal-tools.js.map +1 -0
  396. package/node_modules/@xrkseek/server-face/dist/handlers/checkpoint.d.ts +10 -0
  397. package/node_modules/@xrkseek/server-face/dist/handlers/checkpoint.d.ts.map +1 -0
  398. package/node_modules/@xrkseek/server-face/dist/handlers/checkpoint.js +156 -0
  399. package/node_modules/@xrkseek/server-face/dist/handlers/checkpoint.js.map +1 -0
  400. package/node_modules/@xrkseek/server-face/dist/handlers/session.d.ts +7 -0
  401. package/node_modules/@xrkseek/server-face/dist/handlers/session.d.ts.map +1 -1
  402. package/node_modules/@xrkseek/server-face/dist/handlers/session.js +88 -2
  403. package/node_modules/@xrkseek/server-face/dist/handlers/session.js.map +1 -1
  404. package/node_modules/@xrkseek/server-face/dist/handlers/subagent.d.ts.map +1 -1
  405. package/node_modules/@xrkseek/server-face/dist/handlers/subagent.js +62 -3
  406. package/node_modules/@xrkseek/server-face/dist/handlers/subagent.js.map +1 -1
  407. package/node_modules/@xrkseek/server-face/dist/index.d.ts +19 -5
  408. package/node_modules/@xrkseek/server-face/dist/index.d.ts.map +1 -1
  409. package/node_modules/@xrkseek/server-face/dist/index.js +18 -4
  410. package/node_modules/@xrkseek/server-face/dist/index.js.map +1 -1
  411. package/node_modules/@xrkseek/server-face/dist/managed-worktree.d.ts +115 -0
  412. package/node_modules/@xrkseek/server-face/dist/managed-worktree.d.ts.map +1 -0
  413. package/node_modules/@xrkseek/server-face/dist/managed-worktree.js +330 -0
  414. package/node_modules/@xrkseek/server-face/dist/managed-worktree.js.map +1 -0
  415. package/node_modules/@xrkseek/server-face/dist/mcp-oauth.d.ts +33 -0
  416. package/node_modules/@xrkseek/server-face/dist/mcp-oauth.d.ts.map +1 -0
  417. package/node_modules/@xrkseek/server-face/dist/mcp-oauth.js +352 -0
  418. package/node_modules/@xrkseek/server-face/dist/mcp-oauth.js.map +1 -0
  419. package/node_modules/@xrkseek/server-face/dist/projections/index.d.ts +1 -1
  420. package/node_modules/@xrkseek/server-face/dist/projections/index.d.ts.map +1 -1
  421. package/node_modules/@xrkseek/server-face/dist/projections/index.js.map +1 -1
  422. package/node_modules/@xrkseek/server-face/dist/projections/units/context-timeline.d.ts +15 -1
  423. package/node_modules/@xrkseek/server-face/dist/projections/units/context-timeline.d.ts.map +1 -1
  424. package/node_modules/@xrkseek/server-face/dist/projections/units/context-timeline.js +26 -2
  425. package/node_modules/@xrkseek/server-face/dist/projections/units/context-timeline.js.map +1 -1
  426. package/node_modules/@xrkseek/server-face/dist/propose-skill.d.ts +20 -0
  427. package/node_modules/@xrkseek/server-face/dist/propose-skill.d.ts.map +1 -0
  428. package/node_modules/@xrkseek/server-face/dist/propose-skill.js +65 -0
  429. package/node_modules/@xrkseek/server-face/dist/propose-skill.js.map +1 -0
  430. package/node_modules/@xrkseek/server-face/dist/ralph-tool.d.ts +33 -0
  431. package/node_modules/@xrkseek/server-face/dist/ralph-tool.d.ts.map +1 -0
  432. package/node_modules/@xrkseek/server-face/dist/ralph-tool.js +366 -0
  433. package/node_modules/@xrkseek/server-face/dist/ralph-tool.js.map +1 -0
  434. package/node_modules/@xrkseek/server-face/dist/reference-discovery.d.ts.map +1 -1
  435. package/node_modules/@xrkseek/server-face/dist/reference-discovery.js +1 -0
  436. package/node_modules/@xrkseek/server-face/dist/reference-discovery.js.map +1 -1
  437. package/node_modules/@xrkseek/server-face/dist/rollout-trace.d.ts +58 -0
  438. package/node_modules/@xrkseek/server-face/dist/rollout-trace.d.ts.map +1 -0
  439. package/node_modules/@xrkseek/server-face/dist/rollout-trace.js +194 -0
  440. package/node_modules/@xrkseek/server-face/dist/rollout-trace.js.map +1 -0
  441. package/node_modules/@xrkseek/server-face/dist/runtime.d.ts +7 -0
  442. package/node_modules/@xrkseek/server-face/dist/runtime.d.ts.map +1 -1
  443. package/node_modules/@xrkseek/server-face/dist/runtime.js +93 -4
  444. package/node_modules/@xrkseek/server-face/dist/runtime.js.map +1 -1
  445. package/node_modules/@xrkseek/server-face/dist/session-export.d.ts.map +1 -1
  446. package/node_modules/@xrkseek/server-face/dist/session-export.js +74 -0
  447. package/node_modules/@xrkseek/server-face/dist/session-export.js.map +1 -1
  448. package/node_modules/@xrkseek/server-face/dist/session-query-tools.d.ts +23 -0
  449. package/node_modules/@xrkseek/server-face/dist/session-query-tools.d.ts.map +1 -0
  450. package/node_modules/@xrkseek/server-face/dist/session-query-tools.js +275 -0
  451. package/node_modules/@xrkseek/server-face/dist/session-query-tools.js.map +1 -0
  452. package/node_modules/@xrkseek/server-face/dist/session-status.d.ts +209 -0
  453. package/node_modules/@xrkseek/server-face/dist/session-status.d.ts.map +1 -0
  454. package/node_modules/@xrkseek/server-face/dist/session-status.js +559 -0
  455. package/node_modules/@xrkseek/server-face/dist/session-status.js.map +1 -0
  456. package/node_modules/@xrkseek/server-face/dist/settings-credentials.d.ts +2 -0
  457. package/node_modules/@xrkseek/server-face/dist/settings-credentials.d.ts.map +1 -1
  458. package/node_modules/@xrkseek/server-face/dist/settings-credentials.js +67 -0
  459. package/node_modules/@xrkseek/server-face/dist/settings-credentials.js.map +1 -1
  460. package/node_modules/@xrkseek/server-face/dist/settings-document.d.ts +5 -0
  461. package/node_modules/@xrkseek/server-face/dist/settings-document.d.ts.map +1 -1
  462. package/node_modules/@xrkseek/server-face/dist/settings-document.js +69 -0
  463. package/node_modules/@xrkseek/server-face/dist/settings-document.js.map +1 -1
  464. package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts.map +1 -1
  465. package/node_modules/@xrkseek/server-face/dist/settings-schemas.js +220 -1
  466. package/node_modules/@xrkseek/server-face/dist/settings-schemas.js.map +1 -1
  467. package/node_modules/@xrkseek/server-face/dist/slash.d.ts.map +1 -1
  468. package/node_modules/@xrkseek/server-face/dist/slash.js +70 -16
  469. package/node_modules/@xrkseek/server-face/dist/slash.js.map +1 -1
  470. package/node_modules/@xrkseek/server-face/dist/subagent-registry.d.ts +4 -0
  471. package/node_modules/@xrkseek/server-face/dist/subagent-registry.d.ts.map +1 -1
  472. package/node_modules/@xrkseek/server-face/dist/subagent-registry.js +4 -0
  473. package/node_modules/@xrkseek/server-face/dist/subagent-registry.js.map +1 -1
  474. package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts +14 -1
  475. package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts.map +1 -1
  476. package/node_modules/@xrkseek/server-face/dist/subagent-tools.js +614 -62
  477. package/node_modules/@xrkseek/server-face/dist/subagent-tools.js.map +1 -1
  478. package/node_modules/@xrkseek/server-face/dist/subagent-worktree.d.ts.map +1 -1
  479. package/node_modules/@xrkseek/server-face/dist/subagent-worktree.js +7 -2
  480. package/node_modules/@xrkseek/server-face/dist/subagent-worktree.js.map +1 -1
  481. package/node_modules/@xrkseek/server-face/dist/types.d.ts +4 -0
  482. package/node_modules/@xrkseek/server-face/dist/types.d.ts.map +1 -1
  483. package/node_modules/@xrkseek/server-face/dist/wire/rpc-error.d.ts.map +1 -1
  484. package/node_modules/@xrkseek/server-face/dist/wire/rpc-error.js +11 -0
  485. package/node_modules/@xrkseek/server-face/dist/wire/rpc-error.js.map +1 -1
  486. package/node_modules/@xrkseek/server-face/dist/workspace-checkpoint.d.ts +40 -0
  487. package/node_modules/@xrkseek/server-face/dist/workspace-checkpoint.d.ts.map +1 -0
  488. package/node_modules/@xrkseek/server-face/dist/workspace-checkpoint.js +154 -0
  489. package/node_modules/@xrkseek/server-face/dist/workspace-checkpoint.js.map +1 -0
  490. package/node_modules/@xrkseek/server-face/dist/workspace-face.d.ts +1 -0
  491. package/node_modules/@xrkseek/server-face/dist/workspace-face.d.ts.map +1 -1
  492. package/node_modules/@xrkseek/server-face/dist/workspace-face.js +25 -0
  493. package/node_modules/@xrkseek/server-face/dist/workspace-face.js.map +1 -1
  494. package/node_modules/@xrkseek/server-face/dist/workspace-registry.d.ts +11 -0
  495. package/node_modules/@xrkseek/server-face/dist/workspace-registry.d.ts.map +1 -1
  496. package/node_modules/@xrkseek/server-face/dist/workspace-registry.js +14 -4
  497. package/node_modules/@xrkseek/server-face/dist/workspace-registry.js.map +1 -1
  498. package/node_modules/@xrkseek/server-face/package.json +3 -0
  499. package/node_modules/@xrkseek/server-host/dist/index.d.ts +61 -0
  500. package/node_modules/@xrkseek/server-host/dist/index.d.ts.map +1 -1
  501. package/node_modules/@xrkseek/server-host/dist/index.js +376 -10
  502. package/node_modules/@xrkseek/server-host/dist/index.js.map +1 -1
  503. package/node_modules/@xrkseek/server-host/dist/invariants-fail-fast.d.ts +16 -0
  504. package/node_modules/@xrkseek/server-host/dist/invariants-fail-fast.d.ts.map +1 -0
  505. package/node_modules/@xrkseek/server-host/dist/invariants-fail-fast.js +24 -0
  506. package/node_modules/@xrkseek/server-host/dist/invariants-fail-fast.js.map +1 -0
  507. package/node_modules/@xrkseek/server-host/dist/standing-tools.d.ts.map +1 -1
  508. package/node_modules/@xrkseek/server-host/dist/standing-tools.js +4 -1
  509. package/node_modules/@xrkseek/server-host/dist/standing-tools.js.map +1 -1
  510. package/node_modules/@xrkseek/server-host/package.json +10 -0
  511. package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.d.ts.map +1 -1
  512. package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.js +10 -4
  513. package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.js.map +1 -1
  514. package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-types.d.ts +17 -0
  515. package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-types.d.ts.map +1 -1
  516. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-classifier.d.ts +8 -0
  517. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-classifier.d.ts.map +1 -1
  518. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-classifier.js +20 -5
  519. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-classifier.js.map +1 -1
  520. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-http.js +1 -1
  521. package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-http.js.map +1 -1
  522. package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-compat-matrix.js +2 -2
  523. package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-compat-matrix.js.map +1 -1
  524. package/node_modules/@xrkseek/server-http/dist/dsh-compat/im-gateway-sidecar.d.ts +5 -17
  525. package/node_modules/@xrkseek/server-http/dist/dsh-compat/im-gateway-sidecar.d.ts.map +1 -1
  526. package/node_modules/@xrkseek/server-http/dist/dsh-compat/im-gateway-sidecar.js +50 -49
  527. package/node_modules/@xrkseek/server-http/dist/dsh-compat/im-gateway-sidecar.js.map +1 -1
  528. package/node_modules/@xrkseek/server-http/dist/dsh-compat/memory-embeddings.d.ts +14 -4
  529. package/node_modules/@xrkseek/server-http/dist/dsh-compat/memory-embeddings.d.ts.map +1 -1
  530. package/node_modules/@xrkseek/server-http/dist/dsh-compat/memory-embeddings.js +30 -14
  531. package/node_modules/@xrkseek/server-http/dist/dsh-compat/memory-embeddings.js.map +1 -1
  532. package/node_modules/@xrkseek/server-http/dist/dsh-compat/noema.d.ts +3 -0
  533. package/node_modules/@xrkseek/server-http/dist/dsh-compat/noema.d.ts.map +1 -1
  534. package/node_modules/@xrkseek/server-http/dist/dsh-compat/noema.js +5 -5
  535. package/node_modules/@xrkseek/server-http/dist/dsh-compat/noema.js.map +1 -1
  536. package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.d.ts +5 -0
  537. package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.d.ts.map +1 -1
  538. package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.js +1 -0
  539. package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.js.map +1 -1
  540. package/node_modules/@xrkseek/server-http/package.json +1 -0
  541. package/node_modules/@xrkseek/server-loader/dist/index.d.ts +1 -1
  542. package/node_modules/@xrkseek/server-loader/dist/index.d.ts.map +1 -1
  543. package/node_modules/@xrkseek/server-loader/dist/index.js +1 -1
  544. package/node_modules/@xrkseek/server-loader/dist/index.js.map +1 -1
  545. package/node_modules/@xrkseek/server-loader/dist/shell-hooks.d.ts +75 -3
  546. package/node_modules/@xrkseek/server-loader/dist/shell-hooks.d.ts.map +1 -1
  547. package/node_modules/@xrkseek/server-loader/dist/shell-hooks.js +415 -46
  548. package/node_modules/@xrkseek/server-loader/dist/shell-hooks.js.map +1 -1
  549. package/node_modules/@xrkseek/session-format/README.md +20 -0
  550. package/node_modules/@xrkseek/session-format/dist/catalog.d.ts +27 -0
  551. package/node_modules/@xrkseek/session-format/dist/catalog.d.ts.map +1 -0
  552. package/node_modules/@xrkseek/session-format/dist/catalog.js +36 -0
  553. package/node_modules/@xrkseek/session-format/dist/catalog.js.map +1 -0
  554. package/node_modules/@xrkseek/session-format/dist/chain.d.ts +38 -0
  555. package/node_modules/@xrkseek/session-format/dist/chain.d.ts.map +1 -0
  556. package/node_modules/@xrkseek/session-format/dist/chain.js +86 -0
  557. package/node_modules/@xrkseek/session-format/dist/chain.js.map +1 -0
  558. package/node_modules/@xrkseek/session-format/dist/detect.d.ts +29 -0
  559. package/node_modules/@xrkseek/session-format/dist/detect.d.ts.map +1 -0
  560. package/node_modules/@xrkseek/session-format/dist/detect.js +68 -0
  561. package/node_modules/@xrkseek/session-format/dist/detect.js.map +1 -0
  562. package/node_modules/@xrkseek/session-format/dist/index.d.ts +12 -0
  563. package/node_modules/@xrkseek/session-format/dist/index.d.ts.map +1 -0
  564. package/node_modules/@xrkseek/session-format/dist/index.js +12 -0
  565. package/node_modules/@xrkseek/session-format/dist/index.js.map +1 -0
  566. package/node_modules/@xrkseek/session-format/dist/interchange-version.d.ts +6 -0
  567. package/node_modules/@xrkseek/session-format/dist/interchange-version.d.ts.map +1 -0
  568. package/node_modules/@xrkseek/session-format/dist/interchange-version.js +6 -0
  569. package/node_modules/@xrkseek/session-format/dist/interchange-version.js.map +1 -0
  570. package/node_modules/@xrkseek/session-format/dist/sqlite-schema.d.ts +31 -0
  571. package/node_modules/@xrkseek/session-format/dist/sqlite-schema.d.ts.map +1 -0
  572. package/node_modules/@xrkseek/session-format/dist/sqlite-schema.js +52 -0
  573. package/node_modules/@xrkseek/session-format/dist/sqlite-schema.js.map +1 -0
  574. package/node_modules/@xrkseek/session-format/package.json +24 -0
  575. package/node_modules/@xrkseek/session-telemetry/dist/index.d.ts +18 -4
  576. package/node_modules/@xrkseek/session-telemetry/dist/index.d.ts.map +1 -1
  577. package/node_modules/@xrkseek/session-telemetry/dist/index.js +97 -36
  578. package/node_modules/@xrkseek/session-telemetry/dist/index.js.map +1 -1
  579. package/node_modules/@xrkseek/spill/README.md +27 -0
  580. package/node_modules/@xrkseek/spill/dist/index.d.ts +11 -0
  581. package/node_modules/@xrkseek/spill/dist/index.d.ts.map +1 -0
  582. package/node_modules/@xrkseek/spill/dist/index.js +11 -0
  583. package/node_modules/@xrkseek/spill/dist/index.js.map +1 -0
  584. package/node_modules/@xrkseek/spill/dist/local-store.d.ts +30 -0
  585. package/node_modules/@xrkseek/spill/dist/local-store.d.ts.map +1 -0
  586. package/node_modules/@xrkseek/spill/dist/local-store.js +73 -0
  587. package/node_modules/@xrkseek/spill/dist/local-store.js.map +1 -0
  588. package/node_modules/@xrkseek/spill/dist/policy.d.ts +59 -0
  589. package/node_modules/@xrkseek/spill/dist/policy.d.ts.map +1 -0
  590. package/node_modules/@xrkseek/spill/dist/policy.js +143 -0
  591. package/node_modules/@xrkseek/spill/dist/policy.js.map +1 -0
  592. package/node_modules/@xrkseek/spill/dist/types.d.ts +46 -0
  593. package/node_modules/@xrkseek/spill/dist/types.d.ts.map +1 -0
  594. package/node_modules/@xrkseek/spill/dist/types.js +8 -0
  595. package/node_modules/@xrkseek/spill/dist/types.js.map +1 -0
  596. package/node_modules/@xrkseek/spill/package.json +27 -0
  597. package/node_modules/@xrkseek/workspace/dist/ecosystem-instructions.d.ts.map +1 -1
  598. package/node_modules/@xrkseek/workspace/dist/ecosystem-instructions.js +2 -0
  599. package/node_modules/@xrkseek/workspace/dist/ecosystem-instructions.js.map +1 -1
  600. package/node_modules/@xrkseek/workspace/dist/index.d.ts +1 -0
  601. package/node_modules/@xrkseek/workspace/dist/index.d.ts.map +1 -1
  602. package/node_modules/@xrkseek/workspace/dist/index.js +1 -0
  603. package/node_modules/@xrkseek/workspace/dist/index.js.map +1 -1
  604. package/node_modules/@xrkseek/workspace/dist/skill-propose.d.ts +71 -0
  605. package/node_modules/@xrkseek/workspace/dist/skill-propose.d.ts.map +1 -0
  606. package/node_modules/@xrkseek/workspace/dist/skill-propose.js +259 -0
  607. package/node_modules/@xrkseek/workspace/dist/skill-propose.js.map +1 -0
  608. package/node_modules/@xrkseek/xrk-file-reference-local/README.md +46 -45
  609. package/node_modules/@xrkseek/xrk-file-reference-local/README.zh.md +46 -45
  610. package/node_modules/@xrkseek/xrk-file-reference-local/dist/gitignore.d.ts +37 -0
  611. package/node_modules/@xrkseek/xrk-file-reference-local/dist/gitignore.d.ts.map +1 -0
  612. package/node_modules/@xrkseek/xrk-file-reference-local/dist/gitignore.js +91 -0
  613. package/node_modules/@xrkseek/xrk-file-reference-local/dist/gitignore.js.map +1 -0
  614. package/node_modules/@xrkseek/xrk-file-reference-local/dist/search.d.ts +7 -0
  615. package/node_modules/@xrkseek/xrk-file-reference-local/dist/search.d.ts.map +1 -1
  616. package/node_modules/@xrkseek/xrk-file-reference-local/dist/search.js +46 -4
  617. package/node_modules/@xrkseek/xrk-file-reference-local/dist/search.js.map +1 -1
  618. package/node_modules/@xrkseek/xrk-file-reference-local/package.json +30 -29
  619. package/node_modules/ignore/LICENSE-MIT +21 -0
  620. package/node_modules/ignore/README.md +452 -0
  621. package/node_modules/ignore/index.d.ts +81 -0
  622. package/node_modules/ignore/index.js +793 -0
  623. package/node_modules/ignore/legacy.js +690 -0
  624. package/node_modules/ignore/package.json +87 -0
  625. package/package.json +17 -1
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Apply parsed Codex-style hunks onto LF-normalized file text (seek_sequence).
3
+ */
4
+ import { detectLineEndings, normalizeLineEndings, restoreLineEndings, } from "./edit-text.js";
5
+ export class ApplyPatchError extends Error {
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = "ApplyPatchError";
9
+ }
10
+ }
11
+ function normaliseUnicode(s) {
12
+ return s
13
+ .trim()
14
+ .split("")
15
+ .map((c) => {
16
+ const code = c.codePointAt(0) ?? 0;
17
+ if (code === 0x2010 ||
18
+ code === 0x2011 ||
19
+ code === 0x2012 ||
20
+ code === 0x2013 ||
21
+ code === 0x2014 ||
22
+ code === 0x2015 ||
23
+ code === 0x2212) {
24
+ return "-";
25
+ }
26
+ if (code === 0x2018 || code === 0x2019 || code === 0x201a || code === 0x201b) {
27
+ return "'";
28
+ }
29
+ if (code === 0x201c || code === 0x201d || code === 0x201e || code === 0x201f) {
30
+ return '"';
31
+ }
32
+ if (code === 0x00a0 ||
33
+ (code >= 0x2002 && code <= 0x200a) ||
34
+ code === 0x202f ||
35
+ code === 0x205f ||
36
+ code === 0x3000) {
37
+ return " ";
38
+ }
39
+ return c;
40
+ })
41
+ .join("");
42
+ }
43
+ /** Locate `pattern` in `lines` at/after `start` (Codex seek_sequence). */
44
+ export function seekSequence(lines, pattern, start, eof) {
45
+ if (pattern.length === 0)
46
+ return start;
47
+ if (pattern.length > lines.length)
48
+ return undefined;
49
+ const searchStart = eof && lines.length >= pattern.length
50
+ ? Math.max(start, lines.length - pattern.length)
51
+ : start;
52
+ const passes = [
53
+ (a, b) => a === b,
54
+ (a, b) => a.trimEnd() === b.trimEnd(),
55
+ (a, b) => a.trim() === b.trim(),
56
+ (a, b) => normaliseUnicode(a) === normaliseUnicode(b),
57
+ ];
58
+ for (const eq of passes) {
59
+ for (let i = searchStart; i <= lines.length - pattern.length; i += 1) {
60
+ let ok = true;
61
+ for (let p = 0; p < pattern.length; p += 1) {
62
+ if (!eq(lines[i + p], pattern[p])) {
63
+ ok = false;
64
+ break;
65
+ }
66
+ }
67
+ if (ok)
68
+ return i;
69
+ }
70
+ }
71
+ return undefined;
72
+ }
73
+ function splitLfLines(content) {
74
+ const lines = content.split("\n");
75
+ if (lines.length > 0 && lines[lines.length - 1] === "") {
76
+ lines.pop();
77
+ }
78
+ return lines;
79
+ }
80
+ function computeReplacements(originalLines, path, chunks) {
81
+ const replacements = [];
82
+ let lineIndex = 0;
83
+ for (const chunk of chunks) {
84
+ if (chunk.changeContext !== undefined) {
85
+ const idx = seekSequence(originalLines, [chunk.changeContext], lineIndex, false);
86
+ if (idx === undefined) {
87
+ throw new ApplyPatchError(`Failed to find context '${chunk.changeContext}' in ${path}`);
88
+ }
89
+ lineIndex = idx + 1;
90
+ }
91
+ if (chunk.oldLines.length === 0) {
92
+ const insertionIdx = originalLines.length;
93
+ replacements.push([insertionIdx, 0, [...chunk.newLines]]);
94
+ continue;
95
+ }
96
+ let pattern = chunk.oldLines;
97
+ let newSlice = chunk.newLines;
98
+ let found = seekSequence(originalLines, pattern, lineIndex, chunk.isEndOfFile);
99
+ if (found === undefined &&
100
+ pattern.length > 0 &&
101
+ pattern[pattern.length - 1] === "") {
102
+ pattern = pattern.slice(0, -1);
103
+ if (newSlice.length > 0 && newSlice[newSlice.length - 1] === "") {
104
+ newSlice = newSlice.slice(0, -1);
105
+ }
106
+ found = seekSequence(originalLines, pattern, lineIndex, chunk.isEndOfFile);
107
+ }
108
+ if (found === undefined) {
109
+ throw new ApplyPatchError(`Failed to find expected lines in ${path}:\n${chunk.oldLines.join("\n")}`);
110
+ }
111
+ replacements.push([found, pattern.length, [...newSlice]]);
112
+ lineIndex = found + pattern.length;
113
+ }
114
+ replacements.sort((a, b) => a[0] - b[0]);
115
+ return replacements;
116
+ }
117
+ function applyReplacements(lines, replacements) {
118
+ const next = [...lines];
119
+ for (const [startIdx, oldLen, newSegment] of [...replacements].reverse()) {
120
+ for (let i = 0; i < oldLen; i += 1) {
121
+ if (startIdx < next.length)
122
+ next.splice(startIdx, 1);
123
+ }
124
+ for (let offset = 0; offset < newSegment.length; offset += 1) {
125
+ next.splice(startIdx + offset, 0, newSegment[offset]);
126
+ }
127
+ }
128
+ return next;
129
+ }
130
+ /** Derive new file body (LF + trailing newline) from update chunks. */
131
+ export function deriveUpdatedContents(originalRaw, path, chunks) {
132
+ const endings = detectLineEndings(originalRaw);
133
+ const originalLf = normalizeLineEndings(originalRaw);
134
+ const originalLines = splitLfLines(originalLf);
135
+ const replacements = computeReplacements(originalLines, path, chunks);
136
+ const newLines = applyReplacements(originalLines, replacements);
137
+ if (newLines.length === 0 || newLines[newLines.length - 1] !== "") {
138
+ newLines.push("");
139
+ }
140
+ const nextLf = newLines.join("\n");
141
+ return {
142
+ original: originalRaw,
143
+ next: restoreLineEndings(nextLf, endings),
144
+ };
145
+ }
146
+ /**
147
+ * Pure planning step: compute all writes/deletes from hunks + current file map.
148
+ * `readFile` returns raw UTF-8 or `undefined` when missing.
149
+ */
150
+ export function planPatchApplication(hunks, readFile) {
151
+ const writes = new Map();
152
+ const deletes = [];
153
+ const ops = [];
154
+ for (const hunk of hunks) {
155
+ if (hunk.kind === "add") {
156
+ if (readFile(hunk.path) !== undefined || writes.has(hunk.path)) {
157
+ throw new ApplyPatchError(`Add File failed: ${hunk.path} already exists`);
158
+ }
159
+ writes.set(hunk.path, hunk.contents);
160
+ ops.push({ action: "add", path: hunk.path });
161
+ continue;
162
+ }
163
+ if (hunk.kind === "delete") {
164
+ if (readFile(hunk.path) === undefined && !writes.has(hunk.path)) {
165
+ throw new ApplyPatchError(`Delete File failed: ${hunk.path} not found`);
166
+ }
167
+ writes.delete(hunk.path);
168
+ deletes.push(hunk.path);
169
+ ops.push({ action: "delete", path: hunk.path });
170
+ continue;
171
+ }
172
+ const raw = writes.get(hunk.path) ?? readFile(hunk.path);
173
+ if (raw === undefined) {
174
+ throw new ApplyPatchError(`Update File failed: ${hunk.path} not found`);
175
+ }
176
+ if (hunk.chunks.length === 0 && !hunk.movePath) {
177
+ throw new ApplyPatchError(`Update file hunk for path '${hunk.path}' is empty`);
178
+ }
179
+ const updated = hunk.chunks.length === 0
180
+ ? raw
181
+ : deriveUpdatedContents(raw, hunk.path, hunk.chunks).next;
182
+ const dest = hunk.movePath ?? hunk.path;
183
+ if (hunk.movePath) {
184
+ if (readFile(hunk.movePath) !== undefined || writes.has(hunk.movePath)) {
185
+ throw new ApplyPatchError(`Move failed: destination ${hunk.movePath} already exists`);
186
+ }
187
+ writes.delete(hunk.path);
188
+ deletes.push(hunk.path);
189
+ writes.set(hunk.movePath, updated);
190
+ ops.push({
191
+ action: "move",
192
+ path: hunk.movePath,
193
+ fromPath: hunk.path,
194
+ });
195
+ }
196
+ else {
197
+ writes.set(dest, updated);
198
+ ops.push({ action: "update", path: dest });
199
+ }
200
+ }
201
+ return { ops, writes, deletes };
202
+ }
203
+ //# sourceMappingURL=apply-patch-apply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-patch-apply.js","sourceRoot":"","sources":["../src/apply-patch-apply.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAID,SAAS,gBAAgB,CAAC,CAAS;IACjC,OAAO,CAAC;SACL,IAAI,EAAE;SACN,KAAK,CAAC,EAAE,CAAC;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACnC,IACE,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,MAAM;YACf,IAAI,KA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,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAClC,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Codex apply_patch grammar (portable subset).
3
+ * Markers: Begin/End Patch · Add/Delete/Update File · Move to · @@ · End of File.
4
+ */
5
+ export declare const BEGIN_PATCH_MARKER = "*** Begin Patch";
6
+ export declare const END_PATCH_MARKER = "*** End Patch";
7
+ export declare const ADD_FILE_MARKER = "*** Add File: ";
8
+ export declare const DELETE_FILE_MARKER = "*** Delete File: ";
9
+ export declare const UPDATE_FILE_MARKER = "*** Update File: ";
10
+ export declare const MOVE_TO_MARKER = "*** Move to: ";
11
+ export declare const EOF_MARKER = "*** End of File";
12
+ export declare const CHANGE_CONTEXT_MARKER = "@@ ";
13
+ export declare const EMPTY_CHANGE_CONTEXT_MARKER = "@@";
14
+ export declare class PatchParseError extends Error {
15
+ readonly lineNumber?: number;
16
+ constructor(message: string, lineNumber?: number);
17
+ }
18
+ export interface UpdateFileChunk {
19
+ readonly changeContext?: string;
20
+ readonly oldLines: string[];
21
+ readonly newLines: string[];
22
+ /** Pairs of indices into old/new that were explicit context (` ` lines). */
23
+ readonly contextLineIndices: ReadonlyArray<readonly [number, number]>;
24
+ readonly isEndOfFile: boolean;
25
+ }
26
+ export type PatchHunk = {
27
+ readonly kind: "add";
28
+ readonly path: string;
29
+ readonly contents: string;
30
+ } | {
31
+ readonly kind: "delete";
32
+ readonly path: string;
33
+ } | {
34
+ readonly kind: "update";
35
+ readonly path: string;
36
+ readonly movePath?: string;
37
+ readonly chunks: readonly UpdateFileChunk[];
38
+ };
39
+ export interface ParsedPatch {
40
+ readonly hunks: readonly PatchHunk[];
41
+ readonly patch: string;
42
+ }
43
+ /**
44
+ * Parse a full `*** Begin Patch` … `*** End Patch` document into hunks.
45
+ * Lenient: trims marker lines; strips a trivial `<<EOF` heredoc wrapper.
46
+ */
47
+ export declare function parsePatch(raw: string): ParsedPatch;
48
+ /** Paths that already exist on disk and must be observed (write-intent). */
49
+ export declare function patchPathsRequiringRead(hunks: readonly PatchHunk[]): readonly string[];
50
+ /** All paths touched by the patch (for presentation / intent emit). */
51
+ export declare function patchTouchedPaths(hunks: readonly PatchHunk[]): readonly string[];
52
+ //# sourceMappingURL=apply-patch-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-patch-parser.d.ts","sourceRoot":"","sources":["../src/apply-patch-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AACpD,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAChD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAC5C,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAKjD;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC5B,4EAA4E;IAC5E,QAAQ,CAAC,kBAAkB,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC1E;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClD;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;CAC7C,CAAC;AAEN,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AA8BD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CA6QnD;AAED,4EAA4E;AAC5E,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,SAAS,SAAS,EAAE,GAC1B,SAAS,MAAM,EAAE,CAOnB;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,SAAS,EAAE,GAC1B,SAAS,MAAM,EAAE,CAWnB"}
@@ -0,0 +1,260 @@
1
+ /**
2
+ * Codex apply_patch grammar (portable subset).
3
+ * Markers: Begin/End Patch · Add/Delete/Update File · Move to · @@ · End of File.
4
+ */
5
+ export const BEGIN_PATCH_MARKER = "*** Begin Patch";
6
+ export const END_PATCH_MARKER = "*** End Patch";
7
+ export const ADD_FILE_MARKER = "*** Add File: ";
8
+ export const DELETE_FILE_MARKER = "*** Delete File: ";
9
+ export const UPDATE_FILE_MARKER = "*** Update File: ";
10
+ export const MOVE_TO_MARKER = "*** Move to: ";
11
+ export const EOF_MARKER = "*** End of File";
12
+ export const CHANGE_CONTEXT_MARKER = "@@ ";
13
+ export const EMPTY_CHANGE_CONTEXT_MARKER = "@@";
14
+ export class PatchParseError extends Error {
15
+ lineNumber;
16
+ constructor(message, lineNumber) {
17
+ super(message);
18
+ this.name = "PatchParseError";
19
+ if (lineNumber !== undefined)
20
+ this.lineNumber = lineNumber;
21
+ }
22
+ }
23
+ function pushContext(chunk, line) {
24
+ chunk.contextLineIndices.push([chunk.oldLines.length, chunk.newLines.length]);
25
+ chunk.oldLines.push(line);
26
+ chunk.newLines.push(line);
27
+ }
28
+ /**
29
+ * Parse a full `*** Begin Patch` … `*** End Patch` document into hunks.
30
+ * Lenient: trims marker lines; strips a trivial `<<EOF` heredoc wrapper.
31
+ */
32
+ export function parsePatch(raw) {
33
+ let text = raw.trim();
34
+ const heredoc = text.match(/^<<['"]?EOF['"]?\r?\n([\s\S]*?)\r?\nEOF\s*$/);
35
+ if (heredoc?.[1] !== undefined)
36
+ text = heredoc[1].trim();
37
+ const lines = text.split(/\r?\n/);
38
+ if (lines.length === 0) {
39
+ throw new PatchParseError("The first line of the patch must be '*** Begin Patch'");
40
+ }
41
+ const hunks = [];
42
+ /** not-started | started | add | delete | update | ended */
43
+ let mode = "not-started";
44
+ let updateHunkLine = 0;
45
+ let lineNumber = 0;
46
+ const ensureUpdateNotEmpty = (forLine) => {
47
+ const last = hunks[hunks.length - 1];
48
+ if (!last || last.kind !== "update")
49
+ return;
50
+ if (last.chunks.length === 0 && mode === "update") {
51
+ throw new PatchParseError(`Update file hunk for path '${last.path}' is empty`, updateHunkLine);
52
+ }
53
+ const chunk = last.chunks[last.chunks.length - 1];
54
+ if (chunk && chunk.oldLines.length === 0 && chunk.newLines.length === 0) {
55
+ if (forLine.trim() === END_PATCH_MARKER) {
56
+ throw new PatchParseError("Update hunk does not contain any lines", lineNumber);
57
+ }
58
+ throw new PatchParseError(`Unexpected line found in update hunk: '${forLine}'. Every line should start with ' ' (context line), '+' (added line), or '-' (removed line)`, lineNumber);
59
+ }
60
+ };
61
+ const startHunkHeader = (trimmed) => {
62
+ if (trimmed === END_PATCH_MARKER) {
63
+ ensureUpdateNotEmpty(trimmed);
64
+ mode = "ended";
65
+ return true;
66
+ }
67
+ if (trimmed.startsWith(ADD_FILE_MARKER)) {
68
+ ensureUpdateNotEmpty(trimmed);
69
+ hunks.push({
70
+ kind: "add",
71
+ path: trimmed.slice(ADD_FILE_MARKER.length),
72
+ contents: "",
73
+ });
74
+ mode = "add";
75
+ return true;
76
+ }
77
+ if (trimmed.startsWith(DELETE_FILE_MARKER)) {
78
+ ensureUpdateNotEmpty(trimmed);
79
+ hunks.push({
80
+ kind: "delete",
81
+ path: trimmed.slice(DELETE_FILE_MARKER.length),
82
+ });
83
+ mode = "delete";
84
+ return true;
85
+ }
86
+ if (trimmed.startsWith(UPDATE_FILE_MARKER)) {
87
+ ensureUpdateNotEmpty(trimmed);
88
+ hunks.push({
89
+ kind: "update",
90
+ path: trimmed.slice(UPDATE_FILE_MARKER.length),
91
+ chunks: [],
92
+ });
93
+ mode = "update";
94
+ updateHunkLine = lineNumber;
95
+ return true;
96
+ }
97
+ return false;
98
+ };
99
+ for (const line of lines) {
100
+ lineNumber += 1;
101
+ const trimmed = line.trim();
102
+ if (mode === "not-started") {
103
+ if (trimmed === BEGIN_PATCH_MARKER) {
104
+ mode = "started";
105
+ continue;
106
+ }
107
+ throw new PatchParseError("The first line of the patch must be '*** Begin Patch'", lineNumber);
108
+ }
109
+ if (mode === "ended") {
110
+ if (trimmed === "")
111
+ continue;
112
+ throw new PatchParseError(`Unexpected content after '*** End Patch': '${trimmed}'`, lineNumber);
113
+ }
114
+ if (mode === "started") {
115
+ if (startHunkHeader(trimmed))
116
+ continue;
117
+ throw new PatchParseError(`'${trimmed}' is not a valid hunk header. Valid hunk headers: '*** Add File: {path}', '*** Delete File: {path}', '*** Update File: {path}'`, lineNumber);
118
+ }
119
+ if (mode === "add") {
120
+ if (startHunkHeader(trimmed))
121
+ continue;
122
+ if (line.startsWith("+")) {
123
+ const last = hunks[hunks.length - 1];
124
+ if (last?.kind === "add") {
125
+ last.contents += `${line.slice(1)}\n`;
126
+ }
127
+ continue;
128
+ }
129
+ throw new PatchParseError(`'${trimmed}' is not a valid hunk header. Valid hunk headers: '*** Add File: {path}', '*** Delete File: {path}', '*** Update File: {path}'`, lineNumber);
130
+ }
131
+ if (mode === "delete") {
132
+ if (startHunkHeader(trimmed))
133
+ continue;
134
+ throw new PatchParseError(`'${trimmed}' is not a valid hunk header. Valid hunk headers: '*** Add File: {path}', '*** Delete File: {path}', '*** Update File: {path}'`, lineNumber);
135
+ }
136
+ // update
137
+ const updateLine = line.trimEnd();
138
+ if (startHunkHeader(updateLine.trim()))
139
+ continue;
140
+ const last = hunks[hunks.length - 1];
141
+ if (!last || last.kind !== "update") {
142
+ throw new PatchParseError("internal: expected update hunk", lineNumber);
143
+ }
144
+ const update = last;
145
+ if (update.chunks.at(-1)?.isEndOfFile) {
146
+ if (updateLine === "")
147
+ continue;
148
+ if (updateLine !== EMPTY_CHANGE_CONTEXT_MARKER &&
149
+ !updateLine.startsWith(CHANGE_CONTEXT_MARKER)) {
150
+ throw new PatchParseError(`Expected update hunk to start with a @@ context marker, got: '${line}'`, lineNumber);
151
+ }
152
+ }
153
+ if (update.chunks.length === 0 &&
154
+ update.movePath === undefined &&
155
+ updateLine.startsWith(MOVE_TO_MARKER)) {
156
+ update.movePath = updateLine.slice(MOVE_TO_MARKER.length);
157
+ continue;
158
+ }
159
+ if ((updateLine === EMPTY_CHANGE_CONTEXT_MARKER ||
160
+ updateLine.startsWith(CHANGE_CONTEXT_MARKER)) &&
161
+ update.chunks.at(-1) &&
162
+ update.chunks.at(-1).oldLines.length === 0 &&
163
+ update.chunks.at(-1).newLines.length === 0) {
164
+ throw new PatchParseError(`Unexpected line found in update hunk: '${line}'. Every line should start with ' ' (context line), '+' (added line), or '-' (removed line)`, lineNumber);
165
+ }
166
+ if (updateLine === EMPTY_CHANGE_CONTEXT_MARKER) {
167
+ update.chunks.push({
168
+ oldLines: [],
169
+ newLines: [],
170
+ contextLineIndices: [],
171
+ isEndOfFile: false,
172
+ });
173
+ continue;
174
+ }
175
+ if (updateLine.startsWith(CHANGE_CONTEXT_MARKER)) {
176
+ update.chunks.push({
177
+ changeContext: updateLine.slice(CHANGE_CONTEXT_MARKER.length),
178
+ oldLines: [],
179
+ newLines: [],
180
+ contextLineIndices: [],
181
+ isEndOfFile: false,
182
+ });
183
+ continue;
184
+ }
185
+ if (updateLine === EOF_MARKER) {
186
+ const chunk = update.chunks.at(-1);
187
+ if (!chunk || (chunk.oldLines.length === 0 && chunk.newLines.length === 0)) {
188
+ throw new PatchParseError("Update hunk does not contain any lines", lineNumber);
189
+ }
190
+ chunk.isEndOfFile = true;
191
+ continue;
192
+ }
193
+ const ensureChunk = () => {
194
+ if (update.chunks.length === 0) {
195
+ update.chunks.push({
196
+ oldLines: [],
197
+ newLines: [],
198
+ contextLineIndices: [],
199
+ isEndOfFile: false,
200
+ });
201
+ }
202
+ return update.chunks[update.chunks.length - 1];
203
+ };
204
+ if (line === "") {
205
+ pushContext(ensureChunk(), "");
206
+ continue;
207
+ }
208
+ if (line.startsWith(" ")) {
209
+ pushContext(ensureChunk(), line.slice(1));
210
+ continue;
211
+ }
212
+ if (line.startsWith("+")) {
213
+ ensureChunk().newLines.push(line.slice(1));
214
+ continue;
215
+ }
216
+ if (line.startsWith("-")) {
217
+ ensureChunk().oldLines.push(line.slice(1));
218
+ continue;
219
+ }
220
+ const lastChunk = update.chunks.at(-1);
221
+ if (lastChunk &&
222
+ (lastChunk.oldLines.length > 0 || lastChunk.newLines.length > 0)) {
223
+ throw new PatchParseError(`Expected update hunk to start with a @@ context marker, got: '${line}'`, lineNumber);
224
+ }
225
+ throw new PatchParseError(`Unexpected line found in update hunk: '${line}'. Every line should start with ' ' (context line), '+' (added line), or '-' (removed line)`, lineNumber);
226
+ }
227
+ if (mode !== "ended") {
228
+ throw new PatchParseError("The last line of the patch must be '*** End Patch'");
229
+ }
230
+ if (hunks.length === 0) {
231
+ throw new PatchParseError("Patch contains no hunks");
232
+ }
233
+ return { hunks: hunks, patch: text };
234
+ }
235
+ /** Paths that already exist on disk and must be observed (write-intent). */
236
+ export function patchPathsRequiringRead(hunks) {
237
+ const out = [];
238
+ for (const hunk of hunks) {
239
+ if (hunk.kind === "add")
240
+ continue;
241
+ out.push(hunk.path);
242
+ }
243
+ return out;
244
+ }
245
+ /** All paths touched by the patch (for presentation / intent emit). */
246
+ export function patchTouchedPaths(hunks) {
247
+ const out = [];
248
+ for (const hunk of hunks) {
249
+ if (hunk.kind === "add" || hunk.kind === "delete") {
250
+ out.push(hunk.path);
251
+ }
252
+ else {
253
+ out.push(hunk.path);
254
+ if (hunk.movePath)
255
+ out.push(hunk.movePath);
256
+ }
257
+ }
258
+ return out;
259
+ }
260
+ //# sourceMappingURL=apply-patch-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-patch-parser.js","sourceRoot":"","sources":["../src/apply-patch-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AACpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAC3C,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,UAAU,CAAU;IAE7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C,yBAAyB,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACvC,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,uBAAuB,CACrC,KAA2B;IAE3B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK;YAAE,SAAS;QAClC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,iBAAiB,CAC/B,KAA2B;IAE3B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpB,IAAI,IAAI,CAAC,QAAQ;gBAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Apply a Codex-format patch through FsService (path-jail + intents).
3
+ */
4
+ export interface ApplyPatchResult {
5
+ readonly ops: readonly {
6
+ readonly action: "add" | "update" | "delete" | "move";
7
+ readonly path: string;
8
+ readonly fromPath?: string;
9
+ }[];
10
+ readonly hunkCount: number;
11
+ }
12
+ export interface ApplyPatchFs {
13
+ read(userPath: string, maxBytes?: number): Promise<{
14
+ readonly content: string;
15
+ readonly truncated?: boolean;
16
+ }>;
17
+ write(userPath: string, content: string): Promise<void>;
18
+ remove(userPath: string): Promise<void>;
19
+ stat(userPath: string): Promise<{
20
+ readonly size: number;
21
+ readonly isFile: boolean;
22
+ readonly isDirectory: boolean;
23
+ }>;
24
+ }
25
+ /** Parse + apply; emits write intents via FsService. */
26
+ export declare function applyPatchToFs(fs: ApplyPatchFs, patchText: string): Promise<ApplyPatchResult>;
27
+ //# sourceMappingURL=apply-patch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-patch.d.ts","sourceRoot":"","sources":["../src/apply-patch.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,SAAS;QACrB,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;QACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;KAC5B,EAAE,CAAC;IACJ,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CACF,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACvE,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;QACzB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;KAC/B,CAAC,CAAC;CACJ;AA4BD,wDAAwD;AACxD,wBAAsB,cAAc,CAClC,EAAE,EAAE,YAAY,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,CAAC,CAyC3B"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Apply a Codex-format patch through FsService (path-jail + intents).
3
+ */
4
+ import { ApplyPatchError, planPatchApplication } from "./apply-patch-apply.js";
5
+ import { parsePatch, PatchParseError, } from "./apply-patch-parser.js";
6
+ async function tryRead(fs, userPath) {
7
+ try {
8
+ const st = await fs.stat(userPath);
9
+ if (st.isDirectory) {
10
+ throw new ApplyPatchError(`cannot apply patch to directory: ${userPath}`);
11
+ }
12
+ const out = await fs.read(userPath);
13
+ return out.content;
14
+ }
15
+ catch (err) {
16
+ if (err instanceof ApplyPatchError)
17
+ throw err;
18
+ const message = err instanceof Error ? err.message : String(err);
19
+ if (/ENOENT|no such file|not found|PathEscape/i.test(message) ||
20
+ err?.code === "ENOENT") {
21
+ return undefined;
22
+ }
23
+ throw err;
24
+ }
25
+ }
26
+ /** Parse + apply; emits write intents via FsService. */
27
+ export async function applyPatchToFs(fs, patchText) {
28
+ let hunks;
29
+ try {
30
+ hunks = parsePatch(patchText).hunks;
31
+ }
32
+ catch (err) {
33
+ if (err instanceof PatchParseError)
34
+ throw err;
35
+ throw err;
36
+ }
37
+ const cache = new Map();
38
+ const readFile = (p) => {
39
+ if (!cache.has(p)) {
40
+ throw new ApplyPatchError(`internal: missing cached read for ${p}`);
41
+ }
42
+ return cache.get(p);
43
+ };
44
+ for (const hunk of hunks) {
45
+ if (hunk.kind === "add") {
46
+ cache.set(hunk.path, await tryRead(fs, hunk.path));
47
+ }
48
+ else if (hunk.kind === "delete") {
49
+ cache.set(hunk.path, await tryRead(fs, hunk.path));
50
+ }
51
+ else {
52
+ cache.set(hunk.path, await tryRead(fs, hunk.path));
53
+ if (hunk.movePath) {
54
+ cache.set(hunk.movePath, await tryRead(fs, hunk.movePath));
55
+ }
56
+ }
57
+ }
58
+ const plan = planPatchApplication(hunks, readFile);
59
+ for (const [userPath, content] of plan.writes) {
60
+ await fs.write(userPath, content);
61
+ }
62
+ for (const userPath of plan.deletes) {
63
+ if (plan.writes.has(userPath))
64
+ continue;
65
+ await fs.remove(userPath);
66
+ }
67
+ return { ops: plan.ops, hunkCount: hunks.length };
68
+ }
69
+ //# sourceMappingURL=apply-patch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-patch.js","sourceRoot":"","sources":["../src/apply-patch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EACL,UAAU,EACV,eAAe,GAEhB,MAAM,yBAAyB,CAAC;AAyBjC,KAAK,UAAU,OAAO,CACpB,EAAgB,EAChB,QAAgB;IAEhB,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YACnB,MAAM,IAAI,eAAe,CACvB,oCAAoC,QAAQ,EAAE,CAC/C,CAAC;QACJ,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,OAAO,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,eAAe;YAAE,MAAM,GAAG,CAAC;QAC9C,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,IACE,2CAA2C,CAAC,IAAI,CAAC,OAAO,CAAC;YACxD,GAA6B,EAAE,IAAI,KAAK,QAAQ,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