@steipete/summarize 0.10.0 → 0.11.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 (374) hide show
  1. package/CHANGELOG.md +80 -28
  2. package/README.md +115 -30
  3. package/dist/cli.js +1 -1
  4. package/dist/esm/cache.js +67 -65
  5. package/dist/esm/cache.js.map +1 -1
  6. package/dist/esm/cli-main.js +27 -27
  7. package/dist/esm/cli-main.js.map +1 -1
  8. package/dist/esm/cli.js +2 -2
  9. package/dist/esm/cli.js.map +1 -1
  10. package/dist/esm/config.js +310 -166
  11. package/dist/esm/config.js.map +1 -1
  12. package/dist/esm/content/asset.js +53 -50
  13. package/dist/esm/content/asset.js.map +1 -1
  14. package/dist/esm/content/index.js +1 -1
  15. package/dist/esm/content/index.js.map +1 -1
  16. package/dist/esm/costs.js +1 -1
  17. package/dist/esm/costs.js.map +1 -1
  18. package/dist/esm/daemon/agent.js +165 -164
  19. package/dist/esm/daemon/agent.js.map +1 -1
  20. package/dist/esm/daemon/auto-mode.js +3 -3
  21. package/dist/esm/daemon/auto-mode.js.map +1 -1
  22. package/dist/esm/daemon/chat.js +16 -14
  23. package/dist/esm/daemon/chat.js.map +1 -1
  24. package/dist/esm/daemon/cli-entrypoint.js +72 -0
  25. package/dist/esm/daemon/cli-entrypoint.js.map +1 -0
  26. package/dist/esm/daemon/cli.js +63 -87
  27. package/dist/esm/daemon/cli.js.map +1 -1
  28. package/dist/esm/daemon/config.js +15 -15
  29. package/dist/esm/daemon/config.js.map +1 -1
  30. package/dist/esm/daemon/constants.js +6 -6
  31. package/dist/esm/daemon/constants.js.map +1 -1
  32. package/dist/esm/daemon/env-merge.js.map +1 -1
  33. package/dist/esm/daemon/env-snapshot.js +36 -31
  34. package/dist/esm/daemon/env-snapshot.js.map +1 -1
  35. package/dist/esm/daemon/flow-context.js +59 -28
  36. package/dist/esm/daemon/flow-context.js.map +1 -1
  37. package/dist/esm/daemon/launchd.js +100 -55
  38. package/dist/esm/daemon/launchd.js.map +1 -1
  39. package/dist/esm/daemon/meta.js +5 -5
  40. package/dist/esm/daemon/meta.js.map +1 -1
  41. package/dist/esm/daemon/models.js +54 -31
  42. package/dist/esm/daemon/models.js.map +1 -1
  43. package/dist/esm/daemon/process-registry.js +15 -15
  44. package/dist/esm/daemon/process-registry.js.map +1 -1
  45. package/dist/esm/daemon/schtasks.js +42 -42
  46. package/dist/esm/daemon/schtasks.js.map +1 -1
  47. package/dist/esm/daemon/server.js +248 -244
  48. package/dist/esm/daemon/server.js.map +1 -1
  49. package/dist/esm/daemon/summarize-progress.js +11 -11
  50. package/dist/esm/daemon/summarize-progress.js.map +1 -1
  51. package/dist/esm/daemon/summarize.js +29 -29
  52. package/dist/esm/daemon/summarize.js.map +1 -1
  53. package/dist/esm/daemon/systemd.js +47 -47
  54. package/dist/esm/daemon/systemd.js.map +1 -1
  55. package/dist/esm/firecrawl.js +12 -12
  56. package/dist/esm/firecrawl.js.map +1 -1
  57. package/dist/esm/flags.js +32 -32
  58. package/dist/esm/flags.js.map +1 -1
  59. package/dist/esm/index.js +3 -3
  60. package/dist/esm/index.js.map +1 -1
  61. package/dist/esm/language.js +1 -1
  62. package/dist/esm/language.js.map +1 -1
  63. package/dist/esm/llm/cli.js +128 -64
  64. package/dist/esm/llm/cli.js.map +1 -1
  65. package/dist/esm/llm/errors.js +1 -1
  66. package/dist/esm/llm/errors.js.map +1 -1
  67. package/dist/esm/llm/generate-text.js +107 -98
  68. package/dist/esm/llm/generate-text.js.map +1 -1
  69. package/dist/esm/llm/google-models.js +17 -17
  70. package/dist/esm/llm/google-models.js.map +1 -1
  71. package/dist/esm/llm/html-to-markdown.js +3 -3
  72. package/dist/esm/llm/html-to-markdown.js.map +1 -1
  73. package/dist/esm/llm/model-id.js +38 -16
  74. package/dist/esm/llm/model-id.js.map +1 -1
  75. package/dist/esm/llm/prompt.js +5 -5
  76. package/dist/esm/llm/prompt.js.map +1 -1
  77. package/dist/esm/llm/providers/anthropic.js +33 -33
  78. package/dist/esm/llm/providers/anthropic.js.map +1 -1
  79. package/dist/esm/llm/providers/google.js +19 -19
  80. package/dist/esm/llm/providers/google.js.map +1 -1
  81. package/dist/esm/llm/providers/models.js +30 -30
  82. package/dist/esm/llm/providers/models.js.map +1 -1
  83. package/dist/esm/llm/providers/openai.js +35 -34
  84. package/dist/esm/llm/providers/openai.js.map +1 -1
  85. package/dist/esm/llm/providers/shared.js +8 -8
  86. package/dist/esm/llm/providers/shared.js.map +1 -1
  87. package/dist/esm/llm/transcript-to-markdown.js +9 -5
  88. package/dist/esm/llm/transcript-to-markdown.js.map +1 -1
  89. package/dist/esm/llm/usage.js +18 -18
  90. package/dist/esm/llm/usage.js.map +1 -1
  91. package/dist/esm/logging/daemon.js +21 -21
  92. package/dist/esm/logging/daemon.js.map +1 -1
  93. package/dist/esm/logging/ring-file.js +5 -5
  94. package/dist/esm/logging/ring-file.js.map +1 -1
  95. package/dist/esm/markitdown.js +21 -19
  96. package/dist/esm/markitdown.js.map +1 -1
  97. package/dist/esm/media-cache.js +39 -39
  98. package/dist/esm/media-cache.js.map +1 -1
  99. package/dist/esm/model-auto.js +175 -106
  100. package/dist/esm/model-auto.js.map +1 -1
  101. package/dist/esm/model-spec.js +52 -42
  102. package/dist/esm/model-spec.js.map +1 -1
  103. package/dist/esm/pricing/litellm.js +4 -4
  104. package/dist/esm/pricing/litellm.js.map +1 -1
  105. package/dist/esm/processes.js +1 -1
  106. package/dist/esm/processes.js.map +1 -1
  107. package/dist/esm/prompts/index.js +1 -1
  108. package/dist/esm/prompts/index.js.map +1 -1
  109. package/dist/esm/refresh-free.js +81 -81
  110. package/dist/esm/refresh-free.js.map +1 -1
  111. package/dist/esm/run/attachments.js +47 -44
  112. package/dist/esm/run/attachments.js.map +1 -1
  113. package/dist/esm/run/bird.js +26 -26
  114. package/dist/esm/run/bird.js.map +1 -1
  115. package/dist/esm/run/cache-state.js +7 -7
  116. package/dist/esm/run/cache-state.js.map +1 -1
  117. package/dist/esm/run/cli-fallback-state.js +45 -0
  118. package/dist/esm/run/cli-fallback-state.js.map +1 -0
  119. package/dist/esm/run/cli-preflight.js +24 -24
  120. package/dist/esm/run/cli-preflight.js.map +1 -1
  121. package/dist/esm/run/constants.js +12 -12
  122. package/dist/esm/run/constants.js.map +1 -1
  123. package/dist/esm/run/cookies/twitter.js +47 -47
  124. package/dist/esm/run/cookies/twitter.js.map +1 -1
  125. package/dist/esm/run/env.js +21 -15
  126. package/dist/esm/run/env.js.map +1 -1
  127. package/dist/esm/run/fetch-with-timeout.js +4 -4
  128. package/dist/esm/run/fetch-with-timeout.js.map +1 -1
  129. package/dist/esm/run/finish-line.js +68 -68
  130. package/dist/esm/run/finish-line.js.map +1 -1
  131. package/dist/esm/run/flows/asset/extract.js +15 -15
  132. package/dist/esm/run/flows/asset/extract.js.map +1 -1
  133. package/dist/esm/run/flows/asset/input.js +47 -66
  134. package/dist/esm/run/flows/asset/input.js.map +1 -1
  135. package/dist/esm/run/flows/asset/media-policy.js +1 -1
  136. package/dist/esm/run/flows/asset/media-policy.js.map +1 -1
  137. package/dist/esm/run/flows/asset/media.js +49 -40
  138. package/dist/esm/run/flows/asset/media.js.map +1 -1
  139. package/dist/esm/run/flows/asset/output.js +12 -12
  140. package/dist/esm/run/flows/asset/output.js.map +1 -1
  141. package/dist/esm/run/flows/asset/preprocess.js +79 -44
  142. package/dist/esm/run/flows/asset/preprocess.js.map +1 -1
  143. package/dist/esm/run/flows/asset/summary.js +173 -106
  144. package/dist/esm/run/flows/asset/summary.js.map +1 -1
  145. package/dist/esm/run/flows/url/extract.js +26 -26
  146. package/dist/esm/run/flows/url/extract.js.map +1 -1
  147. package/dist/esm/run/flows/url/flow.js +104 -98
  148. package/dist/esm/run/flows/url/flow.js.map +1 -1
  149. package/dist/esm/run/flows/url/markdown.js +57 -57
  150. package/dist/esm/run/flows/url/markdown.js.map +1 -1
  151. package/dist/esm/run/flows/url/slides-output.js +61 -59
  152. package/dist/esm/run/flows/url/slides-output.js.map +1 -1
  153. package/dist/esm/run/flows/url/slides-text.js +85 -85
  154. package/dist/esm/run/flows/url/slides-text.js.map +1 -1
  155. package/dist/esm/run/flows/url/summary.js +174 -107
  156. package/dist/esm/run/flows/url/summary.js.map +1 -1
  157. package/dist/esm/run/format.js +10 -10
  158. package/dist/esm/run/format.js.map +1 -1
  159. package/dist/esm/run/help.js +141 -135
  160. package/dist/esm/run/help.js.map +1 -1
  161. package/dist/esm/run/logging.js +10 -10
  162. package/dist/esm/run/logging.js.map +1 -1
  163. package/dist/esm/run/markdown.js +12 -12
  164. package/dist/esm/run/markdown.js.map +1 -1
  165. package/dist/esm/run/media-cache-state.js +5 -5
  166. package/dist/esm/run/media-cache-state.js.map +1 -1
  167. package/dist/esm/run/model-attempts.js.map +1 -1
  168. package/dist/esm/run/openrouter.js +11 -11
  169. package/dist/esm/run/openrouter.js.map +1 -1
  170. package/dist/esm/run/progress.js +1 -1
  171. package/dist/esm/run/progress.js.map +1 -1
  172. package/dist/esm/run/run-config.js +16 -16
  173. package/dist/esm/run/run-config.js.map +1 -1
  174. package/dist/esm/run/run-context.js +2 -2
  175. package/dist/esm/run/run-context.js.map +1 -1
  176. package/dist/esm/run/run-env.js +55 -54
  177. package/dist/esm/run/run-env.js.map +1 -1
  178. package/dist/esm/run/run-input.js +3 -3
  179. package/dist/esm/run/run-input.js.map +1 -1
  180. package/dist/esm/run/run-metrics.js +16 -16
  181. package/dist/esm/run/run-metrics.js.map +1 -1
  182. package/dist/esm/run/run-models.js +28 -23
  183. package/dist/esm/run/run-models.js.map +1 -1
  184. package/dist/esm/run/run-output.js +3 -3
  185. package/dist/esm/run/run-output.js.map +1 -1
  186. package/dist/esm/run/run-settings.js +83 -34
  187. package/dist/esm/run/run-settings.js.map +1 -1
  188. package/dist/esm/run/run-stream.js +4 -4
  189. package/dist/esm/run/run-stream.js.map +1 -1
  190. package/dist/esm/run/runner.js +166 -127
  191. package/dist/esm/run/runner.js.map +1 -1
  192. package/dist/esm/run/slides-cli.js +43 -42
  193. package/dist/esm/run/slides-cli.js.map +1 -1
  194. package/dist/esm/run/slides-render.js +36 -36
  195. package/dist/esm/run/slides-render.js.map +1 -1
  196. package/dist/esm/run/stdin-temp-file.js +77 -0
  197. package/dist/esm/run/stdin-temp-file.js.map +1 -0
  198. package/dist/esm/run/stream-output.js +7 -7
  199. package/dist/esm/run/stream-output.js.map +1 -1
  200. package/dist/esm/run/streaming.js +16 -16
  201. package/dist/esm/run/streaming.js.map +1 -1
  202. package/dist/esm/run/summary-engine.js +57 -51
  203. package/dist/esm/run/summary-engine.js.map +1 -1
  204. package/dist/esm/run/summary-llm.js +3 -3
  205. package/dist/esm/run/summary-llm.js.map +1 -1
  206. package/dist/esm/run/terminal.js +4 -4
  207. package/dist/esm/run/terminal.js.map +1 -1
  208. package/dist/esm/run/tips.js +2 -2
  209. package/dist/esm/run/tips.js.map +1 -1
  210. package/dist/esm/run/transcriber-cli.js +49 -49
  211. package/dist/esm/run/transcriber-cli.js.map +1 -1
  212. package/dist/esm/run.js +1 -1
  213. package/dist/esm/run.js.map +1 -1
  214. package/dist/esm/shared/contracts.js +1 -1
  215. package/dist/esm/shared/contracts.js.map +1 -1
  216. package/dist/esm/shared/sse-events.js +16 -16
  217. package/dist/esm/shared/sse-events.js.map +1 -1
  218. package/dist/esm/shared/streaming-merge.js +3 -3
  219. package/dist/esm/shared/streaming-merge.js.map +1 -1
  220. package/dist/esm/slides/extract.js +258 -249
  221. package/dist/esm/slides/extract.js.map +1 -1
  222. package/dist/esm/slides/index.js +3 -3
  223. package/dist/esm/slides/index.js.map +1 -1
  224. package/dist/esm/slides/settings.js +14 -14
  225. package/dist/esm/slides/settings.js.map +1 -1
  226. package/dist/esm/slides/store.js +9 -9
  227. package/dist/esm/slides/store.js.map +1 -1
  228. package/dist/esm/tty/format.js +13 -13
  229. package/dist/esm/tty/format.js.map +1 -1
  230. package/dist/esm/tty/osc-progress.js +1 -1
  231. package/dist/esm/tty/osc-progress.js.map +1 -1
  232. package/dist/esm/tty/progress/fetch-html.js +14 -14
  233. package/dist/esm/tty/progress/fetch-html.js.map +1 -1
  234. package/dist/esm/tty/progress/transcript.js +70 -62
  235. package/dist/esm/tty/progress/transcript.js.map +1 -1
  236. package/dist/esm/tty/spinner.js +20 -9
  237. package/dist/esm/tty/spinner.js.map +1 -1
  238. package/dist/esm/tty/theme.js +92 -92
  239. package/dist/esm/tty/theme.js.map +1 -1
  240. package/dist/esm/tty/website-progress.js +32 -32
  241. package/dist/esm/tty/website-progress.js.map +1 -1
  242. package/dist/esm/version.js +29 -29
  243. package/dist/esm/version.js.map +1 -1
  244. package/dist/types/cache.d.ts +6 -6
  245. package/dist/types/config.d.ts +49 -7
  246. package/dist/types/content/asset.d.ts +8 -6
  247. package/dist/types/content/index.d.ts +1 -1
  248. package/dist/types/costs.d.ts +3 -3
  249. package/dist/types/daemon/agent.d.ts +1 -1
  250. package/dist/types/daemon/auto-mode.d.ts +3 -3
  251. package/dist/types/daemon/chat.d.ts +2 -2
  252. package/dist/types/daemon/cli-entrypoint.d.ts +2 -0
  253. package/dist/types/daemon/config.d.ts +2 -2
  254. package/dist/types/daemon/env-merge.d.ts +1 -1
  255. package/dist/types/daemon/env-snapshot.d.ts +1 -1
  256. package/dist/types/daemon/flow-context.d.ts +7 -7
  257. package/dist/types/daemon/launchd.d.ts +8 -0
  258. package/dist/types/daemon/models.d.ts +6 -2
  259. package/dist/types/daemon/process-registry.d.ts +5 -5
  260. package/dist/types/daemon/server.d.ts +2 -2
  261. package/dist/types/daemon/summarize-progress.d.ts +1 -1
  262. package/dist/types/daemon/summarize.d.ts +7 -7
  263. package/dist/types/firecrawl.d.ts +1 -1
  264. package/dist/types/flags.d.ts +11 -11
  265. package/dist/types/index.d.ts +4 -4
  266. package/dist/types/language.d.ts +1 -1
  267. package/dist/types/llm/attachments.d.ts +1 -1
  268. package/dist/types/llm/cli.d.ts +3 -3
  269. package/dist/types/llm/generate-text.d.ts +7 -7
  270. package/dist/types/llm/html-to-markdown.d.ts +3 -3
  271. package/dist/types/llm/model-id.d.ts +1 -1
  272. package/dist/types/llm/prompt.d.ts +2 -2
  273. package/dist/types/llm/providers/anthropic.d.ts +3 -3
  274. package/dist/types/llm/providers/google.d.ts +3 -3
  275. package/dist/types/llm/providers/models.d.ts +2 -2
  276. package/dist/types/llm/providers/openai.d.ts +4 -4
  277. package/dist/types/llm/providers/shared.d.ts +2 -2
  278. package/dist/types/llm/transcript-to-markdown.d.ts +4 -2
  279. package/dist/types/llm/usage.d.ts +1 -1
  280. package/dist/types/logging/daemon.d.ts +4 -4
  281. package/dist/types/markitdown.d.ts +1 -1
  282. package/dist/types/media-cache.d.ts +2 -2
  283. package/dist/types/model-auto.d.ts +14 -4
  284. package/dist/types/model-spec.d.ts +10 -10
  285. package/dist/types/pricing/litellm.d.ts +1 -1
  286. package/dist/types/processes.d.ts +1 -1
  287. package/dist/types/prompts/index.d.ts +1 -1
  288. package/dist/types/run/attachments.d.ts +7 -7
  289. package/dist/types/run/bird.d.ts +2 -2
  290. package/dist/types/run/cache-state.d.ts +2 -2
  291. package/dist/types/run/cli-fallback-state.d.ts +6 -0
  292. package/dist/types/run/constants.d.ts +1 -1
  293. package/dist/types/run/cookies/twitter.d.ts +1 -1
  294. package/dist/types/run/env.d.ts +1 -1
  295. package/dist/types/run/finish-line.d.ts +5 -5
  296. package/dist/types/run/flows/asset/extract.d.ts +4 -4
  297. package/dist/types/run/flows/asset/input.d.ts +9 -3
  298. package/dist/types/run/flows/asset/media.d.ts +1 -1
  299. package/dist/types/run/flows/asset/output.d.ts +5 -5
  300. package/dist/types/run/flows/asset/preprocess.d.ts +23 -17
  301. package/dist/types/run/flows/asset/summary.d.ts +19 -17
  302. package/dist/types/run/flows/url/extract.d.ts +1 -1
  303. package/dist/types/run/flows/url/flow.d.ts +1 -1
  304. package/dist/types/run/flows/url/markdown.d.ts +6 -6
  305. package/dist/types/run/flows/url/slides-output.d.ts +7 -7
  306. package/dist/types/run/flows/url/slides-text.d.ts +9 -9
  307. package/dist/types/run/flows/url/summary.d.ts +11 -11
  308. package/dist/types/run/flows/url/types.d.ts +26 -22
  309. package/dist/types/run/format.d.ts +3 -3
  310. package/dist/types/run/help.d.ts +1 -1
  311. package/dist/types/run/media-cache-state.d.ts +2 -2
  312. package/dist/types/run/model-attempts.d.ts +1 -1
  313. package/dist/types/run/run-config.d.ts +4 -4
  314. package/dist/types/run/run-context.d.ts +3 -1
  315. package/dist/types/run/run-env.d.ts +3 -1
  316. package/dist/types/run/run-input.d.ts +2 -2
  317. package/dist/types/run/run-metrics.d.ts +3 -3
  318. package/dist/types/run/run-models.d.ts +3 -2
  319. package/dist/types/run/run-output.d.ts +1 -1
  320. package/dist/types/run/run-settings.d.ts +15 -6
  321. package/dist/types/run/run-stream.d.ts +2 -2
  322. package/dist/types/run/runner.d.ts +3 -2
  323. package/dist/types/run/slides-render.d.ts +4 -4
  324. package/dist/types/run/stdin-temp-file.d.ts +9 -0
  325. package/dist/types/run/stream-output.d.ts +1 -1
  326. package/dist/types/run/streaming.d.ts +4 -4
  327. package/dist/types/run/summary-engine.d.ts +11 -11
  328. package/dist/types/run/summary-llm.d.ts +5 -5
  329. package/dist/types/run/types.d.ts +4 -4
  330. package/dist/types/run.d.ts +1 -1
  331. package/dist/types/shared/contracts.d.ts +2 -2
  332. package/dist/types/shared/sse-events.d.ts +9 -9
  333. package/dist/types/slides/extract.d.ts +5 -4
  334. package/dist/types/slides/index.d.ts +5 -5
  335. package/dist/types/slides/store.d.ts +2 -2
  336. package/dist/types/slides/types.d.ts +2 -2
  337. package/dist/types/tty/osc-progress.d.ts +5 -5
  338. package/dist/types/tty/progress/fetch-html.d.ts +3 -3
  339. package/dist/types/tty/progress/transcript.d.ts +3 -3
  340. package/dist/types/tty/spinner.d.ts +2 -2
  341. package/dist/types/tty/theme.d.ts +2 -2
  342. package/dist/types/tty/website-progress.d.ts +3 -3
  343. package/dist/types/version.d.ts +1 -1
  344. package/docs/agent.md +38 -4
  345. package/docs/assets/site.js +46 -46
  346. package/docs/chrome-extension.md +11 -5
  347. package/docs/cli.md +59 -13
  348. package/docs/config.md +59 -10
  349. package/docs/extract-only.md +2 -0
  350. package/docs/index.html +33 -14
  351. package/docs/llm.md +7 -4
  352. package/docs/media.md +5 -4
  353. package/docs/model-auto.md +3 -2
  354. package/docs/nvidia-onnx-transcription.md +3 -3
  355. package/docs/openai.md +1 -1
  356. package/docs/releasing.md +3 -0
  357. package/docs/site/404.html +4 -1
  358. package/docs/site/assets/site.js +46 -46
  359. package/docs/site/docs/chrome-extension.html +18 -6
  360. package/docs/site/docs/config.html +29 -8
  361. package/docs/site/docs/extract-only.html +16 -4
  362. package/docs/site/docs/firecrawl.html +12 -3
  363. package/docs/site/docs/index.html +35 -6
  364. package/docs/site/docs/llm.html +19 -5
  365. package/docs/site/docs/openai.html +18 -5
  366. package/docs/site/docs/website.html +29 -9
  367. package/docs/site/docs/youtube.html +12 -3
  368. package/docs/site/index.html +33 -14
  369. package/docs/slides.md +13 -5
  370. package/docs/smoketest.md +29 -20
  371. package/docs/timestamps.md +21 -0
  372. package/docs/website.md +2 -1
  373. package/docs/youtube.md +4 -0
  374. package/package.json +36 -35
