@nhtio/adk 1.20260607.2 → 1.20260609.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (521) hide show
  1. package/CHANGELOG.md +230 -0
  2. package/batteries/embeddings/openai/adapter.cjs +1 -1
  3. package/batteries/embeddings/openai/adapter.mjs +1 -1
  4. package/batteries/embeddings/openai/exceptions.cjs +1 -1
  5. package/batteries/embeddings/openai/exceptions.mjs +1 -1
  6. package/batteries/embeddings/openai/types.d.ts +7 -0
  7. package/batteries/embeddings/webllm/adapter.cjs +1 -1
  8. package/batteries/embeddings/webllm/adapter.mjs +1 -1
  9. package/batteries/embeddings/webllm/exceptions.cjs +1 -1
  10. package/batteries/embeddings/webllm/exceptions.mjs +1 -1
  11. package/batteries/llm/chat_common/helpers.d.ts +165 -0
  12. package/batteries/llm/chat_common/types.d.ts +309 -0
  13. package/batteries/llm/index.d.ts +5 -0
  14. package/batteries/llm/ollama/adapter.cjs +736 -0
  15. package/batteries/llm/ollama/adapter.cjs.map +1 -0
  16. package/batteries/llm/ollama/adapter.d.ts +64 -0
  17. package/batteries/llm/ollama/adapter.mjs +734 -0
  18. package/batteries/llm/ollama/adapter.mjs.map +1 -0
  19. package/batteries/llm/ollama/exceptions.cjs +105 -0
  20. package/batteries/llm/ollama/exceptions.cjs.map +1 -0
  21. package/batteries/llm/ollama/exceptions.d.ts +112 -0
  22. package/batteries/llm/ollama/exceptions.mjs +96 -0
  23. package/batteries/llm/ollama/exceptions.mjs.map +1 -0
  24. package/batteries/llm/ollama/helpers.cjs +487 -0
  25. package/batteries/llm/ollama/helpers.cjs.map +1 -0
  26. package/batteries/llm/ollama/helpers.d.ts +158 -0
  27. package/batteries/llm/ollama/helpers.mjs +450 -0
  28. package/batteries/llm/ollama/helpers.mjs.map +1 -0
  29. package/batteries/llm/ollama/index.d.ts +29 -0
  30. package/batteries/llm/ollama/types.cjs +2 -0
  31. package/batteries/llm/ollama/types.d.ts +334 -0
  32. package/batteries/llm/ollama/types.mjs +0 -0
  33. package/batteries/llm/ollama/validation.cjs +130 -0
  34. package/batteries/llm/ollama/validation.cjs.map +1 -0
  35. package/batteries/llm/ollama/validation.d.ts +31 -0
  36. package/batteries/llm/ollama/validation.mjs +127 -0
  37. package/batteries/llm/ollama/validation.mjs.map +1 -0
  38. package/batteries/llm/ollama.cjs +54 -0
  39. package/batteries/llm/ollama.mjs +6 -0
  40. package/batteries/llm/openai_chat_completions/adapter.cjs +36 -19
  41. package/batteries/llm/openai_chat_completions/adapter.cjs.map +1 -1
  42. package/batteries/llm/openai_chat_completions/adapter.mjs +23 -6
  43. package/batteries/llm/openai_chat_completions/adapter.mjs.map +1 -1
  44. package/batteries/llm/openai_chat_completions/exceptions.cjs +1 -1
  45. package/batteries/llm/openai_chat_completions/exceptions.mjs +1 -1
  46. package/batteries/llm/openai_chat_completions/helpers.cjs +80 -320
  47. package/batteries/llm/openai_chat_completions/helpers.cjs.map +1 -1
  48. package/batteries/llm/openai_chat_completions/helpers.d.ts +68 -144
  49. package/batteries/llm/openai_chat_completions/helpers.mjs +40 -280
  50. package/batteries/llm/openai_chat_completions/helpers.mjs.map +1 -1
  51. package/batteries/llm/openai_chat_completions/types.d.ts +273 -181
  52. package/batteries/llm/openai_chat_completions/validation.cjs +2 -2
  53. package/batteries/llm/openai_chat_completions/validation.cjs.map +1 -1
  54. package/batteries/llm/openai_chat_completions/validation.mjs +2 -2
  55. package/batteries/llm/openai_chat_completions/validation.mjs.map +1 -1
  56. package/batteries/llm/openai_chat_completions.cjs +29 -28
  57. package/batteries/llm/openai_chat_completions.mjs +2 -1
  58. package/batteries/llm/webllm_chat_completions/adapter.cjs +38 -19
  59. package/batteries/llm/webllm_chat_completions/adapter.cjs.map +1 -1
  60. package/batteries/llm/webllm_chat_completions/adapter.d.ts +18 -0
  61. package/batteries/llm/webllm_chat_completions/adapter.mjs +25 -6
  62. package/batteries/llm/webllm_chat_completions/adapter.mjs.map +1 -1
  63. package/batteries/llm/webllm_chat_completions/exceptions.cjs +1 -1
  64. package/batteries/llm/webllm_chat_completions/exceptions.mjs +1 -1
  65. package/batteries/llm/webllm_chat_completions/helpers.cjs +29 -28
  66. package/batteries/llm/webllm_chat_completions/helpers.mjs +2 -1
  67. package/batteries/llm/webllm_chat_completions/types.d.ts +21 -0
  68. package/batteries/llm/webllm_chat_completions/validation.cjs +13 -1
  69. package/batteries/llm/webllm_chat_completions/validation.cjs.map +1 -1
  70. package/batteries/llm/webllm_chat_completions/validation.d.ts +12 -0
  71. package/batteries/llm/webllm_chat_completions/validation.mjs +13 -1
  72. package/batteries/llm/webllm_chat_completions/validation.mjs.map +1 -1
  73. package/batteries/llm/webllm_chat_completions.cjs +29 -28
  74. package/batteries/llm/webllm_chat_completions.mjs +2 -1
  75. package/batteries/llm.cjs +44 -28
  76. package/batteries/llm.mjs +9 -4
  77. package/batteries/storage/flydrive.cjs +1 -1
  78. package/batteries/storage/flydrive.mjs +1 -1
  79. package/batteries/storage/in_memory/index.d.ts +1 -1
  80. package/batteries/storage/in_memory.cjs +2 -2
  81. package/batteries/storage/in_memory.cjs.map +1 -1
  82. package/batteries/storage/in_memory.mjs +2 -2
  83. package/batteries/storage/in_memory.mjs.map +1 -1
  84. package/batteries/storage/opfs/index.d.ts +19 -0
  85. package/batteries/storage/opfs.cjs +1 -1
  86. package/batteries/storage/opfs.cjs.map +1 -1
  87. package/batteries/storage/opfs.mjs +1 -1
  88. package/batteries/storage/opfs.mjs.map +1 -1
  89. package/batteries/tools/_shared/index.d.ts +121 -0
  90. package/batteries/tools/_shared.cjs +157 -0
  91. package/batteries/tools/_shared.cjs.map +1 -0
  92. package/batteries/tools/_shared.mjs +149 -0
  93. package/batteries/tools/_shared.mjs.map +1 -0
  94. package/batteries/tools/color.cjs +3 -2
  95. package/batteries/tools/color.cjs.map +1 -1
  96. package/batteries/tools/color.mjs +3 -2
  97. package/batteries/tools/color.mjs.map +1 -1
  98. package/batteries/tools/comparison.cjs +4 -3
  99. package/batteries/tools/comparison.cjs.map +1 -1
  100. package/batteries/tools/comparison.mjs +4 -3
  101. package/batteries/tools/comparison.mjs.map +1 -1
  102. package/batteries/tools/data_structure.cjs +30 -10
  103. package/batteries/tools/data_structure.cjs.map +1 -1
  104. package/batteries/tools/data_structure.mjs +30 -10
  105. package/batteries/tools/data_structure.mjs.map +1 -1
  106. package/batteries/tools/datetime_extended.cjs +5 -10
  107. package/batteries/tools/datetime_extended.cjs.map +1 -1
  108. package/batteries/tools/datetime_extended.mjs +5 -10
  109. package/batteries/tools/datetime_extended.mjs.map +1 -1
  110. package/batteries/tools/datetime_math.cjs +2 -2
  111. package/batteries/tools/datetime_math.mjs +2 -2
  112. package/batteries/tools/encoding.cjs +13 -4
  113. package/batteries/tools/encoding.cjs.map +1 -1
  114. package/batteries/tools/encoding.mjs +13 -4
  115. package/batteries/tools/encoding.mjs.map +1 -1
  116. package/batteries/tools/formatting.cjs +4 -4
  117. package/batteries/tools/formatting.cjs.map +1 -1
  118. package/batteries/tools/formatting.mjs +4 -4
  119. package/batteries/tools/formatting.mjs.map +1 -1
  120. package/batteries/tools/geo_basics.cjs +2 -2
  121. package/batteries/tools/geo_basics.mjs +2 -2
  122. package/batteries/tools/index.d.ts +3 -0
  123. package/batteries/tools/math.cjs +10 -8
  124. package/batteries/tools/math.cjs.map +1 -1
  125. package/batteries/tools/math.mjs +10 -8
  126. package/batteries/tools/math.mjs.map +1 -1
  127. package/batteries/tools/memory.cjs +5 -5
  128. package/batteries/tools/memory.mjs +5 -5
  129. package/batteries/tools/parsing.cjs +9 -5
  130. package/batteries/tools/parsing.cjs.map +1 -1
  131. package/batteries/tools/parsing.mjs +9 -5
  132. package/batteries/tools/parsing.mjs.map +1 -1
  133. package/batteries/tools/retrievables.cjs +4 -4
  134. package/batteries/tools/retrievables.mjs +4 -4
  135. package/batteries/tools/scrapper/exceptions.d.ts +21 -0
  136. package/batteries/tools/scrapper/index.d.ts +172 -0
  137. package/batteries/tools/scrapper/shared.d.ts +139 -0
  138. package/batteries/tools/scrapper.cjs +8 -0
  139. package/batteries/tools/scrapper.mjs +2 -0
  140. package/batteries/tools/searxng/exceptions.d.ts +21 -0
  141. package/batteries/tools/searxng/index.d.ts +177 -0
  142. package/batteries/tools/searxng.cjs +6 -0
  143. package/batteries/tools/searxng.mjs +2 -0
  144. package/batteries/tools/standing_instructions.cjs +4 -4
  145. package/batteries/tools/standing_instructions.mjs +4 -4
  146. package/batteries/tools/statistics.cjs +54 -43
  147. package/batteries/tools/statistics.cjs.map +1 -1
  148. package/batteries/tools/statistics.mjs +54 -43
  149. package/batteries/tools/statistics.mjs.map +1 -1
  150. package/batteries/tools/string_processing.cjs +5 -5
  151. package/batteries/tools/string_processing.cjs.map +1 -1
  152. package/batteries/tools/string_processing.mjs +5 -5
  153. package/batteries/tools/string_processing.mjs.map +1 -1
  154. package/batteries/tools/structured_data.cjs +8 -13
  155. package/batteries/tools/structured_data.cjs.map +1 -1
  156. package/batteries/tools/structured_data.mjs +8 -13
  157. package/batteries/tools/structured_data.mjs.map +1 -1
  158. package/batteries/tools/text_analysis.cjs +3 -3
  159. package/batteries/tools/text_analysis.mjs +3 -3
  160. package/batteries/tools/text_comparison.cjs +2 -2
  161. package/batteries/tools/text_comparison.mjs +2 -2
  162. package/batteries/tools/time.cjs +2 -2
  163. package/batteries/tools/time.mjs +2 -2
  164. package/batteries/tools/unit_conversion.cjs +10 -8
  165. package/batteries/tools/unit_conversion.cjs.map +1 -1
  166. package/batteries/tools/unit_conversion.mjs +10 -8
  167. package/batteries/tools/unit_conversion.mjs.map +1 -1
  168. package/batteries/tools/web_retrieval/index.d.ts +186 -0
  169. package/batteries/tools/web_retrieval.cjs +206 -0
  170. package/batteries/tools/web_retrieval.cjs.map +1 -0
  171. package/batteries/tools/web_retrieval.mjs +201 -0
  172. package/batteries/tools/web_retrieval.mjs.map +1 -0
  173. package/batteries/tools.cjs +15 -0
  174. package/batteries/tools.mjs +4 -1
  175. package/batteries/vector/arangodb/index.d.ts +2 -0
  176. package/batteries/vector/arangodb.cjs +2 -1
  177. package/batteries/vector/arangodb.cjs.map +1 -1
  178. package/batteries/vector/arangodb.mjs +2 -1
  179. package/batteries/vector/arangodb.mjs.map +1 -1
  180. package/batteries/vector/builder.cjs +31 -0
  181. package/batteries/vector/builder.cjs.map +1 -1
  182. package/batteries/vector/builder.d.ts +58 -0
  183. package/batteries/vector/builder.mjs +31 -0
  184. package/batteries/vector/builder.mjs.map +1 -1
  185. package/batteries/vector/chroma/index.d.ts +4 -0
  186. package/batteries/vector/chroma.cjs +3 -0
  187. package/batteries/vector/chroma.cjs.map +1 -1
  188. package/batteries/vector/chroma.mjs +3 -0
  189. package/batteries/vector/chroma.mjs.map +1 -1
  190. package/batteries/vector/clickhouse/index.d.ts +2 -0
  191. package/batteries/vector/clickhouse.cjs +2 -1
  192. package/batteries/vector/clickhouse.cjs.map +1 -1
  193. package/batteries/vector/clickhouse.mjs +2 -1
  194. package/batteries/vector/clickhouse.mjs.map +1 -1
  195. package/batteries/vector/cloudflare/index.d.ts +2 -0
  196. package/batteries/vector/cloudflare.cjs +2 -1
  197. package/batteries/vector/cloudflare.cjs.map +1 -1
  198. package/batteries/vector/cloudflare.mjs +2 -1
  199. package/batteries/vector/cloudflare.mjs.map +1 -1
  200. package/batteries/vector/conformance/index.d.ts +22 -0
  201. package/batteries/vector/conformance.cjs +22 -0
  202. package/batteries/vector/conformance.cjs.map +1 -1
  203. package/batteries/vector/conformance.mjs +22 -0
  204. package/batteries/vector/conformance.mjs.map +1 -1
  205. package/batteries/vector/contract.cjs +22 -0
  206. package/batteries/vector/contract.cjs.map +1 -1
  207. package/batteries/vector/contract.d.ts +51 -0
  208. package/batteries/vector/contract.mjs +22 -0
  209. package/batteries/vector/contract.mjs.map +1 -1
  210. package/batteries/vector/couchbase/index.d.ts +2 -0
  211. package/batteries/vector/couchbase.cjs +2 -1
  212. package/batteries/vector/couchbase.cjs.map +1 -1
  213. package/batteries/vector/couchbase.mjs +2 -1
  214. package/batteries/vector/couchbase.mjs.map +1 -1
  215. package/batteries/vector/duckdb/index.d.ts +2 -0
  216. package/batteries/vector/duckdb.cjs +2 -1
  217. package/batteries/vector/duckdb.cjs.map +1 -1
  218. package/batteries/vector/duckdb.mjs +2 -1
  219. package/batteries/vector/duckdb.mjs.map +1 -1
  220. package/batteries/vector/elasticsearch/index.d.ts +2 -0
  221. package/batteries/vector/elasticsearch.cjs +2 -1
  222. package/batteries/vector/elasticsearch.cjs.map +1 -1
  223. package/batteries/vector/elasticsearch.mjs +2 -1
  224. package/batteries/vector/elasticsearch.mjs.map +1 -1
  225. package/batteries/vector/exceptions.cjs +1 -1
  226. package/batteries/vector/exceptions.mjs +1 -1
  227. package/batteries/vector/factory.cjs +6 -0
  228. package/batteries/vector/factory.cjs.map +1 -1
  229. package/batteries/vector/factory.d.ts +14 -0
  230. package/batteries/vector/factory.mjs +6 -0
  231. package/batteries/vector/factory.mjs.map +1 -1
  232. package/batteries/vector/filters.cjs +22 -1
  233. package/batteries/vector/filters.cjs.map +1 -1
  234. package/batteries/vector/filters.d.ts +38 -0
  235. package/batteries/vector/filters.mjs +22 -1
  236. package/batteries/vector/filters.mjs.map +1 -1
  237. package/batteries/vector/helpers.cjs +13 -0
  238. package/batteries/vector/helpers.cjs.map +1 -1
  239. package/batteries/vector/helpers.d.ts +14 -0
  240. package/batteries/vector/helpers.mjs +13 -0
  241. package/batteries/vector/helpers.mjs.map +1 -1
  242. package/batteries/vector/hnswlib/index.d.ts +2 -0
  243. package/batteries/vector/hnswlib.cjs +2 -1
  244. package/batteries/vector/hnswlib.cjs.map +1 -1
  245. package/batteries/vector/hnswlib.mjs +2 -1
  246. package/batteries/vector/hnswlib.mjs.map +1 -1
  247. package/batteries/vector/in_memory/index.d.ts +1 -0
  248. package/batteries/vector/in_memory.cjs +1 -0
  249. package/batteries/vector/in_memory.cjs.map +1 -1
  250. package/batteries/vector/in_memory.mjs +1 -0
  251. package/batteries/vector/in_memory.mjs.map +1 -1
  252. package/batteries/vector/lancedb/index.d.ts +2 -0
  253. package/batteries/vector/lancedb.cjs +2 -1
  254. package/batteries/vector/lancedb.cjs.map +1 -1
  255. package/batteries/vector/lancedb.mjs +2 -1
  256. package/batteries/vector/lancedb.mjs.map +1 -1
  257. package/batteries/vector/mariadb/index.d.ts +2 -0
  258. package/batteries/vector/mariadb.cjs +2 -1
  259. package/batteries/vector/mariadb.cjs.map +1 -1
  260. package/batteries/vector/mariadb.mjs +2 -1
  261. package/batteries/vector/mariadb.mjs.map +1 -1
  262. package/batteries/vector/meilisearch/index.d.ts +2 -0
  263. package/batteries/vector/meilisearch.cjs +2 -1
  264. package/batteries/vector/meilisearch.cjs.map +1 -1
  265. package/batteries/vector/meilisearch.mjs +2 -1
  266. package/batteries/vector/meilisearch.mjs.map +1 -1
  267. package/batteries/vector/migrate.cjs +18 -1
  268. package/batteries/vector/migrate.cjs.map +1 -1
  269. package/batteries/vector/migrate.d.ts +31 -0
  270. package/batteries/vector/migrate.mjs +18 -1
  271. package/batteries/vector/migrate.mjs.map +1 -1
  272. package/batteries/vector/milvus/index.d.ts +5 -0
  273. package/batteries/vector/milvus.cjs +4 -0
  274. package/batteries/vector/milvus.cjs.map +1 -1
  275. package/batteries/vector/milvus.mjs +4 -0
  276. package/batteries/vector/milvus.mjs.map +1 -1
  277. package/batteries/vector/mongodb/index.d.ts +2 -0
  278. package/batteries/vector/mongodb.cjs +2 -1
  279. package/batteries/vector/mongodb.cjs.map +1 -1
  280. package/batteries/vector/mongodb.mjs +2 -1
  281. package/batteries/vector/mongodb.mjs.map +1 -1
  282. package/batteries/vector/neo4j/index.d.ts +2 -0
  283. package/batteries/vector/neo4j.cjs +2 -1
  284. package/batteries/vector/neo4j.cjs.map +1 -1
  285. package/batteries/vector/neo4j.mjs +2 -1
  286. package/batteries/vector/neo4j.mjs.map +1 -1
  287. package/batteries/vector/opensearch/index.d.ts +2 -0
  288. package/batteries/vector/opensearch.cjs +2 -1
  289. package/batteries/vector/opensearch.cjs.map +1 -1
  290. package/batteries/vector/opensearch.mjs +2 -1
  291. package/batteries/vector/opensearch.mjs.map +1 -1
  292. package/batteries/vector/oracle23ai/index.d.ts +2 -0
  293. package/batteries/vector/oracle23ai.cjs +2 -1
  294. package/batteries/vector/oracle23ai.cjs.map +1 -1
  295. package/batteries/vector/oracle23ai.mjs +2 -1
  296. package/batteries/vector/oracle23ai.mjs.map +1 -1
  297. package/batteries/vector/orama/index.d.ts +1 -0
  298. package/batteries/vector/orama.cjs +1 -0
  299. package/batteries/vector/orama.cjs.map +1 -1
  300. package/batteries/vector/orama.mjs +1 -0
  301. package/batteries/vector/orama.mjs.map +1 -1
  302. package/batteries/vector/pgvector/index.d.ts +9 -2
  303. package/batteries/vector/pgvector.cjs +4 -0
  304. package/batteries/vector/pgvector.cjs.map +1 -1
  305. package/batteries/vector/pgvector.mjs +4 -0
  306. package/batteries/vector/pgvector.mjs.map +1 -1
  307. package/batteries/vector/pinecone/index.d.ts +5 -0
  308. package/batteries/vector/pinecone.cjs +3 -1
  309. package/batteries/vector/pinecone.cjs.map +1 -1
  310. package/batteries/vector/pinecone.mjs +3 -1
  311. package/batteries/vector/pinecone.mjs.map +1 -1
  312. package/batteries/vector/plan.d.ts +27 -0
  313. package/batteries/vector/qdrant/index.d.ts +5 -0
  314. package/batteries/vector/qdrant.cjs +4 -0
  315. package/batteries/vector/qdrant.cjs.map +1 -1
  316. package/batteries/vector/qdrant.mjs +4 -0
  317. package/batteries/vector/qdrant.mjs.map +1 -1
  318. package/batteries/vector/redis/index.d.ts +2 -0
  319. package/batteries/vector/redis.cjs +2 -1
  320. package/batteries/vector/redis.cjs.map +1 -1
  321. package/batteries/vector/redis.mjs +2 -1
  322. package/batteries/vector/redis.mjs.map +1 -1
  323. package/batteries/vector/retrievable.cjs +9 -1
  324. package/batteries/vector/retrievable.cjs.map +1 -1
  325. package/batteries/vector/retrievable.mjs +9 -1
  326. package/batteries/vector/retrievable.mjs.map +1 -1
  327. package/batteries/vector/retrievable_glue.d.ts +21 -0
  328. package/batteries/vector/s3vectors/index.d.ts +2 -0
  329. package/batteries/vector/s3vectors.cjs +2 -1
  330. package/batteries/vector/s3vectors.cjs.map +1 -1
  331. package/batteries/vector/s3vectors.mjs +2 -1
  332. package/batteries/vector/s3vectors.mjs.map +1 -1
  333. package/batteries/vector/schema.cjs +28 -0
  334. package/batteries/vector/schema.cjs.map +1 -1
  335. package/batteries/vector/schema.d.ts +39 -0
  336. package/batteries/vector/schema.mjs +28 -0
  337. package/batteries/vector/schema.mjs.map +1 -1
  338. package/batteries/vector/solr/index.d.ts +2 -0
  339. package/batteries/vector/solr.cjs +2 -1
  340. package/batteries/vector/solr.cjs.map +1 -1
  341. package/batteries/vector/solr.mjs +2 -1
  342. package/batteries/vector/solr.mjs.map +1 -1
  343. package/batteries/vector/sqlite_vec/index.d.ts +6 -3
  344. package/batteries/vector/sqlite_vec.cjs +2 -0
  345. package/batteries/vector/sqlite_vec.cjs.map +1 -1
  346. package/batteries/vector/sqlite_vec.mjs +2 -0
  347. package/batteries/vector/sqlite_vec.mjs.map +1 -1
  348. package/batteries/vector/surrealdb/index.d.ts +2 -0
  349. package/batteries/vector/surrealdb.cjs +2 -1
  350. package/batteries/vector/surrealdb.cjs.map +1 -1
  351. package/batteries/vector/surrealdb.mjs +2 -1
  352. package/batteries/vector/surrealdb.mjs.map +1 -1
  353. package/batteries/vector/types.d.ts +27 -0
  354. package/batteries/vector/typesense/index.d.ts +2 -0
  355. package/batteries/vector/typesense.cjs +2 -1
  356. package/batteries/vector/typesense.cjs.map +1 -1
  357. package/batteries/vector/typesense.mjs +2 -1
  358. package/batteries/vector/typesense.mjs.map +1 -1
  359. package/batteries/vector/validation.cjs +14 -0
  360. package/batteries/vector/validation.cjs.map +1 -1
  361. package/batteries/vector/validation.d.ts +14 -0
  362. package/batteries/vector/validation.mjs +14 -0
  363. package/batteries/vector/validation.mjs.map +1 -1
  364. package/batteries/vector/vector_store_constructor.cjs +1 -1
  365. package/batteries/vector/vector_store_constructor.cjs.map +1 -1
  366. package/batteries/vector/vector_store_constructor.d.ts +1 -1
  367. package/batteries/vector/vector_store_constructor.mjs +1 -1
  368. package/batteries/vector/vector_store_constructor.mjs.map +1 -1
  369. package/batteries/vector/vespa/index.d.ts +2 -0
  370. package/batteries/vector/vespa.cjs +2 -1
  371. package/batteries/vector/vespa.cjs.map +1 -1
  372. package/batteries/vector/vespa.mjs +2 -1
  373. package/batteries/vector/vespa.mjs.map +1 -1
  374. package/batteries/vector/weaviate/index.d.ts +2 -0
  375. package/batteries/vector/weaviate.cjs +2 -1
  376. package/batteries/vector/weaviate.cjs.map +1 -1
  377. package/batteries/vector/weaviate.mjs +2 -1
  378. package/batteries/vector/weaviate.mjs.map +1 -1
  379. package/batteries.cjs +58 -28
  380. package/batteries.mjs +12 -5
  381. package/{common-BT0nfCi9.mjs → common-DYDUi99O.mjs} +9 -9
  382. package/common-DYDUi99O.mjs.map +1 -0
  383. package/{common-Cj8TaQ9U.js → common-DZl3ADJs.js} +9 -9
  384. package/common-DZl3ADJs.js.map +1 -0
  385. package/common.cjs +7 -7
  386. package/common.mjs +7 -7
  387. package/{dispatch_runner-DPcS7Y_M.mjs → dispatch_runner--ZhdDWRZ.mjs} +27 -5
  388. package/{dispatch_runner-DPcS7Y_M.mjs.map → dispatch_runner--ZhdDWRZ.mjs.map} +1 -1
  389. package/{dispatch_runner-BHBNupqp.js → dispatch_runner-nHDKkxye.js} +27 -5
  390. package/{dispatch_runner-BHBNupqp.js.map → dispatch_runner-nHDKkxye.js.map} +1 -1
  391. package/dispatch_runner.cjs +1 -1
  392. package/dispatch_runner.d.ts +1 -1
  393. package/dispatch_runner.mjs +1 -1
  394. package/eslint/rules/artifact_tool_forbids_artifact_constructor.cjs +1 -0
  395. package/eslint/rules/artifact_tool_forbids_artifact_constructor.cjs.map +1 -1
  396. package/eslint/rules/artifact_tool_forbids_artifact_constructor.d.ts +1 -0
  397. package/eslint/rules/artifact_tool_forbids_artifact_constructor.mjs +1 -0
  398. package/eslint/rules/artifact_tool_forbids_artifact_constructor.mjs.map +1 -1
  399. package/eslint/rules/no_model_in_tool_handler.cjs +1 -0
  400. package/eslint/rules/no_model_in_tool_handler.cjs.map +1 -1
  401. package/eslint/rules/no_model_in_tool_handler.d.ts +1 -0
  402. package/eslint/rules/no_model_in_tool_handler.mjs +1 -0
  403. package/eslint/rules/no_model_in_tool_handler.mjs.map +1 -1
  404. package/eslint/rules/require_validator_any_required.cjs +1 -0
  405. package/eslint/rules/require_validator_any_required.cjs.map +1 -1
  406. package/eslint/rules/require_validator_any_required.d.ts +1 -0
  407. package/eslint/rules/require_validator_any_required.mjs +1 -0
  408. package/eslint/rules/require_validator_any_required.mjs.map +1 -1
  409. package/eslint/rules/thought_payload_requires_replay_tag.cjs +1 -0
  410. package/eslint/rules/thought_payload_requires_replay_tag.cjs.map +1 -1
  411. package/eslint/rules/thought_payload_requires_replay_tag.d.ts +1 -0
  412. package/eslint/rules/thought_payload_requires_replay_tag.mjs +1 -0
  413. package/eslint/rules/thought_payload_requires_replay_tag.mjs.map +1 -1
  414. package/eslint/rules/token_encoding_requires_context_window.cjs +1 -0
  415. package/eslint/rules/token_encoding_requires_context_window.cjs.map +1 -1
  416. package/eslint/rules/token_encoding_requires_context_window.d.ts +1 -0
  417. package/eslint/rules/token_encoding_requires_context_window.mjs +1 -0
  418. package/eslint/rules/token_encoding_requires_context_window.mjs.map +1 -1
  419. package/eslint/rules.cjs +1 -1
  420. package/eslint/rules.mjs +1 -1
  421. package/eslint.cjs +2 -2
  422. package/eslint.mjs +2 -2
  423. package/{exceptions-BeWH2FwP.mjs → exceptions-BDhN0Xzr.mjs} +3 -2
  424. package/exceptions-BDhN0Xzr.mjs.map +1 -0
  425. package/{exceptions-CitH5wZI.js → exceptions-BRXrUKiW.js} +3 -2
  426. package/exceptions-BRXrUKiW.js.map +1 -0
  427. package/exceptions.cjs +2 -2
  428. package/exceptions.mjs +2 -2
  429. package/factories.cjs +1 -1
  430. package/factories.mjs +1 -1
  431. package/forge.cjs +4 -4
  432. package/forge.d.ts +1 -1
  433. package/forge.mjs +4 -4
  434. package/guards.cjs +9 -9
  435. package/guards.mjs +9 -9
  436. package/helpers-DSTFxTiC.js +497 -0
  437. package/helpers-DSTFxTiC.js.map +1 -0
  438. package/helpers-xhrQbMAG.mjs +306 -0
  439. package/helpers-xhrQbMAG.mjs.map +1 -0
  440. package/index.cjs +12 -12
  441. package/index.mjs +12 -12
  442. package/lib/classes/base_exception.d.ts +1 -0
  443. package/lib/classes/media.d.ts +10 -0
  444. package/lib/classes/retrievable.d.ts +1 -1
  445. package/lib/classes/spooled_json_artifact.d.ts +1 -1
  446. package/lib/classes/spooled_markdown_artifact.d.ts +1 -0
  447. package/lib/classes/tokenizable.d.ts +3 -0
  448. package/lib/classes/tool.d.ts +8 -0
  449. package/lib/classes/turn_gate.d.ts +6 -0
  450. package/lib/dispatch_runner.d.ts +4 -32
  451. package/lib/helpers/bignum.cjs +82 -0
  452. package/lib/helpers/bignum.cjs.map +1 -0
  453. package/lib/helpers/bignum.d.ts +52 -0
  454. package/lib/helpers/bignum.mjs +74 -0
  455. package/lib/helpers/bignum.mjs.map +1 -0
  456. package/lib/turn_runner.d.ts +1 -1
  457. package/lib/types/dispatch_runner.d.ts +83 -0
  458. package/lib/utils/exceptions.d.ts +1 -1
  459. package/lib/utils/retry.cjs.map +1 -1
  460. package/lib/utils/retry.d.ts +2 -0
  461. package/lib/utils/retry.mjs.map +1 -1
  462. package/mcp/adk-docs-corpus.json +1 -1
  463. package/package.json +259 -204
  464. package/{runtime-j92CNi5z.mjs → runtime-Bz5zA8wc.mjs} +2 -2
  465. package/{runtime-j92CNi5z.mjs.map → runtime-Bz5zA8wc.mjs.map} +1 -1
  466. package/{runtime-MFFcJrRv.js → runtime-DslE1aBw.js} +2 -2
  467. package/{runtime-MFFcJrRv.js.map → runtime-DslE1aBw.js.map} +1 -1
  468. package/scrapper-BHM1mCde.mjs +432 -0
  469. package/scrapper-BHM1mCde.mjs.map +1 -0
  470. package/scrapper-BeweWurk.js +462 -0
  471. package/scrapper-BeweWurk.js.map +1 -0
  472. package/searxng-BJFulNcK.mjs +247 -0
  473. package/searxng-BJFulNcK.mjs.map +1 -0
  474. package/searxng-B_D--V5q.js +265 -0
  475. package/searxng-B_D--V5q.js.map +1 -0
  476. package/skills/adk-assembly/SKILL.md +2 -2
  477. package/{spooled_artifact-CHoZgWwI.mjs → spooled_artifact-7eePq7JA.mjs} +5 -5
  478. package/{spooled_artifact-CHoZgWwI.mjs.map → spooled_artifact-7eePq7JA.mjs.map} +1 -1
  479. package/{spooled_artifact-BTq6Nzfy.js → spooled_artifact-DX8LLyUX.js} +5 -5
  480. package/{spooled_artifact-BTq6Nzfy.js.map → spooled_artifact-DX8LLyUX.js.map} +1 -1
  481. package/spooled_artifact.cjs +2 -2
  482. package/spooled_artifact.mjs +2 -2
  483. package/{spooled_markdown_artifact-CALSDxIx.js → spooled_markdown_artifact-ClX72lek.js} +4 -4
  484. package/spooled_markdown_artifact-ClX72lek.js.map +1 -0
  485. package/{spooled_markdown_artifact-Ci5UL7l4.mjs → spooled_markdown_artifact-wkrBF3oX.mjs} +4 -4
  486. package/spooled_markdown_artifact-wkrBF3oX.mjs.map +1 -0
  487. package/{thought-D34QQZZ9.mjs → thought-B_vxAiKU.mjs} +5 -5
  488. package/{thought-D34QQZZ9.mjs.map → thought-B_vxAiKU.mjs.map} +1 -1
  489. package/{thought-BbwhJ1wb.js → thought-DLwpF7MI.js} +5 -5
  490. package/{thought-BbwhJ1wb.js.map → thought-DLwpF7MI.js.map} +1 -1
  491. package/{tool-CVyZkFC7.js → tool-D5WGVIcI.js} +4 -4
  492. package/{tool-CVyZkFC7.js.map → tool-D5WGVIcI.js.map} +1 -1
  493. package/{tool-CMhaDRNd.mjs → tool-wMYMVl60.mjs} +4 -4
  494. package/{tool-CMhaDRNd.mjs.map → tool-wMYMVl60.mjs.map} +1 -1
  495. package/{tool_call-CV5qVNlb.mjs → tool_call-B4-_-vjG.mjs} +5 -5
  496. package/tool_call-B4-_-vjG.mjs.map +1 -0
  497. package/{tool_call-Db68hB7y.js → tool_call-DixVlW40.js} +5 -5
  498. package/tool_call-DixVlW40.js.map +1 -0
  499. package/{tool_registry-D1pSSlsd.mjs → tool_registry-791Vrjtf.mjs} +4 -3
  500. package/tool_registry-791Vrjtf.mjs.map +1 -0
  501. package/{tool_registry-DYUYqXvo.js → tool_registry-CKJPze3j.js} +4 -3
  502. package/tool_registry-CKJPze3j.js.map +1 -0
  503. package/{turn_runner-DqWHNP80.js → turn_runner-HXImLGIn.js} +7 -7
  504. package/turn_runner-HXImLGIn.js.map +1 -0
  505. package/{turn_runner-fg1Wc3dK.mjs → turn_runner-ZyYO-Kti.mjs} +7 -7
  506. package/turn_runner-ZyYO-Kti.mjs.map +1 -0
  507. package/turn_runner.cjs +1 -1
  508. package/turn_runner.mjs +1 -1
  509. package/types.d.ts +1 -1
  510. package/common-BT0nfCi9.mjs.map +0 -1
  511. package/common-Cj8TaQ9U.js.map +0 -1
  512. package/exceptions-BeWH2FwP.mjs.map +0 -1
  513. package/exceptions-CitH5wZI.js.map +0 -1
  514. package/spooled_markdown_artifact-CALSDxIx.js.map +0 -1
  515. package/spooled_markdown_artifact-Ci5UL7l4.mjs.map +0 -1
  516. package/tool_call-CV5qVNlb.mjs.map +0 -1
  517. package/tool_call-Db68hB7y.js.map +0 -1
  518. package/tool_registry-D1pSSlsd.mjs.map +0 -1
  519. package/tool_registry-DYUYqXvo.js.map +0 -1
  520. package/turn_runner-DqWHNP80.js.map +0 -1
  521. package/turn_runner-fg1Wc3dK.mjs.map +0 -1
