@xrkseek/harness-cli 0.0.6 → 0.0.7

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 (299) hide show
  1. package/dist/plugin/classify.js +1 -1
  2. package/dist/plugin/classify.js.map +1 -1
  3. package/node_modules/@xrkseek/core-agent/dist/index.d.ts +9 -2
  4. package/node_modules/@xrkseek/core-agent/dist/index.d.ts.map +1 -1
  5. package/node_modules/@xrkseek/core-agent/dist/index.js +5 -2
  6. package/node_modules/@xrkseek/core-agent/dist/index.js.map +1 -1
  7. package/node_modules/@xrkseek/core-agent-loop/dist/cancel-finalize.d.ts +6 -3
  8. package/node_modules/@xrkseek/core-agent-loop/dist/cancel-finalize.d.ts.map +1 -1
  9. package/node_modules/@xrkseek/core-agent-loop/dist/cancel-finalize.js +50 -4
  10. package/node_modules/@xrkseek/core-agent-loop/dist/cancel-finalize.js.map +1 -1
  11. package/node_modules/@xrkseek/core-agent-loop/dist/index.d.ts +12 -1
  12. package/node_modules/@xrkseek/core-agent-loop/dist/index.d.ts.map +1 -1
  13. package/node_modules/@xrkseek/core-agent-loop/dist/index.js +215 -43
  14. package/node_modules/@xrkseek/core-agent-loop/dist/index.js.map +1 -1
  15. package/node_modules/@xrkseek/core-agent-loop/dist/llm-retry.d.ts +32 -0
  16. package/node_modules/@xrkseek/core-agent-loop/dist/llm-retry.d.ts.map +1 -0
  17. package/node_modules/@xrkseek/core-agent-loop/dist/llm-retry.js +92 -0
  18. package/node_modules/@xrkseek/core-agent-loop/dist/llm-retry.js.map +1 -0
  19. package/node_modules/@xrkseek/core-agent-loop/dist/settle-batch.d.ts +18 -8
  20. package/node_modules/@xrkseek/core-agent-loop/dist/settle-batch.d.ts.map +1 -1
  21. package/node_modules/@xrkseek/core-agent-loop/dist/settle-batch.js +187 -29
  22. package/node_modules/@xrkseek/core-agent-loop/dist/settle-batch.js.map +1 -1
  23. package/node_modules/@xrkseek/core-session/README.md +1 -1
  24. package/node_modules/@xrkseek/core-session/dist/chunk-pack.d.ts +18 -4
  25. package/node_modules/@xrkseek/core-session/dist/chunk-pack.d.ts.map +1 -1
  26. package/node_modules/@xrkseek/core-session/dist/chunk-pack.js +114 -34
  27. package/node_modules/@xrkseek/core-session/dist/chunk-pack.js.map +1 -1
  28. package/node_modules/@xrkseek/core-session/dist/compaction.d.ts.map +1 -1
  29. package/node_modules/@xrkseek/core-session/dist/compaction.js +24 -4
  30. package/node_modules/@xrkseek/core-session/dist/compaction.js.map +1 -1
  31. package/node_modules/@xrkseek/core-session/dist/dangling.d.ts +28 -1
  32. package/node_modules/@xrkseek/core-session/dist/dangling.d.ts.map +1 -1
  33. package/node_modules/@xrkseek/core-session/dist/dangling.js +35 -5
  34. package/node_modules/@xrkseek/core-session/dist/dangling.js.map +1 -1
  35. package/node_modules/@xrkseek/core-session/dist/index.d.ts +3 -2
  36. package/node_modules/@xrkseek/core-session/dist/index.d.ts.map +1 -1
  37. package/node_modules/@xrkseek/core-session/dist/index.js +3 -2
  38. package/node_modules/@xrkseek/core-session/dist/index.js.map +1 -1
  39. package/node_modules/@xrkseek/core-session/dist/latch.d.ts +1 -1
  40. package/node_modules/@xrkseek/core-session/dist/latch.d.ts.map +1 -1
  41. package/node_modules/@xrkseek/core-session/dist/latch.js +2 -2
  42. package/node_modules/@xrkseek/core-session/dist/latch.js.map +1 -1
  43. package/node_modules/@xrkseek/core-session/dist/repair-open-turn.d.ts.map +1 -1
  44. package/node_modules/@xrkseek/core-session/dist/repair-open-turn.js +44 -4
  45. package/node_modules/@xrkseek/core-session/dist/repair-open-turn.js.map +1 -1
  46. package/node_modules/@xrkseek/core-session/dist/sqlite-store.d.ts +1 -0
  47. package/node_modules/@xrkseek/core-session/dist/sqlite-store.d.ts.map +1 -1
  48. package/node_modules/@xrkseek/core-session/dist/sqlite-store.js +10 -5
  49. package/node_modules/@xrkseek/core-session/dist/sqlite-store.js.map +1 -1
  50. package/node_modules/@xrkseek/core-session/dist/surface-fold.d.ts +5 -0
  51. package/node_modules/@xrkseek/core-session/dist/surface-fold.d.ts.map +1 -1
  52. package/node_modules/@xrkseek/core-session/dist/surface-fold.js +29 -3
  53. package/node_modules/@xrkseek/core-session/dist/surface-fold.js.map +1 -1
  54. package/node_modules/@xrkseek/core-session/dist/tool-result-prune.d.ts +35 -0
  55. package/node_modules/@xrkseek/core-session/dist/tool-result-prune.d.ts.map +1 -0
  56. package/node_modules/@xrkseek/core-session/dist/tool-result-prune.js +99 -0
  57. package/node_modules/@xrkseek/core-session/dist/tool-result-prune.js.map +1 -0
  58. package/node_modules/@xrkseek/core-system-prompt/dist/index.d.ts +1 -1
  59. package/node_modules/@xrkseek/core-system-prompt/dist/index.d.ts.map +1 -1
  60. package/node_modules/@xrkseek/core-system-prompt/dist/index.js +1 -1
  61. package/node_modules/@xrkseek/core-system-prompt/dist/index.js.map +1 -1
  62. package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.d.ts +15 -2
  63. package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.d.ts.map +1 -1
  64. package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.js +38 -4
  65. package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.js.map +1 -1
  66. package/node_modules/@xrkseek/core-tools/dist/abort.d.ts +5 -0
  67. package/node_modules/@xrkseek/core-tools/dist/abort.d.ts.map +1 -0
  68. package/node_modules/@xrkseek/core-tools/dist/abort.js +14 -0
  69. package/node_modules/@xrkseek/core-tools/dist/abort.js.map +1 -0
  70. package/node_modules/@xrkseek/core-tools/dist/definition.d.ts +32 -1
  71. package/node_modules/@xrkseek/core-tools/dist/definition.d.ts.map +1 -1
  72. package/node_modules/@xrkseek/core-tools/dist/definition.js +1 -0
  73. package/node_modules/@xrkseek/core-tools/dist/definition.js.map +1 -1
  74. package/node_modules/@xrkseek/core-tools/dist/execution-mode.d.ts +15 -0
  75. package/node_modules/@xrkseek/core-tools/dist/execution-mode.d.ts.map +1 -0
  76. package/node_modules/@xrkseek/core-tools/dist/execution-mode.js +17 -0
  77. package/node_modules/@xrkseek/core-tools/dist/execution-mode.js.map +1 -0
  78. package/node_modules/@xrkseek/core-tools/dist/index.d.ts +2 -0
  79. package/node_modules/@xrkseek/core-tools/dist/index.d.ts.map +1 -1
  80. package/node_modules/@xrkseek/core-tools/dist/index.js +2 -0
  81. package/node_modules/@xrkseek/core-tools/dist/index.js.map +1 -1
  82. package/node_modules/@xrkseek/core-tools/dist/pipeline.d.ts.map +1 -1
  83. package/node_modules/@xrkseek/core-tools/dist/pipeline.js +36 -10
  84. package/node_modules/@xrkseek/core-tools/dist/pipeline.js.map +1 -1
  85. package/node_modules/@xrkseek/core-tools/dist/types.d.ts +7 -0
  86. package/node_modules/@xrkseek/core-tools/dist/types.d.ts.map +1 -1
  87. package/node_modules/@xrkseek/core-tools/dist/types.js.map +1 -1
  88. package/node_modules/@xrkseek/exec-fs/dist/index.d.ts.map +1 -1
  89. package/node_modules/@xrkseek/exec-fs/dist/index.js +3 -0
  90. package/node_modules/@xrkseek/exec-fs/dist/index.js.map +1 -1
  91. package/node_modules/@xrkseek/exec-lsp/dist/tools.d.ts.map +1 -1
  92. package/node_modules/@xrkseek/exec-lsp/dist/tools.js +1 -0
  93. package/node_modules/@xrkseek/exec-lsp/dist/tools.js.map +1 -1
  94. package/node_modules/@xrkseek/exec-pty/dist/tools.d.ts.map +1 -1
  95. package/node_modules/@xrkseek/exec-pty/dist/tools.js +2 -0
  96. package/node_modules/@xrkseek/exec-pty/dist/tools.js.map +1 -1
  97. package/node_modules/@xrkseek/exec-shell/dist/index.d.ts.map +1 -1
  98. package/node_modules/@xrkseek/exec-shell/dist/index.js +4 -0
  99. package/node_modules/@xrkseek/exec-shell/dist/index.js.map +1 -1
  100. package/node_modules/@xrkseek/exec-web/dist/search-providers.js.map +1 -1
  101. package/node_modules/@xrkseek/exec-web/dist/tools.d.ts.map +1 -1
  102. package/node_modules/@xrkseek/exec-web/dist/tools.js +2 -0
  103. package/node_modules/@xrkseek/exec-web/dist/tools.js.map +1 -1
  104. package/node_modules/@xrkseek/llm/dist/failure.d.ts +45 -0
  105. package/node_modules/@xrkseek/llm/dist/failure.d.ts.map +1 -0
  106. package/node_modules/@xrkseek/llm/dist/failure.js +115 -0
  107. package/node_modules/@xrkseek/llm/dist/failure.js.map +1 -0
  108. package/node_modules/@xrkseek/llm/dist/index.d.ts +80 -1
  109. package/node_modules/@xrkseek/llm/dist/index.d.ts.map +1 -1
  110. package/node_modules/@xrkseek/llm/dist/index.js +167 -2
  111. package/node_modules/@xrkseek/llm/dist/index.js.map +1 -1
  112. package/node_modules/@xrkseek/llm/dist/retry-policy.d.ts +23 -0
  113. package/node_modules/@xrkseek/llm/dist/retry-policy.d.ts.map +1 -0
  114. package/node_modules/@xrkseek/llm/dist/retry-policy.js +74 -0
  115. package/node_modules/@xrkseek/llm/dist/retry-policy.js.map +1 -0
  116. package/node_modules/@xrkseek/llm-anthropic/dist/index.d.ts.map +1 -1
  117. package/node_modules/@xrkseek/llm-anthropic/dist/index.js +152 -22
  118. package/node_modules/@xrkseek/llm-anthropic/dist/index.js.map +1 -1
  119. package/node_modules/@xrkseek/llm-deepseek/README.md +3 -3
  120. package/node_modules/@xrkseek/llm-deepseek/dist/index.d.ts +32 -2
  121. package/node_modules/@xrkseek/llm-deepseek/dist/index.d.ts.map +1 -1
  122. package/node_modules/@xrkseek/llm-deepseek/dist/index.js +59 -5
  123. package/node_modules/@xrkseek/llm-deepseek/dist/index.js.map +1 -1
  124. package/node_modules/@xrkseek/llm-gemini/dist/index.d.ts.map +1 -1
  125. package/node_modules/@xrkseek/llm-gemini/dist/index.js +18 -8
  126. package/node_modules/@xrkseek/llm-gemini/dist/index.js.map +1 -1
  127. package/node_modules/@xrkseek/llm-openai-compatible/dist/deepseek-thinking.d.ts +16 -0
  128. package/node_modules/@xrkseek/llm-openai-compatible/dist/deepseek-thinking.d.ts.map +1 -0
  129. package/node_modules/@xrkseek/llm-openai-compatible/dist/deepseek-thinking.js +40 -0
  130. package/node_modules/@xrkseek/llm-openai-compatible/dist/deepseek-thinking.js.map +1 -0
  131. package/node_modules/@xrkseek/llm-openai-compatible/dist/index.d.ts +9 -1
  132. package/node_modules/@xrkseek/llm-openai-compatible/dist/index.d.ts.map +1 -1
  133. package/node_modules/@xrkseek/llm-openai-compatible/dist/index.js +78 -21
  134. package/node_modules/@xrkseek/llm-openai-compatible/dist/index.js.map +1 -1
  135. package/node_modules/@xrkseek/llm-openai-responses/dist/index.d.ts.map +1 -1
  136. package/node_modules/@xrkseek/llm-openai-responses/dist/index.js +18 -8
  137. package/node_modules/@xrkseek/llm-openai-responses/dist/index.js.map +1 -1
  138. package/node_modules/@xrkseek/llm-registry/dist/registry.d.ts.map +1 -1
  139. package/node_modules/@xrkseek/llm-registry/dist/registry.js +6 -4
  140. package/node_modules/@xrkseek/llm-registry/dist/registry.js.map +1 -1
  141. package/node_modules/@xrkseek/llm-registry/dist/routing-adapter.d.ts.map +1 -1
  142. package/node_modules/@xrkseek/llm-registry/dist/routing-adapter.js +15 -3
  143. package/node_modules/@xrkseek/llm-registry/dist/routing-adapter.js.map +1 -1
  144. package/node_modules/@xrkseek/llm-replay/dist/index.d.ts.map +1 -1
  145. package/node_modules/@xrkseek/llm-replay/dist/index.js +4 -1
  146. package/node_modules/@xrkseek/llm-replay/dist/index.js.map +1 -1
  147. package/node_modules/@xrkseek/mcp/dist/client.d.ts +3 -1
  148. package/node_modules/@xrkseek/mcp/dist/client.d.ts.map +1 -1
  149. package/node_modules/@xrkseek/mcp/dist/client.js +31 -7
  150. package/node_modules/@xrkseek/mcp/dist/client.js.map +1 -1
  151. package/node_modules/@xrkseek/mcp/dist/index.d.ts +2 -2
  152. package/node_modules/@xrkseek/mcp/dist/index.d.ts.map +1 -1
  153. package/node_modules/@xrkseek/mcp/dist/index.js +1 -1
  154. package/node_modules/@xrkseek/mcp/dist/index.js.map +1 -1
  155. package/node_modules/@xrkseek/mcp/dist/register.d.ts.map +1 -1
  156. package/node_modules/@xrkseek/mcp/dist/register.js +3 -0
  157. package/node_modules/@xrkseek/mcp/dist/register.js.map +1 -1
  158. package/node_modules/@xrkseek/mcp/dist/types.d.ts +10 -0
  159. package/node_modules/@xrkseek/mcp/dist/types.d.ts.map +1 -1
  160. package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts +18 -1
  161. package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts.map +1 -1
  162. package/node_modules/@xrkseek/preset-harness/dist/preset.js +19 -1
  163. package/node_modules/@xrkseek/preset-harness/dist/preset.js.map +1 -1
  164. package/node_modules/@xrkseek/preset-harness/dist/tsconfig.tsbuildinfo +1 -1
  165. package/node_modules/@xrkseek/preset-minimal/dist/preset.d.ts.map +1 -1
  166. package/node_modules/@xrkseek/preset-minimal/dist/preset.js +1 -0
  167. package/node_modules/@xrkseek/preset-minimal/dist/preset.js.map +1 -1
  168. package/node_modules/@xrkseek/preset-minimal/dist/tsconfig.tsbuildinfo +1 -1
  169. package/node_modules/@xrkseek/preset-server/dist/preset.d.ts.map +1 -1
  170. package/node_modules/@xrkseek/preset-server/dist/preset.js +5 -1
  171. package/node_modules/@xrkseek/preset-server/dist/preset.js.map +1 -1
  172. package/node_modules/@xrkseek/preset-server/dist/tsconfig.tsbuildinfo +1 -1
  173. package/node_modules/@xrkseek/protocol/dist/index.d.ts +3 -1
  174. package/node_modules/@xrkseek/protocol/dist/index.d.ts.map +1 -1
  175. package/node_modules/@xrkseek/protocol/dist/index.js +2 -0
  176. package/node_modules/@xrkseek/protocol/dist/index.js.map +1 -1
  177. package/node_modules/@xrkseek/protocol/dist/json-schema.d.ts +72 -0
  178. package/node_modules/@xrkseek/protocol/dist/json-schema.d.ts.map +1 -1
  179. package/node_modules/@xrkseek/protocol/dist/json-schema.js +50 -0
  180. package/node_modules/@xrkseek/protocol/dist/json-schema.js.map +1 -1
  181. package/node_modules/@xrkseek/protocol/dist/messages.d.ts +7 -0
  182. package/node_modules/@xrkseek/protocol/dist/messages.d.ts.map +1 -1
  183. package/node_modules/@xrkseek/protocol/dist/session-events.d.ts +62 -6
  184. package/node_modules/@xrkseek/protocol/dist/session-events.d.ts.map +1 -1
  185. package/node_modules/@xrkseek/protocol/dist/session-events.js +19 -0
  186. package/node_modules/@xrkseek/protocol/dist/session-events.js.map +1 -1
  187. package/node_modules/@xrkseek/protocol/dist/tools.d.ts +15 -0
  188. package/node_modules/@xrkseek/protocol/dist/tools.d.ts.map +1 -1
  189. package/node_modules/@xrkseek/protocol/dist/tools.js +6 -1
  190. package/node_modules/@xrkseek/protocol/dist/tools.js.map +1 -1
  191. package/node_modules/@xrkseek/protocol/dist/validate.d.ts.map +1 -1
  192. package/node_modules/@xrkseek/protocol/dist/validate.js +107 -1
  193. package/node_modules/@xrkseek/protocol/dist/validate.js.map +1 -1
  194. package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.d.ts +2 -0
  195. package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.d.ts.map +1 -1
  196. package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.js +25 -7
  197. package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.js.map +1 -1
  198. package/node_modules/@xrkseek/server-face/dist/goal-store.d.ts +1 -1
  199. package/node_modules/@xrkseek/server-face/dist/goal-store.d.ts.map +1 -1
  200. package/node_modules/@xrkseek/server-face/dist/goal-store.js +1 -1
  201. package/node_modules/@xrkseek/server-face/dist/goal-store.js.map +1 -1
  202. package/node_modules/@xrkseek/server-face/dist/handlers/session.d.ts.map +1 -1
  203. package/node_modules/@xrkseek/server-face/dist/handlers/session.js +2 -2
  204. package/node_modules/@xrkseek/server-face/dist/handlers/session.js.map +1 -1
  205. package/node_modules/@xrkseek/server-face/dist/index.d.ts +1 -1
  206. package/node_modules/@xrkseek/server-face/dist/index.d.ts.map +1 -1
  207. package/node_modules/@xrkseek/server-face/dist/index.js.map +1 -1
  208. package/node_modules/@xrkseek/server-face/dist/llm-resolve.js +1 -1
  209. package/node_modules/@xrkseek/server-face/dist/llm-resolve.js.map +1 -1
  210. package/node_modules/@xrkseek/server-face/dist/projections/index.d.ts +1 -1
  211. package/node_modules/@xrkseek/server-face/dist/projections/index.d.ts.map +1 -1
  212. package/node_modules/@xrkseek/server-face/dist/projections/index.js.map +1 -1
  213. package/node_modules/@xrkseek/server-face/dist/projections/registry.d.ts +12 -50
  214. package/node_modules/@xrkseek/server-face/dist/projections/registry.d.ts.map +1 -1
  215. package/node_modules/@xrkseek/server-face/dist/projections/registry.js +4 -146
  216. package/node_modules/@xrkseek/server-face/dist/projections/registry.js.map +1 -1
  217. package/node_modules/@xrkseek/server-face/dist/projections/units/context-breakdown.d.ts.map +1 -1
  218. package/node_modules/@xrkseek/server-face/dist/projections/units/context-breakdown.js +13 -11
  219. package/node_modules/@xrkseek/server-face/dist/projections/units/context-breakdown.js.map +1 -1
  220. package/node_modules/@xrkseek/server-face/dist/projections/units/context-pressure.d.ts.map +1 -1
  221. package/node_modules/@xrkseek/server-face/dist/projections/units/context-pressure.js +27 -25
  222. package/node_modules/@xrkseek/server-face/dist/projections/units/context-pressure.js.map +1 -1
  223. package/node_modules/@xrkseek/server-face/dist/projections/units/image-limits.d.ts.map +1 -1
  224. package/node_modules/@xrkseek/server-face/dist/projections/units/image-limits.js +31 -29
  225. package/node_modules/@xrkseek/server-face/dist/projections/units/image-limits.js.map +1 -1
  226. package/node_modules/@xrkseek/server-face/dist/projections/units/permissions.d.ts.map +1 -1
  227. package/node_modules/@xrkseek/server-face/dist/projections/units/permissions.js +27 -25
  228. package/node_modules/@xrkseek/server-face/dist/projections/units/permissions.js.map +1 -1
  229. package/node_modules/@xrkseek/server-face/dist/projections/units/plan.d.ts.map +1 -1
  230. package/node_modules/@xrkseek/server-face/dist/projections/units/plan.js +12 -10
  231. package/node_modules/@xrkseek/server-face/dist/projections/units/plan.js.map +1 -1
  232. package/node_modules/@xrkseek/server-face/dist/projections/units/session-list-metadata.d.ts.map +1 -1
  233. package/node_modules/@xrkseek/server-face/dist/projections/units/session-list-metadata.js +15 -13
  234. package/node_modules/@xrkseek/server-face/dist/projections/units/session-list-metadata.js.map +1 -1
  235. package/node_modules/@xrkseek/server-face/dist/projections/units/session-stats.d.ts.map +1 -1
  236. package/node_modules/@xrkseek/server-face/dist/projections/units/session-stats.js +27 -25
  237. package/node_modules/@xrkseek/server-face/dist/projections/units/session-stats.js.map +1 -1
  238. package/node_modules/@xrkseek/server-face/dist/projections/units/title.d.ts.map +1 -1
  239. package/node_modules/@xrkseek/server-face/dist/projections/units/title.js +9 -7
  240. package/node_modules/@xrkseek/server-face/dist/projections/units/title.js.map +1 -1
  241. package/node_modules/@xrkseek/server-face/dist/projections/units/todos.d.ts.map +1 -1
  242. package/node_modules/@xrkseek/server-face/dist/projections/units/todos.js +25 -23
  243. package/node_modules/@xrkseek/server-face/dist/projections/units/todos.js.map +1 -1
  244. package/node_modules/@xrkseek/server-face/dist/projections/units/token-usage.d.ts.map +1 -1
  245. package/node_modules/@xrkseek/server-face/dist/projections/units/token-usage.js +14 -12
  246. package/node_modules/@xrkseek/server-face/dist/projections/units/token-usage.js.map +1 -1
  247. package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts +8 -13
  248. package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts.map +1 -1
  249. package/node_modules/@xrkseek/server-face/dist/settings-schemas.js +29 -1
  250. package/node_modules/@xrkseek/server-face/dist/settings-schemas.js.map +1 -1
  251. package/node_modules/@xrkseek/server-face/package.json +1 -0
  252. package/node_modules/@xrkseek/server-host/dist/agent-cache.js +1 -1
  253. package/node_modules/@xrkseek/server-host/dist/agent-cache.js.map +1 -1
  254. package/node_modules/@xrkseek/server-host/dist/index.d.ts +8 -0
  255. package/node_modules/@xrkseek/server-host/dist/index.d.ts.map +1 -1
  256. package/node_modules/@xrkseek/server-host/dist/index.js +39 -1
  257. package/node_modules/@xrkseek/server-host/dist/index.js.map +1 -1
  258. package/node_modules/@xrkseek/session-projection/README.md +22 -0
  259. package/node_modules/@xrkseek/session-projection/dist/index.d.ts +100 -0
  260. package/node_modules/@xrkseek/session-projection/dist/index.d.ts.map +1 -0
  261. package/node_modules/@xrkseek/session-projection/dist/index.js +241 -0
  262. package/node_modules/@xrkseek/session-projection/dist/index.js.map +1 -0
  263. package/node_modules/@xrkseek/session-projection/dist/types.d.ts +20 -0
  264. package/node_modules/@xrkseek/session-projection/dist/types.d.ts.map +1 -0
  265. package/node_modules/@xrkseek/session-projection/dist/types.js +9 -0
  266. package/node_modules/@xrkseek/session-projection/dist/types.js.map +1 -0
  267. package/node_modules/@xrkseek/session-projection/package.json +31 -0
  268. package/node_modules/@xrkseek/workspace/dist/skill-tools.d.ts.map +1 -1
  269. package/node_modules/@xrkseek/workspace/dist/skill-tools.js +1 -0
  270. package/node_modules/@xrkseek/workspace/dist/skill-tools.js.map +1 -1
  271. package/package.json +3 -1
  272. package/product-web/boot.json +1 -1
  273. package/product-web/plugins/@xrkseek/client-locale/client.js +2 -2
  274. package/product-web/plugins/@xrkseek/client-ui-agent-preset/client.js +41 -41
  275. package/product-web/plugins/@xrkseek/client-ui-commands/client.js +7 -7
  276. package/product-web/plugins/@xrkseek/client-ui-conversation/client.js +165 -179
  277. package/product-web/plugins/@xrkseek/client-ui-deliverables/client.js +3 -3
  278. package/product-web/plugins/@xrkseek/client-ui-directory-picker-browse/client.js +28 -28
  279. package/product-web/plugins/@xrkseek/client-ui-goal/client.js +7 -7
  280. package/product-web/plugins/@xrkseek/client-ui-input-trigger/client.js +6 -6
  281. package/product-web/plugins/@xrkseek/client-ui-jobs/client.js +8 -8
  282. package/product-web/plugins/@xrkseek/client-ui-layout/client.js +4 -4
  283. package/product-web/plugins/@xrkseek/client-ui-message-feedback/client.js +4 -4
  284. package/product-web/plugins/@xrkseek/client-ui-model-selection/client.js +19 -19
  285. package/product-web/plugins/@xrkseek/client-ui-permission-presets/client.js +4 -4
  286. package/product-web/plugins/@xrkseek/client-ui-plan/client.js +3 -3
  287. package/product-web/plugins/@xrkseek/client-ui-settings-general/client.js +15 -15
  288. package/product-web/plugins/@xrkseek/client-ui-settings-models/client.js +55 -55
  289. package/product-web/plugins/@xrkseek/client-ui-settings-plugin-inventory/client.js +13 -13
  290. package/product-web/plugins/@xrkseek/client-ui-settings-plugins/client.js +134 -63
  291. package/product-web/plugins/@xrkseek/client-ui-sidebar/client.js +15 -15
  292. package/product-web/plugins/@xrkseek/client-ui-skill/client.js +13 -13
  293. package/product-web/plugins/@xrkseek/client-ui-subagent/client.js +18 -18
  294. package/product-web/plugins/@xrkseek/client-ui-theme/client.js +2 -2
  295. package/product-web/plugins/@xrkseek/client-ui-tool/client.js +35 -35
  296. package/product-web/plugins/@xrkseek/client-ui-trajectory/client.js +140 -140
  297. package/product-web/plugins/@xrkseek/client-ui-user-questions/client.js +29 -29
  298. package/product-web/plugins/@xrkseek/client-ui-workflow-run/client.js +16 -16
  299. package/product-web/plugins/@xrkseek/client-ui-workspace/client.js +52 -52