@@ -1,10 +1,10 @@
1
- import { completeSimple, getModel, streamSimple } from '@mariozechner/pi-ai';
2
- import { buildPromptHash } from '../cache.js';
3
- import { createSyntheticModel } from '../llm/providers/shared.js';
4
- import { buildAutoModelAttempts } from '../model-auto.js';
5
- import { resolveRunContextState } from '../run/run-context.js';
6
- import { resolveModelSelection } from '../run/run-models.js';
7
- import { resolveRunOverrides } from '../run/run-settings.js';
1
+ import { completeSimple, getModel, streamSimple } from "@mariozechner/pi-ai";
2
+ import { buildPromptHash } from "../cache.js";
3
+ import { createSyntheticModel } from "../llm/providers/shared.js";
4
+ import { buildAutoModelAttempts, envHasKey } from "../model-auto.js";
5
+ import { resolveRunContextState } from "../run/run-context.js";
6
+ import { resolveModelSelection } from "../run/run-models.js";
7
+ import { resolveRunOverrides } from "../run/run-settings.js";
8
8
  const AGENT_PROMPT_AUTOMATION = `You are Summarize Automation, not Claude.
9
9
 
10
10
  # Purpose
@@ -45,239 +45,239 @@ export function buildAgentPromptHash(automationEnabled) {
45
45
  }
46
46
  const TOOL_DEFINITIONS = {
47
47
  navigate: {
48
- name: 'navigate',
49
- description: 'Navigate the active tab to a URL, list open tabs, or switch tabs. Use this for ALL navigation. Never use window.location/history in code.',
48
+ name: "navigate",
49
+ description: "Navigate the active tab to a URL, list open tabs, or switch tabs. Use this for ALL navigation. Never use window.location/history in code.",
50
50
  parameters: {
51
- type: 'object',
51
+ type: "object",
52
52
  additionalProperties: false,
53
53
  properties: {
54
- url: { type: 'string', description: 'URL to navigate to' },
55
- newTab: { type: 'boolean', description: 'Open in a new tab', default: false },
56
- listTabs: { type: 'boolean', description: 'List open tabs in the current window' },
57
- switchToTab: { type: 'number', description: 'Tab ID to switch to' },
54
+ url: { type: "string", description: "URL to navigate to" },
55
+ newTab: { type: "boolean", description: "Open in a new tab", default: false },
56
+ listTabs: { type: "boolean", description: "List open tabs in the current window" },
57
+ switchToTab: { type: "number", description: "Tab ID to switch to" },
58
58
  },
59
59
  },
60
60
  },
61
61
  repl: {
62
- name: 'repl',
63
- description: 'Execute JavaScript in a sandbox. Helpers: browserjs(fn), navigate(), sleep(ms), returnFile(), createOrUpdateArtifact(), getArtifact(), listArtifacts(), deleteArtifact().',
62
+ name: "repl",
63
+ description: "Execute JavaScript in a sandbox. Helpers: browserjs(fn), navigate(), sleep(ms), returnFile(), createOrUpdateArtifact(), getArtifact(), listArtifacts(), deleteArtifact().",
64
64
  parameters: {
65
- type: 'object',
65
+ type: "object",
66
66
  additionalProperties: false,
67
67
  properties: {
68
- title: { type: 'string', description: 'Short description of the code intent' },
69
- code: { type: 'string', description: 'JavaScript code to execute' },
68
+ title: { type: "string", description: "Short description of the code intent" },
69
+ code: { type: "string", description: "JavaScript code to execute" },
70
70
  },
71
- required: ['title', 'code'],
71
+ required: ["title", "code"],
72
72
  },
73
73
  },
74
74
  ask_user_which_element: {
75
- name: 'ask_user_which_element',
76
- description: 'Ask the user to click the desired element in the page.',
75
+ name: "ask_user_which_element",
76
+ description: "Ask the user to click the desired element in the page.",
77
77
  parameters: {
78
- type: 'object',
78
+ type: "object",
79
79
  additionalProperties: false,
80
80
  properties: {
81
- message: { type: 'string', description: 'Optional instruction shown to the user' },
81
+ message: { type: "string", description: "Optional instruction shown to the user" },
82
82
  },
83
83
  },
84
84
  },
85
85
  skill: {
86
- name: 'skill',
87
- description: 'Create, update, list, or delete domain-specific automation libraries that auto-inject into browserjs().',
86
+ name: "skill",
87
+ description: "Create, update, list, or delete domain-specific automation libraries that auto-inject into browserjs().",
88
88
  parameters: {
89
- type: 'object',
89
+ type: "object",
90
90
  additionalProperties: false,
91
91
  properties: {
92
92
  action: {
93
- type: 'string',
94
- enum: ['get', 'list', 'create', 'rewrite', 'update', 'delete'],
95
- description: 'Action to perform',
93
+ type: "string",
94
+ enum: ["get", "list", "create", "rewrite", "update", "delete"],
95
+ description: "Action to perform",
96
96
  },
97
97
  name: {
98
- type: 'string',
99
- description: 'Skill name (required for get/rewrite/update/delete)',
98
+ type: "string",
99
+ description: "Skill name (required for get/rewrite/update/delete)",
100
100
  },
101
101
  url: {
102
- type: 'string',
103
- description: 'URL to filter skills by (optional for list action; defaults to current tab)',
102
+ type: "string",
103
+ description: "URL to filter skills by (optional for list action; defaults to current tab)",
104
104
  },
105
105
  includeLibraryCode: {
106
- type: 'boolean',
107
- description: 'Use with get action to include library code in output (only needed when editing library code).',
106
+ type: "boolean",
107
+ description: "Use with get action to include library code in output (only needed when editing library code).",
108
108
  },
109
109
  data: {
110
- type: 'object',
110
+ type: "object",
111
111
  additionalProperties: false,
112
112
  properties: {
113
- name: { type: 'string', description: 'Unique skill name' },
113
+ name: { type: "string", description: "Unique skill name" },
114
114
  domainPatterns: {
115
- type: 'array',
116
- items: { type: 'string' },
115
+ type: "array",
116
+ items: { type: "string" },
117
117
  description: 'Glob-like domain patterns (e.g., ["github.com", "github.com/*/issues"])',
118
118
  },
119
- shortDescription: { type: 'string', description: 'One-line description' },
120
- description: { type: 'string', description: 'Full markdown description' },
121
- examples: { type: 'string', description: 'Plain JavaScript examples' },
122
- library: { type: 'string', description: 'JavaScript library code to inject' },
119
+ shortDescription: { type: "string", description: "One-line description" },
120
+ description: { type: "string", description: "Full markdown description" },
121
+ examples: { type: "string", description: "Plain JavaScript examples" },
122
+ library: { type: "string", description: "JavaScript library code to inject" },
123
123
  },
124
124
  },
125
125
  updates: {
126
- type: 'object',
126
+ type: "object",
127
127
  additionalProperties: false,
128
128
  properties: {
129
129
  name: {
130
- type: 'object',
130
+ type: "object",
131
131
  properties: {
132
- old_string: { type: 'string' },
133
- new_string: { type: 'string' },
132
+ old_string: { type: "string" },
133
+ new_string: { type: "string" },
134
134
  },
135
135
  },
136
136
  shortDescription: {
137
- type: 'object',
137
+ type: "object",
138
138
  properties: {
139
- old_string: { type: 'string' },
140
- new_string: { type: 'string' },
139
+ old_string: { type: "string" },
140
+ new_string: { type: "string" },
141
141
  },
142
142
  },
143
143
  domainPatterns: {
144
- type: 'object',
144
+ type: "object",
145
145
  properties: {
146
- old_string: { type: 'string' },
147
- new_string: { type: 'string' },
146
+ old_string: { type: "string" },
147
+ new_string: { type: "string" },
148
148
  },
149
149
  },
150
150
  description: {
151
- type: 'object',
151
+ type: "object",
152
152
  properties: {
153
- old_string: { type: 'string' },
154
- new_string: { type: 'string' },
153
+ old_string: { type: "string" },
154
+ new_string: { type: "string" },
155
155
  },
156
156
  },
157
157
  examples: {
158
- type: 'object',
158
+ type: "object",
159
159
  properties: {
160
- old_string: { type: 'string' },
161
- new_string: { type: 'string' },
160
+ old_string: { type: "string" },
161
+ new_string: { type: "string" },
162
162
  },
163
163
  },
164
164
  library: {
165
- type: 'object',
165
+ type: "object",
166
166
  properties: {
167
- old_string: { type: 'string' },
168
- new_string: { type: 'string' },
167
+ old_string: { type: "string" },
168
+ new_string: { type: "string" },
169
169
  },
170
170
  },
171
171
  },
172
172
  },
173
173
  },
174
- required: ['action'],
174
+ required: ["action"],
175
175
  },
176
176
  },
177
177
  artifacts: {
178
- name: 'artifacts',
179
- description: 'Create, read, update, list, or delete session artifacts (notes, CSVs, JSON, binary files).',
178
+ name: "artifacts",
179
+ description: "Create, read, update, list, or delete session artifacts (notes, CSVs, JSON, binary files).",
180
180
  parameters: {
181
- type: 'object',
181
+ type: "object",
182
182
  additionalProperties: false,
183
183
  properties: {
184
184
  action: {
185
- type: 'string',
186
- enum: ['list', 'get', 'create', 'update', 'delete'],
187
- description: 'Action to perform',
185
+ type: "string",
186
+ enum: ["list", "get", "create", "update", "delete"],
187
+ description: "Action to perform",
188
188
  },
189
189
  fileName: {
190
- type: 'string',
191
- description: 'Artifact filename (required for get/create/update/delete)',
190
+ type: "string",
191
+ description: "Artifact filename (required for get/create/update/delete)",
192
192
  },
193
193
  content: {
194
- description: 'Content to store (string or JSON-serializable object)',
195
- type: ['string', 'object', 'array', 'number', 'boolean', 'null'],
194
+ description: "Content to store (string or JSON-serializable object)",
195
+ type: ["string", "object", "array", "number", "boolean", "null"],
196
196
  },
197
- mimeType: { type: 'string', description: 'Optional MIME type override' },
198
- contentBase64: { type: 'string', description: 'Base64 payload for binary files' },
197
+ mimeType: { type: "string", description: "Optional MIME type override" },
198
+ contentBase64: { type: "string", description: "Base64 payload for binary files" },
199
199
  asBase64: {
200
- type: 'boolean',
201
- description: 'Return base64 payload for get action instead of parsed text/JSON',
200
+ type: "boolean",
201
+ description: "Return base64 payload for get action instead of parsed text/JSON",
202
202
  },
203
203
  },
204
- required: ['action'],
204
+ required: ["action"],
205
205
  },
206
206
  },
207
207
  summarize: {
208
- name: 'summarize',
209
- description: 'Run Summarize on a URL (summary or extract-only). Use extractOnly + format=markdown to return Markdown.',
208
+ name: "summarize",
209
+ description: "Run Summarize on a URL (summary or extract-only). Use extractOnly + format=markdown to return Markdown.",
210
210
  parameters: {
211
- type: 'object',
211
+ type: "object",
212
212
  additionalProperties: false,
213
213
  properties: {
214
- url: { type: 'string', description: 'URL to summarize (defaults to active tab)' },
214
+ url: { type: "string", description: "URL to summarize (defaults to active tab)" },
215
215
  extractOnly: {
216
- type: 'boolean',
217
- description: 'Extract content only (no summary)',
216
+ type: "boolean",
217
+ description: "Extract content only (no summary)",
218
218
  default: false,
219
219
  },
220
220
  format: {
221
- type: 'string',
222
- enum: ['text', 'markdown'],
223
- description: 'Extraction format when extractOnly is true (default: text)',
221
+ type: "string",
222
+ enum: ["text", "markdown"],
223
+ description: "Extraction format when extractOnly is true (default: text)",
224
224
  },
225
225
  markdownMode: {
226
- type: 'string',
227
- enum: ['off', 'auto', 'llm', 'readability'],
228
- description: 'Markdown conversion mode (only when format=markdown)',
226
+ type: "string",
227
+ enum: ["off", "auto", "llm", "readability"],
228
+ description: "Markdown conversion mode (only when format=markdown)",
229
229
  },
230
- model: { type: 'string', description: 'Model override (e.g. openai/gpt-5-mini)' },
231
- length: { type: 'string', description: 'Summary length (short|medium|long|xl|...)' },
232
- language: { type: 'string', description: 'Output language (auto or tag)' },
233
- prompt: { type: 'string', description: 'Prompt override' },
234
- timeout: { type: 'string', description: 'Timeout (e.g. 30s, 2m)' },
235
- maxOutputTokens: { type: 'string', description: 'Max output tokens (e.g. 2k)' },
236
- noCache: { type: 'boolean', description: 'Bypass cache' },
230
+ model: { type: "string", description: "Model override (e.g. openai/gpt-5-mini)" },
231
+ length: { type: "string", description: "Summary length (short|medium|long|xl|...)" },
232
+ language: { type: "string", description: "Output language (auto or tag)" },
233
+ prompt: { type: "string", description: "Prompt override" },
234
+ timeout: { type: "string", description: "Timeout (e.g. 30s, 2m)" },
235
+ maxOutputTokens: { type: "string", description: "Max output tokens (e.g. 2k)" },
236
+ noCache: { type: "boolean", description: "Bypass cache" },
237
237
  firecrawl: {
238
- type: 'string',
239
- enum: ['off', 'auto', 'always'],
240
- description: 'Firecrawl mode',
238
+ type: "string",
239
+ enum: ["off", "auto", "always"],
240
+ description: "Firecrawl mode",
241
241
  },
242
242
  preprocess: {
243
- type: 'string',
244
- enum: ['off', 'auto', 'always'],
245
- description: 'Preprocess/markitdown mode',
243
+ type: "string",
244
+ enum: ["off", "auto", "always"],
245
+ description: "Preprocess/markitdown mode",
246
246
  },
247
247
  youtube: {
248
- type: 'string',
249
- enum: ['auto', 'web', 'yt-dlp', 'apify', 'no-auto'],
250
- description: 'YouTube transcript mode',
248
+ type: "string",
249
+ enum: ["auto", "web", "yt-dlp", "apify", "no-auto"],
250
+ description: "YouTube transcript mode",
251
251
  },
252
252
  videoMode: {
253
- type: 'string',
254
- enum: ['auto', 'transcript', 'understand'],
255
- description: 'Video mode',
253
+ type: "string",
254
+ enum: ["auto", "transcript", "understand"],
255
+ description: "Video mode",
256
256
  },
257
- timestamps: { type: 'boolean', description: 'Include transcript timestamps' },
257
+ timestamps: { type: "boolean", description: "Include transcript timestamps" },
258
258
  forceSummary: {
259
- type: 'boolean',
260
- description: 'Force LLM summary even when content is shorter than requested length',
259
+ type: "boolean",
260
+ description: "Force LLM summary even when content is shorter than requested length",
261
261
  },
262
- maxCharacters: { type: 'number', description: 'Max characters for extraction' },
262
+ maxCharacters: { type: "number", description: "Max characters for extraction" },
263
263
  },
264
264
  },
265
265
  },
266
266
  debugger: {
267
- name: 'debugger',
268
- description: 'Run JavaScript in the main world via the Chrome debugger. LAST RESORT; shows a banner to the user.',
267
+ name: "debugger",
268
+ description: "Run JavaScript in the main world via the Chrome debugger. LAST RESORT; shows a banner to the user.",
269
269
  parameters: {
270
- type: 'object',
270
+ type: "object",
271
271
  additionalProperties: false,
272
272
  properties: {
273
273
  action: {
274
- type: 'string',
275
- enum: ['eval'],
276
- description: 'Action to perform',
274
+ type: "string",
275
+ enum: ["eval"],
276
+ description: "Action to perform",
277
277
  },
278
- code: { type: 'string', description: 'JavaScript to evaluate in the main world' },
278
+ code: { type: "string", description: "JavaScript to evaluate in the main world" },
279
279
  },
280
- required: ['action', 'code'],
280
+ required: ["action", "code"],
281
281
  },
282
282
  },
283
283
  };
@@ -286,7 +286,7 @@ function buildSystemPrompt({ pageUrl, pageTitle, pageContent, automationEnabled,
286
286
  return `${base}
