@draht/agent-core 2026.10.20 → 2026.10.23

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 (468) hide show
  1. package/dist/agent-loop.d.ts +6 -1
  2. package/dist/agent-loop.d.ts.map +1 -1
  3. package/dist/agent-loop.js +16 -2
  4. package/dist/agent-loop.js.map +1 -1
  5. package/dist/agent.d.ts +8 -1
  6. package/dist/agent.d.ts.map +1 -1
  7. package/dist/agent.js +4 -0
  8. package/dist/agent.js.map +1 -1
  9. package/dist/index.d.ts +0 -22
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +0 -20
  12. package/dist/index.js.map +1 -1
  13. package/dist/proxy.d.ts +2 -5
  14. package/dist/proxy.d.ts.map +1 -1
  15. package/dist/proxy.js +2 -14
  16. package/dist/proxy.js.map +1 -1
  17. package/dist/types.d.ts +4 -0
  18. package/dist/types.d.ts.map +1 -1
  19. package/dist/types.js.map +1 -1
  20. package/package.json +4 -47
  21. package/dist/harness/agent-harness.d.ts +0 -716
  22. package/dist/harness/agent-harness.d.ts.map +0 -1
  23. package/dist/harness/agent-harness.js +0 -6
  24. package/dist/harness/agent-harness.js.map +0 -1
  25. package/dist/harness/compaction/branch-summarization.d.ts +0 -68
  26. package/dist/harness/compaction/branch-summarization.d.ts.map +0 -1
  27. package/dist/harness/compaction/branch-summarization.js +0 -176
  28. package/dist/harness/compaction/branch-summarization.js.map +0 -1
  29. package/dist/harness/compaction/compaction.d.ts +0 -126
  30. package/dist/harness/compaction/compaction.d.ts.map +0 -1
  31. package/dist/harness/compaction/compaction.js +0 -561
  32. package/dist/harness/compaction/compaction.js.map +0 -1
  33. package/dist/harness/compaction/utils.d.ts +0 -28
  34. package/dist/harness/compaction/utils.d.ts.map +0 -1
  35. package/dist/harness/compaction/utils.js +0 -123
  36. package/dist/harness/compaction/utils.js.map +0 -1
  37. package/dist/harness/config.d.ts +0 -9
  38. package/dist/harness/config.d.ts.map +0 -1
  39. package/dist/harness/config.js +0 -35
  40. package/dist/harness/config.js.map +0 -1
  41. package/dist/harness/context.d.ts +0 -9
  42. package/dist/harness/context.d.ts.map +0 -1
  43. package/dist/harness/context.js +0 -13
  44. package/dist/harness/context.js.map +0 -1
  45. package/dist/harness/env/nodejs.d.ts +0 -43
  46. package/dist/harness/env/nodejs.d.ts.map +0 -1
  47. package/dist/harness/env/nodejs.js +0 -865
  48. package/dist/harness/env/nodejs.js.map +0 -1
  49. package/dist/harness/events.d.ts +0 -24
  50. package/dist/harness/events.d.ts.map +0 -1
  51. package/dist/harness/events.js +0 -233
  52. package/dist/harness/events.js.map +0 -1
  53. package/dist/harness/execution/assistant.d.ts +0 -42
  54. package/dist/harness/execution/assistant.d.ts.map +0 -1
  55. package/dist/harness/execution/assistant.js +0 -82
  56. package/dist/harness/execution/assistant.js.map +0 -1
  57. package/dist/harness/execution/effect-gate.d.ts +0 -22
  58. package/dist/harness/execution/effect-gate.d.ts.map +0 -1
  59. package/dist/harness/execution/effect-gate.js +0 -49
  60. package/dist/harness/execution/effect-gate.js.map +0 -1
  61. package/dist/harness/execution/tools.d.ts +0 -67
  62. package/dist/harness/execution/tools.d.ts.map +0 -1
  63. package/dist/harness/execution/tools.js +0 -119
  64. package/dist/harness/execution/tools.js.map +0 -1
  65. package/dist/harness/execution-env.d.ts +0 -4
  66. package/dist/harness/execution-env.d.ts.map +0 -1
  67. package/dist/harness/execution-env.js +0 -3
  68. package/dist/harness/execution-env.js.map +0 -1
  69. package/dist/harness/hooks.d.ts +0 -38
  70. package/dist/harness/hooks.d.ts.map +0 -1
  71. package/dist/harness/hooks.js +0 -406
  72. package/dist/harness/hooks.js.map +0 -1
  73. package/dist/harness/messages.d.ts +0 -51
  74. package/dist/harness/messages.d.ts.map +0 -1
  75. package/dist/harness/messages.js +0 -103
  76. package/dist/harness/messages.js.map +0 -1
  77. package/dist/harness/pico3/bash.d.ts +0 -10
  78. package/dist/harness/pico3/bash.d.ts.map +0 -1
  79. package/dist/harness/pico3/bash.js +0 -25
  80. package/dist/harness/pico3/bash.js.map +0 -1
  81. package/dist/harness/pico3/bounded.d.ts +0 -21
  82. package/dist/harness/pico3/bounded.d.ts.map +0 -1
  83. package/dist/harness/pico3/bounded.js +0 -98
  84. package/dist/harness/pico3/bounded.js.map +0 -1
  85. package/dist/harness/pico3/chord.d.ts +0 -41
  86. package/dist/harness/pico3/chord.d.ts.map +0 -1
  87. package/dist/harness/pico3/chord.js +0 -147
  88. package/dist/harness/pico3/chord.js.map +0 -1
  89. package/dist/harness/pico3/context.d.ts +0 -16
  90. package/dist/harness/pico3/context.d.ts.map +0 -1
  91. package/dist/harness/pico3/context.js +0 -88
  92. package/dist/harness/pico3/context.js.map +0 -1
  93. package/dist/harness/pico3/harness.d.ts +0 -198
  94. package/dist/harness/pico3/harness.d.ts.map +0 -1
  95. package/dist/harness/pico3/harness.js +0 -654
  96. package/dist/harness/pico3/harness.js.map +0 -1
  97. package/dist/harness/pico3/hooks.d.ts +0 -10
  98. package/dist/harness/pico3/hooks.d.ts.map +0 -1
  99. package/dist/harness/pico3/hooks.js +0 -33
  100. package/dist/harness/pico3/hooks.js.map +0 -1
  101. package/dist/harness/pico3/index.d.ts +0 -19
  102. package/dist/harness/pico3/index.d.ts.map +0 -1
  103. package/dist/harness/pico3/index.js +0 -15
  104. package/dist/harness/pico3/index.js.map +0 -1
  105. package/dist/harness/pico3/jsonl.d.ts +0 -58
  106. package/dist/harness/pico3/jsonl.d.ts.map +0 -1
  107. package/dist/harness/pico3/jsonl.js +0 -325
  108. package/dist/harness/pico3/jsonl.js.map +0 -1
  109. package/dist/harness/pico3/kinds/collapse.d.ts +0 -49
  110. package/dist/harness/pico3/kinds/collapse.d.ts.map +0 -1
  111. package/dist/harness/pico3/kinds/collapse.js +0 -191
  112. package/dist/harness/pico3/kinds/collapse.js.map +0 -1
  113. package/dist/harness/pico3/kinds/entries.d.ts +0 -78
  114. package/dist/harness/pico3/kinds/entries.d.ts.map +0 -1
  115. package/dist/harness/pico3/kinds/entries.js +0 -13
  116. package/dist/harness/pico3/kinds/entries.js.map +0 -1
  117. package/dist/harness/pico3/kinds/frames.d.ts +0 -9
  118. package/dist/harness/pico3/kinds/frames.d.ts.map +0 -1
  119. package/dist/harness/pico3/kinds/frames.js +0 -75
  120. package/dist/harness/pico3/kinds/frames.js.map +0 -1
  121. package/dist/harness/pico3/kinds/generation.d.ts +0 -94
  122. package/dist/harness/pico3/kinds/generation.d.ts.map +0 -1
  123. package/dist/harness/pico3/kinds/generation.js +0 -504
  124. package/dist/harness/pico3/kinds/generation.js.map +0 -1
  125. package/dist/harness/pico3/kinds/job.d.ts +0 -44
  126. package/dist/harness/pico3/kinds/job.d.ts.map +0 -1
  127. package/dist/harness/pico3/kinds/job.js +0 -143
  128. package/dist/harness/pico3/kinds/job.js.map +0 -1
  129. package/dist/harness/pico3/kinds/plugin.d.ts +0 -15
  130. package/dist/harness/pico3/kinds/plugin.d.ts.map +0 -1
  131. package/dist/harness/pico3/kinds/plugin.js +0 -35
  132. package/dist/harness/pico3/kinds/plugin.js.map +0 -1
  133. package/dist/harness/pico3/kinds/post-tools.d.ts +0 -22
  134. package/dist/harness/pico3/kinds/post-tools.d.ts.map +0 -1
  135. package/dist/harness/pico3/kinds/post-tools.js +0 -145
  136. package/dist/harness/pico3/kinds/post-tools.js.map +0 -1
  137. package/dist/harness/pico3/kinds/task-api.d.ts +0 -3
  138. package/dist/harness/pico3/kinds/task-api.d.ts.map +0 -1
  139. package/dist/harness/pico3/kinds/task-api.js +0 -45
  140. package/dist/harness/pico3/kinds/task-api.js.map +0 -1
  141. package/dist/harness/pico3/kinds/tool.d.ts +0 -43
  142. package/dist/harness/pico3/kinds/tool.d.ts.map +0 -1
  143. package/dist/harness/pico3/kinds/tool.js +0 -373
  144. package/dist/harness/pico3/kinds/tool.js.map +0 -1
  145. package/dist/harness/pico3/legacy-tracker.d.ts +0 -11
  146. package/dist/harness/pico3/legacy-tracker.d.ts.map +0 -1
  147. package/dist/harness/pico3/legacy-tracker.js +0 -41
  148. package/dist/harness/pico3/legacy-tracker.js.map +0 -1
  149. package/dist/harness/pico3/membrane.d.ts +0 -23
  150. package/dist/harness/pico3/membrane.d.ts.map +0 -1
  151. package/dist/harness/pico3/membrane.js +0 -141
  152. package/dist/harness/pico3/membrane.js.map +0 -1
  153. package/dist/harness/pico3/memory.d.ts +0 -53
  154. package/dist/harness/pico3/memory.d.ts.map +0 -1
  155. package/dist/harness/pico3/memory.js +0 -264
  156. package/dist/harness/pico3/memory.js.map +0 -1
  157. package/dist/harness/pico3/scheduler.d.ts +0 -49
  158. package/dist/harness/pico3/scheduler.d.ts.map +0 -1
  159. package/dist/harness/pico3/scheduler.js +0 -438
  160. package/dist/harness/pico3/scheduler.js.map +0 -1
  161. package/dist/harness/pico3/session.d.ts +0 -264
  162. package/dist/harness/pico3/session.d.ts.map +0 -1
  163. package/dist/harness/pico3/session.js +0 -1348
  164. package/dist/harness/pico3/session.js.map +0 -1
  165. package/dist/harness/pico3/system.d.ts +0 -126
  166. package/dist/harness/pico3/system.d.ts.map +0 -1
  167. package/dist/harness/pico3/system.js +0 -244
  168. package/dist/harness/pico3/system.js.map +0 -1
  169. package/dist/harness/pico3/types.d.ts +0 -973
  170. package/dist/harness/pico3/types.d.ts.map +0 -1
  171. package/dist/harness/pico3/types.js +0 -106
  172. package/dist/harness/pico3/types.js.map +0 -1
  173. package/dist/harness/pico3/view.d.ts +0 -34
  174. package/dist/harness/pico3/view.d.ts.map +0 -1
  175. package/dist/harness/pico3/view.js +0 -411
  176. package/dist/harness/pico3/view.js.map +0 -1
  177. package/dist/harness/prompt-templates.d.ts +0 -49
  178. package/dist/harness/prompt-templates.d.ts.map +0 -1
  179. package/dist/harness/prompt-templates.js +0 -225
  180. package/dist/harness/prompt-templates.js.map +0 -1
  181. package/dist/harness/result.d.ts +0 -133
  182. package/dist/harness/result.d.ts.map +0 -1
  183. package/dist/harness/result.js +0 -81
  184. package/dist/harness/result.js.map +0 -1
  185. package/dist/harness/runtime/drive/boundary.d.ts +0 -28
  186. package/dist/harness/runtime/drive/boundary.d.ts.map +0 -1
  187. package/dist/harness/runtime/drive/boundary.js +0 -173
  188. package/dist/harness/runtime/drive/boundary.js.map +0 -1
  189. package/dist/harness/runtime/drive/checkpoint.d.ts +0 -8
  190. package/dist/harness/runtime/drive/checkpoint.d.ts.map +0 -1
  191. package/dist/harness/runtime/drive/checkpoint.js +0 -133
  192. package/dist/harness/runtime/drive/checkpoint.js.map +0 -1
  193. package/dist/harness/runtime/drive/deferred.d.ts +0 -15
  194. package/dist/harness/runtime/drive/deferred.d.ts.map +0 -1
  195. package/dist/harness/runtime/drive/deferred.js +0 -179
  196. package/dist/harness/runtime/drive/deferred.js.map +0 -1
  197. package/dist/harness/runtime/drive/generation.d.ts +0 -8
  198. package/dist/harness/runtime/drive/generation.d.ts.map +0 -1
  199. package/dist/harness/runtime/drive/generation.js +0 -205
  200. package/dist/harness/runtime/drive/generation.js.map +0 -1
  201. package/dist/harness/runtime/drive/reconcile.d.ts +0 -5
  202. package/dist/harness/runtime/drive/reconcile.d.ts.map +0 -1
  203. package/dist/harness/runtime/drive/reconcile.js +0 -140
  204. package/dist/harness/runtime/drive/reconcile.js.map +0 -1
  205. package/dist/harness/runtime/drive/recovery.d.ts +0 -8
  206. package/dist/harness/runtime/drive/recovery.d.ts.map +0 -1
  207. package/dist/harness/runtime/drive/recovery.js +0 -85
  208. package/dist/harness/runtime/drive/recovery.js.map +0 -1
  209. package/dist/harness/runtime/drive/response.d.ts +0 -23
  210. package/dist/harness/runtime/drive/response.d.ts.map +0 -1
  211. package/dist/harness/runtime/drive/response.js +0 -394
  212. package/dist/harness/runtime/drive/response.js.map +0 -1
  213. package/dist/harness/runtime/drive/retry.d.ts +0 -4
  214. package/dist/harness/runtime/drive/retry.d.ts.map +0 -1
  215. package/dist/harness/runtime/drive/retry.js +0 -34
  216. package/dist/harness/runtime/drive/retry.js.map +0 -1
  217. package/dist/harness/runtime/drive/structural.d.ts +0 -32
  218. package/dist/harness/runtime/drive/structural.d.ts.map +0 -1
  219. package/dist/harness/runtime/drive/structural.js +0 -929
  220. package/dist/harness/runtime/drive/structural.js.map +0 -1
  221. package/dist/harness/runtime/drive/terminal.d.ts +0 -7
  222. package/dist/harness/runtime/drive/terminal.d.ts.map +0 -1
  223. package/dist/harness/runtime/drive/terminal.js +0 -49
  224. package/dist/harness/runtime/drive/terminal.js.map +0 -1
  225. package/dist/harness/runtime/drive/tool-placement.d.ts +0 -14
  226. package/dist/harness/runtime/drive/tool-placement.d.ts.map +0 -1
  227. package/dist/harness/runtime/drive/tool-placement.js +0 -219
  228. package/dist/harness/runtime/drive/tool-placement.js.map +0 -1
  229. package/dist/harness/runtime/drive/tools.d.ts +0 -6
  230. package/dist/harness/runtime/drive/tools.d.ts.map +0 -1
  231. package/dist/harness/runtime/drive/tools.js +0 -449
  232. package/dist/harness/runtime/drive/tools.js.map +0 -1
  233. package/dist/harness/runtime/drive.d.ts +0 -6
  234. package/dist/harness/runtime/drive.d.ts.map +0 -1
  235. package/dist/harness/runtime/drive.js +0 -93
  236. package/dist/harness/runtime/drive.js.map +0 -1
  237. package/dist/harness/runtime/harness.d.ts +0 -59
  238. package/dist/harness/runtime/harness.d.ts.map +0 -1
  239. package/dist/harness/runtime/harness.js +0 -311
  240. package/dist/harness/runtime/harness.js.map +0 -1
  241. package/dist/harness/runtime/index.d.ts +0 -2
  242. package/dist/harness/runtime/index.d.ts.map +0 -1
  243. package/dist/harness/runtime/index.js +0 -2
  244. package/dist/harness/runtime/index.js.map +0 -1
  245. package/dist/harness/runtime/lane.d.ts +0 -118
  246. package/dist/harness/runtime/lane.d.ts.map +0 -1
  247. package/dist/harness/runtime/lane.js +0 -1575
  248. package/dist/harness/runtime/lane.js.map +0 -1
  249. package/dist/harness/runtime/progress.d.ts +0 -15
  250. package/dist/harness/runtime/progress.d.ts.map +0 -1
  251. package/dist/harness/runtime/progress.js +0 -66
  252. package/dist/harness/runtime/progress.js.map +0 -1
  253. package/dist/harness/runtime/reducer.d.ts +0 -5
  254. package/dist/harness/runtime/reducer.d.ts.map +0 -1
  255. package/dist/harness/runtime/reducer.js +0 -240
  256. package/dist/harness/runtime/reducer.js.map +0 -1
  257. package/dist/harness/runtime/restore.d.ts +0 -24
  258. package/dist/harness/runtime/restore.d.ts.map +0 -1
  259. package/dist/harness/runtime/restore.js +0 -117
  260. package/dist/harness/runtime/restore.js.map +0 -1
  261. package/dist/harness/runtime/transcript.d.ts +0 -21
  262. package/dist/harness/runtime/transcript.d.ts.map +0 -1
  263. package/dist/harness/runtime/transcript.js +0 -72
  264. package/dist/harness/runtime/transcript.js.map +0 -1
  265. package/dist/harness/runtime/types.d.ts +0 -105
  266. package/dist/harness/runtime/types.d.ts.map +0 -1
  267. package/dist/harness/runtime/types.js +0 -61
  268. package/dist/harness/runtime/types.js.map +0 -1
  269. package/dist/harness/session/commit.d.ts +0 -53
  270. package/dist/harness/session/commit.d.ts.map +0 -1
  271. package/dist/harness/session/commit.js +0 -57
  272. package/dist/harness/session/commit.js.map +0 -1
  273. package/dist/harness/session/context.d.ts +0 -10
  274. package/dist/harness/session/context.d.ts.map +0 -1
  275. package/dist/harness/session/context.js +0 -49
  276. package/dist/harness/session/context.js.map +0 -1
  277. package/dist/harness/session/fork-policy.d.ts +0 -21
  278. package/dist/harness/session/fork-policy.d.ts.map +0 -1
  279. package/dist/harness/session/fork-policy.js +0 -55
  280. package/dist/harness/session/fork-policy.js.map +0 -1
  281. package/dist/harness/session/fork.d.ts +0 -16
  282. package/dist/harness/session/fork.d.ts.map +0 -1
  283. package/dist/harness/session/fork.js +0 -79
  284. package/dist/harness/session/fork.js.map +0 -1
  285. package/dist/harness/session/in-memory-storage-state.d.ts +0 -39
  286. package/dist/harness/session/in-memory-storage-state.d.ts.map +0 -1
  287. package/dist/harness/session/in-memory-storage-state.js +0 -276
  288. package/dist/harness/session/in-memory-storage-state.js.map +0 -1
  289. package/dist/harness/session/index.d.ts +0 -11
  290. package/dist/harness/session/index.d.ts.map +0 -1
  291. package/dist/harness/session/index.js +0 -9
  292. package/dist/harness/session/index.js.map +0 -1
  293. package/dist/harness/session/jsonl/codec.d.ts +0 -21
  294. package/dist/harness/session/jsonl/codec.d.ts.map +0 -1
  295. package/dist/harness/session/jsonl/codec.js +0 -45
  296. package/dist/harness/session/jsonl/codec.js.map +0 -1
  297. package/dist/harness/session/jsonl/fork.d.ts +0 -38
  298. package/dist/harness/session/jsonl/fork.d.ts.map +0 -1
  299. package/dist/harness/session/jsonl/fork.js +0 -264
  300. package/dist/harness/session/jsonl/fork.js.map +0 -1
  301. package/dist/harness/session/jsonl/index.d.ts +0 -4
  302. package/dist/harness/session/jsonl/index.d.ts.map +0 -1
  303. package/dist/harness/session/jsonl/index.js +0 -4
  304. package/dist/harness/session/jsonl/index.js.map +0 -1
  305. package/dist/harness/session/jsonl/io.d.ts +0 -14
  306. package/dist/harness/session/jsonl/io.d.ts.map +0 -1
  307. package/dist/harness/session/jsonl/io.js +0 -86
  308. package/dist/harness/session/jsonl/io.js.map +0 -1
  309. package/dist/harness/session/jsonl/legacy-v3.d.ts +0 -44
  310. package/dist/harness/session/jsonl/legacy-v3.d.ts.map +0 -1
  311. package/dist/harness/session/jsonl/legacy-v3.js +0 -462
  312. package/dist/harness/session/jsonl/legacy-v3.js.map +0 -1
  313. package/dist/harness/session/jsonl/repo.d.ts +0 -35
  314. package/dist/harness/session/jsonl/repo.d.ts.map +0 -1
  315. package/dist/harness/session/jsonl/repo.js +0 -301
  316. package/dist/harness/session/jsonl/repo.js.map +0 -1
  317. package/dist/harness/session/jsonl/storage.d.ts +0 -41
  318. package/dist/harness/session/jsonl/storage.d.ts.map +0 -1
  319. package/dist/harness/session/jsonl/storage.js +0 -200
  320. package/dist/harness/session/jsonl/storage.js.map +0 -1
  321. package/dist/harness/session/jsonl/types.d.ts +0 -39
  322. package/dist/harness/session/jsonl/types.d.ts.map +0 -1
  323. package/dist/harness/session/jsonl/types.js +0 -3
  324. package/dist/harness/session/jsonl/types.js.map +0 -1
  325. package/dist/harness/session/memory.d.ts +0 -48
  326. package/dist/harness/session/memory.d.ts.map +0 -1
  327. package/dist/harness/session/memory.js +0 -369
  328. package/dist/harness/session/memory.js.map +0 -1
  329. package/dist/harness/session/mutation-line.d.ts +0 -8
  330. package/dist/harness/session/mutation-line.d.ts.map +0 -1
  331. package/dist/harness/session/mutation-line.js +0 -21
  332. package/dist/harness/session/mutation-line.js.map +0 -1
  333. package/dist/harness/session/session.d.ts +0 -82
  334. package/dist/harness/session/session.d.ts.map +0 -1
  335. package/dist/harness/session/session.js +0 -361
  336. package/dist/harness/session/session.js.map +0 -1
  337. package/dist/harness/session/testing/benchmark/datasets.d.ts +0 -12
  338. package/dist/harness/session/testing/benchmark/datasets.d.ts.map +0 -1
  339. package/dist/harness/session/testing/benchmark/datasets.js +0 -24
  340. package/dist/harness/session/testing/benchmark/datasets.js.map +0 -1
  341. package/dist/harness/session/testing/benchmark/session-repo.d.ts +0 -42
  342. package/dist/harness/session/testing/benchmark/session-repo.d.ts.map +0 -1
  343. package/dist/harness/session/testing/benchmark/session-repo.js +0 -127
  344. package/dist/harness/session/testing/benchmark/session-repo.js.map +0 -1
  345. package/dist/harness/session/testing/benchmark/storage.d.ts +0 -25
  346. package/dist/harness/session/testing/benchmark/storage.d.ts.map +0 -1
  347. package/dist/harness/session/testing/benchmark/storage.js +0 -114
  348. package/dist/harness/session/testing/benchmark/storage.js.map +0 -1
  349. package/dist/harness/session/testing/conformance/session-repo.d.ts +0 -23
  350. package/dist/harness/session/testing/conformance/session-repo.d.ts.map +0 -1
  351. package/dist/harness/session/testing/conformance/session-repo.js +0 -809
  352. package/dist/harness/session/testing/conformance/session-repo.js.map +0 -1
  353. package/dist/harness/session/testing/conformance/storage.d.ts +0 -4
  354. package/dist/harness/session/testing/conformance/storage.d.ts.map +0 -1
  355. package/dist/harness/session/testing/conformance/storage.js +0 -600
  356. package/dist/harness/session/testing/conformance/storage.js.map +0 -1
  357. package/dist/harness/session/testing/gating-storage.d.ts +0 -26
  358. package/dist/harness/session/testing/gating-storage.d.ts.map +0 -1
  359. package/dist/harness/session/testing/gating-storage.js +0 -100
  360. package/dist/harness/session/testing/gating-storage.js.map +0 -1
  361. package/dist/harness/session/testing/index.d.ts +0 -10
  362. package/dist/harness/session/testing/index.d.ts.map +0 -1
  363. package/dist/harness/session/testing/index.js +0 -9
  364. package/dist/harness/session/testing/index.js.map +0 -1
  365. package/dist/harness/session/testing/instrumented-storage.d.ts +0 -11
  366. package/dist/harness/session/testing/instrumented-storage.d.ts.map +0 -1
  367. package/dist/harness/session/testing/instrumented-storage.js +0 -16
  368. package/dist/harness/session/testing/instrumented-storage.js.map +0 -1
  369. package/dist/harness/session/testing/storage-decorator.d.ts +0 -20
  370. package/dist/harness/session/testing/storage-decorator.d.ts.map +0 -1
  371. package/dist/harness/session/testing/storage-decorator.js +0 -41
  372. package/dist/harness/session/testing/storage-decorator.js.map +0 -1
  373. package/dist/harness/session/testing/types.d.ts +0 -12
  374. package/dist/harness/session/testing/types.d.ts.map +0 -1
  375. package/dist/harness/session/testing/types.js +0 -2
  376. package/dist/harness/session/testing/types.js.map +0 -1
  377. package/dist/harness/session/types.d.ts +0 -512
  378. package/dist/harness/session/types.d.ts.map +0 -1
  379. package/dist/harness/session/types.js +0 -9
  380. package/dist/harness/session/types.js.map +0 -1
  381. package/dist/harness/session/values.d.ts +0 -95
  382. package/dist/harness/session/values.d.ts.map +0 -1
  383. package/dist/harness/session/values.js +0 -81
  384. package/dist/harness/session/values.js.map +0 -1
  385. package/dist/harness/skills.d.ts +0 -46
  386. package/dist/harness/skills.d.ts.map +0 -1
  387. package/dist/harness/skills.js +0 -326
  388. package/dist/harness/skills.js.map +0 -1
  389. package/dist/harness/system-prompt.d.ts +0 -3
  390. package/dist/harness/system-prompt.d.ts.map +0 -1
  391. package/dist/harness/system-prompt.js +0 -30
  392. package/dist/harness/system-prompt.js.map +0 -1
  393. package/dist/harness/telemetry.d.ts +0 -1242
  394. package/dist/harness/telemetry.d.ts.map +0 -1
  395. package/dist/harness/telemetry.js +0 -527
  396. package/dist/harness/telemetry.js.map +0 -1
  397. package/dist/harness/tools/bash.d.ts +0 -27
  398. package/dist/harness/tools/bash.d.ts.map +0 -1
  399. package/dist/harness/tools/bash.js +0 -105
  400. package/dist/harness/tools/bash.js.map +0 -1
  401. package/dist/harness/tools/edit-diff.d.ts +0 -89
  402. package/dist/harness/tools/edit-diff.d.ts.map +0 -1
  403. package/dist/harness/tools/edit-diff.js +0 -386
  404. package/dist/harness/tools/edit-diff.js.map +0 -1
  405. package/dist/harness/tools/edit.d.ts +0 -19
  406. package/dist/harness/tools/edit.d.ts.map +0 -1
  407. package/dist/harness/tools/edit.js +0 -108
  408. package/dist/harness/tools/edit.js.map +0 -1
  409. package/dist/harness/tools/file-mutation-queue.d.ts +0 -5
  410. package/dist/harness/tools/file-mutation-queue.d.ts.map +0 -1
  411. package/dist/harness/tools/file-mutation-queue.js +0 -46
  412. package/dist/harness/tools/file-mutation-queue.js.map +0 -1
  413. package/dist/harness/tools/image.d.ts +0 -3
  414. package/dist/harness/tools/image.d.ts.map +0 -1
  415. package/dist/harness/tools/image.js +0 -106
  416. package/dist/harness/tools/image.js.map +0 -1
  417. package/dist/harness/tools/index.d.ts +0 -6
  418. package/dist/harness/tools/index.d.ts.map +0 -1
  419. package/dist/harness/tools/index.js +0 -5
  420. package/dist/harness/tools/index.js.map +0 -1
  421. package/dist/harness/tools/path-utils.d.ts +0 -5
  422. package/dist/harness/tools/path-utils.d.ts.map +0 -1
  423. package/dist/harness/tools/path-utils.js +0 -26
  424. package/dist/harness/tools/path-utils.js.map +0 -1
  425. package/dist/harness/tools/read.d.ts +0 -35
  426. package/dist/harness/tools/read.d.ts.map +0 -1
  427. package/dist/harness/tools/read.js +0 -108
  428. package/dist/harness/tools/read.js.map +0 -1
  429. package/dist/harness/tools/tool-context.d.ts +0 -6
  430. package/dist/harness/tools/tool-context.d.ts.map +0 -1
  431. package/dist/harness/tools/tool-context.js +0 -2
  432. package/dist/harness/tools/tool-context.js.map +0 -1
  433. package/dist/harness/tools/write.d.ts +0 -11
  434. package/dist/harness/tools/write.d.ts.map +0 -1
  435. package/dist/harness/tools/write.js +0 -31
  436. package/dist/harness/tools/write.js.map +0 -1
  437. package/dist/harness/types.d.ts +0 -305
  438. package/dist/harness/types.d.ts.map +0 -1
  439. package/dist/harness/types.js +0 -75
  440. package/dist/harness/types.js.map +0 -1
  441. package/dist/harness/utils/adaptive-publisher.d.ts +0 -24
  442. package/dist/harness/utils/adaptive-publisher.d.ts.map +0 -1
  443. package/dist/harness/utils/adaptive-publisher.js +0 -79
  444. package/dist/harness/utils/adaptive-publisher.js.map +0 -1
  445. package/dist/harness/utils/output-capture.d.ts +0 -31
  446. package/dist/harness/utils/output-capture.d.ts.map +0 -1
  447. package/dist/harness/utils/output-capture.js +0 -217
  448. package/dist/harness/utils/output-capture.js.map +0 -1
  449. package/dist/harness/utils/shell-output.d.ts +0 -29
  450. package/dist/harness/utils/shell-output.d.ts.map +0 -1
  451. package/dist/harness/utils/shell-output.js +0 -71
  452. package/dist/harness/utils/shell-output.js.map +0 -1
  453. package/dist/harness/utils/truncate.d.ts +0 -71
  454. package/dist/harness/utils/truncate.d.ts.map +0 -1
  455. package/dist/harness/utils/truncate.js +0 -296
  456. package/dist/harness/utils/truncate.js.map +0 -1
  457. package/dist/harness/utils/usage.d.ts +0 -4
  458. package/dist/harness/utils/usage.d.ts.map +0 -1
  459. package/dist/harness/utils/usage.js +0 -33
  460. package/dist/harness/utils/usage.js.map +0 -1
  461. package/dist/node.d.ts +0 -3
  462. package/dist/node.d.ts.map +0 -1
  463. package/dist/node.js +0 -3
  464. package/dist/node.js.map +0 -1
  465. package/dist/search/index.d.ts +0 -29
  466. package/dist/search/index.d.ts.map +0 -1
  467. package/dist/search/index.js +0 -2
  468. package/dist/search/index.js.map +0 -1