@@ -0,0 +1,462 @@
1
+ require("./chunk-Ble4zEEl.js");
2
+ const require_exceptions = require("./exceptions-BRXrUKiW.js");
3
+ const require_tool_registry = require("./tool_registry-CKJPze3j.js");
4
+ const require_tool = require("./tool-D5WGVIcI.js");
5
+ const require_spooled_markdown_artifact = require("./spooled_markdown_artifact-ClX72lek.js");
6
+ require("./factories.cjs");
7
+ require("./forge.cjs");
8
+ require("./guards.cjs");
9
+ require("./spooled_artifact.cjs");
10
+ const require_batteries_tools__shared = require("./batteries/tools/_shared.cjs");
11
+ let _nhtio_validation = require("@nhtio/validation");
12
+ let _nhtio_middleware = require("@nhtio/middleware");
13
+ //#region src/batteries/tools/scrapper/exceptions.ts
14
+ /**
15
+ * Battery-scoped exception constructors for the Scrapper web-extraction tool.
16
+ *
17
+ * @remarks
18
+ * Battery-scoped exception classes owned by the Scrapper tool battery (not the ADK core). Minted
19
+ * via `createException` from `@nhtio/adk/factories` and re-exported from the battery's barrel
20
+ * (`@nhtio/adk/batteries/tools/scrapper`). This file intentionally carries **no** `@module` tag:
21
+ * it is an internal sibling relative-imported by `index.ts`, so it does not mint its own
22
+ * `…/scrapper/exceptions` entrypoint (whose `exceptions` leaf basename would collide with sibling
23
+ * batteries under the `vite-plugin-dts` rolled-up `.d.ts` rule).
24
+ */
25
+ /**
26
+ * Thrown when a Scrapper factory receives invalid configuration.
27
+ *
28
+ * @remarks
29
+ * Fatal: config bugs (missing/unparseable `instanceUrl`, a bad `artifact` resolver, or an async
30
+ * resolver passed to a `*Sync` factory) fail loud at factory-call time rather than at first scrape.
31
+ */
32
+ var E_INVALID_SCRAPPER_CONFIG = require_exceptions.createException("E_INVALID_SCRAPPER_CONFIG", "Invalid Scrapper tool config: %s", "E_INVALID_SCRAPPER_CONFIG", 529, true);
33
+ //#endregion
34
+ //#region src/batteries/tools/scrapper/shared.ts
35
+ /**
36
+ * Internal core shared by both Scrapper verbs (article / links).
37
+ *
38
+ * @remarks
39
+ * No `@module` tag — this is a sibling of `index.ts`, relative-imported, not its own entrypoint.
40
+ * Houses the per-parameter disposition machinery (schema building from `fixed`/`defaults`), the
41
+ * snake→kebab wire mapping, the request/response contexts, and the `fetch`+pipeline handler core.
42
+ * Generic harness helpers (artifact/header resolution, pipeline runners) come from `../_shared`.
43
+ */
44
+ var DEFAULT_REQUEST_TIMEOUT = 65e3;
45
+ /** Throw the battery-scoped config error. */
46
+ var failConfig = (reason) => {
47
+ throw new E_INVALID_SCRAPPER_CONFIG([reason]);
48
+ };
49
+ /** Serialise a parameter value to its wire string. */
50
+ var toWire = (value) => String(value);
51
+ /**
52
+ * Build the model-facing input schema from a verb's param specs and the factory's disposition.
53
+ * `url` is always required. A `fixed` param is omitted (the model can't set it); a `defaults` param
54
+ * gets `.default(value)`; everything else is `.optional()`.
55
+ */
56
+ var buildScrapperSchema = (specs, fixed, defaults, extra = {}) => {
57
+ const shape = { url: _nhtio_validation.validator.string().required().description("The absolute URL of the page to load.") };
58
+ for (const spec of specs) {
59
+ if (fixed && spec.key in fixed) continue;
60
+ let sch = spec.schema;
61
+ if (defaults && spec.key in defaults) sch = sch.default(defaults[spec.key]);
62
+ else sch = sch.optional();
63
+ shape[spec.key] = sch.description(spec.description);
64
+ }
65
+ return _nhtio_validation.validator.object({
66
+ ...shape,
67
+ ...extra
68
+ });
69
+ };
70
+ /**
71
+ * Assemble the wire-kebab query params for one request: each spec's value is `fixed` (if pinned)
72
+ * else the validated model/default value; then `fixedQuery` raw passthrough is layered on. `url`
73
+ * is handled separately (it is the search target, never pinned).
74
+ */
75
+ var buildWireParams = (args, specs, fixed, fixedQuery) => {
76
+ const out = {};
77
+ for (const spec of specs) {
78
+ const value = fixed && spec.key in fixed ? fixed[spec.key] : args[spec.key];
79
+ if (value !== void 0 && value !== null) out[spec.wire] = toWire(value);
80
+ }
81
+ for (const [k, v] of Object.entries(fixedQuery ?? {})) out[k] = v;
82
+ return out;
83
+ };
84
+ /** Parse a Scrapper error body (`{ detail: [{ msg }] }`) into a single message, best-effort. */
85
+ var parseScrapperError = (body, status, statusText) => {
86
+ if (body && typeof body === "object" && Array.isArray(body.detail)) {
87
+ const msgs = body.detail.map((d) => {
88
+ const loc = Array.isArray(d.loc) ? d.loc.join(".") : void 0;
89
+ const msg = typeof d.msg === "string" ? d.msg : void 0;
90
+ if (msg && loc) return `${loc}: ${msg}`;
91
+ return msg ?? loc;
92
+ }).filter((m) => typeof m === "string");
93
+ if (msgs.length) return msgs.join("; ");
94
+ }
95
+ return `HTTP ${status} ${statusText}`.trim();
96
+ };
97
+ /**
98
+ * Build a configured Scrapper {@link Tool} from validated config + an already-resolved sync
99
+ * artifact constructor. Shared by every verb and by both the async and sync factories.
100
+ */
101
+ var assembleScrapperTool = (verb, config, instanceUrl, artifactConstructor) => {
102
+ const requestTimeoutMs = config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT;
103
+ const resultFormat = config.resultFormat ?? "either";
104
+ const toolName = config.name ?? verb.defaultName;
105
+ const fixed = config.fixed;
106
+ const defaults = config.defaults;
107
+ const inputMw = new _nhtio_middleware.Middleware();
108
+ for (const fn of config.inputPipeline ?? []) inputMw.add(fn);
109
+ const outputMw = new _nhtio_middleware.Middleware();
110
+ for (const fn of config.outputPipeline ?? []) outputMw.add(fn);
111
+ const hasInput = (config.inputPipeline ?? []).length > 0;
112
+ const hasOutput = (config.outputPipeline ?? []).length > 0;
113
+ const extra = resultFormat === "either" ? { format: _nhtio_validation.validator.string().valid("normalized", "raw").default("normalized").description("Output shape: \"normalized\" (trimmed) or \"raw\" (full Scrapper JSON).") } : {};
114
+ const inputSchema = buildScrapperSchema(verb.specs, fixed, defaults, extra);
115
+ return new require_tool.Tool({
116
+ name: toolName,
117
+ description: config.description ?? verb.defaultDescription,
118
+ inputSchema,
119
+ artifactConstructor,
120
+ handler: async (args) => {
121
+ const a = args;
122
+ try {
123
+ const format = resultFormat === "either" ? a.format ?? "normalized" : resultFormat;
124
+ const headers = {
125
+ Accept: "application/json",
126
+ ...await require_batteries_tools__shared.resolveHeaders(config.headers)
127
+ };
128
+ const params = buildWireParams(a, verb.specs, fixed, config.fixedQuery);
129
+ const stash = /* @__PURE__ */ new Map();
130
+ const requestCtx = {
131
+ toolName,
132
+ url: a.url,
133
+ params,
134
+ headers,
135
+ instanceUrl,
136
+ stash,
137
+ shortCircuit: require_batteries_tools__shared.makeShortCircuit()
138
+ };
139
+ if (hasInput) {
140
+ const short = await require_batteries_tools__shared.runInputPipeline(inputMw, requestCtx, "Scrapper");
141
+ if (short !== void 0) return short;
142
+ }
143
+ const url = new URL(verb.endpoint, instanceUrl + "/");
144
+ url.searchParams.set("url", requestCtx.url);
145
+ for (const [k, v] of Object.entries(requestCtx.params)) url.searchParams.set(k, v);
146
+ const controller = new AbortController();
147
+ const timer = setTimeout(() => controller.abort(), requestTimeoutMs);
148
+ let response;
149
+ try {
150
+ response = await fetch(url, {
151
+ method: "GET",
152
+ headers: requestCtx.headers,
153
+ signal: controller.signal
154
+ });
155
+ } finally {
156
+ clearTimeout(timer);
157
+ }
158
+ if (!response.ok) {
159
+ let body;
160
+ try {
161
+ body = await response.json();
162
+ } catch {
163
+ body = void 0;
164
+ }
165
+ return `Error: Scrapper request failed — ${parseScrapperError(body, response.status, response.statusText)}.`;
166
+ }
167
+ const body = await response.json();
168
+ const responseCtx = {
169
+ toolName,
170
+ request: requestCtx,
171
+ raw: body,
172
+ result: verb.normalize(body),
173
+ format,
174
+ stash
175
+ };
176
+ if (hasOutput) await require_batteries_tools__shared.runOutputPipeline(outputMw, responseCtx, "Scrapper");
177
+ if (typeof responseCtx.output === "string") return responseCtx.output;
178
+ if (responseCtx.format === "raw") return JSON.stringify(responseCtx.raw, null, 2);
179
+ return JSON.stringify(responseCtx.result, null, 2);
180
+ } catch (err) {
181
+ if (require_batteries_tools__shared.isShortCircuit(err)) return err.result;
182
+ return `Error: ${require_tool_registry.isError(err) ? err.message : String(err)}`;
183
+ }
184
+ }
185
+ });
186
+ };
187
+ /** Validate `instanceUrl` and return the trailing-slash-normalised base. */
188
+ var validateScrapperInstanceUrl = (config) => {
189
+ if (typeof config?.instanceUrl !== "string" || config.instanceUrl.trim() === "") failConfig("instanceUrl is required");
190
+ try {
191
+ new URL(config.instanceUrl);
192
+ } catch {
193
+ failConfig(`instanceUrl is not a valid URL: ${config.instanceUrl}`);
194
+ }
195
+ return config.instanceUrl.replace(/\/+$/, "");
196
+ };
197
+ //#endregion
198
+ //#region src/batteries/tools/scrapper/index.ts
199
+ /**
200
+ * Factories for configured Scrapper web-extraction tools (article + links).
201
+ *
202
+ * @module @nhtio/adk/batteries/tools/scrapper
203
+ *
204
+ * @remarks
205
+ * [Scrapper](https://github.com/amerkurev/scrapper) is a self-hosted service that loads a page in a
206
+ * real headless browser and extracts either the readable article (`/api/article`) or the page's
207
+ * links (`/api/links`). It gives an agent browser-grade reading power — JS-rendered pages a
208
+ * renderless fetcher can't see — but as a **stateless** HTTP call: each request runs in a fresh
209
+ * incognito context, stores no session or credentials, and shares nothing with any other call.
210
+ *
211
+ * Like the SearXNG battery, this exports **factories** (not ready-made `Tool` constants), because a
212
+ * scrape tool needs per-deployment config (instance URL + custom auth headers). Two verbs, each with
213
+ * an async factory ({@link createScrapperArticleTool} / {@link createScrapperLinksTool}, accepting a
214
+ * dynamic-import `artifact` resolver) and a sync variant ({@link createScrapperArticleToolSync} /
215
+ * {@link createScrapperLinksToolSync}). Because these are factories, they MUST NOT be bulk-registered
216
+ * via `Object.values(batteries)` — call one, then register the returned tool.
217
+ *
218
+ * @see https://github.com/amerkurev/scrapper
219
+ */
220
+ var commonSpecs = [
221
+ {
222
+ key: "cache",
223
+ wire: "cache",
224
+ type: "boolean",
225
+ schema: _nhtio_validation.validator.boolean(),
226
+ description: "Return a cached result when available instead of re-scraping."
227
+ },
228
+ {
229
+ key: "screenshot",
230
+ wire: "screenshot",
231
+ type: "boolean",
232
+ schema: _nhtio_validation.validator.boolean(),
233
+ description: "Capture a screenshot; the result carries a screenshotUri."
234
+ },
235
+ {
236
+ key: "incognito",
237
+ wire: "incognito",
238
+ type: "boolean",
239
+ schema: _nhtio_validation.validator.boolean(),
240
+ description: "Run in an incognito browser context (no persisted data)."
241
+ },
242
+ {
243
+ key: "timeout",
244
+ wire: "timeout",
245
+ type: "number",
246
+ schema: _nhtio_validation.validator.number().min(0),
247
+ description: "Browser navigation timeout in ms (0 disables)."
248
+ },
249
+ {
250
+ key: "wait_until",
251
+ wire: "wait-until",
252
+ type: "string",
253
+ schema: _nhtio_validation.validator.string().valid("load", "domcontentloaded", "networkidle", "commit"),
254
+ description: "When navigation is considered finished."
255
+ },
256
+ {
257
+ key: "sleep",
258
+ wire: "sleep",
259
+ type: "number",
260
+ schema: _nhtio_validation.validator.number().min(0),
261
+ description: "Wait this many ms after load before parsing."
262
+ },
263
+ {
264
+ key: "scroll_down",
265
+ wire: "scroll-down",
266
+ type: "number",
267
+ schema: _nhtio_validation.validator.number().min(0),
268
+ description: "Scroll down N pixels for lazy-loading pages (requires a positive sleep)."
269
+ },
270
+ {
271
+ key: "device",
272
+ wire: "device",
273
+ type: "string",
274
+ schema: _nhtio_validation.validator.string(),
275
+ description: "Emulated device, e.g. \"Desktop Chrome\"."
276
+ },
277
+ {
278
+ key: "user_agent",
279
+ wire: "user-agent",
280
+ type: "string",
281
+ schema: _nhtio_validation.validator.string(),
282
+ description: "Explicit user-agent (prefer device)."
283
+ },
284
+ {
285
+ key: "extra_http_headers",
286
+ wire: "extra-http-headers",
287
+ type: "string",
288
+ schema: _nhtio_validation.validator.string(),
289
+ description: "Extra headers the scraper sends to the TARGET site, formatted \"K:v;K2:v2\"."
290
+ },
291
+ {
292
+ key: "proxy_server",
293
+ wire: "proxy-server",
294
+ type: "string",
295
+ schema: _nhtio_validation.validator.string(),
296
+ description: "Upstream proxy, e.g. \"http://host:3128\" or \"socks5://host:1080\"."
297
+ }
298
+ ];
299
+ var articleSpecs = [...commonSpecs, {
300
+ key: "full_content",
301
+ wire: "full-content",
302
+ type: "boolean",
303
+ schema: _nhtio_validation.validator.boolean(),
304
+ description: "Populate fullContent with the page full HTML."
305
+ }];
306
+ var linksSpecs = [
307
+ ...commonSpecs,
308
+ {
309
+ key: "text_len_threshold",
310
+ wire: "text-len-threshold",
311
+ type: "number",
312
+ schema: _nhtio_validation.validator.number().min(0),
313
+ description: "Median link-text length threshold for the link parser."
314
+ },
315
+ {
316
+ key: "words_threshold",
317
+ wire: "words-threshold",
318
+ type: "number",
319
+ schema: _nhtio_validation.validator.number().min(0),
320
+ description: "Median words-per-link threshold for the link parser."
321
+ }
322
+ ];
323
+ var str = (v) => typeof v === "string" ? v : void 0;
324
+ var num = (v) => typeof v === "number" ? v : void 0;
325
+ var normalizeArticle = (body) => {
326
+ const out = {};
327
+ out.url = str(body.url);
328
+ out.title = str(body.title);
329
+ out.byline = str(body.byline);
330
+ out.excerpt = str(body.excerpt);
331
+ out.siteName = str(body.siteName);
332
+ out.lang = str(body.lang);
333
+ out.length = num(body.length);
334
+ out.publishedTime = str(body.publishedTime);
335
+ out.date = str(body.date);
336
+ out.textContent = str(body.textContent);
337
+ if (str(body.content)) out.content = str(body.content);
338
+ if (str(body.fullContent)) out.fullContent = str(body.fullContent);
339
+ if (str(body.screenshotUri)) out.screenshotUri = str(body.screenshotUri);
340
+ return JSON.parse(JSON.stringify(out));
341
+ };
342
+ var normalizeLinks = (body) => {
343
+ const out = { links: (Array.isArray(body.links) ? body.links : []).map((l) => {
344
+ const r = l ?? {};
345
+ const item = {};
346
+ if (str(r.url)) item.url = str(r.url);
347
+ if (str(r.text)) item.text = str(r.text);
348
+ return item;
349
+ }) };
350
+ if (str(body.url)) out.url = str(body.url);
351
+ if (str(body.title)) out.title = str(body.title);
352
+ if (str(body.domain)) out.domain = str(body.domain);
353
+ if (str(body.date)) out.date = str(body.date);
354
+ if (str(body.screenshotUri)) out.screenshotUri = str(body.screenshotUri);
355
+ return out;
356
+ };
357
+ var articleVerb = {
358
+ endpoint: "/api/article",
359
+ specs: articleSpecs,
360
+ defaultName: "scrapper_article",
361
+ defaultDescription: "Load a web page in a real (headless) browser and extract its readable article — title, byline, text content, and metadata. Renders JavaScript-heavy pages a plain fetch cannot. Each call is stateless (fresh incognito context, no stored session).",
362
+ normalize: normalizeArticle
363
+ };
364
+ var linksVerb = {
365
+ endpoint: "/api/links",
366
+ specs: linksSpecs,
367
+ defaultName: "scrapper_links",
368
+ defaultDescription: "Load a web page in a real (headless) browser and collect its article/navigation links (each { url, text }). Renders JavaScript-heavy index pages a plain fetch cannot. Each call is stateless (fresh incognito context, no stored session).",
369
+ normalize: normalizeLinks
370
+ };
371
+ var defaultArtifact = () => require_spooled_markdown_artifact.SpooledJsonArtifact;
372
+ /**
373
+ * Create a configured Scrapper **article** {@link Tool} (async — accepts a dynamic-import `artifact`).
374
+ *
375
+ * @remarks
376
+ * Async because `artifact` may be an async / dynamic-import resolver, which must resolve to the sync
377
+ * `() => Ctor` `Tool.artifactConstructor` requires before the tool is built. For the common case,
378
+ * use {@link createScrapperArticleToolSync} and skip the `await`.
379
+ *
380
+ * @warning
381
+ * Two distinct "headers": `config.headers` authenticates to the Scrapper *instance*; the
382
+ * `extra_http_headers` *parameter* is what the scraper's browser sends to the *target site* — do not
383
+ * conflate them. Also note `scroll_down` requires a positive `sleep`, and `resultUri`/`screenshotUri`
384
+ * are instance-relative and may come back `http://` even over HTTPS — do not assume they match
385
+ * `instanceUrl`.
386
+ *
387
+ * @param config - Instance URL, instance-auth headers, output policy, `artifact` resolver,
388
+ * per-parameter disposition (`fixed`/`defaults`/`fixedQuery`), and middleware pipelines.
389
+ * @returns A promise of a `Tool` ready to register in a `ToolRegistry`.
390
+ * @throws {@link E_INVALID_SCRAPPER_CONFIG} when `instanceUrl` or `artifact` is invalid.
391
+ */
392
+ var createScrapperArticleTool = async (config) => {
393
+ return assembleScrapperTool(articleVerb, config, validateScrapperInstanceUrl(config), await require_batteries_tools__shared.resolveArtifact(config.artifact ?? defaultArtifact, failConfig));
394
+ };
395
+ /**
396
+ * Synchronous {@link createScrapperArticleTool} — `artifact` narrowed to the sync subset.
397
+ *
398
+ * @param config - Same as {@link createScrapperArticleTool}, with a sync-only `artifact`.
399
+ * @returns A `Tool` ready to register in a `ToolRegistry`.
400
+ * @throws {@link E_INVALID_SCRAPPER_CONFIG} when `instanceUrl` or `artifact` is invalid (incl. an async resolver).
401
+ */
402
+ var createScrapperArticleToolSync = (config) => {
403
+ return assembleScrapperTool(articleVerb, config, validateScrapperInstanceUrl(config), require_batteries_tools__shared.resolveArtifactSync(config.artifact ?? defaultArtifact, failConfig));
404
+ };
405
+ /**
406
+ * Create a configured Scrapper **links** {@link Tool} (async — accepts a dynamic-import `artifact`).
407
+ *
408
+ * @remarks
409
+ * See {@link createScrapperArticleTool} for the two-headers caveat and the async rationale. Each
410
+ * `links` item is `{ url, text }`.
411
+ *
412
+ * @param config - Instance URL, instance-auth headers, output policy, `artifact` resolver,
413
+ * per-parameter disposition, and middleware pipelines.
414
+ * @returns A promise of a `Tool` ready to register in a `ToolRegistry`.
415
+ * @throws {@link E_INVALID_SCRAPPER_CONFIG} when `instanceUrl` or `artifact` is invalid.
416
+ */
417
+ var createScrapperLinksTool = async (config) => {
418
+ return assembleScrapperTool(linksVerb, config, validateScrapperInstanceUrl(config), await require_batteries_tools__shared.resolveArtifact(config.artifact ?? defaultArtifact, failConfig));
419
+ };
420
+ /**
421
+ * Synchronous {@link createScrapperLinksTool} — `artifact` narrowed to the sync subset.
422
+ *
423
+ * @param config - Same as {@link createScrapperLinksTool}, with a sync-only `artifact`.
424
+ * @returns A `Tool` ready to register in a `ToolRegistry`.
425
+ * @throws {@link E_INVALID_SCRAPPER_CONFIG} when `instanceUrl` or `artifact` is invalid (incl. an async resolver).
426
+ */
427
+ var createScrapperLinksToolSync = (config) => {
428
+ return assembleScrapperTool(linksVerb, config, validateScrapperInstanceUrl(config), require_batteries_tools__shared.resolveArtifactSync(config.artifact ?? defaultArtifact, failConfig));
429
+ };
430
+ //#endregion
431
+ Object.defineProperty(exports, "E_INVALID_SCRAPPER_CONFIG", {
432
+ enumerable: true,
433
+ get: function() {
434
+ return E_INVALID_SCRAPPER_CONFIG;
435
+ }
436
+ });
437
+ Object.defineProperty(exports, "createScrapperArticleTool", {
438
+ enumerable: true,
439
+ get: function() {
440
+ return createScrapperArticleTool;
441
+ }
442
+ });
443
+ Object.defineProperty(exports, "createScrapperArticleToolSync", {
444
+ enumerable: true,
445
+ get: function() {
446
+ return createScrapperArticleToolSync;
447
+ }
448
+ });
449
+ Object.defineProperty(exports, "createScrapperLinksTool", {
450
+ enumerable: true,
451
+ get: function() {
452
+ return createScrapperLinksTool;
453
+ }
454
+ });
455
+ Object.defineProperty(exports, "createScrapperLinksToolSync", {
456
+ enumerable: true,
457
+ get: function() {
458
+ return createScrapperLinksToolSync;
459
+ }
460
+ });
461
+
462
+ //# sourceMappingURL=scrapper-BeweWurk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrapper-BeweWurk.js","names":[],"sources":["../src/batteries/tools/scrapper/exceptions.ts","../src/batteries/tools/scrapper/shared.ts","../src/batteries/tools/scrapper/index.ts"],"sourcesContent":["/**\n * Battery-scoped exception constructors for the Scrapper web-extraction tool.\n *\n * @remarks\n * Battery-scoped exception classes owned by the Scrapper tool battery (not the ADK core). Minted\n * via `createException` from `@nhtio/adk/factories` and re-exported from the battery's barrel\n * (`@nhtio/adk/batteries/tools/scrapper`). This file intentionally carries **no** `@module` tag:\n * it is an internal sibling relative-imported by `index.ts`, so it does not mint its own\n * `…/scrapper/exceptions` entrypoint (whose `exceptions` leaf basename would collide with sibling\n * batteries under the `vite-plugin-dts` rolled-up `.d.ts` rule).\n */\n\nimport { createException } from '@nhtio/adk/factories'\n\n/**\n * Thrown when a Scrapper factory receives invalid configuration.\n *\n * @remarks\n * Fatal: config bugs (missing/unparseable `instanceUrl`, a bad `artifact` resolver, or an async\n * resolver passed to a `*Sync` factory) fail loud at factory-call time rather than at first scrape.\n */\nexport const E_INVALID_SCRAPPER_CONFIG = createException<[string]>(\n 'E_INVALID_SCRAPPER_CONFIG',\n 'Invalid Scrapper tool config: %s',\n 'E_INVALID_SCRAPPER_CONFIG',\n 529,\n true\n)\n","/**\n * Internal core shared by both Scrapper verbs (article / links).\n *\n * @remarks\n * No `@module` tag — this is a sibling of `index.ts`, relative-imported, not its own entrypoint.\n * Houses the per-parameter disposition machinery (schema building from `fixed`/`defaults`), the\n * snake→kebab wire mapping, the request/response contexts, and the `fetch`+pipeline handler core.\n * Generic harness helpers (artifact/header resolution, pipeline runners) come from `../_shared`.\n */\n\nimport { Tool } from '@nhtio/adk/forge'\nimport { isError } from '@nhtio/adk/guards'\nimport { validator } from '@nhtio/validation'\nimport { Middleware } from '@nhtio/middleware'\nimport { E_INVALID_SCRAPPER_CONFIG } from './exceptions'\nimport {\n resolveHeaders,\n makeShortCircuit,\n isShortCircuit,\n runInputPipeline,\n runOutputPipeline,\n type ToolHeaders,\n type ToolHeadersResolver,\n type SpooledArtifactCtor,\n type MiddlewareFn,\n} from '../_shared'\nimport type { Schema } from '@nhtio/validation'\nimport type { NextFn } from '@nhtio/middleware'\n\nconst DEFAULT_REQUEST_TIMEOUT = 65_000\n\n/** Throw the battery-scoped config error. */\nexport const failConfig = (reason: string): never => {\n throw new E_INVALID_SCRAPPER_CONFIG([reason])\n}\n\n// ── Parameter specs (per-parameter disposition) ──────────────────────────────\n\n/** The wire type of a Scrapper query parameter — controls serialisation. */\nexport type ScrapperParamType = 'string' | 'number' | 'boolean'\n\n/**\n * One curated, model-facing Scrapper parameter: its snake_case key (used in the model schema and\n * in `fixed`/`defaults`), its kebab-case wire name, its type, the base validator, and a description.\n */\nexport interface ScrapperParamSpec {\n /** snake_case key as seen by the model and in `config.fixed` / `config.defaults`. */\n key: string\n /** kebab-case name sent to the Scrapper API. */\n wire: string\n /** Wire type, controlling string/number/boolean serialisation. */\n type: ScrapperParamType\n /** Base `@nhtio/validation` schema (no `.required()`/`.default()`/`.optional()` applied yet). */\n schema: Schema\n /** Human-readable description surfaced to the model. */\n description: string\n}\n\n/** Serialise a parameter value to its wire string. */\nconst toWire = (value: unknown): string => String(value)\n\n/**\n * Build the model-facing input schema from a verb's param specs and the factory's disposition.\n * `url` is always required. A `fixed` param is omitted (the model can't set it); a `defaults` param\n * gets `.default(value)`; everything else is `.optional()`.\n */\nexport const buildScrapperSchema = (\n specs: ScrapperParamSpec[],\n fixed: Record<string, unknown> | undefined,\n defaults: Record<string, unknown> | undefined,\n extra: Record<string, Schema> = {}\n): Schema => {\n const shape: Record<string, Schema> = {\n url: validator.string().required().description('The absolute URL of the page to load.'),\n }\n for (const spec of specs) {\n if (fixed && spec.key in fixed) continue // pinned → not model-visible\n let sch = spec.schema\n if (defaults && spec.key in defaults) {\n sch = sch.default(defaults[spec.key] as never)\n } else {\n sch = sch.optional()\n }\n shape[spec.key] = sch.description(spec.description)\n }\n return validator.object({ ...shape, ...extra })\n}\n\n/**\n * Assemble the wire-kebab query params for one request: each spec's value is `fixed` (if pinned)\n * else the validated model/default value; then `fixedQuery` raw passthrough is layered on. `url`\n * is handled separately (it is the search target, never pinned).\n */\nexport const buildWireParams = (\n args: Record<string, unknown>,\n specs: ScrapperParamSpec[],\n fixed: Record<string, unknown> | undefined,\n fixedQuery: Record<string, string> | undefined\n): Record<string, string> => {\n const out: Record<string, string> = {}\n for (const spec of specs) {\n const value = fixed && spec.key in fixed ? fixed[spec.key] : args[spec.key]\n if (value !== undefined && value !== null) out[spec.wire] = toWire(value)\n }\n for (const [k, v] of Object.entries(fixedQuery ?? {})) out[k] = v\n return out\n}\n\n// ── Contexts ─────────────────────────────────────────────────────────────────\n\n/**\n * Mutable context handed to each input-pipeline stage **before** the HTTP request is sent.\n * Identical for both verbs.\n */\nexport interface ScrapperRequestContext {\n /** The tool's name (read-only). */\n readonly toolName: string\n /** The target page URL (the `url` argument). Mutable. */\n url: string\n /** Wire-kebab query params (everything except `url`). Mutable. */\n params: Record<string, string>\n /** Resolved request headers sent to the SCRAPPER INSTANCE (auth). Mutable. */\n headers: ToolHeaders\n /** The Scrapper instance base URL (read-only). */\n readonly instanceUrl: string\n /** Cross-stage scratch space; also carried onto the response context. */\n readonly stash: Map<string, unknown>\n /** Skip the fetch and return `result` verbatim as the tool's output (e.g. a cache hit). */\n shortCircuit(result: string): void\n}\n\n/**\n * Mutable context handed to each output-pipeline stage **after** the response JSON is parsed.\n *\n * @typeParam R - The verb's normalised result type (article object or links payload).\n */\nexport interface ScrapperResponseContext<R> {\n /** The tool's name (read-only). */\n readonly toolName: string\n /** The request context as it was sent (post-input-pipeline). */\n readonly request: ScrapperRequestContext\n /** The parsed Scrapper JSON body. Mutable (used when `format` is `raw`). */\n raw: unknown\n /** The normalised result. Mutable — reshape, redact, enrich. */\n result: R\n /** The effective payload shape for this call. */\n format: 'normalized' | 'raw'\n /** When set, used verbatim as the tool's output (overrides serialisation). */\n output?: string\n /** Cross-stage scratch space; carried over from the request context. */\n readonly stash: Map<string, unknown>\n}\n\n/** An input-pipeline stage. Onion middleware over {@link ScrapperRequestContext}. */\nexport type ScrapperInputMiddlewareFn = (\n ctx: ScrapperRequestContext,\n next: NextFn\n) => void | Promise<void>\n\n/** An output-pipeline stage over a verb's {@link ScrapperResponseContext}. */\nexport type ScrapperOutputMiddlewareFn<R> = (\n ctx: ScrapperResponseContext<R>,\n next: NextFn\n) => void | Promise<void>\n\n// ── Config (shared shape; `artifact` variant supplied by the verb factory) ────\n\n/** Configuration common to every Scrapper factory. `A` is the accepted `artifact` resolver type. */\nexport interface ScrapperBaseConfig<P, R, A> {\n /** Base URL of the Scrapper instance, e.g. `https://scrapper.example.org`. Required. */\n instanceUrl: string\n /** Headers sent to the Scrapper INSTANCE for auth (X-API-Key / Basic) — static or resolver. */\n headers?: ToolHeaders | ToolHeadersResolver\n /** The tool's own `fetch` AbortController timeout in ms. Default `65_000` (> Scrapper's 60s browser default). */\n requestTimeoutMs?: number\n /** Output shape. `normalized`/`raw` pin it; `either` (default) exposes a `format` arg to the model. */\n resultFormat?: 'normalized' | 'raw' | 'either'\n /** Spool-artifact resolver for the output. Default `() => SpooledJsonArtifact`. */\n artifact?: A\n /** Tool name override. */\n name?: string\n /** Tool description override. */\n description?: string\n /** Pinned params — sent always, removed from the model schema. */\n fixed?: Partial<P>\n /** Model-overridable default param values. */\n defaults?: Partial<P>\n /** Raw, un-modeled wire params (kebab keys) — always sent, never model-visible. Keeps the battery generic. */\n fixedQuery?: Record<string, string>\n /** Stages run before the HTTP request. See {@link ScrapperRequestContext}. */\n inputPipeline?: ScrapperInputMiddlewareFn[]\n /** Stages run after the response is parsed. See {@link ScrapperResponseContext}. */\n outputPipeline?: ScrapperOutputMiddlewareFn<R>[]\n}\n\n/** Verb-specific wiring passed to {@link assembleScrapperTool}. */\nexport interface ScrapperVerb<R> {\n /** Scrapper endpoint path, e.g. `/api/article`. */\n endpoint: string\n /** The curated param specs for this verb. */\n specs: ScrapperParamSpec[]\n /** Default tool name (`scrapper_article` / `scrapper_links`). */\n defaultName: string\n /** Default tool description. */\n defaultDescription: string\n /** Map a parsed Scrapper body to the verb's normalised result. */\n normalize: (body: Record<string, unknown>) => R\n}\n\n/** Parse a Scrapper error body (`{ detail: [{ msg }] }`) into a single message, best-effort. */\nconst parseScrapperError = (body: unknown, status: number, statusText: string): string => {\n if (body && typeof body === 'object' && Array.isArray((body as { detail?: unknown }).detail)) {\n const detail = (body as { detail: Array<{ msg?: unknown; loc?: unknown }> }).detail\n const msgs = detail\n .map((d) => {\n const loc = Array.isArray(d.loc) ? d.loc.join('.') : undefined\n const msg = typeof d.msg === 'string' ? d.msg : undefined\n if (msg && loc) return `${loc}: ${msg}`\n return msg ?? loc\n })\n .filter((m): m is string => typeof m === 'string')\n if (msgs.length) return msgs.join('; ')\n }\n return `HTTP ${status} ${statusText}`.trim()\n}\n\n/**\n * Build a configured Scrapper {@link Tool} from validated config + an already-resolved sync\n * artifact constructor. Shared by every verb and by both the async and sync factories.\n */\nexport const assembleScrapperTool = <P, R>(\n verb: ScrapperVerb<R>,\n config: ScrapperBaseConfig<P, R, unknown>,\n instanceUrl: string,\n artifactConstructor: () => SpooledArtifactCtor\n): Tool => {\n const requestTimeoutMs = config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT\n const resultFormat = config.resultFormat ?? 'either'\n const toolName = config.name ?? verb.defaultName\n const fixed = config.fixed as Record<string, unknown> | undefined\n const defaults = config.defaults as Record<string, unknown> | undefined\n\n const inputMw = new Middleware<MiddlewareFn<ScrapperRequestContext>>()\n for (const fn of config.inputPipeline ?? []) inputMw.add(fn)\n const outputMw = new Middleware<MiddlewareFn<ScrapperResponseContext<R>>>()\n for (const fn of config.outputPipeline ?? [])\n outputMw.add(fn as MiddlewareFn<ScrapperResponseContext<R>>)\n const hasInput = (config.inputPipeline ?? []).length > 0\n const hasOutput = (config.outputPipeline ?? []).length > 0\n\n // Build the schema, conditionally exposing `format` only when the factory is neutral.\n const extra: Record<string, Schema> =\n resultFormat === 'either'\n ? {\n format: validator\n .string()\n .valid('normalized', 'raw')\n .default('normalized')\n .description('Output shape: \"normalized\" (trimmed) or \"raw\" (full Scrapper JSON).'),\n }\n : {}\n const inputSchema = buildScrapperSchema(verb.specs, fixed, defaults, extra)\n\n return new Tool({\n name: toolName,\n description: config.description ?? verb.defaultDescription,\n inputSchema,\n artifactConstructor,\n handler: async (args) => {\n const a = args as Record<string, unknown> & { url: string; format?: 'normalized' | 'raw' }\n try {\n const format: 'normalized' | 'raw' =\n resultFormat === 'either' ? (a.format ?? 'normalized') : resultFormat\n\n const headers: ToolHeaders = {\n Accept: 'application/json',\n ...(await resolveHeaders(config.headers)),\n }\n\n const params = buildWireParams(a, verb.specs, fixed, config.fixedQuery)\n const stash = new Map<string, unknown>()\n\n const requestCtx: ScrapperRequestContext = {\n toolName,\n url: a.url,\n params,\n headers,\n instanceUrl,\n stash,\n shortCircuit: makeShortCircuit(),\n }\n\n if (hasInput) {\n const short = await runInputPipeline(inputMw, requestCtx, 'Scrapper')\n if (short !== undefined) return short\n }\n\n const url = new URL(verb.endpoint, instanceUrl + '/')\n url.searchParams.set('url', requestCtx.url)\n for (const [k, v] of Object.entries(requestCtx.params)) url.searchParams.set(k, v)\n\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), requestTimeoutMs)\n let response: Response\n try {\n response = await fetch(url, {\n method: 'GET',\n headers: requestCtx.headers,\n signal: controller.signal,\n })\n } finally {\n clearTimeout(timer)\n }\n\n if (!response.ok) {\n let body: unknown\n try {\n body = await response.json()\n } catch {\n body = undefined\n }\n return `Error: Scrapper request failed — ${parseScrapperError(body, response.status, response.statusText)}.`\n }\n\n const body = (await response.json()) as Record<string, unknown>\n\n const responseCtx: ScrapperResponseContext<R> = {\n toolName,\n request: requestCtx,\n raw: body,\n result: verb.normalize(body),\n format,\n stash,\n }\n\n if (hasOutput) await runOutputPipeline(outputMw, responseCtx, 'Scrapper')\n\n if (typeof responseCtx.output === 'string') return responseCtx.output\n if (responseCtx.format === 'raw') return JSON.stringify(responseCtx.raw, null, 2)\n return JSON.stringify(responseCtx.result, null, 2)\n } catch (err) {\n if (isShortCircuit(err)) return err.result\n return `Error: ${isError(err) ? err.message : String(err)}`\n }\n },\n })\n}\n\n/** Validate `instanceUrl` and return the trailing-slash-normalised base. */\nexport const validateScrapperInstanceUrl = (config: { instanceUrl?: string }): string => {\n if (typeof config?.instanceUrl !== 'string' || config.instanceUrl.trim() === '') {\n failConfig('instanceUrl is required')\n }\n try {\n new URL(config.instanceUrl as string)\n } catch {\n failConfig(`instanceUrl is not a valid URL: ${config.instanceUrl}`)\n }\n return (config.instanceUrl as string).replace(/\\/+$/, '')\n}\n","/**\n * Factories for configured Scrapper web-extraction tools (article + links).\n *\n * @module @nhtio/adk/batteries/tools/scrapper\n *\n * @remarks\n * [Scrapper](https://github.com/amerkurev/scrapper) is a self-hosted service that loads a page in a\n * real headless browser and extracts either the readable article (`/api/article`) or the page's\n * links (`/api/links`). It gives an agent browser-grade reading power — JS-rendered pages a\n * renderless fetcher can't see — but as a **stateless** HTTP call: each request runs in a fresh\n * incognito context, stores no session or credentials, and shares nothing with any other call.\n *\n * Like the SearXNG battery, this exports **factories** (not ready-made `Tool` constants), because a\n * scrape tool needs per-deployment config (instance URL + custom auth headers). Two verbs, each with\n * an async factory ({@link createScrapperArticleTool} / {@link createScrapperLinksTool}, accepting a\n * dynamic-import `artifact` resolver) and a sync variant ({@link createScrapperArticleToolSync} /\n * {@link createScrapperLinksToolSync}). Because these are factories, they MUST NOT be bulk-registered\n * via `Object.values(batteries)` — call one, then register the returned tool.\n *\n * @see https://github.com/amerkurev/scrapper\n */\n\nimport { validator } from '@nhtio/validation'\nimport { SpooledJsonArtifact } from '@nhtio/adk/spooled_artifact'\nimport { resolveArtifact, resolveArtifactSync } from '../_shared'\nimport {\n failConfig,\n validateScrapperInstanceUrl,\n assembleScrapperTool,\n type ScrapperBaseConfig,\n type ScrapperParamSpec,\n type ScrapperVerb,\n} from './shared'\nimport type { Tool } from '@nhtio/adk/forge'\nimport type { ArtifactResolver, SyncArtifactResolver } from '../_shared'\n\nexport { E_INVALID_SCRAPPER_CONFIG } from './exceptions'\nexport type {\n ScrapperRequestContext,\n ScrapperResponseContext,\n ScrapperInputMiddlewareFn,\n ScrapperOutputMiddlewareFn,\n} from './shared'\n\n// ── Param sets ───────────────────────────────────────────────────────────────\n\n/** Model-facing params common to both verbs (snake_case; mapped to kebab on the wire). */\nexport interface ScrapperCommonParams {\n /** Return a cached result when available instead of re-scraping. */\n cache?: boolean\n /** Capture a screenshot; the result carries a `screenshotUri`. */\n screenshot?: boolean\n /** Run in an incognito browser context (no persisted browsing data). Default true upstream. */\n incognito?: boolean\n /** Browser navigation timeout in ms (`0` disables). Distinct from the tool's own fetch timeout. */\n timeout?: number\n /** When navigation is considered finished. */\n wait_until?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit'\n /** Wait this many ms after load before parsing. */\n sleep?: number\n /** Scroll down N pixels for lazy-loading pages. Requires a positive `sleep`. */\n scroll_down?: number\n /** Emulated device, e.g. `Desktop Chrome`. Overrides individual viewport/UA settings. */\n device?: string\n /** Explicit user-agent (prefer `device`). */\n user_agent?: string\n /** Extra headers the SCRAPER's browser sends to the TARGET site, `K:v;K2:v2` (NOT instance auth). */\n extra_http_headers?: string\n /** Upstream proxy, e.g. `http://host:3128` or `socks5://host:1080`. */\n proxy_server?: string\n}\n\n/** Model-facing params for `/api/article`. */\nexport interface ScrapperArticleParams extends ScrapperCommonParams {\n /** Populate `fullContent` with the page's full HTML. */\n full_content?: boolean\n}\n\n/** Model-facing params for `/api/links`. */\nexport interface ScrapperLinksParams extends ScrapperCommonParams {\n /** Median link-text length threshold for the link parser. */\n text_len_threshold?: number\n /** Median words-per-link threshold for the link parser. */\n words_threshold?: number\n}\n\nconst commonSpecs: ScrapperParamSpec[] = [\n {\n key: 'cache',\n wire: 'cache',\n type: 'boolean',\n schema: validator.boolean(),\n description: 'Return a cached result when available instead of re-scraping.',\n },\n {\n key: 'screenshot',\n wire: 'screenshot',\n type: 'boolean',\n schema: validator.boolean(),\n description: 'Capture a screenshot; the result carries a screenshotUri.',\n },\n {\n key: 'incognito',\n wire: 'incognito',\n type: 'boolean',\n schema: validator.boolean(),\n description: 'Run in an incognito browser context (no persisted data).',\n },\n {\n key: 'timeout',\n wire: 'timeout',\n type: 'number',\n schema: validator.number().min(0),\n description: 'Browser navigation timeout in ms (0 disables).',\n },\n {\n key: 'wait_until',\n wire: 'wait-until',\n type: 'string',\n schema: validator.string().valid('load', 'domcontentloaded', 'networkidle', 'commit'),\n description: 'When navigation is considered finished.',\n },\n {\n key: 'sleep',\n wire: 'sleep',\n type: 'number',\n schema: validator.number().min(0),\n description: 'Wait this many ms after load before parsing.',\n },\n {\n key: 'scroll_down',\n wire: 'scroll-down',\n type: 'number',\n schema: validator.number().min(0),\n description: 'Scroll down N pixels for lazy-loading pages (requires a positive sleep).',\n },\n {\n key: 'device',\n wire: 'device',\n type: 'string',\n schema: validator.string(),\n description: 'Emulated device, e.g. \"Desktop Chrome\".',\n },\n {\n key: 'user_agent',\n wire: 'user-agent',\n type: 'string',\n schema: validator.string(),\n description: 'Explicit user-agent (prefer device).',\n },\n {\n key: 'extra_http_headers',\n wire: 'extra-http-headers',\n type: 'string',\n schema: validator.string(),\n description: 'Extra headers the scraper sends to the TARGET site, formatted \"K:v;K2:v2\".',\n },\n {\n key: 'proxy_server',\n wire: 'proxy-server',\n type: 'string',\n schema: validator.string(),\n description: 'Upstream proxy, e.g. \"http://host:3128\" or \"socks5://host:1080\".',\n },\n]\n\nconst articleSpecs: ScrapperParamSpec[] = [\n ...commonSpecs,\n {\n key: 'full_content',\n wire: 'full-content',\n type: 'boolean',\n schema: validator.boolean(),\n description: 'Populate fullContent with the page full HTML.',\n },\n]\n\nconst linksSpecs: ScrapperParamSpec[] = [\n ...commonSpecs,\n {\n key: 'text_len_threshold',\n wire: 'text-len-threshold',\n type: 'number',\n schema: validator.number().min(0),\n description: 'Median link-text length threshold for the link parser.',\n },\n {\n key: 'words_threshold',\n wire: 'words-threshold',\n type: 'number',\n schema: validator.number().min(0),\n description: 'Median words-per-link threshold for the link parser.',\n },\n]\n\n// ── Normalised result shapes ─────────────────────────────────────────────────\n\n/** A normalised Scrapper article (loose/nullable upstream). */\nexport interface ScrapperArticle {\n /** The page URL the article was extracted from. */\n url?: string\n /** Article title. */\n title?: string\n /** Author / byline metadata. */\n byline?: string\n /** Short excerpt or description of the article. */\n excerpt?: string\n /** Name of the site the article came from. */\n siteName?: string\n /** Detected content language. */\n lang?: string\n /** Character count of the extracted article text. */\n length?: number\n /** Publication time, when the page exposed one. */\n publishedTime?: string\n /** Scrapper's own date field for the result. */\n date?: string\n /** Article text with HTML stripped. */\n textContent?: string\n /** Processed article HTML; present when the caller requested it. */\n content?: string\n /** Full page HTML; present only when `full_content` was set. */\n fullContent?: string\n /** Screenshot URI; present only when `screenshot` was set. */\n screenshotUri?: string\n}\n\n/** A single link from `/api/links` (verified live: `{ url, text }`). */\nexport interface ScrapperLink {\n /** The link's target URL. */\n url?: string\n /** The link's anchor text. */\n text?: string\n}\n\n/** A normalised Scrapper links payload. */\nexport interface ScrapperLinks {\n /** The page URL the links were collected from. */\n url?: string\n /** The page title. */\n title?: string\n /** The page's domain. */\n domain?: string\n /** Scrapper's own date field for the result. */\n date?: string\n /** The collected links, each `{ url, text }`. */\n links: ScrapperLink[]\n /** Screenshot URI; present only when `screenshot` was set. */\n screenshotUri?: string\n}\n\nconst str = (v: unknown): string | undefined => (typeof v === 'string' ? v : undefined)\nconst num = (v: unknown): number | undefined => (typeof v === 'number' ? v : undefined)\n\nconst normalizeArticle = (body: Record<string, unknown>): ScrapperArticle => {\n const out: ScrapperArticle = {}\n out.url = str(body.url)\n out.title = str(body.title)\n out.byline = str(body.byline)\n out.excerpt = str(body.excerpt)\n out.siteName = str(body.siteName)\n out.lang = str(body.lang)\n out.length = num(body.length)\n out.publishedTime = str(body.publishedTime)\n out.date = str(body.date)\n out.textContent = str(body.textContent)\n if (str(body.content)) out.content = str(body.content)\n if (str(body.fullContent)) out.fullContent = str(body.fullContent)\n if (str(body.screenshotUri)) out.screenshotUri = str(body.screenshotUri)\n // Drop undefined keys so the serialised payload stays tight.\n return JSON.parse(JSON.stringify(out)) as ScrapperArticle\n}\n\nconst normalizeLinks = (body: Record<string, unknown>): ScrapperLinks => {\n const rawLinks = Array.isArray(body.links) ? body.links : []\n const links: ScrapperLink[] = rawLinks.map((l) => {\n const r = (l ?? {}) as Record<string, unknown>\n const item: ScrapperLink = {}\n if (str(r.url)) item.url = str(r.url)\n if (str(r.text)) item.text = str(r.text)\n return item\n })\n const out: ScrapperLinks = { links }\n if (str(body.url)) out.url = str(body.url)\n if (str(body.title)) out.title = str(body.title)\n if (str(body.domain)) out.domain = str(body.domain)\n if (str(body.date)) out.date = str(body.date)\n if (str(body.screenshotUri)) out.screenshotUri = str(body.screenshotUri)\n return out\n}\n\nconst articleVerb: ScrapperVerb<ScrapperArticle> = {\n endpoint: '/api/article',\n specs: articleSpecs,\n defaultName: 'scrapper_article',\n defaultDescription:\n 'Load a web page in a real (headless) browser and extract its readable article — title, ' +\n 'byline, text content, and metadata. Renders JavaScript-heavy pages a plain fetch cannot. ' +\n 'Each call is stateless (fresh incognito context, no stored session).',\n normalize: normalizeArticle,\n}\n\nconst linksVerb: ScrapperVerb<ScrapperLinks> = {\n endpoint: '/api/links',\n specs: linksSpecs,\n defaultName: 'scrapper_links',\n defaultDescription:\n 'Load a web page in a real (headless) browser and collect its article/navigation links ' +\n '(each { url, text }). Renders JavaScript-heavy index pages a plain fetch cannot. ' +\n 'Each call is stateless (fresh incognito context, no stored session).',\n normalize: normalizeLinks,\n}\n\n// ── Config aliases ────────────────────────────────────────────────────────────\n\n/** Async-factory config for `/api/article` (full `artifact` resolver, incl. dynamic import). */\nexport type ScrapperArticleConfig = ScrapperBaseConfig<\n ScrapperArticleParams,\n ScrapperArticle,\n ArtifactResolver\n>\n/** Sync-factory config for `/api/article` (`artifact` narrowed to the sync subset). */\nexport type ScrapperArticleConfigSync = ScrapperBaseConfig<\n ScrapperArticleParams,\n ScrapperArticle,\n SyncArtifactResolver\n>\n/** Async-factory config for `/api/links`. */\nexport type ScrapperLinksConfig = ScrapperBaseConfig<\n ScrapperLinksParams,\n ScrapperLinks,\n ArtifactResolver\n>\n/** Sync-factory config for `/api/links`. */\nexport type ScrapperLinksConfigSync = ScrapperBaseConfig<\n ScrapperLinksParams,\n ScrapperLinks,\n SyncArtifactResolver\n>\n\nconst defaultArtifact = () => SpooledJsonArtifact\n\n// ── Factories ──────────────────────────────────────────────────────────────────\n\n/**\n * Create a configured Scrapper **article** {@link Tool} (async — accepts a dynamic-import `artifact`).\n *\n * @remarks\n * Async because `artifact` may be an async / dynamic-import resolver, which must resolve to the sync\n * `() => Ctor` `Tool.artifactConstructor` requires before the tool is built. For the common case,\n * use {@link createScrapperArticleToolSync} and skip the `await`.\n *\n * @warning\n * Two distinct \"headers\": `config.headers` authenticates to the Scrapper *instance*; the\n * `extra_http_headers` *parameter* is what the scraper's browser sends to the *target site* — do not\n * conflate them. Also note `scroll_down` requires a positive `sleep`, and `resultUri`/`screenshotUri`\n * are instance-relative and may come back `http://` even over HTTPS — do not assume they match\n * `instanceUrl`.\n *\n * @param config - Instance URL, instance-auth headers, output policy, `artifact` resolver,\n * per-parameter disposition (`fixed`/`defaults`/`fixedQuery`), and middleware pipelines.\n * @returns A promise of a `Tool` ready to register in a `ToolRegistry`.\n * @throws {@link E_INVALID_SCRAPPER_CONFIG} when `instanceUrl` or `artifact` is invalid.\n */\nexport const createScrapperArticleTool = async (config: ScrapperArticleConfig): Promise<Tool> => {\n const instanceUrl = validateScrapperInstanceUrl(config)\n const artifact = await resolveArtifact(config.artifact ?? defaultArtifact, failConfig)\n return assembleScrapperTool(articleVerb, config, instanceUrl, artifact)\n}\n\n/**\n * Synchronous {@link createScrapperArticleTool} — `artifact` narrowed to the sync subset.\n *\n * @param config - Same as {@link createScrapperArticleTool}, with a sync-only `artifact`.\n * @returns A `Tool` ready to register in a `ToolRegistry`.\n * @throws {@link E_INVALID_SCRAPPER_CONFIG} when `instanceUrl` or `artifact` is invalid (incl. an async resolver).\n */\nexport const createScrapperArticleToolSync = (config: ScrapperArticleConfigSync): Tool => {\n const instanceUrl = validateScrapperInstanceUrl(config)\n const artifact = resolveArtifactSync(config.artifact ?? defaultArtifact, failConfig)\n return assembleScrapperTool(articleVerb, config, instanceUrl, artifact)\n}\n\n/**\n * Create a configured Scrapper **links** {@link Tool} (async — accepts a dynamic-import `artifact`).\n *\n * @remarks\n * See {@link createScrapperArticleTool} for the two-headers caveat and the async rationale. Each\n * `links` item is `{ url, text }`.\n *\n * @param config - Instance URL, instance-auth headers, output policy, `artifact` resolver,\n * per-parameter disposition, and middleware pipelines.\n * @returns A promise of a `Tool` ready to register in a `ToolRegistry`.\n * @throws {@link E_INVALID_SCRAPPER_CONFIG} when `instanceUrl` or `artifact` is invalid.\n */\nexport const createScrapperLinksTool = async (config: ScrapperLinksConfig): Promise<Tool> => {\n const instanceUrl = validateScrapperInstanceUrl(config)\n const artifact = await resolveArtifact(config.artifact ?? defaultArtifact, failConfig)\n return assembleScrapperTool(linksVerb, config, instanceUrl, artifact)\n}\n\n/**\n * Synchronous {@link createScrapperLinksTool} — `artifact` narrowed to the sync subset.\n *\n * @param config - Same as {@link createScrapperLinksTool}, with a sync-only `artifact`.\n * @returns A `Tool` ready to register in a `ToolRegistry`.\n * @throws {@link E_INVALID_SCRAPPER_CONFIG} when `instanceUrl` or `artifact` is invalid (incl. an async resolver).\n */\nexport const createScrapperLinksToolSync = (config: ScrapperLinksConfigSync): Tool => {\n const instanceUrl = validateScrapperInstanceUrl(config)\n const artifact = resolveArtifactSync(config.artifact ?? defaultArtifact, failConfig)\n return assembleScrapperTool(linksVerb, config, instanceUrl, artifact)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,4BAA4B,mBAAA,gBACvC,6BACA,oCACA,6BACA,KACA,IACF;;;;;;;;;;;;ACEA,IAAM,0BAA0B;;AAGhC,IAAa,cAAc,WAA0B;CACnD,MAAM,IAAI,0BAA0B,CAAC,MAAM,CAAC;AAC9C;;AAyBA,IAAM,UAAU,UAA2B,OAAO,KAAK;;;;;;AAOvD,IAAa,uBACX,OACA,OACA,UACA,QAAgC,CAAC,MACtB;CACX,MAAM,QAAgC,EACpC,KAAK,kBAAA,UAAU,OAAO,EAAE,SAAS,EAAE,YAAY,uCAAuC,EACxF;CACA,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,SAAS,KAAK,OAAO,OAAO;EAChC,IAAI,MAAM,KAAK;EACf,IAAI,YAAY,KAAK,OAAO,UAC1B,MAAM,IAAI,QAAQ,SAAS,KAAK,IAAa;OAE7C,MAAM,IAAI,SAAS;EAErB,MAAM,KAAK,OAAO,IAAI,YAAY,KAAK,WAAW;CACpD;CACA,OAAO,kBAAA,UAAU,OAAO;EAAE,GAAG;EAAO,GAAG;CAAM,CAAC;AAChD;;;;;;AAOA,IAAa,mBACX,MACA,OACA,OACA,eAC2B;CAC3B,MAAM,MAA8B,CAAC;CACrC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,QAAQ,SAAS,KAAK,OAAO,QAAQ,MAAM,KAAK,OAAO,KAAK,KAAK;EACvE,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,IAAI,KAAK,QAAQ,OAAO,KAAK;CAC1E;CAC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