287
287
 
288
288
  Page URL: ${pageUrl}
289
- ${pageTitle ? `Page Title: ${pageTitle}` : ''}
289
+ ${pageTitle ? `Page Title: ${pageTitle}` : ""}
290
290
 
291
291
  <page_content>
292
292
  ${pageContent}
@@ -298,14 +298,13 @@ function normalizeMessages(raw) {
298
298
  return [];
299
299
  const out = [];
300
300
  for (const item of raw) {
301
- if (!item || typeof item !== 'object')
301
+ if (!item || typeof item !== "object")
302
302
  continue;
303
303
  const role = item.role;
304
- if (role !== 'user' && role !== 'assistant' && role !== 'toolResult')
304
+ if (role !== "user" && role !== "assistant" && role !== "toolResult")
305
305
  continue;
306
306
  const msg = item;
307
- if (!msg.timestamp || typeof msg.timestamp !== 'number') {
308
- ;
307
+ if (!msg.timestamp || typeof msg.timestamp !== "number") {
309
308
  msg.timestamp = Date.now();
310
309
  }
311
310
  out.push(msg);
@@ -314,9 +313,9 @@ function normalizeMessages(raw) {
314
313
  }
315
314
  function parseProviderModelId(modelId) {
316
315
  const trimmed = modelId.trim();
317
- const slash = trimmed.indexOf('/');
316
+ const slash = trimmed.indexOf("/");
318
317
  if (slash === -1) {
319
- return { provider: 'openai', model: trimmed };
318
+ return { provider: "openai", model: trimmed };
320
319
  }
321
320
  const provider = trimmed.slice(0, slash);
322
321
  const model = trimmed.slice(slash + 1);
@@ -336,17 +335,17 @@ function resolveModelWithFallback({ provider, modelId, baseUrl, }) {
336
335
  return createSyntheticModel({
337
336
  provider: provider,
338
337
  modelId,
339
- api: 'openai-completions',
338
+ api: "openai-completions",
340
339
  baseUrl,
341
340
  allowImages: false,
342
341
  });
343
342
  }
344
- if (provider === 'openrouter') {
343
+ if (provider === "openrouter") {
345
344
  return createSyntheticModel({
346
- provider: 'openrouter',
345
+ provider: "openrouter",
347
346
  modelId,
348
- api: 'openai-completions',
349
- baseUrl: 'https://openrouter.ai/api/v1',
347
+ api: "openai-completions",
348
+ baseUrl: "https://openrouter.ai/api/v1",
350
349
  allowImages: false,
351
350
  });
352
351
  }
@@ -354,27 +353,27 @@ function resolveModelWithFallback({ provider, modelId, baseUrl, }) {
354
353
  }
355
354
  }
356
355
  const REQUIRED_ENV_BY_PROVIDER = {
357
- openrouter: 'OPENROUTER_API_KEY',
358
- openai: 'OPENAI_API_KEY',
359
- anthropic: 'ANTHROPIC_API_KEY',
360
- google: 'GEMINI_API_KEY',
361
- xai: 'XAI_API_KEY',
362
- zai: 'Z_AI_API_KEY',
356
+ openrouter: "OPENROUTER_API_KEY",
357
+ openai: "OPENAI_API_KEY",
358
+ anthropic: "ANTHROPIC_API_KEY",
359
+ google: "GEMINI_API_KEY",
360
+ xai: "XAI_API_KEY",
361
+ zai: "Z_AI_API_KEY",
363
362
  };
364
363
  function resolveApiKeyForModel({ model, apiKeys, }) {
365
364
  const resolved = (() => {
366
365
  switch (model.provider) {
367
- case 'openrouter':
366
+ case "openrouter":
368
367
  return apiKeys.openrouterApiKey;
369
- case 'openai':
368
+ case "openai":
370
369
  return apiKeys.openaiApiKey;
371
- case 'anthropic':
370
+ case "anthropic":
372
371
  return apiKeys.anthropicApiKey;
373
- case 'google':
372
+ case "google":
374
373
  return apiKeys.googleApiKey;
375
- case 'xai':
374
+ case "xai":
376
375
  return apiKeys.xaiApiKey;
377
- case 'zai':
376
+ case "zai":
378
377
  return apiKeys.zaiApiKey;
379
378
  default:
380
379
  return null;
@@ -392,7 +391,7 @@ async function resolveAgentModel({ env, pageContent, modelOverride, }) {
392
391
  const { config, configPath, configForCli, apiKey, openrouterApiKey, anthropicApiKey, googleApiKey, xaiApiKey, zaiApiKey, providerBaseUrls, zaiBaseUrl, envForAuto, cliAvailability, } = resolveRunContextState({
393
392
  env,
394
393
  envForRun: env,
395
- programOpts: { videoMode: 'auto' },
394
+ programOpts: { videoMode: "auto" },
396
395
  languageExplicitlySet: false,
397
396
  videoModeExplicitlySet: false,
398
397
  cliFlagPresent: false,
@@ -426,12 +425,12 @@ async function resolveAgentModel({ env, pageContent, modelOverride, }) {
426
425
  const baseUrl = providerBaseUrlMap[provider] ?? null;
427
426
  return resolveModelWithFallback({ provider, modelId, baseUrl });
428
427
  };
429
- if (requestedModel.kind === 'fixed') {
430
- if (requestedModel.transport === 'cli') {
431
- throw new Error('CLI models are not supported in the daemon');
428
+ if (requestedModel.kind === "fixed") {
429
+ if (requestedModel.transport === "cli") {
430
+ throw new Error("CLI models are not supported in the daemon");
432
431
  }
433
- if (requestedModel.transport === 'openrouter') {
434
- const provider = 'openrouter';
432
+ if (requestedModel.transport === "openrouter") {
433
+ const provider = "openrouter";
435
434
  const modelId = requestedModel.openrouterModelId;
436
435
  return { model: applyBaseUrlOverride(provider, modelId), maxOutputTokens, apiKeys };
437
436
  }
@@ -439,11 +438,11 @@ async function resolveAgentModel({ env, pageContent, modelOverride, }) {
439
438
  return { model: applyBaseUrlOverride(provider, model), maxOutputTokens, apiKeys };
440
439
  }
441
440
  if (!isFallbackModel) {
442
- throw new Error('No model available for agent');
441
+ throw new Error("No model available for agent");
443
442
  }
444
443
  const estimatedPromptTokens = Math.ceil(pageContent.length / 4);
445
444
  const attempts = buildAutoModelAttempts({
446
- kind: 'website',
445
+ kind: "website",
447
446
  promptTokens: estimatedPromptTokens,
448
447
  desiredOutputTokens: maxOutputTokens,
449
448
  requiresVideoUnderstanding: false,
@@ -454,16 +453,18 @@ async function resolveAgentModel({ env, pageContent, modelOverride, }) {
454
453
  cliAvailability,
455
454
  });
456
455
  for (const attempt of attempts) {
457
- if (attempt.transport === 'cli')
456
+ if (attempt.transport === "cli")
458
457
  continue;
459
- if (attempt.transport === 'openrouter') {
460
- const modelId = attempt.userModelId.replace(/^openrouter\//i, '');
461
- return { model: applyBaseUrlOverride('openrouter', modelId), maxOutputTokens, apiKeys };
458
+ if (!envHasKey(envForAuto, attempt.requiredEnv))
459
+ continue;
460
+ if (attempt.transport === "openrouter") {
461
+ const modelId = attempt.userModelId.replace(/^openrouter\//i, "");
462
+ return { model: applyBaseUrlOverride("openrouter", modelId), maxOutputTokens, apiKeys };
462
463
  }
463
464
  const { provider, model } = parseProviderModelId(attempt.userModelId);
464
465
  return { model: applyBaseUrlOverride(provider, model), maxOutputTokens, apiKeys };
465
466
  }
466
- throw new Error('No model available for agent');
467
+ throw new Error("No model available for agent");
467
468
  }
468
469
  export async function streamAgentResponse({ env, pageUrl, pageTitle, pageContent, messages, modelOverride, tools, automationEnabled, onChunk, onAssistant, signal, }) {
469
470
  const normalizedMessages = normalizeMessages(messages);
@@ -495,15 +496,15 @@ export async function streamAgentResponse({ env, pageUrl, pageTitle, pageContent
495
496
  });
496
497
  let assistant = null;
497
498
  for await (const event of stream) {
498
- if (event.type === 'text_delta') {
499
+ if (event.type === "text_delta") {
499
500
  onChunk(event.delta);
500
501
  }
501
- else if (event.type === 'done') {
502
+ else if (event.type === "done") {
502
503
  assistant = event.message;
503
504
  break;
504
505
  }
505
- else if (event.type === 'error') {
506
- const message = event.error?.errorMessage || 'Agent stream failed.';
506
+ else if (event.type === "error") {
507
+ const message = event.error?.errorMessage || "Agent stream failed.";
507
508
  throw new Error(message);
508
509
  }
509
510
  }
@@ -511,7 +512,7 @@ export async function streamAgentResponse({ env, pageUrl, pageTitle, pageContent
511
512
  assistant = await stream.result().catch(() => null);
512
513
  }
513
514
  if (!assistant) {
514
- throw new Error('Agent stream ended without a result.');
515
+ throw new Error("Agent stream ended without a result.");
515
516
  }
516
517
  onAssistant(assistant);
517
518
  }