@@ -1,71 +0,0 @@
1
- /**
2
- * Shared truncation utilities for tool outputs.
3
- *
4
- * Truncation is based on two independent limits - whichever is hit first wins:
5
- * - Line limit (default: 2000 lines)
6
- * - Byte limit (default: 50KB)
7
- *
8
- * Never returns partial lines (except bash tail truncation edge case).
9
- */
10
- export declare const DEFAULT_MAX_LINES = 2000;
11
- export declare const DEFAULT_MAX_BYTES: number;
12
- export declare const GREP_MAX_LINE_LENGTH = 500;
13
- export interface TruncationResult {
14
- /** The truncated content */
15
- content: string;
16
- /** Whether truncation occurred */
17
- truncated: boolean;
18
- /** Which limit was hit: "lines", "bytes", or null if not truncated */
19
- truncatedBy: "lines" | "bytes" | null;
20
- /** Total number of lines in the original content */
21
- totalLines: number;
22
- /** Total number of bytes in the original content */
23
- totalBytes: number;
24
- /** Number of complete lines in the truncated output */
25
- outputLines: number;
26
- /** Number of bytes in the truncated output */
27
- outputBytes: number;
28
- /** Whether the last line was partially truncated (only for tail truncation edge case) */
29
- lastLinePartial: boolean;
30
- /** Whether the first line exceeded the byte limit (for head truncation) */
31
- firstLineExceedsLimit: boolean;
32
- /** The max lines limit that was applied */
33
- maxLines: number;
34
- /** The max bytes limit that was applied */
35
- maxBytes: number;
36
- }
37
- export interface TruncationOptions {
38
- /** Maximum number of lines (default: 2000) */
39
- maxLines?: number;
40
- /** Maximum number of bytes (default: 50KB) */
41
- maxBytes?: number;
42
- }
43
- export declare function utf8ByteLength(content: string): number;
44
- /**
45
- * Format bytes as human-readable size.
46
- */
47
- export declare function formatSize(bytes: number): string;
48
- /**
49
- * Truncate content from the head (keep first N lines/bytes).
50
- * Suitable for file reads where you want to see the beginning.
51
- *
52
- * Never returns partial lines. If first line exceeds byte limit,
53
- * returns empty content with firstLineExceedsLimit=true.
54
- */
55
- export declare function truncateHead(content: string, options?: TruncationOptions): TruncationResult;
56
- /**
57
- * Truncate content from the tail (keep last N lines/bytes).
58
- * Suitable for bash output where you want to see the end (errors, final results).
59
- *
60
- * May return partial first line if the last line of original content exceeds byte limit.
61
- */
62
- export declare function truncateTail(content: string, options?: TruncationOptions): TruncationResult;
63
- /**
64
- * Truncate a single line to max characters, adding [truncated] suffix.
65
- * Used for grep match lines.
66
- */
67
- export declare function truncateLine(line: string, maxChars?: number): {
68
- text: string;
69
- wasTruncated: boolean;
70
- };
71
- //# sourceMappingURL=truncate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"truncate.d.ts","sourceRoot":"","sources":["../../../src/harness/utils/truncate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,iBAAiB,QAAY,CAAC;AAC3C,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAChC,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,WAAW,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;IACtC,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,eAAe,EAAE,OAAO,CAAC;IACzB,2EAA2E;IAC3E,qBAAqB,EAAE,OAAO,CAAC;IAC/B,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IACjC,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AASD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA0BtD;AAgCD;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQhD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,gBAAgB,CAkF/F;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,gBAAgB,CAyE/F;AA2CD;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAA6B,GACrC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,CAKzC"}
@@ -1,296 +0,0 @@
1
- /**
2
- * Shared truncation utilities for tool outputs.
3
- *
4
- * Truncation is based on two independent limits - whichever is hit first wins:
5
- * - Line limit (default: 2000 lines)
6
- * - Byte limit (default: 50KB)
7
- *
8
- * Never returns partial lines (except bash tail truncation edge case).
9
- */
10
- export const DEFAULT_MAX_LINES = 2000;
11
- export const DEFAULT_MAX_BYTES = 50 * 1024; // 50KB
12
- export const GREP_MAX_LINE_LENGTH = 500; // Max chars per grep match line
13
- const runtimeBuffer = globalThis.Buffer;
14
- const nonAsciiPattern = /[^\x00-\x7f]/;
15
- export function utf8ByteLength(content) {
16
- if (runtimeBuffer)
17
- return runtimeBuffer.byteLength(content, "utf8");
18
- const firstNonAscii = content.search(nonAsciiPattern);
19
- if (firstNonAscii === -1)
20
- return content.length;
21
- let bytes = firstNonAscii;
22
- for (let i = firstNonAscii; i < content.length; i++) {
23
- const code = content.charCodeAt(i);
24
- if (code <= 0x7f) {
25
- bytes += 1;
26
- }
27
- else if (code <= 0x7ff) {
28
- bytes += 2;
29
- }
30
- else if (code >= 0xd800 && code <= 0xdbff && i + 1 < content.length) {
31
- const next = content.charCodeAt(i + 1);
32
- if (next >= 0xdc00 && next <= 0xdfff) {
33
- bytes += 4;
34
- i++;
35
- }
36
- else {
37
- bytes += 3;
38
- }
39
- }
40
- else {
41
- bytes += 3;
42
- }
43
- }
44
- return bytes;
45
- }
46
- function splitLinesForCounting(content) {
47
- if (content.length === 0)
48
- return [];
49
- const lines = content.split("\n");
50
- if (content.endsWith("\n"))
51
- lines.pop();
52
- return lines;
53
- }
54
- function replaceUnpairedSurrogates(content) {
55
- let output = "";
56
- for (let i = 0; i < content.length; i++) {
57
- const code = content.charCodeAt(i);
58
- if (code >= 0xd800 && code <= 0xdbff) {
59
- if (i + 1 < content.length) {
60
- const next = content.charCodeAt(i + 1);
61
- if (next >= 0xdc00 && next <= 0xdfff) {
62
- output += content[i] + content[i + 1];
63
- i++;
64
- continue;
65
- }
66
- }
67
- output += "�";
68
- }
69
- else if (code >= 0xdc00 && code <= 0xdfff) {
70
- output += "�";
71
- }
72
- else {
73
- output += content[i];
74
- }
75
- }
76
- return output;
77
- }
78
- /**
79
- * Format bytes as human-readable size.
80
- */
81
- export function formatSize(bytes) {
82
- if (bytes < 1024) {
83
- return `${bytes}B`;
84
- }
85
- else if (bytes < 1024 * 1024) {
86
- return `${(bytes / 1024).toFixed(1)}KB`;
87
- }
88
- else {
89
- return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
90
- }
91
- }
92
- /**
93
- * Truncate content from the head (keep first N lines/bytes).
94
- * Suitable for file reads where you want to see the beginning.
95
- *
96
- * Never returns partial lines. If first line exceeds byte limit,
97
- * returns empty content with firstLineExceedsLimit=true.
98
- */
99
- export function truncateHead(content, options = {}) {
100
- const maxLines = options.maxLines ?? DEFAULT_MAX_LINES;
101
- const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
102
- const totalBytes = utf8ByteLength(content);
103
- const lines = splitLinesForCounting(content);
104
- const totalLines = lines.length;
105
- // Check if no truncation needed
106
- if (totalLines <= maxLines && totalBytes <= maxBytes) {
107
- return {
108
- content,
109
- truncated: false,
110
- truncatedBy: null,
111
- totalLines,
112
- totalBytes,
113
- outputLines: totalLines,
114
- outputBytes: totalBytes,
115
- lastLinePartial: false,
116
- firstLineExceedsLimit: false,
117
- maxLines,
118
- maxBytes,
119
- };
120
- }
121
- // Check if first line alone exceeds byte limit
122
- const firstLineBytes = utf8ByteLength(lines[0]);
123
- if (firstLineBytes > maxBytes) {
124
- return {
125
- content: "",
126
- truncated: true,
127
- truncatedBy: "bytes",
128
- totalLines,
129
- totalBytes,
130
- outputLines: 0,
131
- outputBytes: 0,
132
- lastLinePartial: false,
133
- firstLineExceedsLimit: true,
134
- maxLines,
135
- maxBytes,
136
- };
137
- }
138
- // Collect complete lines that fit
139
- const outputLinesArr = [];
140
- let outputBytesCount = 0;
141
- let truncatedBy = "lines";
142
- for (let i = 0; i < lines.length && i < maxLines; i++) {
143
- const line = lines[i];
144
- const lineBytes = utf8ByteLength(line) + (i > 0 ? 1 : 0); // +1 for newline
145
- if (outputBytesCount + lineBytes > maxBytes) {
146
- truncatedBy = "bytes";
147
- break;
148
- }
149
- outputLinesArr.push(line);
150
- outputBytesCount += lineBytes;
151
- }
152
- // If we exited due to line limit
153
- if (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {
154
- truncatedBy = "lines";
155
- }
156
- const outputContent = outputLinesArr.join("\n");
157
- const finalOutputBytes = utf8ByteLength(outputContent);
158
- return {
159
- content: outputContent,
160
- truncated: true,
161
- truncatedBy,
162
- totalLines,
163
- totalBytes,
164
- outputLines: outputLinesArr.length,
165
- outputBytes: finalOutputBytes,
166
- lastLinePartial: false,
167
- firstLineExceedsLimit: false,
168
- maxLines,
169
- maxBytes,
170
- };
171
- }
172
- /**
173
- * Truncate content from the tail (keep last N lines/bytes).
174
- * Suitable for bash output where you want to see the end (errors, final results).
175
- *
176
- * May return partial first line if the last line of original content exceeds byte limit.
177
- */
178
- export function truncateTail(content, options = {}) {
179
- const maxLines = options.maxLines ?? DEFAULT_MAX_LINES;
180
- const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
181
- const totalBytes = utf8ByteLength(content);
182
- const lines = splitLinesForCounting(content);
183
- const totalLines = lines.length;
184
- // Check if no truncation needed
185
- if (totalLines <= maxLines && totalBytes <= maxBytes) {
186
- return {
187
- content,
188
- truncated: false,
189
- truncatedBy: null,
190
- totalLines,
191
- totalBytes,
192
- outputLines: totalLines,
193
- outputBytes: totalBytes,
194
- lastLinePartial: false,
195
- firstLineExceedsLimit: false,
196
- maxLines,
197
- maxBytes,
198
- };
199
- }
200
- // Work backwards from the end
201
- const outputLinesArr = [];
202
- let outputBytesCount = 0;
203
- let truncatedBy = "lines";
204
- let lastLinePartial = false;
205
- for (let i = lines.length - 1; i >= 0 && outputLinesArr.length < maxLines; i--) {
206
- const line = lines[i];
207
- const lineBytes = utf8ByteLength(line) + (outputLinesArr.length > 0 ? 1 : 0); // +1 for newline
208
- if (outputBytesCount + lineBytes > maxBytes) {
209
- truncatedBy = "bytes";
210
- // Edge case: if we haven't added ANY lines yet and this line exceeds maxBytes,
211
- // take the end of the line (partial)
212
- if (outputLinesArr.length === 0) {
213
- const truncatedLine = truncateStringToBytesFromEnd(line, maxBytes);
214
- outputLinesArr.unshift(truncatedLine);
215
- outputBytesCount = utf8ByteLength(truncatedLine);
216
- lastLinePartial = true;
217
- }
218
- break;
219
- }
220
- outputLinesArr.unshift(line);
221
- outputBytesCount += lineBytes;
222
- }
223
- // If we exited due to line limit
224
- if (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {
225
- truncatedBy = "lines";
226
- }
227
- const outputContent = outputLinesArr.join("\n");
228
- const finalOutputBytes = utf8ByteLength(outputContent);
229
- return {
230
- content: outputContent,
231
- truncated: true,
232
- truncatedBy,
233
- totalLines,
234
- totalBytes,
235
- outputLines: outputLinesArr.length,
236
- outputBytes: finalOutputBytes,
237
- lastLinePartial,
238
- firstLineExceedsLimit: false,
239
- maxLines,
240
- maxBytes,
241
- };
242
- }
243
- /**
244
- * Truncate a string to fit within a byte limit (from the end).
245
- * Handles multi-byte UTF-8 characters correctly.
246
- */
247
- function truncateStringToBytesFromEnd(str, maxBytes) {
248
- if (maxBytes <= 0)
249
- return "";
250
- let outputBytes = 0;
251
- let start = str.length;
252
- let needsReplacement = false;
253
- for (let i = str.length; i > 0;) {
254
- let characterStart = i - 1;
255
- const code = str.charCodeAt(characterStart);
256
- let characterBytes;
257
- let unpairedSurrogate = false;
258
- if (code >= 0xdc00 && code <= 0xdfff && characterStart > 0) {
259
- const previous = str.charCodeAt(characterStart - 1);
260
- if (previous >= 0xd800 && previous <= 0xdbff) {
261
- characterStart--;
262
- characterBytes = 4;
263
- }
264
- else {
265
- characterBytes = 3;
266
- unpairedSurrogate = true;
267
- }
268
- }
269
- else if (code >= 0xd800 && code <= 0xdfff) {
270
- characterBytes = 3;
271
- unpairedSurrogate = true;
272
- }
273
- else {
274
- characterBytes = code <= 0x7f ? 1 : code <= 0x7ff ? 2 : 3;
275
- }
276
- if (outputBytes + characterBytes > maxBytes)
277
- break;
278
- outputBytes += characterBytes;
279
- start = characterStart;
280
- needsReplacement ||= unpairedSurrogate;
281
- i = characterStart;
282
- }
283
- const output = str.slice(start);
284
- return needsReplacement ? replaceUnpairedSurrogates(output) : output;
285
- }
286
- /**
287
- * Truncate a single line to max characters, adding [truncated] suffix.
288
- * Used for grep match lines.
289
- */
290
- export function truncateLine(line, maxChars = GREP_MAX_LINE_LENGTH) {
291
- if (line.length <= maxChars) {
292
- return { text: line, wasTruncated: false };
293
- }
294
- return { text: `${line.slice(0, maxChars)}... [truncated]`, wasTruncated: true };
295
- }
296
- //# sourceMappingURL=truncate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"truncate.js","sourceRoot":"","sources":["../../../src/harness/utils/truncate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO;AACnD,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC,CAAC,gCAAgC;AAsCzE,MAAM,aAAa,GAAI,UAAyC,CAAC,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,cAAc,CAAC;QAC9B,KAAK,GAAG,cAAc,CAAC;QACvB,gBAAgB,KAAK,iBAAiB,CAAC;QACvC,CAAC,GAAG,cAAc,CAAC;IACpB,CAAC;IAED,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChC,OAAO,gBAAgB,CAAC,CAAC,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACtE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC3B,IAAY,EACZ,QAAQ,GAAW,oBAAoB;IAEvC,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC7B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IAC5C,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,iBAAiB,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AAClF,CAAC","sourcesContent":["/**\n * Shared truncation utilities for tool outputs.\n *\n * Truncation is based on two independent limits - whichever is hit first wins:\n * - Line limit (default: 2000 lines)\n * - Byte limit (default: 50KB)\n *\n * Never returns partial lines (except bash tail truncation edge case).\n */\n\nexport const DEFAULT_MAX_LINES = 2000;\nexport const DEFAULT_MAX_BYTES = 50 * 1024; // 50KB\nexport const GREP_MAX_LINE_LENGTH = 500; // Max chars per grep match line\n\nexport interface TruncationResult {\n\t/** The truncated content */\n\tcontent: string;\n\t/** Whether truncation occurred */\n\ttruncated: boolean;\n\t/** Which limit was hit: \"lines\", \"bytes\", or null if not truncated */\n\ttruncatedBy: \"lines\" | \"bytes\" | null;\n\t/** Total number of lines in the original content */\n\ttotalLines: number;\n\t/** Total number of bytes in the original content */\n\ttotalBytes: number;\n\t/** Number of complete lines in the truncated output */\n\toutputLines: number;\n\t/** Number of bytes in the truncated output */\n\toutputBytes: number;\n\t/** Whether the last line was partially truncated (only for tail truncation edge case) */\n\tlastLinePartial: boolean;\n\t/** Whether the first line exceeded the byte limit (for head truncation) */\n\tfirstLineExceedsLimit: boolean;\n\t/** The max lines limit that was applied */\n\tmaxLines: number;\n\t/** The max bytes limit that was applied */\n\tmaxBytes: number;\n}\n\nexport interface TruncationOptions {\n\t/** Maximum number of lines (default: 2000) */\n\tmaxLines?: number;\n\t/** Maximum number of bytes (default: 50KB) */\n\tmaxBytes?: number;\n}\n\ninterface RuntimeBuffer {\n\tbyteLength(content: string, encoding: \"utf8\"): number;\n}\n\nconst runtimeBuffer = (globalThis as { Buffer?: RuntimeBuffer }).Buffer;\nconst nonAsciiPattern = /[^\\x00-\\x7f]/;\n\nexport function utf8ByteLength(content: string): number {\n\tif (runtimeBuffer) return runtimeBuffer.byteLength(content, \"utf8\");\n\n\tconst firstNonAscii = content.search(nonAsciiPattern);\n\tif (firstNonAscii === -1) return content.length;\n\n\tlet bytes = firstNonAscii;\n\tfor (let i = firstNonAscii; i < content.length; i++) {\n\t\tconst code = content.charCodeAt(i);\n\t\tif (code <= 0x7f) {\n\t\t\tbytes += 1;\n\t\t} else if (code <= 0x7ff) {\n\t\t\tbytes += 2;\n\t\t} else if (code >= 0xd800 && code <= 0xdbff && i + 1 < content.length) {\n\t\t\tconst next = content.charCodeAt(i + 1);\n\t\t\tif (next >= 0xdc00 && next <= 0xdfff) {\n\t\t\t\tbytes += 4;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tbytes += 3;\n\t\t\t}\n\t\t} else {\n\t\t\tbytes += 3;\n\t\t}\n\t}\n\treturn bytes;\n}\n\nfunction splitLinesForCounting(content: string): string[] {\n\tif (content.length === 0) return [];\n\tconst lines = content.split(\"\\n\");\n\tif (content.endsWith(\"\\n\")) lines.pop();\n\treturn lines;\n}\n\nfunction replaceUnpairedSurrogates(content: string): string {\n\tlet output = \"\";\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst code = content.charCodeAt(i);\n\t\tif (code >= 0xd800 && code <= 0xdbff) {\n\t\t\tif (i + 1 < content.length) {\n\t\t\t\tconst next = content.charCodeAt(i + 1);\n\t\t\t\tif (next >= 0xdc00 && next <= 0xdfff) {\n\t\t\t\t\toutput += content[i] + content[i + 1];\n\t\t\t\t\ti++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\toutput += \"�\";\n\t\t} else if (code >= 0xdc00 && code <= 0xdfff) {\n\t\t\toutput += \"�\";\n\t\t} else {\n\t\t\toutput += content[i];\n\t\t}\n\t}\n\treturn output;\n}\n\n/**\n * Format bytes as human-readable size.\n */\nexport function formatSize(bytes: number): string {\n\tif (bytes < 1024) {\n\t\treturn `${bytes}B`;\n\t} else if (bytes < 1024 * 1024) {\n\t\treturn `${(bytes / 1024).toFixed(1)}KB`;\n\t} else {\n\t\treturn `${(bytes / (1024 * 1024)).toFixed(1)}MB`;\n\t}\n}\n\n/**\n * Truncate content from the head (keep first N lines/bytes).\n * Suitable for file reads where you want to see the beginning.\n *\n * Never returns partial lines. If first line exceeds byte limit,\n * returns empty content with firstLineExceedsLimit=true.\n */\nexport function truncateHead(content: string, options: TruncationOptions = {}): TruncationResult {\n\tconst maxLines = options.maxLines ?? DEFAULT_MAX_LINES;\n\tconst maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n\n\tconst totalBytes = utf8ByteLength(content);\n\tconst lines = splitLinesForCounting(content);\n\tconst totalLines = lines.length;\n\n\t// Check if no truncation needed\n\tif (totalLines <= maxLines && totalBytes <= maxBytes) {\n\t\treturn {\n\t\t\tcontent,\n\t\t\ttruncated: false,\n\t\t\ttruncatedBy: null,\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: totalLines,\n\t\t\toutputBytes: totalBytes,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: false,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Check if first line alone exceeds byte limit\n\tconst firstLineBytes = utf8ByteLength(lines[0]);\n\tif (firstLineBytes > maxBytes) {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\ttruncated: true,\n\t\t\ttruncatedBy: \"bytes\",\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: 0,\n\t\t\toutputBytes: 0,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: true,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Collect complete lines that fit\n\tconst outputLinesArr: string[] = [];\n\tlet outputBytesCount = 0;\n\tlet truncatedBy: \"lines\" | \"bytes\" = \"lines\";\n\n\tfor (let i = 0; i < lines.length && i < maxLines; i++) {\n\t\tconst line = lines[i];\n\t\tconst lineBytes = utf8ByteLength(line) + (i > 0 ? 1 : 0); // +1 for newline\n\n\t\tif (outputBytesCount + lineBytes > maxBytes) {\n\t\t\ttruncatedBy = \"bytes\";\n\t\t\tbreak;\n\t\t}\n\n\t\toutputLinesArr.push(line);\n\t\toutputBytesCount += lineBytes;\n\t}\n\n\t// If we exited due to line limit\n\tif (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {\n\t\ttruncatedBy = \"lines\";\n\t}\n\n\tconst outputContent = outputLinesArr.join(\"\\n\");\n\tconst finalOutputBytes = utf8ByteLength(outputContent);\n\n\treturn {\n\t\tcontent: outputContent,\n\t\ttruncated: true,\n\t\ttruncatedBy,\n\t\ttotalLines,\n\t\ttotalBytes,\n\t\toutputLines: outputLinesArr.length,\n\t\toutputBytes: finalOutputBytes,\n\t\tlastLinePartial: false,\n\t\tfirstLineExceedsLimit: false,\n\t\tmaxLines,\n\t\tmaxBytes,\n\t};\n}\n\n/**\n * Truncate content from the tail (keep last N lines/bytes).\n * Suitable for bash output where you want to see the end (errors, final results).\n *\n * May return partial first line if the last line of original content exceeds byte limit.\n */\nexport function truncateTail(content: string, options: TruncationOptions = {}): TruncationResult {\n\tconst maxLines = options.maxLines ?? DEFAULT_MAX_LINES;\n\tconst maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n\n\tconst totalBytes = utf8ByteLength(content);\n\tconst lines = splitLinesForCounting(content);\n\tconst totalLines = lines.length;\n\n\t// Check if no truncation needed\n\tif (totalLines <= maxLines && totalBytes <= maxBytes) {\n\t\treturn {\n\t\t\tcontent,\n\t\t\ttruncated: false,\n\t\t\ttruncatedBy: null,\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: totalLines,\n\t\t\toutputBytes: totalBytes,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: false,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Work backwards from the end\n\tconst outputLinesArr: string[] = [];\n\tlet outputBytesCount = 0;\n\tlet truncatedBy: \"lines\" | \"bytes\" = \"lines\";\n\tlet lastLinePartial = false;\n\n\tfor (let i = lines.length - 1; i >= 0 && outputLinesArr.length < maxLines; i--) {\n\t\tconst line = lines[i];\n\t\tconst lineBytes = utf8ByteLength(line) + (outputLinesArr.length > 0 ? 1 : 0); // +1 for newline\n\n\t\tif (outputBytesCount + lineBytes > maxBytes) {\n\t\t\ttruncatedBy = \"bytes\";\n\t\t\t// Edge case: if we haven't added ANY lines yet and this line exceeds maxBytes,\n\t\t\t// take the end of the line (partial)\n\t\t\tif (outputLinesArr.length === 0) {\n\t\t\t\tconst truncatedLine = truncateStringToBytesFromEnd(line, maxBytes);\n\t\t\t\toutputLinesArr.unshift(truncatedLine);\n\t\t\t\toutputBytesCount = utf8ByteLength(truncatedLine);\n\t\t\t\tlastLinePartial = true;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\toutputLinesArr.unshift(line);\n\t\toutputBytesCount += lineBytes;\n\t}\n\n\t// If we exited due to line limit\n\tif (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {\n\t\ttruncatedBy = \"lines\";\n\t}\n\n\tconst outputContent = outputLinesArr.join(\"\\n\");\n\tconst finalOutputBytes = utf8ByteLength(outputContent);\n\n\treturn {\n\t\tcontent: outputContent,\n\t\ttruncated: true,\n\t\ttruncatedBy,\n\t\ttotalLines,\n\t\ttotalBytes,\n\t\toutputLines: outputLinesArr.length,\n\t\toutputBytes: finalOutputBytes,\n\t\tlastLinePartial,\n\t\tfirstLineExceedsLimit: false,\n\t\tmaxLines,\n\t\tmaxBytes,\n\t};\n}\n\n/**\n * Truncate a string to fit within a byte limit (from the end).\n * Handles multi-byte UTF-8 characters correctly.\n */\nfunction truncateStringToBytesFromEnd(str: string, maxBytes: number): string {\n\tif (maxBytes <= 0) return \"\";\n\n\tlet outputBytes = 0;\n\tlet start = str.length;\n\tlet needsReplacement = false;\n\tfor (let i = str.length; i > 0; ) {\n\t\tlet characterStart = i - 1;\n\t\tconst code = str.charCodeAt(characterStart);\n\t\tlet characterBytes: number;\n\t\tlet unpairedSurrogate = false;\n\t\tif (code >= 0xdc00 && code <= 0xdfff && characterStart > 0) {\n\t\t\tconst previous = str.charCodeAt(characterStart - 1);\n\t\t\tif (previous >= 0xd800 && previous <= 0xdbff) {\n\t\t\t\tcharacterStart--;\n\t\t\t\tcharacterBytes = 4;\n\t\t\t} else {\n\t\t\t\tcharacterBytes = 3;\n\t\t\t\tunpairedSurrogate = true;\n\t\t\t}\n\t\t} else if (code >= 0xd800 && code <= 0xdfff) {\n\t\t\tcharacterBytes = 3;\n\t\t\tunpairedSurrogate = true;\n\t\t} else {\n\t\t\tcharacterBytes = code <= 0x7f ? 1 : code <= 0x7ff ? 2 : 3;\n\t\t}\n\t\tif (outputBytes + characterBytes > maxBytes) break;\n\t\toutputBytes += characterBytes;\n\t\tstart = characterStart;\n\t\tneedsReplacement ||= unpairedSurrogate;\n\t\ti = characterStart;\n\t}\n\n\tconst output = str.slice(start);\n\treturn needsReplacement ? replaceUnpairedSurrogates(output) : output;\n}\n\n/**\n * Truncate a single line to max characters, adding [truncated] suffix.\n * Used for grep match lines.\n */\nexport function truncateLine(\n\tline: string,\n\tmaxChars: number = GREP_MAX_LINE_LENGTH,\n): { text: string; wasTruncated: boolean } {\n\tif (line.length <= maxChars) {\n\t\treturn { text: line, wasTruncated: false };\n\t}\n\treturn { text: `${line.slice(0, maxChars)}... [truncated]`, wasTruncated: true };\n}\n"]}
@@ -1,4 +0,0 @@
1
- import type { Usage } from "@draht/ai";
2
- export declare function emptyUsage(): Usage;
3
- export declare function addUsage(left: Usage, right: Usage): Usage;
4
- //# sourceMappingURL=usage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/harness/utils/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,wBAAgB,UAAU,IAAI,KAAK,CASlC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAqBzD"}
@@ -1,33 +0,0 @@
1
- export function emptyUsage() {
2
- return {
3
- input: 0,
4
- output: 0,
5
- cacheRead: 0,
6
- cacheWrite: 0,
7
- totalTokens: 0,
8
- cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
9
- };
10
- }
11
- export function addUsage(left, right) {
12
- return {
13
- input: left.input + right.input,
14
- output: left.output + right.output,
15
- cacheRead: left.cacheRead + right.cacheRead,
16
- cacheWrite: left.cacheWrite + right.cacheWrite,
17
- ...(left.cacheWrite1h === undefined && right.cacheWrite1h === undefined
18
- ? {}
19
- : { cacheWrite1h: (left.cacheWrite1h ?? 0) + (right.cacheWrite1h ?? 0) }),
20
- ...(left.reasoning === undefined && right.reasoning === undefined
21
- ? {}
22
- : { reasoning: (left.reasoning ?? 0) + (right.reasoning ?? 0) }),
23
- totalTokens: left.totalTokens + right.totalTokens,
24
- cost: {
25
- input: left.cost.input + right.cost.input,
26
- output: left.cost.output + right.cost.output,
27
- cacheRead: left.cost.cacheRead + right.cost.cacheRead,
28
- cacheWrite: left.cost.cacheWrite + right.cost.cacheWrite,
29
- total: left.cost.total + right.cost.total,
30
- },
31
- };
32
- }
33
- //# sourceMappingURL=usage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/harness/utils/usage.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU;IACzB,OAAO;QACN,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;QACZ,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,CAAC;QACd,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;KACpE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAW,EAAE,KAAY;IACjD,OAAO;QACN,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK;QAC/B,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM;QAClC,SAAS,EAAE,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS;QAC3C,UAAU,EAAE,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU;QAC9C,GAAG,CAAC,IAAI,CAAC,YAAY,KAAK,SAAS,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS;YACtE,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC,EAAE,CAAC;QAC1E,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS;YAChE,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC;QACjE,WAAW,EAAE,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW;QACjD,IAAI,EAAE;YACL,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK;YACzC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM;YAC5C,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS;YACrD,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU;YACxD,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK;SACzC;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { Usage } from \"@draht/ai\";\n\nexport function emptyUsage(): Usage {\n\treturn {\n\t\tinput: 0,\n\t\toutput: 0,\n\t\tcacheRead: 0,\n\t\tcacheWrite: 0,\n\t\ttotalTokens: 0,\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t};\n}\n\nexport function addUsage(left: Usage, right: Usage): Usage {\n\treturn {\n\t\tinput: left.input + right.input,\n\t\toutput: left.output + right.output,\n\t\tcacheRead: left.cacheRead + right.cacheRead,\n\t\tcacheWrite: left.cacheWrite + right.cacheWrite,\n\t\t...(left.cacheWrite1h === undefined && right.cacheWrite1h === undefined\n\t\t\t? {}\n\t\t\t: { cacheWrite1h: (left.cacheWrite1h ?? 0) + (right.cacheWrite1h ?? 0) }),\n\t\t...(left.reasoning === undefined && right.reasoning === undefined\n\t\t\t? {}\n\t\t\t: { reasoning: (left.reasoning ?? 0) + (right.reasoning ?? 0) }),\n\t\ttotalTokens: left.totalTokens + right.totalTokens,\n\t\tcost: {\n\t\t\tinput: left.cost.input + right.cost.input,\n\t\t\toutput: left.cost.output + right.cost.output,\n\t\t\tcacheRead: left.cost.cacheRead + right.cost.cacheRead,\n\t\t\tcacheWrite: left.cost.cacheWrite + right.cost.cacheWrite,\n\t\t\ttotal: left.cost.total + right.cost.total,\n\t\t},\n\t};\n}\n"]}
package/dist/node.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { NodeExecutionEnv } from "./harness/env/nodejs.ts";
2
- export * from "./index.ts";
3
- //# sourceMappingURL=node.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,cAAc,YAAY,CAAC"}
package/dist/node.js DELETED
@@ -1,3 +0,0 @@
1
- export { NodeExecutionEnv } from "./harness/env/nodejs.js";
2
- export * from "./index.js";
3
- //# sourceMappingURL=node.js.map
package/dist/node.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,cAAc,YAAY,CAAC","sourcesContent":["export { NodeExecutionEnv } from \"./harness/env/nodejs.ts\";\nexport * from \"./index.ts\";\n"]}
@@ -1,29 +0,0 @@
1
- export interface SearchQuery {
2
- text: string;
3
- limit?: number;
4
- }
5
- export interface SessionSearchHit {
6
- sessionId: string;
7
- score?: number;
8
- top?: {
9
- entryId: string;
10
- snippet?: string;
11
- timestamp: number;
12
- };
13
- }
14
- export interface EntrySearchHit {
15
- sessionId: string;
16
- entryId: string;
17
- timestamp: number;
18
- snippet?: string;
19
- score?: number;
20
- }
21
- export interface SessionSearchService {
22
- searchSessions(query: SearchQuery): Promise<SessionSearchHit[]>;
23
- searchEntries?(query: SearchQuery): Promise<EntrySearchHit[]>;
24
- sync(): Promise<void>;
25
- notify(sessionId: string): void;
26
- remove(sessionId: string): Promise<void>;
27
- close(): Promise<void>;
28
- }
29
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/search/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/D;AAED,MAAM,WAAW,cAAc;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACpC,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAChE,aAAa,CAAC,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC9D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/search/index.ts"],"names":[],"mappings":"","sourcesContent":["export interface SearchQuery {\n\ttext: string;\n\tlimit?: number;\n}\n\nexport interface SessionSearchHit {\n\tsessionId: string;\n\tscore?: number;\n\ttop?: { entryId: string; snippet?: string; timestamp: number };\n}\n\nexport interface EntrySearchHit {\n\tsessionId: string;\n\tentryId: string;\n\ttimestamp: number;\n\tsnippet?: string;\n\tscore?: number;\n}\n\nexport interface SessionSearchService {\n\tsearchSessions(query: SearchQuery): Promise<SessionSearchHit[]>;\n\tsearchEntries?(query: SearchQuery): Promise<EntrySearchHit[]>;\n\tsync(): Promise<void>;\n\tnotify(sessionId: string): void;\n\tremove(sessionId: string): Promise<void>;\n\tclose(): Promise<void>;\n}\n"]}