@@ -5,12 +5,17 @@
5
5
  * `shadowedTokenCount` applies signed delta:
6
6
  * estimate(formatCompactionForModel) − shadowedTokenCount
7
7
  * Legacy compaction without the field folds at 0 (DSH replace-without-claim).
8
+ *
9
+ * Pruned `tool/result` replacements carry
10
+ * `meta.xrkPrunePreviousSurfaceTokens` so the fold can apply a net delta
11
+ * without re-scanning the log.
8
12
  */
9
13
  import type { SessionEvent } from "@xrkseek/protocol";
10
14
  export declare function foldSurfaceTokens(surfaceTokens: number, event: SessionEvent): number;
11
15
  /**
12
16
  * Heuristic price of the current model window's append surface
13
17
  * (events after the latest compaction, or from 0).
18
+ * Uses the latest `tool/result` per callId (prune replacements).
14
19
  * Used by compaction producers as `shadowedTokenCount`.
15
20
  */
16
21
  export declare function priceCurrentSurfaceWindow(events: readonly SessionEvent[]): number;
@@ -1 +1 @@
1
- {"version":3,"file":"surface-fold.d.ts","sourceRoot":"","sources":["../src/surface-fold.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAA0B,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA6C9E,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,YAAY,GAClB,MAAM,CAIR;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,YAAY,EAAE,GAC9B,MAAM,CAQR"}
1
+ {"version":3,"file":"surface-fold.d.ts","sourceRoot":"","sources":["../src/surface-fold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAA0B,YAAY,EAAmB,MAAM,mBAAmB,CAAC;AAuD/F,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,YAAY,GAClB,MAAM,CAIR;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,YAAY,EAAE,GAC9B,MAAM,CAkBR"}
@@ -5,9 +5,14 @@
5
5
  * `shadowedTokenCount` applies signed delta:
6
6
  * estimate(formatCompactionForModel) − shadowedTokenCount
7
7
  * Legacy compaction without the field folds at 0 (DSH replace-without-claim).
8
+ *
9
+ * Pruned `tool/result` replacements carry
10
+ * `meta.xrkPrunePreviousSurfaceTokens` so the fold can apply a net delta
11
+ * without re-scanning the log.
8
12
  */
9
13
  import { formatCompactionForModel, findLatestCompaction } from "./compaction.js";
10
14
  import { estimateAssistantSurface, estimateMessageContent, } from "./surface-estimate.js";
15
+ import { TOOL_RESULT_PRUNE_META_PREV_TOKENS } from "./tool-result-prune.js";
11
16
  /** Append-only surface price (excludes compaction). */
12
17
  function appendSurfaceDelta(event) {
13
18
  switch (event.type) {
@@ -17,11 +22,19 @@ function appendSurfaceDelta(event) {
17
22
  case "assistant/message":
18
23
  return estimateAssistantSurface(event.content, event.toolCalls);
19
24
  case "tool/result":
20
- return estimateMessageContent(event.result.content);
25
+ return toolResultSurfaceDelta(event);
21
26
  default:
22
27
  return 0;
23
28
  }
24
29
  }
30
+ function toolResultSurfaceDelta(event) {
31
+ const next = estimateMessageContent(event.result.content);
32
+ const prevRaw = event.result.meta?.[TOOL_RESULT_PRUNE_META_PREV_TOKENS];
33
+ if (typeof prevRaw === "number" && Number.isFinite(prevRaw)) {
34
+ return next - prevRaw;
35
+ }
36
+ return next;
37
+ }
25
38
  /** Checkpoint price after a compaction window swap (one synthetic user message). */
26
39
  function estimateCompactionCheckpoint(event) {
27
40
  return estimateMessageContent(formatCompactionForModel(event));
@@ -50,14 +63,27 @@ export function foldSurfaceTokens(surfaceTokens, event) {
50
63
  /**
51
64
  * Heuristic price of the current model window's append surface
52
65
  * (events after the latest compaction, or from 0).
66
+ * Uses the latest `tool/result` per callId (prune replacements).
53
67
  * Used by compaction producers as `shadowedTokenCount`.
54
68
  */
55
69
  export function priceCurrentSurfaceWindow(events) {
56
70
  const latest = findLatestCompaction(events);
57
71
  const start = latest ? latest.index + 1 : 0;
58
72
  let tokens = 0;
59
- for (let i = start; i < events.length; i++) {
60
- tokens += appendSurfaceDelta(events[i]);
73
+ const seenToolResults = new Set();
74
+ // Walk newest-first so the first tool/result per callId is the surface.
75
+ for (let i = events.length - 1; i >= start; i--) {
76
+ const ev = events[i];
77
+ if (ev.type === "tool/result") {
78
+ if (seenToolResults.has(ev.result.toolCallId))
79
+ continue;
80
+ seenToolResults.add(ev.result.toolCallId);
81
+ tokens += estimateMessageContent(ev.result.content);
82
+ continue;
83
+ }
84
+ if (ev.type === "context/compaction")
85
+ continue;
86
+ tokens += appendSurfaceDelta(ev);
61
87
  }
62
88
  return tokens;
63
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"surface-fold.js","sourceRoot":"","sources":["../src/surface-fold.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,uDAAuD;AACvD,SAAS,kBAAkB,CAAC,KAAmB;IAC7C,QAA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C5C,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAC1C,wEAAwE;IACxE,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAChD,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAE,CAAC;QACtB,IAAI,EAAE,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YAC9B,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC;gBAAE,SAAS;YACxD,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC1C,MAAM,IAAI,sBAAsB,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACpD,SAAS;QACX,CAAC;QACD,IAAI,EAAE,CAAC,IAAI,KAAK,oBAAoB;YAAE,SAAS;QAC/C,MAAM,IAAI,kBAAkB,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Truncate oversized model-visible `tool/result` surfaces (DSH-aligned).
3
+ * Appends a replacement `tool/result` for the same callId; log keeps the
4
+ * original. `deriveMessages` / surface pricing fold to the latest per callId.
5
+ */
6
+ import type { SessionStore } from "./store.js";
7
+ /** DSH-aligned: prune when result text exceeds this many characters. */
8
+ export declare const TOOL_RESULT_PRUNE_THRESHOLD_CHARS = 8192;
9
+ export declare const TOOL_RESULT_PRUNE_HEAD_CHARS = 4096;
10
+ export declare const TOOL_RESULT_PRUNE_TAIL_CHARS = 1024;
11
+ /** `tool/result.meta` key: previous surface token price (for O(1) fold delta). */
12
+ export declare const TOOL_RESULT_PRUNE_META_PREV_TOKENS: "xrkPrunePreviousSurfaceTokens";
13
+ export interface ToolResultPruneOptions {
14
+ readonly thresholdChars?: number;
15
+ readonly headChars?: number;
16
+ readonly tailChars?: number;
17
+ readonly now?: () => number;
18
+ readonly turnId?: string;
19
+ readonly stepId?: string;
20
+ }
21
+ export interface ToolResultPruneResult {
22
+ readonly pruned: number;
23
+ }
24
+ export declare function pruneToolResultText(text: string, options?: {
25
+ readonly thresholdChars?: number;
26
+ readonly headChars?: number;
27
+ readonly tailChars?: number;
28
+ }): string | undefined;
29
+ /**
30
+ * Append pruned replacement `tool/result` events for oversized results in the
31
+ * current model window (after latest compaction). Idempotent when the latest
32
+ * surface is already under threshold.
33
+ */
34
+ export declare function pruneOversizedToolResults(store: SessionStore, sessionId: string, options?: ToolResultPruneOptions): ToolResultPruneResult;
35
+ //# sourceMappingURL=tool-result-prune.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-result-prune.d.ts","sourceRoot":"","sources":["../src/tool-result-prune.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wEAAwE;AACxE,eAAO,MAAM,iCAAiC,OAAO,CAAC;AACtD,eAAO,MAAM,4BAA4B,OAAO,CAAC;AACjD,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAEjD,kFAAkF;AAClF,eAAO,MAAM,kCAAkC,EAC7C,+BAAwC,CAAC;AAE3C,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAaD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IACP,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CACxB,GACL,MAAM,GAAG,SAAS,CAYpB;AAgBD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,sBAA2B,GACnC,qBAAqB,CAyCvB"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Truncate oversized model-visible `tool/result` surfaces (DSH-aligned).
3
+ * Appends a replacement `tool/result` for the same callId; log keeps the
4
+ * original. `deriveMessages` / surface pricing fold to the latest per callId.
5
+ */
6
+ import { estimateMessageContent } from "./surface-estimate.js";
7
+ import { findLatestCompaction } from "./compaction.js";
8
+ /** DSH-aligned: prune when result text exceeds this many characters. */
9
+ export const TOOL_RESULT_PRUNE_THRESHOLD_CHARS = 8192;
10
+ export const TOOL_RESULT_PRUNE_HEAD_CHARS = 4096;
11
+ export const TOOL_RESULT_PRUNE_TAIL_CHARS = 1024;
12
+ /** `tool/result.meta` key: previous surface token price (for O(1) fold delta). */
13
+ export const TOOL_RESULT_PRUNE_META_PREV_TOKENS = "xrkPrunePreviousSurfaceTokens";
14
+ function contentPlainText(content) {
15
+ if (typeof content === "string")
16
+ return content;
17
+ if (!Array.isArray(content) || content.length === 0)
18
+ return undefined;
19
+ const parts = [];
20
+ for (const block of content) {
21
+ if (block.type !== "text")
22
+ return undefined;
23
+ parts.push(block.text);
24
+ }
25
+ return parts.join("\n");
26
+ }
27
+ export function pruneToolResultText(text, options = {}) {
28
+ const threshold = options.thresholdChars ?? TOOL_RESULT_PRUNE_THRESHOLD_CHARS;
29
+ const headChars = options.headChars ?? TOOL_RESULT_PRUNE_HEAD_CHARS;
30
+ const tailChars = options.tailChars ?? TOOL_RESULT_PRUNE_TAIL_CHARS;
31
+ // DSH budgets are Unicode code points, not UTF-16 code units.
32
+ const units = Array.from(text);
33
+ if (units.length <= threshold)
34
+ return undefined;
35
+ if (headChars + tailChars >= units.length)
36
+ return undefined;
37
+ const omitted = units.length - headChars - tailChars;
38
+ const head = units.slice(0, headChars).join("");
39
+ const tail = units.slice(-tailChars).join("");
40
+ return `${head}\n\n…[${omitted} chars omitted]…\n\n${tail}`;
41
+ }
42
+ function latestToolResultByCallId(events, start) {
43
+ const latest = new Map();
44
+ for (let i = start; i < events.length; i++) {
45
+ const ev = events[i];
46
+ if (ev.type === "tool/result") {
47
+ latest.set(ev.result.toolCallId, ev);
48
+ }
49
+ }
50
+ return latest;
51
+ }
52
+ /**
53
+ * Append pruned replacement `tool/result` events for oversized results in the
54
+ * current model window (after latest compaction). Idempotent when the latest
55
+ * surface is already under threshold.
56
+ */
57
+ export function pruneOversizedToolResults(store, sessionId, options = {}) {
58
+ const threshold = options.thresholdChars ?? TOOL_RESULT_PRUNE_THRESHOLD_CHARS;
59
+ const headChars = options.headChars ?? TOOL_RESULT_PRUNE_HEAD_CHARS;
60
+ const tailChars = options.tailChars ?? TOOL_RESULT_PRUNE_TAIL_CHARS;
61
+ const now = options.now ?? Date.now;
62
+ const events = store.get(sessionId).events;
63
+ const latestCompaction = findLatestCompaction(events);
64
+ const start = latestCompaction ? latestCompaction.index + 1 : 0;
65
+ const latest = latestToolResultByCallId(events, start);
66
+ let pruned = 0;
67
+ for (const ev of latest.values()) {
68
+ const plain = contentPlainText(ev.result.content);
69
+ if (plain === undefined)
70
+ continue;
71
+ const next = pruneToolResultText(plain, {
72
+ thresholdChars: threshold,
73
+ headChars,
74
+ tailChars,
75
+ });
76
+ if (next === undefined)
77
+ continue;
78
+ const previousSurfaceTokens = estimateMessageContent(ev.result.content);
79
+ store.append(sessionId, {
80
+ type: "tool/result",
81
+ ts: now(),
82
+ turnId: options.turnId ?? ev.turnId,
83
+ stepId: options.stepId ?? ev.stepId,
84
+ result: {
85
+ toolCallId: ev.result.toolCallId,
86
+ name: ev.result.name,
87
+ content: next,
88
+ ...(ev.result.isError ? { isError: true } : {}),
89
+ meta: {
90
+ ...(ev.result.meta ?? {}),
91
+ [TOOL_RESULT_PRUNE_META_PREV_TOKENS]: previousSurfaceTokens,
92
+ },
93
+ },
94
+ });
95
+ pruned += 1;
96
+ }
97
+ return { pruned };
98
+ }
99
+ //# sourceMappingURL=tool-result-prune.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-result-prune.js","sourceRoot":"","sources":["../src/tool-result-prune.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGvD,wEAAwE;AACxE,MAAM,CAAC,MAAM,iCAAiC,GAAG,IAAI,CAAC;AACtD,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC;AACjD,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC;AAEjD,kFAAkF;AAClF,MAAM,CAAC,MAAM,kCAAkC,GAC7C,+BAAwC,CAAC;AAe3C,SAAS,gBAAgB,CAAC,OAAuB;IAC/C,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACtE,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO,SAAS,CAAC;QAC5C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IACD,OAAO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,CAAC;QACxE,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE;YACtB,IAAI,EAAE,aAAa;YACnB,EAAE,EAAE,GAAG,EAAE;YACT,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,MAAM;YACnC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,MAAM;YACnC,MAAM,EAAE;gBACN,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU;gBAChC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI;gBACpB,OAAO,EAAE,IAAI;gBACb,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/C,IAAI,EAAE;oBACJ,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;oBACzB,CAAC,kCAAkC,CAAC,EAAE,qBAAqB;iBAC5D;aACF;SACF,CAAC,CAAC;QACH,MAAM,IAAI,CAAC,CAAC;IACd,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { SessionEvent } from "@xrkseek/protocol";
2
2
  import { type ThreeLayerInput } from "./three-layer.js";
3
3
  import { type PipelineStep, type SlashResolveFn } from "./outbound.js";
4
- export { assembleThreeLayers, buildSkeletonSystem, buildSkeletonUser, buildVolatileUser, mergeHistory, orderToolsForWire, type AssembledRequest, type SkeletonSystemInput, type SkeletonUserInput, type ThreeLayerInput, type VolatileUserInput, } from "./three-layer.js";
4
+ export { assembleThreeLayers, buildSkeletonSystem, buildSkeletonUser, buildVolatileUser, mergeHistory, orderToolsForWire, TOOL_ORDER_REST, type AssembledRequest, type SkeletonSystemInput, type SkeletonUserInput, type ThreeLayerInput, type VolatileUserInput, } from "./three-layer.js";
5
5
  export { compactionStep, createAssembleStep, createContextWindowStep, createOutboundPipeline, createSlashRecipeStep, createToolPairStep, slashRecipeStep, type OutboundPipeline, type PipelineStep, type PipelineStepContext, type SlashExpandResult, type SlashResolveFn, } from "./outbound.js";
6
6
  export interface PromptSection {
7
7
  readonly id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAKnE,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IACvC,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED,wBAAgB,2BAA2B,IAAI,qBAAqB,CAqBnE;AAED;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AAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IACvC,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED,wBAAgB,2BAA2B,IAAI,qBAAqB,CAqBnE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,UAAU,EAAE,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7D,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IACrC,YAAY,CAAC,EAAE,cAAc,CAAC;CAC/B,4CA2BA"}
@@ -1,7 +1,7 @@
1
1
  import { assertModelVisible, deriveMessages, } from "@xrkseek/core-session";
2
2
  import { assembleThreeLayers, } from "./three-layer.js";
3
3
  import { compactionStep, createAssembleStep, createContextWindowStep, createOutboundPipeline, createSlashRecipeStep, createToolPairStep, slashRecipeStep, } from "./outbound.js";
4
- export { assembleThreeLayers, buildSkeletonSystem, buildSkeletonUser, buildVolatileUser, mergeHistory, orderToolsForWire, } from "./three-layer.js";
4
+ export { assembleThreeLayers, buildSkeletonSystem, buildSkeletonUser, buildVolatileUser, mergeHistory, orderToolsForWire, TOOL_ORDER_REST, } from "./three-layer.js";
5
5
  export { compactionStep, createAssembleStep, createContextWindowStep, createOutboundPipeline, createSlashRecipeStep, createToolPairStep, slashRecipeStep, } from "./outbound.js";
6
6
  export function createSystemPromptAssembler() {
7
7
  const sections = [];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,mBAAmB,GAEpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,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,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -40,6 +40,13 @@ export interface ThreeLayerInput {
40
40
  * so the volatile suffix can stay byte-stable across a turn's tool loop.
41
41
  */
42
42
  readonly includeVolatileTime?: boolean;
43
+ /**
44
+ * Optional tool wire order (DSH `toolOrder`). Exactly one `' '` rest marker;
45
+ * named tools before/after the rest appear in that order, remaining tools
46
+ * fill the rest slot in lexicographic order. Omit / empty → pure lex sort.
47
+ * Unknown names, duplicates, or wrong rest count throw.
48
+ */
49
+ readonly toolOrder?: readonly string[];
43
50
  }
44
51
  export declare function buildSkeletonSystem(input: SkeletonSystemInput): string;
45
52
  export declare function buildSkeletonUser(input: SkeletonUserInput): ChatMessage;
@@ -51,13 +58,19 @@ export declare function mergeHistory(history: readonly ChatMessage[], options?:
51
58
  readonly includeCurrentMarker?: boolean;
52
59
  }): ChatMessage[];
53
60
  /** Lexicographic tool order — registration order must not leak to the wire. */
54
- export declare function orderToolsForWire(tools: AssembledRequest["tools"]): AssembledRequest["tools"];
61
+ export declare const TOOL_ORDER_REST: " ";
62
+ /**
63
+ * Order tools for the wire.
64
+ * @param tools - tool definitions for this request
65
+ * @param toolOrder - optional DSH-style order with exactly one `' '` rest
66
+ */
67
+ export declare function orderToolsForWire(tools: AssembledRequest["tools"], toolOrder?: readonly string[]): AssembledRequest["tools"];
55
68
  /**
56
69
  * Fixed order:
57
70
  * 1. system = skeleton system (+ optional workspace blocks appended)
58
71
  * 2. messages = history(+optional marker) + skeleton user + volatile user
59
72
  * Volatile content must never appear in `system`.
60
- * Tools are sorted by name for prompt-cache stability (DSH parity).
73
+ * Tools are sorted by name (or `toolOrder`) for prompt-cache stability (DSH parity).
61
74
  */
62
75
  export declare function assembleThreeLayers(input: ThreeLayerInput): AssembledRequest;
63
76
  //# sourceMappingURL=three-layer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"three-layer.d.ts","sourceRo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,OAAO,CAAA;CAAO,GAC/C,WAAW,CAWb;AAED,qFAAqF;AACrF,wBAAgB,YAAY,CAC1B,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,OAAO,GAAE;IAAE,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAAO,GACxD,WAAW,EAAE,CAWf;AAED,+EAA+E;AAC/E,eAAO,MAAM,eAAe,EAAG,GAAY,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAC5B,gBAAgB,CAAC,OAAO,CAAC,CAkC3B;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,eAAe,GACrB,gBAAgB,CA0BlB"}
@@ -43,15 +43,49 @@ export function mergeHistory(history, options = {}) {
43
43
  ];
44
44
  }
45
45
  /** Lexicographic tool order — registration order must not leak to the wire. */
46
- export function orderToolsForWire(tools) {
47
- return [...tools].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
46
+ export const TOOL_ORDER_REST = " ";
47
+ /**
48
+ * Order tools for the wire.
49
+ * @param tools - tool definitions for this request
50
+ * @param toolOrder - optional DSH-style order with exactly one `' '` rest
51
+ */
52
+ export function orderToolsForWire(tools, toolOrder) {
53
+ const lex = [...tools].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
54
+ if (!toolOrder || toolOrder.length === 0)
55
+ return lex;
56
+ const restMarks = toolOrder.filter((x) => x === TOOL_ORDER_REST);
57
+ if (restMarks.length !== 1) {
58
+ throw new Error(`toolOrder must contain exactly one ' ' rest marker (got ${restMarks.length})`);
59
+ }
60
+ const named = toolOrder.filter((x) => x !== TOOL_ORDER_REST);
61
+ if (new Set(named).size !== named.length) {
62
+ throw new Error("toolOrder must not list the same tool name twice");
63
+ }
64
+ const byName = new Map(tools.map((t) => [t.name, t]));
65
+ for (const name of named) {
66
+ if (!byName.has(name)) {
67
+ throw new Error(`toolOrder references unknown tool: ${name}`);
68
+ }
69
+ }
70
+ const restIdx = toolOrder.indexOf(TOOL_ORDER_REST);
71
+ const before = toolOrder.slice(0, restIdx).filter((x) => x !== TOOL_ORDER_REST);
72
+ const after = toolOrder.slice(restIdx + 1).filter((x) => x !== TOOL_ORDER_REST);
73
+ const pinned = new Set([...before, ...after]);
74
+ const middle = lex.filter((t) => !pinned.has(t.name));
75
+ const pick = (names) => names.map((n) => {
76
+ const t = byName.get(n);
77
+ if (!t)
78
+ throw new Error(`toolOrder references unknown tool: ${n}`);
79
+ return t;
80
+ });
81
+ return [...pick(before), ...middle, ...pick(after)];
48
82
  }
49
83
  /**
50
84
  * Fixed order:
51
85
  * 1. system = skeleton system (+ optional workspace blocks appended)
52
86
  * 2. messages = history(+optional marker) + skeleton user + volatile user
53
87
  * Volatile content must never appear in `system`.
54
- * Tools are sorted by name for prompt-cache stability (DSH parity).
88
+ * Tools are sorted by name (or `toolOrder`) for prompt-cache stability (DSH parity).
55
89
  */
56
90
  export function assembleThreeLayers(input) {
57
91
  const systemParts = [buildSkeletonSystem(input.skeletonSystem)];
@@ -71,7 +105,7 @@ export function assembleThreeLayers(input) {
71
105
  return {
72
106
  system,
73
107
  messages,
74
- tools: orderToolsForWire(input.tools ?? []),
108
+ tools: orderToolsForWire(input.tools ?? [], input.toolOrder),
75
109
  };
76
110
  }
77
111
  //# sourceMappingURL=three-layer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"three-layer.js","sourceRoot":"","sources":["../src/three-layer.ts"],"names":[],"mappings":"AAiDA,MAAM,UAAU,mBAAmB,CAAC,KAA0B;IAC5D,MAAM,KAAK,GAAG;QACZ,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,iCAAiC;QAC1D,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE;KAChC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClB,OA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K,CAAC,mBAAmB,KAAK,SAAS;YACrC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,mBAAmB,EAAE,CAC/C;KACF,CAAC;IACF,OAAO;QACL,MAAM;QACN,QAAQ;QACR,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC;KAC7D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { ToolResultContent } from "./definition.js";
2
+ export declare function isAbortError(err: unknown): boolean;
3
+ /** Model-facing result when cancel wins after the tool body was invoked. */
4
+ export declare function abortedToolContent(): ToolResultContent;
5
+ //# sourceMappingURL=abort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../src/abort.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKlD;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,IAAI,iBAAiB,CAMtD"}
@@ -0,0 +1,14 @@
1
+ import { TOOL_ABORTED, TOOL_ABORTED_MESSAGE, } from "@xrkseek/protocol";
2
+ export function isAbortError(err) {
3
+ return ((err instanceof DOMException || err instanceof Error) &&
4
+ err.name === "AbortError");
5
+ }
6
+ /** Model-facing result when cancel wins after the tool body was invoked. */
7
+ export function abortedToolContent() {
8
+ return {
9
+ content: TOOL_ABORTED_MESSAGE,
10
+ isError: true,
11
+ error: { name: "AbortError", code: TOOL_ABORTED },
12
+ };
13
+ }
14
+ //# sourceMappingURL=abort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abort.js","sourceRoot":"","sources":["../src/abort.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,OAAO,CACL,CAAC,GAAG,YAAY,YAAY,IAAI,GAAG,YAAY,KAAK,CAAC;QACrD,GAAG,CAAC,IAAI,KAAK,YAAY,CAC1B,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,OAAO,EAAE,oBAAoB;QAC7B,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE;KAClD,CAAC;AACJ,CAAC"}
@@ -1,15 +1,32 @@
1
1
  import type { ToolResult } from "@xrkseek/protocol";
2
2
  import type { MessageContent } from "@xrkseek/protocol";
3
3
  import type { PresentableToolResult, ToolCallView, ToolResultView } from "./presentation.js";
4
- /** Optional execute extras — pipeline wires `emitToolEvent` → session side events. */
4
+ /** Optional execute extras — pipeline wires session side-effects. */
5
5
  export interface ToolExecuteExtras {
6
6
  emitToolEvent(type: string, payload: unknown): void;
7
+ /**
8
+ * Mark a successful final result as terminal for the current agent turn
9
+ * (DSH `ToolRunContext.concludeTurn`). Equivalent to returning
10
+ * `{ concludesTurn: true }`; ignored when the result is an error.
11
+ */
12
+ concludeTurn(): void;
13
+ /**
14
+ * Defer a user-visible context string until after this tool's `tool/result`
15
+ * (DSH `deferContext`, string form — XRK appends `user/message`).
16
+ */
17
+ deferContext(text: string): void;
7
18
  }
8
19
  export interface ToolDefinition<TArgs = unknown> {
9
20
  readonly name: string;
10
21
  readonly description: string;
11
22
  readonly parameters: Record<string, unknown>;
12
23
  execute(args: TArgs, signal?: AbortSignal, extras?: ToolExecuteExtras): Promise<ToolResultContent>;
24
+ /**
25
+ * Per-call concurrency classifier (DSH `isConcurrencySafe`).
26
+ * Exact `true` may run overlapping with other safe calls; undeclared,
27
+ * throwing, or any other return → exclusive barrier.
28
+ */
29
+ isConcurrencySafe?(args: TArgs): boolean;
13
30
  /**
14
31
  * Pure UI render intent. Soft-fail (return undefined / never throw) — Face
15
32
  * `viewFor` catches throws the same way DSH apiproxy does.
@@ -22,6 +39,20 @@ export interface ToolResultContent {
22
39
  readonly isError?: boolean;
23
40
  /** Face presentation replay; copied onto session `tool/result`. */
24
41
  readonly meta?: Readonly<Record<string, unknown>>;
42
+ /**
43
+ * DSH `ToolExecutionSuccess.concludesTurn`: successful body may end the
44
+ * current agent turn after this step settles (no further LLM step).
45
+ * Ignored when `isError` is set.
46
+ */
47
+ readonly concludesTurn?: true;
48
+ /**
49
+ * Structured failure class (e.g. abort codes). Copied onto session
50
+ * `tool/result.error` by {@link normalizeToolResult}.
51
+ */
52
+ readonly error?: {
53
+ readonly name: string;
54
+ readonly code: string;
55
+ };
25
56
  }
26
57
  export interface ToolRegistry {
27
58
  register(tool: ToolDefinition): void;
@@ -1 +1 @@
1
- {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAChC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,cAAc,CAAC,KAAK,GAAG,OAAO;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,OAAO,CACL,IAAI,EAAE,KAAK,EACX,MAAM,CAAC,EAAE,WAAW,EACpB,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAAC;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CAAC;IAClD;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE;QACf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IACrC,0FAA0F;IAC1F,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IAC9C,IAAI,IAAI,SAAS,cAAc,EAAE,CAAC;CACnC;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CA0BjD;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,iBAAiB,GACrB,UAAU,CASZ;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,UAAU,CAOZ;AAED,sDAAsD;AACtD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAE/D"}
@@ -32,6 +32,7 @@ export function normalizeToolResult(callId, name, out) {
32
32
  content: out.content,
33
33
  ...(out.isError ? { isError: true } : {}),
34
34
  ...(out.meta !== undefined ? { meta: out.meta } : {}),
35
+ ...(out.error !== undefined ? { error: out.error } : {}),
35
36
  };
36
37
  }
37
38
  export function errorToolResult(callId, name, content) {
@@ -1 +1 @@
1
- {"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAiDA,MAAM,UAAU,kBAAkB;IAChC,MAAM,KAAK,GAAG,IAAI,G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7B,CAAC;QACD,UAAU,CAAC,IAAI;YACb,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,MAAc,EACd,IAAY,EACZ,GAAsB;IAEtB,OAAO;QACL,UAAU,EAAE,MAAM;QAClB,IAAI;QACJ,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,MAAc,EACd,IAAY,EACZ,OAAe;IAEf,OAAO;QACL,UAAU,EAAE,MAAM;QAClB,IAAI;QACJ,OAAO;QACP,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,gBAAgB,CAAC,MAAkB;IACjD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Fail-closed tool concurrency classification (DSH executionMode).
3
+ */
4
+ import type { ToolCall } from "@xrkseek/protocol";
5
+ import type { ToolRegistry } from "./definition.js";
6
+ export type ToolExecutionModeKind = "parallel" | "exclusive";
7
+ export interface ToolExecutionMode {
8
+ readonly kind: ToolExecutionModeKind;
9
+ }
10
+ /**
11
+ * Classify one pending call. Only exact `true` from a registered tool's
12
+ * `isConcurrencySafe` is parallel; unknown / missing / throw → exclusive.
13
+ */
14
+ export declare function classifyToolExecutionMode(registry: ToolRegistry, call: ToolCall): ToolExecutionMode;
15
+ //# sourceMappingURL=execution-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-mode.d.ts","sourceRoot":"","sources":["../src/execution-mode.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,WAAW,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE,QAAQ,GACb,iBAAiB,CASnB"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Classify one pending call. Only exact `true` from a registered tool's
3
+ * `isConcurrencySafe` is parallel; unknown / missing / throw → exclusive.
4
+ */
5
+ export function classifyToolExecutionMode(registry, call) {
6
+ const tool = registry.get(call.name);
7
+ if (!tool?.isConcurrencySafe)
8
+ return { kind: "exclusive" };
9
+ try {
10
+ const safe = tool.isConcurrencySafe(call.arguments);
11
+ return safe === true ? { kind: "parallel" } : { kind: "exclusive" };
12
+ }
13
+ catch {
14
+ return { kind: "exclusive" };
15
+ }
16
+ }
17
+ //# sourceMappingURL=execution-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-mode.js","sourceRoot":"","sources":["../src/execution-mode.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAsB,EACtB,IAAc;IAEd,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,IAAI,EAAE,iBAAiB;QAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC3D,IAAI,CAAC;QACH,MAAM,IAAI,GAAY,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7D,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IACtE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/B,CAAC;AACH,CAAC"}
@@ -1,4 +1,6 @@
1
+ export { abortedToolContent, isAbortError, } from "./abort.js";
1
2
  export { createToolRegistry, errorToolResult, freezeToolResult, normalizeToolResult, type ToolDefinition, type ToolExecuteExtras, type ToolRegistry, type ToolResultContent, } from "./definition.js";
3
+ export { classifyToolExecutionMode, type ToolExecutionMode, type ToolExecutionModeKind, } from "./execution-mode.js";
2
4
  export { parseExitStatus, type DiffCallView, type DiffResultView, type FileDiff, type FileLocation, type GenericCallView, type GenericResultView, type ParsedExitStatus, type PresentableToolResult, type ReadFileLine, type ReadResultView, type SearchFileMatches, type SearchLineMatch, type SearchMatchesResultView, type SearchPathsResultView, type TerminalCallView, type TerminalResultView, type TextBlock, type ToolCallKind, type ToolCallView, type ToolEventView, type ToolResultView, type WebFetchResultView, type WebResultView, type WebSearchResultView, type WebSource, } from "./presentation.js";
3
5
  export { presentToolEventView, type PresentToolLookup, type ToolCallPairing, } from "./present-event.js";
4
6
  export { createPolicyToolCallGuard, createReadTracker, createSandboxArgvWrapGuard, createWriteIntentGuard, extractPathArg, foldGuardVerdicts, runGuards, } from "./guards.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,gBAA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AAK,qBAAqB,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,iBAAiB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,c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AAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC"}
@@ -1,4 +1,6 @@
1
+ export { abortedToolContent, isAbortError, } from "./abort.js";
1
2
  export { createToolRegistry, errorToolResult, freezeToolResult, normalizeToolResult, } from "./definition.js";
3
+ export { classifyToolExecutionMode, } from "./execution-mode.js";
2
4
  export { parseExitStatus, } from "./presentation.js";
3
5
  export { presentToolEventView, } from "./present-event.js";
4
6
  export { createPolicyToolCallGuard, createReadTracker, createSandboxArgvWrapGuard, createWriteIntentGuard, extractPathArg, foldGuardVerdicts, runGuards, } from "./guards.js";