meetsoma 0.3.2 → 0.3.3

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 (515) hide show
  1. package/dist/thin-cli.js +56 -13
  2. package/package.json +42 -89
  3. package/bin/gum +0 -0
  4. package/dist/bun/cli.d.ts +0 -3
  5. package/dist/bun/cli.d.ts.map +0 -1
  6. package/dist/bun/cli.js +0 -7
  7. package/dist/bun/cli.js.map +0 -1
  8. package/dist/bun/register-bedrock.d.ts +0 -2
  9. package/dist/bun/register-bedrock.d.ts.map +0 -1
  10. package/dist/bun/register-bedrock.js +0 -4
  11. package/dist/bun/register-bedrock.js.map +0 -1
  12. package/dist/cli/args.d.ts +0 -49
  13. package/dist/cli/args.d.ts.map +0 -1
  14. package/dist/cli/args.js +0 -304
  15. package/dist/cli/args.js.map +0 -1
  16. package/dist/cli/config-selector.d.ts +0 -14
  17. package/dist/cli/config-selector.d.ts.map +0 -1
  18. package/dist/cli/config-selector.js +0 -31
  19. package/dist/cli/config-selector.js.map +0 -1
  20. package/dist/cli/file-processor.d.ts +0 -15
  21. package/dist/cli/file-processor.d.ts.map +0 -1
  22. package/dist/cli/file-processor.js +0 -83
  23. package/dist/cli/file-processor.js.map +0 -1
  24. package/dist/cli/initial-message.d.ts +0 -18
  25. package/dist/cli/initial-message.d.ts.map +0 -1
  26. package/dist/cli/initial-message.js +0 -22
  27. package/dist/cli/initial-message.js.map +0 -1
  28. package/dist/cli/list-models.d.ts +0 -9
  29. package/dist/cli/list-models.d.ts.map +0 -1
  30. package/dist/cli/list-models.js +0 -92
  31. package/dist/cli/list-models.js.map +0 -1
  32. package/dist/cli/session-picker.d.ts +0 -9
  33. package/dist/cli/session-picker.d.ts.map +0 -1
  34. package/dist/cli/session-picker.js +0 -35
  35. package/dist/cli/session-picker.js.map +0 -1
  36. package/dist/cli.d.ts +0 -3
  37. package/dist/cli.d.ts.map +0 -1
  38. package/dist/cli.js +0 -601
  39. package/dist/cli.js.map +0 -1
  40. package/dist/config.d.ts +0 -68
  41. package/dist/config.d.ts.map +0 -1
  42. package/dist/config.js +0 -203
  43. package/dist/config.js.map +0 -1
  44. package/dist/core/agent-session-runtime.d.ts +0 -134
  45. package/dist/core/agent-session-runtime.d.ts.map +0 -1
  46. package/dist/core/agent-session-runtime.js +0 -264
  47. package/dist/core/agent-session-runtime.js.map +0 -1
  48. package/dist/core/agent-session.d.ts +0 -585
  49. package/dist/core/agent-session.d.ts.map +0 -1
  50. package/dist/core/agent-session.js +0 -2497
  51. package/dist/core/agent-session.js.map +0 -1
  52. package/dist/core/auth-storage.d.ts +0 -132
  53. package/dist/core/auth-storage.d.ts.map +0 -1
  54. package/dist/core/auth-storage.js +0 -422
  55. package/dist/core/auth-storage.js.map +0 -1
  56. package/dist/core/bash-executor.d.ts +0 -46
  57. package/dist/core/bash-executor.d.ts.map +0 -1
  58. package/dist/core/bash-executor.js +0 -113
  59. package/dist/core/bash-executor.js.map +0 -1
  60. package/dist/core/compaction/branch-summarization.d.ts +0 -88
  61. package/dist/core/compaction/branch-summarization.d.ts.map +0 -1
  62. package/dist/core/compaction/branch-summarization.js +0 -243
  63. package/dist/core/compaction/branch-summarization.js.map +0 -1
  64. package/dist/core/compaction/compaction.d.ts +0 -121
  65. package/dist/core/compaction/compaction.d.ts.map +0 -1
  66. package/dist/core/compaction/compaction.js +0 -613
  67. package/dist/core/compaction/compaction.js.map +0 -1
  68. package/dist/core/compaction/index.d.ts +0 -7
  69. package/dist/core/compaction/index.d.ts.map +0 -1
  70. package/dist/core/compaction/index.js +0 -7
  71. package/dist/core/compaction/index.js.map +0 -1
  72. package/dist/core/compaction/utils.d.ts +0 -38
  73. package/dist/core/compaction/utils.d.ts.map +0 -1
  74. package/dist/core/compaction/utils.js +0 -153
  75. package/dist/core/compaction/utils.js.map +0 -1
  76. package/dist/core/defaults.d.ts +0 -3
  77. package/dist/core/defaults.d.ts.map +0 -1
  78. package/dist/core/defaults.js +0 -2
  79. package/dist/core/defaults.js.map +0 -1
  80. package/dist/core/diagnostics.d.ts +0 -15
  81. package/dist/core/diagnostics.d.ts.map +0 -1
  82. package/dist/core/diagnostics.js +0 -2
  83. package/dist/core/diagnostics.js.map +0 -1
  84. package/dist/core/event-bus.d.ts +0 -9
  85. package/dist/core/event-bus.d.ts.map +0 -1
  86. package/dist/core/event-bus.js +0 -25
  87. package/dist/core/event-bus.js.map +0 -1
  88. package/dist/core/exec.d.ts +0 -29
  89. package/dist/core/exec.d.ts.map +0 -1
  90. package/dist/core/exec.js +0 -75
  91. package/dist/core/exec.js.map +0 -1
  92. package/dist/core/export-html/ansi-to-html.d.ts +0 -22
  93. package/dist/core/export-html/ansi-to-html.d.ts.map +0 -1
  94. package/dist/core/export-html/ansi-to-html.js +0 -249
  95. package/dist/core/export-html/ansi-to-html.js.map +0 -1
  96. package/dist/core/export-html/index.d.ts +0 -37
  97. package/dist/core/export-html/index.d.ts.map +0 -1
  98. package/dist/core/export-html/index.js +0 -224
  99. package/dist/core/export-html/index.js.map +0 -1
  100. package/dist/core/export-html/template.css +0 -1001
  101. package/dist/core/export-html/template.html +0 -55
  102. package/dist/core/export-html/template.js +0 -1690
  103. package/dist/core/export-html/tool-renderer.d.ts +0 -40
  104. package/dist/core/export-html/tool-renderer.d.ts.map +0 -1
  105. package/dist/core/export-html/tool-renderer.js +0 -95
  106. package/dist/core/export-html/tool-renderer.js.map +0 -1
  107. package/dist/core/export-html/vendor/highlight.min.js +0 -1213
  108. package/dist/core/export-html/vendor/marked.min.js +0 -6
  109. package/dist/core/extensions/index.d.ts +0 -12
  110. package/dist/core/extensions/index.d.ts.map +0 -1
  111. package/dist/core/extensions/index.js +0 -9
  112. package/dist/core/extensions/index.js.map +0 -1
  113. package/dist/core/extensions/loader.d.ts +0 -25
  114. package/dist/core/extensions/loader.d.ts.map +0 -1
  115. package/dist/core/extensions/loader.js +0 -436
  116. package/dist/core/extensions/loader.js.map +0 -1
  117. package/dist/core/extensions/runner.d.ts +0 -148
  118. package/dist/core/extensions/runner.d.ts.map +0 -1
  119. package/dist/core/extensions/runner.js +0 -700
  120. package/dist/core/extensions/runner.js.map +0 -1
  121. package/dist/core/extensions/types.d.ts +0 -1076
  122. package/dist/core/extensions/types.d.ts.map +0 -1
  123. package/dist/core/extensions/types.js +0 -35
  124. package/dist/core/extensions/types.js.map +0 -1
  125. package/dist/core/extensions/wrapper.d.ts +0 -20
  126. package/dist/core/extensions/wrapper.d.ts.map +0 -1
  127. package/dist/core/extensions/wrapper.js +0 -22
  128. package/dist/core/extensions/wrapper.js.map +0 -1
  129. package/dist/core/footer-data-provider.d.ts +0 -48
  130. package/dist/core/footer-data-provider.d.ts.map +0 -1
  131. package/dist/core/footer-data-provider.js +0 -314
  132. package/dist/core/footer-data-provider.js.map +0 -1
  133. package/dist/core/index.d.ts +0 -11
  134. package/dist/core/index.d.ts.map +0 -1
  135. package/dist/core/index.js +0 -11
  136. package/dist/core/index.js.map +0 -1
  137. package/dist/core/keybindings.d.ts +0 -285
  138. package/dist/core/keybindings.d.ts.map +0 -1
  139. package/dist/core/keybindings.js +0 -251
  140. package/dist/core/keybindings.js.map +0 -1
  141. package/dist/core/messages.d.ts +0 -77
  142. package/dist/core/messages.d.ts.map +0 -1
  143. package/dist/core/messages.js +0 -123
  144. package/dist/core/messages.js.map +0 -1
  145. package/dist/core/model-registry.d.ts +0 -132
  146. package/dist/core/model-registry.d.ts.map +0 -1
  147. package/dist/core/model-registry.js +0 -583
  148. package/dist/core/model-registry.js.map +0 -1
  149. package/dist/core/model-resolver.d.ts +0 -110
  150. package/dist/core/model-resolver.d.ts.map +0 -1
  151. package/dist/core/model-resolver.js +0 -486
  152. package/dist/core/model-resolver.js.map +0 -1
  153. package/dist/core/output-guard.d.ts +0 -6
  154. package/dist/core/output-guard.d.ts.map +0 -1
  155. package/dist/core/output-guard.js +0 -59
  156. package/dist/core/output-guard.js.map +0 -1
  157. package/dist/core/package-manager.d.ts +0 -172
  158. package/dist/core/package-manager.d.ts.map +0 -1
  159. package/dist/core/package-manager.js +0 -1783
  160. package/dist/core/package-manager.js.map +0 -1
  161. package/dist/core/prompt-templates.d.ts +0 -51
  162. package/dist/core/prompt-templates.d.ts.map +0 -1
  163. package/dist/core/prompt-templates.js +0 -249
  164. package/dist/core/prompt-templates.js.map +0 -1
  165. package/dist/core/resolve-config-value.d.ts +0 -23
  166. package/dist/core/resolve-config-value.d.ts.map +0 -1
  167. package/dist/core/resolve-config-value.js +0 -126
  168. package/dist/core/resolve-config-value.js.map +0 -1
  169. package/dist/core/resource-loader.d.ts +0 -185
  170. package/dist/core/resource-loader.d.ts.map +0 -1
  171. package/dist/core/resource-loader.js +0 -698
  172. package/dist/core/resource-loader.js.map +0 -1
  173. package/dist/core/sdk.d.ts +0 -93
  174. package/dist/core/sdk.d.ts.map +0 -1
  175. package/dist/core/sdk.js +0 -236
  176. package/dist/core/sdk.js.map +0 -1
  177. package/dist/core/session-manager.d.ts +0 -332
  178. package/dist/core/session-manager.d.ts.map +0 -1
  179. package/dist/core/session-manager.js +0 -1104
  180. package/dist/core/session-manager.js.map +0 -1
  181. package/dist/core/settings-manager.d.ts +0 -237
  182. package/dist/core/settings-manager.d.ts.map +0 -1
  183. package/dist/core/settings-manager.js +0 -702
  184. package/dist/core/settings-manager.js.map +0 -1
  185. package/dist/core/skills.d.ts +0 -60
  186. package/dist/core/skills.d.ts.map +0 -1
  187. package/dist/core/skills.js +0 -409
  188. package/dist/core/skills.js.map +0 -1
  189. package/dist/core/slash-commands.d.ts +0 -14
  190. package/dist/core/slash-commands.d.ts.map +0 -1
  191. package/dist/core/slash-commands.js +0 -23
  192. package/dist/core/slash-commands.js.map +0 -1
  193. package/dist/core/source-info.d.ts +0 -18
  194. package/dist/core/source-info.d.ts.map +0 -1
  195. package/dist/core/source-info.js +0 -19
  196. package/dist/core/source-info.js.map +0 -1
  197. package/dist/core/system-prompt.d.ts +0 -28
  198. package/dist/core/system-prompt.d.ts.map +0 -1
  199. package/dist/core/system-prompt.js +0 -116
  200. package/dist/core/system-prompt.js.map +0 -1
  201. package/dist/core/timings.d.ts +0 -8
  202. package/dist/core/timings.d.ts.map +0 -1
  203. package/dist/core/timings.js +0 -31
  204. package/dist/core/timings.js.map +0 -1
  205. package/dist/core/tools/bash.d.ts +0 -73
  206. package/dist/core/tools/bash.d.ts.map +0 -1
  207. package/dist/core/tools/bash.js +0 -342
  208. package/dist/core/tools/bash.js.map +0 -1
  209. package/dist/core/tools/edit-diff.d.ts +0 -85
  210. package/dist/core/tools/edit-diff.d.ts.map +0 -1
  211. package/dist/core/tools/edit-diff.js +0 -337
  212. package/dist/core/tools/edit-diff.js.map +0 -1
  213. package/dist/core/tools/edit.d.ts +0 -53
  214. package/dist/core/tools/edit.d.ts.map +0 -1
  215. package/dist/core/tools/edit.js +0 -196
  216. package/dist/core/tools/edit.js.map +0 -1
  217. package/dist/core/tools/file-mutation-queue.d.ts +0 -6
  218. package/dist/core/tools/file-mutation-queue.d.ts.map +0 -1
  219. package/dist/core/tools/file-mutation-queue.js +0 -37
  220. package/dist/core/tools/file-mutation-queue.js.map +0 -1
  221. package/dist/core/tools/find.d.ts +0 -46
  222. package/dist/core/tools/find.d.ts.map +0 -1
  223. package/dist/core/tools/find.js +0 -258
  224. package/dist/core/tools/find.js.map +0 -1
  225. package/dist/core/tools/grep.d.ts +0 -56
  226. package/dist/core/tools/grep.d.ts.map +0 -1
  227. package/dist/core/tools/grep.js +0 -293
  228. package/dist/core/tools/grep.js.map +0 -1
  229. package/dist/core/tools/index.d.ts +0 -115
  230. package/dist/core/tools/index.d.ts.map +0 -1
  231. package/dist/core/tools/index.js +0 -86
  232. package/dist/core/tools/index.js.map +0 -1
  233. package/dist/core/tools/ls.d.ts +0 -46
  234. package/dist/core/tools/ls.d.ts.map +0 -1
  235. package/dist/core/tools/ls.js +0 -172
  236. package/dist/core/tools/ls.js.map +0 -1
  237. package/dist/core/tools/path-utils.d.ts +0 -8
  238. package/dist/core/tools/path-utils.d.ts.map +0 -1
  239. package/dist/core/tools/path-utils.js +0 -81
  240. package/dist/core/tools/path-utils.js.map +0 -1
  241. package/dist/core/tools/read.d.ts +0 -46
  242. package/dist/core/tools/read.d.ts.map +0 -1
  243. package/dist/core/tools/read.js +0 -225
  244. package/dist/core/tools/read.js.map +0 -1
  245. package/dist/core/tools/render-utils.d.ts +0 -21
  246. package/dist/core/tools/render-utils.d.ts.map +0 -1
  247. package/dist/core/tools/render-utils.js +0 -49
  248. package/dist/core/tools/render-utils.js.map +0 -1
  249. package/dist/core/tools/tool-definition-wrapper.d.ts +0 -14
  250. package/dist/core/tools/tool-definition-wrapper.d.ts.map +0 -1
  251. package/dist/core/tools/tool-definition-wrapper.js +0 -32
  252. package/dist/core/tools/tool-definition-wrapper.js.map +0 -1
  253. package/dist/core/tools/truncate.d.ts +0 -70
  254. package/dist/core/tools/truncate.d.ts.map +0 -1
  255. package/dist/core/tools/truncate.js +0 -205
  256. package/dist/core/tools/truncate.js.map +0 -1
  257. package/dist/core/tools/write.d.ts +0 -35
  258. package/dist/core/tools/write.d.ts.map +0 -1
  259. package/dist/core/tools/write.js +0 -216
  260. package/dist/core/tools/write.js.map +0 -1
  261. package/dist/index.d.ts +0 -28
  262. package/dist/index.d.ts.map +0 -1
  263. package/dist/index.js +0 -43
  264. package/dist/index.js.map +0 -1
  265. package/dist/lib/config.js +0 -22
  266. package/dist/lib/detect.js +0 -94
  267. package/dist/lib/display.js +0 -182
  268. package/dist/main.d.ts +0 -8
  269. package/dist/main.d.ts.map +0 -1
  270. package/dist/main.js +0 -806
  271. package/dist/main.js.map +0 -1
  272. package/dist/migrations.d.ts +0 -33
  273. package/dist/migrations.d.ts.map +0 -1
  274. package/dist/migrations.js +0 -261
  275. package/dist/migrations.js.map +0 -1
  276. package/dist/modes/index.d.ts +0 -9
  277. package/dist/modes/index.d.ts.map +0 -1
  278. package/dist/modes/index.js +0 -8
  279. package/dist/modes/index.js.map +0 -1
  280. package/dist/modes/interactive/components/armin.d.ts +0 -34
  281. package/dist/modes/interactive/components/armin.d.ts.map +0 -1
  282. package/dist/modes/interactive/components/armin.js +0 -333
  283. package/dist/modes/interactive/components/armin.js.map +0 -1
  284. package/dist/modes/interactive/components/assistant-message.d.ts +0 -18
  285. package/dist/modes/interactive/components/assistant-message.d.ts.map +0 -1
  286. package/dist/modes/interactive/components/assistant-message.js +0 -107
  287. package/dist/modes/interactive/components/assistant-message.js.map +0 -1
  288. package/dist/modes/interactive/components/bash-execution.d.ts +0 -34
  289. package/dist/modes/interactive/components/bash-execution.d.ts.map +0 -1
  290. package/dist/modes/interactive/components/bash-execution.js +0 -175
  291. package/dist/modes/interactive/components/bash-execution.js.map +0 -1
  292. package/dist/modes/interactive/components/bordered-loader.d.ts +0 -16
  293. package/dist/modes/interactive/components/bordered-loader.d.ts.map +0 -1
  294. package/dist/modes/interactive/components/bordered-loader.js +0 -51
  295. package/dist/modes/interactive/components/bordered-loader.js.map +0 -1
  296. package/dist/modes/interactive/components/branch-summary-message.d.ts +0 -16
  297. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +0 -1
  298. package/dist/modes/interactive/components/branch-summary-message.js +0 -44
  299. package/dist/modes/interactive/components/branch-summary-message.js.map +0 -1
  300. package/dist/modes/interactive/components/compaction-summary-message.d.ts +0 -16
  301. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +0 -1
  302. package/dist/modes/interactive/components/compaction-summary-message.js +0 -45
  303. package/dist/modes/interactive/components/compaction-summary-message.js.map +0 -1
  304. package/dist/modes/interactive/components/config-selector.d.ts +0 -71
  305. package/dist/modes/interactive/components/config-selector.d.ts.map +0 -1
  306. package/dist/modes/interactive/components/config-selector.js +0 -479
  307. package/dist/modes/interactive/components/config-selector.js.map +0 -1
  308. package/dist/modes/interactive/components/countdown-timer.d.ts +0 -14
  309. package/dist/modes/interactive/components/countdown-timer.d.ts.map +0 -1
  310. package/dist/modes/interactive/components/countdown-timer.js +0 -33
  311. package/dist/modes/interactive/components/countdown-timer.js.map +0 -1
  312. package/dist/modes/interactive/components/custom-editor.d.ts +0 -21
  313. package/dist/modes/interactive/components/custom-editor.d.ts.map +0 -1
  314. package/dist/modes/interactive/components/custom-editor.js +0 -70
  315. package/dist/modes/interactive/components/custom-editor.js.map +0 -1
  316. package/dist/modes/interactive/components/custom-message.d.ts +0 -20
  317. package/dist/modes/interactive/components/custom-message.d.ts.map +0 -1
  318. package/dist/modes/interactive/components/custom-message.js +0 -79
  319. package/dist/modes/interactive/components/custom-message.js.map +0 -1
  320. package/dist/modes/interactive/components/daxnuts.d.ts +0 -23
  321. package/dist/modes/interactive/components/daxnuts.d.ts.map +0 -1
  322. package/dist/modes/interactive/components/daxnuts.js +0 -140
  323. package/dist/modes/interactive/components/daxnuts.js.map +0 -1
  324. package/dist/modes/interactive/components/diff.d.ts +0 -12
  325. package/dist/modes/interactive/components/diff.d.ts.map +0 -1
  326. package/dist/modes/interactive/components/diff.js +0 -133
  327. package/dist/modes/interactive/components/diff.js.map +0 -1
  328. package/dist/modes/interactive/components/dynamic-border.d.ts +0 -15
  329. package/dist/modes/interactive/components/dynamic-border.d.ts.map +0 -1
  330. package/dist/modes/interactive/components/dynamic-border.js +0 -21
  331. package/dist/modes/interactive/components/dynamic-border.js.map +0 -1
  332. package/dist/modes/interactive/components/extension-editor.d.ts +0 -20
  333. package/dist/modes/interactive/components/extension-editor.d.ts.map +0 -1
  334. package/dist/modes/interactive/components/extension-editor.js +0 -111
  335. package/dist/modes/interactive/components/extension-editor.js.map +0 -1
  336. package/dist/modes/interactive/components/extension-input.d.ts +0 -23
  337. package/dist/modes/interactive/components/extension-input.d.ts.map +0 -1
  338. package/dist/modes/interactive/components/extension-input.js +0 -61
  339. package/dist/modes/interactive/components/extension-input.js.map +0 -1
  340. package/dist/modes/interactive/components/extension-selector.d.ts +0 -24
  341. package/dist/modes/interactive/components/extension-selector.d.ts.map +0 -1
  342. package/dist/modes/interactive/components/extension-selector.js +0 -78
  343. package/dist/modes/interactive/components/extension-selector.js.map +0 -1
  344. package/dist/modes/interactive/components/footer.d.ts +0 -27
  345. package/dist/modes/interactive/components/footer.d.ts.map +0 -1
  346. package/dist/modes/interactive/components/footer.js +0 -201
  347. package/dist/modes/interactive/components/footer.js.map +0 -1
  348. package/dist/modes/interactive/components/index.d.ts +0 -32
  349. package/dist/modes/interactive/components/index.d.ts.map +0 -1
  350. package/dist/modes/interactive/components/index.js +0 -33
  351. package/dist/modes/interactive/components/index.js.map +0 -1
  352. package/dist/modes/interactive/components/keybinding-hints.d.ts +0 -8
  353. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +0 -1
  354. package/dist/modes/interactive/components/keybinding-hints.js +0 -22
  355. package/dist/modes/interactive/components/keybinding-hints.js.map +0 -1
  356. package/dist/modes/interactive/components/login-dialog.d.ts +0 -42
  357. package/dist/modes/interactive/components/login-dialog.d.ts.map +0 -1
  358. package/dist/modes/interactive/components/login-dialog.js +0 -145
  359. package/dist/modes/interactive/components/login-dialog.js.map +0 -1
  360. package/dist/modes/interactive/components/model-selector.d.ts +0 -47
  361. package/dist/modes/interactive/components/model-selector.d.ts.map +0 -1
  362. package/dist/modes/interactive/components/model-selector.js +0 -275
  363. package/dist/modes/interactive/components/model-selector.js.map +0 -1
  364. package/dist/modes/interactive/components/oauth-selector.d.ts +0 -19
  365. package/dist/modes/interactive/components/oauth-selector.d.ts.map +0 -1
  366. package/dist/modes/interactive/components/oauth-selector.js +0 -97
  367. package/dist/modes/interactive/components/oauth-selector.js.map +0 -1
  368. package/dist/modes/interactive/components/scoped-models-selector.d.ts +0 -49
  369. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +0 -1
  370. package/dist/modes/interactive/components/scoped-models-selector.js +0 -275
  371. package/dist/modes/interactive/components/scoped-models-selector.js.map +0 -1
  372. package/dist/modes/interactive/components/session-selector-search.d.ts +0 -23
  373. package/dist/modes/interactive/components/session-selector-search.d.ts.map +0 -1
  374. package/dist/modes/interactive/components/session-selector-search.js +0 -155
  375. package/dist/modes/interactive/components/session-selector-search.js.map +0 -1
  376. package/dist/modes/interactive/components/session-selector.d.ts +0 -95
  377. package/dist/modes/interactive/components/session-selector.d.ts.map +0 -1
  378. package/dist/modes/interactive/components/session-selector.js +0 -848
  379. package/dist/modes/interactive/components/session-selector.js.map +0 -1
  380. package/dist/modes/interactive/components/settings-selector.d.ts +0 -58
  381. package/dist/modes/interactive/components/settings-selector.d.ts.map +0 -1
  382. package/dist/modes/interactive/components/settings-selector.js +0 -301
  383. package/dist/modes/interactive/components/settings-selector.js.map +0 -1
  384. package/dist/modes/interactive/components/show-images-selector.d.ts +0 -10
  385. package/dist/modes/interactive/components/show-images-selector.d.ts.map +0 -1
  386. package/dist/modes/interactive/components/show-images-selector.js +0 -39
  387. package/dist/modes/interactive/components/show-images-selector.js.map +0 -1
  388. package/dist/modes/interactive/components/skill-invocation-message.d.ts +0 -17
  389. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +0 -1
  390. package/dist/modes/interactive/components/skill-invocation-message.js +0 -47
  391. package/dist/modes/interactive/components/skill-invocation-message.js.map +0 -1
  392. package/dist/modes/interactive/components/theme-selector.d.ts +0 -11
  393. package/dist/modes/interactive/components/theme-selector.d.ts.map +0 -1
  394. package/dist/modes/interactive/components/theme-selector.js +0 -50
  395. package/dist/modes/interactive/components/theme-selector.js.map +0 -1
  396. package/dist/modes/interactive/components/thinking-selector.d.ts +0 -11
  397. package/dist/modes/interactive/components/thinking-selector.d.ts.map +0 -1
  398. package/dist/modes/interactive/components/thinking-selector.js +0 -51
  399. package/dist/modes/interactive/components/thinking-selector.js.map +0 -1
  400. package/dist/modes/interactive/components/tool-execution.d.ts +0 -58
  401. package/dist/modes/interactive/components/tool-execution.d.ts.map +0 -1
  402. package/dist/modes/interactive/components/tool-execution.js +0 -274
  403. package/dist/modes/interactive/components/tool-execution.js.map +0 -1
  404. package/dist/modes/interactive/components/tree-selector.d.ts +0 -89
  405. package/dist/modes/interactive/components/tree-selector.d.ts.map +0 -1
  406. package/dist/modes/interactive/components/tree-selector.js +0 -1084
  407. package/dist/modes/interactive/components/tree-selector.js.map +0 -1
  408. package/dist/modes/interactive/components/user-message-selector.d.ts +0 -30
  409. package/dist/modes/interactive/components/user-message-selector.d.ts.map +0 -1
  410. package/dist/modes/interactive/components/user-message-selector.js +0 -113
  411. package/dist/modes/interactive/components/user-message-selector.js.map +0 -1
  412. package/dist/modes/interactive/components/user-message.d.ts +0 -9
  413. package/dist/modes/interactive/components/user-message.d.ts.map +0 -1
  414. package/dist/modes/interactive/components/user-message.js +0 -28
  415. package/dist/modes/interactive/components/user-message.js.map +0 -1
  416. package/dist/modes/interactive/components/visual-truncate.d.ts +0 -24
  417. package/dist/modes/interactive/components/visual-truncate.d.ts.map +0 -1
  418. package/dist/modes/interactive/components/visual-truncate.js +0 -33
  419. package/dist/modes/interactive/components/visual-truncate.js.map +0 -1
  420. package/dist/modes/interactive/interactive-mode.d.ts +0 -318
  421. package/dist/modes/interactive/interactive-mode.d.ts.map +0 -1
  422. package/dist/modes/interactive/interactive-mode.js +0 -3907
  423. package/dist/modes/interactive/interactive-mode.js.map +0 -1
  424. package/dist/modes/interactive/theme/dark.json +0 -85
  425. package/dist/modes/interactive/theme/light.json +0 -84
  426. package/dist/modes/interactive/theme/theme-schema.json +0 -335
  427. package/dist/modes/interactive/theme/theme.d.ts +0 -81
  428. package/dist/modes/interactive/theme/theme.d.ts.map +0 -1
  429. package/dist/modes/interactive/theme/theme.js +0 -970
  430. package/dist/modes/interactive/theme/theme.js.map +0 -1
  431. package/dist/modes/print-mode.d.ts +0 -28
  432. package/dist/modes/print-mode.d.ts.map +0 -1
  433. package/dist/modes/print-mode.js +0 -108
  434. package/dist/modes/print-mode.js.map +0 -1
  435. package/dist/modes/rpc/jsonl.d.ts +0 -17
  436. package/dist/modes/rpc/jsonl.d.ts.map +0 -1
  437. package/dist/modes/rpc/jsonl.js +0 -49
  438. package/dist/modes/rpc/jsonl.js.map +0 -1
  439. package/dist/modes/rpc/rpc-client.d.ts +0 -217
  440. package/dist/modes/rpc/rpc-client.d.ts.map +0 -1
  441. package/dist/modes/rpc/rpc-client.js +0 -401
  442. package/dist/modes/rpc/rpc-client.js.map +0 -1
  443. package/dist/modes/rpc/rpc-mode.d.ts +0 -20
  444. package/dist/modes/rpc/rpc-mode.d.ts.map +0 -1
  445. package/dist/modes/rpc/rpc-mode.js +0 -542
  446. package/dist/modes/rpc/rpc-mode.js.map +0 -1
  447. package/dist/modes/rpc/rpc-types.d.ts +0 -408
  448. package/dist/modes/rpc/rpc-types.d.ts.map +0 -1
  449. package/dist/modes/rpc/rpc-types.js +0 -8
  450. package/dist/modes/rpc/rpc-types.js.map +0 -1
  451. package/dist/utils/changelog.d.ts +0 -21
  452. package/dist/utils/changelog.d.ts.map +0 -1
  453. package/dist/utils/changelog.js +0 -87
  454. package/dist/utils/changelog.js.map +0 -1
  455. package/dist/utils/child-process.d.ts +0 -11
  456. package/dist/utils/child-process.d.ts.map +0 -1
  457. package/dist/utils/child-process.js +0 -78
  458. package/dist/utils/child-process.js.map +0 -1
  459. package/dist/utils/clipboard-image.d.ts +0 -11
  460. package/dist/utils/clipboard-image.d.ts.map +0 -1
  461. package/dist/utils/clipboard-image.js +0 -245
  462. package/dist/utils/clipboard-image.js.map +0 -1
  463. package/dist/utils/clipboard-native.d.ts +0 -8
  464. package/dist/utils/clipboard-native.d.ts.map +0 -1
  465. package/dist/utils/clipboard-native.js +0 -14
  466. package/dist/utils/clipboard-native.js.map +0 -1
  467. package/dist/utils/clipboard.d.ts +0 -2
  468. package/dist/utils/clipboard.d.ts.map +0 -1
  469. package/dist/utils/clipboard.js +0 -78
  470. package/dist/utils/clipboard.js.map +0 -1
  471. package/dist/utils/exif-orientation.d.ts +0 -5
  472. package/dist/utils/exif-orientation.d.ts.map +0 -1
  473. package/dist/utils/exif-orientation.js +0 -158
  474. package/dist/utils/exif-orientation.js.map +0 -1
  475. package/dist/utils/frontmatter.d.ts +0 -8
  476. package/dist/utils/frontmatter.d.ts.map +0 -1
  477. package/dist/utils/frontmatter.js +0 -26
  478. package/dist/utils/frontmatter.js.map +0 -1
  479. package/dist/utils/git.d.ts +0 -26
  480. package/dist/utils/git.d.ts.map +0 -1
  481. package/dist/utils/git.js +0 -163
  482. package/dist/utils/git.js.map +0 -1
  483. package/dist/utils/image-convert.d.ts +0 -9
  484. package/dist/utils/image-convert.d.ts.map +0 -1
  485. package/dist/utils/image-convert.js +0 -39
  486. package/dist/utils/image-convert.js.map +0 -1
  487. package/dist/utils/image-resize.d.ts +0 -36
  488. package/dist/utils/image-resize.d.ts.map +0 -1
  489. package/dist/utils/image-resize.js +0 -137
  490. package/dist/utils/image-resize.js.map +0 -1
  491. package/dist/utils/mime.d.ts +0 -2
  492. package/dist/utils/mime.d.ts.map +0 -1
  493. package/dist/utils/mime.js +0 -26
  494. package/dist/utils/mime.js.map +0 -1
  495. package/dist/utils/photon.d.ts +0 -21
  496. package/dist/utils/photon.d.ts.map +0 -1
  497. package/dist/utils/photon.js +0 -121
  498. package/dist/utils/photon.js.map +0 -1
  499. package/dist/utils/shell.d.ts +0 -26
  500. package/dist/utils/shell.d.ts.map +0 -1
  501. package/dist/utils/shell.js +0 -186
  502. package/dist/utils/shell.js.map +0 -1
  503. package/dist/utils/sleep.d.ts +0 -5
  504. package/dist/utils/sleep.d.ts.map +0 -1
  505. package/dist/utils/sleep.js +0 -17
  506. package/dist/utils/sleep.js.map +0 -1
  507. package/dist/utils/tools-manager.d.ts +0 -3
  508. package/dist/utils/tools-manager.d.ts.map +0 -1
  509. package/dist/utils/tools-manager.js +0 -252
  510. package/dist/utils/tools-manager.js.map +0 -1
  511. package/dist/welcome/about.js +0 -50
  512. package/dist/welcome/auth.js +0 -126
  513. package/dist/welcome/intro.js +0 -90
  514. package/dist/welcome/qa.js +0 -131
  515. package/scripts/install-gum.sh +0 -141
@@ -1,158 +0,0 @@
1
- function readOrientationFromTiff(bytes, tiffStart) {
2
- if (tiffStart + 8 > bytes.length)
3
- return 1;
4
- const byteOrder = (bytes[tiffStart] << 8) | bytes[tiffStart + 1];
5
- const le = byteOrder === 0x4949;
6
- const read16 = (pos) => {
7
- if (le)
8
- return bytes[pos] | (bytes[pos + 1] << 8);
9
- return (bytes[pos] << 8) | bytes[pos + 1];
10
- };
11
- const read32 = (pos) => {
12
- if (le)
13
- return bytes[pos] | (bytes[pos + 1] << 8) | (bytes[pos + 2] << 16) | (bytes[pos + 3] << 24);
14
- return ((bytes[pos] << 24) | (bytes[pos + 1] << 16) | (bytes[pos + 2] << 8) | bytes[pos + 3]) >>> 0;
15
- };
16
- const ifdOffset = read32(tiffStart + 4);
17
- const ifdStart = tiffStart + ifdOffset;
18
- if (ifdStart + 2 > bytes.length)
19
- return 1;
20
- const entryCount = read16(ifdStart);
21
- for (let i = 0; i < entryCount; i++) {
22
- const entryPos = ifdStart + 2 + i * 12;
23
- if (entryPos + 12 > bytes.length)
24
- return 1;
25
- if (read16(entryPos) === 0x0112) {
26
- const value = read16(entryPos + 8);
27
- return value >= 1 && value <= 8 ? value : 1;
28
- }
29
- }
30
- return 1;
31
- }
32
- function findJpegTiffOffset(bytes) {
33
- let offset = 2;
34
- while (offset < bytes.length - 1) {
35
- if (bytes[offset] !== 0xff)
36
- return -1;
37
- const marker = bytes[offset + 1];
38
- if (marker === 0xff) {
39
- offset++;
40
- continue;
41
- }
42
- if (marker === 0xe1) {
43
- if (offset + 4 >= bytes.length)
44
- return -1;
45
- const segmentStart = offset + 4;
46
- if (segmentStart + 6 > bytes.length)
47
- return -1;
48
- if (!hasExifHeader(bytes, segmentStart))
49
- return -1;
50
- return segmentStart + 6;
51
- }
52
- if (offset + 4 > bytes.length)
53
- return -1;
54
- const length = (bytes[offset + 2] << 8) | bytes[offset + 3];
55
- offset += 2 + length;
56
- }
57
- return -1;
58
- }
59
- function findWebpTiffOffset(bytes) {
60
- let offset = 12;
61
- while (offset + 8 <= bytes.length) {
62
- const chunkId = String.fromCharCode(bytes[offset], bytes[offset + 1], bytes[offset + 2], bytes[offset + 3]);
63
- const chunkSize = bytes[offset + 4] | (bytes[offset + 5] << 8) | (bytes[offset + 6] << 16) | (bytes[offset + 7] << 24);
64
- const dataStart = offset + 8;
65
- if (chunkId === "EXIF") {
66
- if (dataStart + chunkSize > bytes.length)
67
- return -1;
68
- // Some WebP files have "Exif\0\0" prefix before the TIFF header
69
- const tiffStart = chunkSize >= 6 && hasExifHeader(bytes, dataStart) ? dataStart + 6 : dataStart;
70
- return tiffStart;
71
- }
72
- // RIFF chunks are padded to even size
73
- offset = dataStart + chunkSize + (chunkSize % 2);
74
- }
75
- return -1;
76
- }
77
- function hasExifHeader(bytes, offset) {
78
- return (bytes[offset] === 0x45 &&
79
- bytes[offset + 1] === 0x78 &&
80
- bytes[offset + 2] === 0x69 &&
81
- bytes[offset + 3] === 0x66 &&
82
- bytes[offset + 4] === 0x00 &&
83
- bytes[offset + 5] === 0x00);
84
- }
85
- function getExifOrientation(bytes) {
86
- let tiffOffset = -1;
87
- // JPEG: starts with FF D8
88
- if (bytes.length >= 2 && bytes[0] === 0xff && bytes[1] === 0xd8) {
89
- tiffOffset = findJpegTiffOffset(bytes);
90
- }
91
- // WebP: starts with RIFF....WEBP
92
- else if (bytes.length >= 12 &&
93
- bytes[0] === 0x52 &&
94
- bytes[1] === 0x49 &&
95
- bytes[2] === 0x46 &&
96
- bytes[3] === 0x46 &&
97
- bytes[8] === 0x57 &&
98
- bytes[9] === 0x45 &&
99
- bytes[10] === 0x42 &&
100
- bytes[11] === 0x50) {
101
- tiffOffset = findWebpTiffOffset(bytes);
102
- }
103
- if (tiffOffset === -1)
104
- return 1;
105
- return readOrientationFromTiff(bytes, tiffOffset);
106
- }
107
- function rotate90(photon, image, dstIndex) {
108
- const w = image.get_width();
109
- const h = image.get_height();
110
- const src = image.get_raw_pixels();
111
- const dst = new Uint8Array(src.length);
112
- for (let y = 0; y < h; y++) {
113
- for (let x = 0; x < w; x++) {
114
- const srcIdx = (y * w + x) * 4;
115
- const dstIdx = dstIndex(x, y, w, h) * 4;
116
- dst[dstIdx] = src[srcIdx];
117
- dst[dstIdx + 1] = src[srcIdx + 1];
118
- dst[dstIdx + 2] = src[srcIdx + 2];
119
- dst[dstIdx + 3] = src[srcIdx + 3];
120
- }
121
- }
122
- return new photon.PhotonImage(dst, h, w);
123
- }
124
- // Flip orientations mutate in-place. Rotations return a new image (caller must free the old one if different).
125
- export function applyExifOrientation(photon, image, originalBytes) {
126
- const orientation = getExifOrientation(originalBytes);
127
- if (orientation === 1)
128
- return image;
129
- switch (orientation) {
130
- case 2:
131
- photon.fliph(image);
132
- return image;
133
- case 3:
134
- photon.fliph(image);
135
- photon.flipv(image);
136
- return image;
137
- case 4:
138
- photon.flipv(image);
139
- return image;
140
- case 5: {
141
- const rotated = rotate90(photon, image, (x, y, _w, h) => x * h + (h - 1 - y));
142
- photon.fliph(rotated);
143
- return rotated;
144
- }
145
- case 6:
146
- return rotate90(photon, image, (x, y, _w, h) => x * h + (h - 1 - y));
147
- case 7: {
148
- const rotated = rotate90(photon, image, (x, y, w, h) => (w - 1 - x) * h + y);
149
- photon.fliph(rotated);
150
- return rotated;
151
- }
152
- case 8:
153
- return rotate90(photon, image, (x, y, w, h) => (w - 1 - x) * h + y);
154
- default:
155
- return image;
156
- }
157
- }
158
- //# sourceMappingURL=exif-orientation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exif-orientation.js","sourceRoot":"","sources":["../../src/utils/exif-orientation.ts"],"names":[],"mappings":"AAIA,SAAS,uBAAuB,CAAC,KAAiB,EAAE,SAAiB,EAAU;IAC9E,IAAI,SAAS,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM;QAAE,OAAO,CAAC,CAAC;IAE3C,MAAM,SAAS,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IACjE,MAAM,EAAE,GAAG,SAAS,KAAK,MAAM,CAAC;IAEhC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAU,EAAE,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,OAAO,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAC7E,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtB,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,KAAK,CAAC;YACL,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACrE;YACC,OAAO,KAAK,CAAC;IACf,CAAC;AAAA,CACD","sourcesContent":["import type { PhotonImageType } from \"./photon.js\";\n\ntype Photon = typeof import(\"@silvia-odwyer/photon-node\");\n\nfunction readOrientationFromTiff(bytes: Uint8Array, tiffStart: number): number {\n\tif (tiffStart + 8 > bytes.length) return 1;\n\n\tconst byteOrder = (bytes[tiffStart] << 8) | bytes[tiffStart + 1];\n\tconst le = byteOrder === 0x4949;\n\n\tconst read16 = (pos: number): number => {\n\t\tif (le) return bytes[pos] | (bytes[pos + 1] << 8);\n\t\treturn (bytes[pos] << 8) | bytes[pos + 1];\n\t};\n\n\tconst read32 = (pos: number): number => {\n\t\tif (le) return bytes[pos] | (bytes[pos + 1] << 8) | (bytes[pos + 2] << 16) | (bytes[pos + 3] << 24);\n\t\treturn ((bytes[pos] << 24) | (bytes[pos + 1] << 16) | (bytes[pos + 2] << 8) | bytes[pos + 3]) >>> 0;\n\t};\n\n\tconst ifdOffset = read32(tiffStart + 4);\n\tconst ifdStart = tiffStart + ifdOffset;\n\tif (ifdStart + 2 > bytes.length) return 1;\n\n\tconst entryCount = read16(ifdStart);\n\tfor (let i = 0; i < entryCount; i++) {\n\t\tconst entryPos = ifdStart + 2 + i * 12;\n\t\tif (entryPos + 12 > bytes.length) return 1;\n\n\t\tif (read16(entryPos) === 0x0112) {\n\t\t\tconst value = read16(entryPos + 8);\n\t\t\treturn value >= 1 && value <= 8 ? value : 1;\n\t\t}\n\t}\n\n\treturn 1;\n}\n\nfunction findJpegTiffOffset(bytes: Uint8Array): number {\n\tlet offset = 2;\n\twhile (offset < bytes.length - 1) {\n\t\tif (bytes[offset] !== 0xff) return -1;\n\t\tconst marker = bytes[offset + 1];\n\t\tif (marker === 0xff) {\n\t\t\toffset++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (marker === 0xe1) {\n\t\t\tif (offset + 4 >= bytes.length) return -1;\n\t\t\tconst segmentStart = offset + 4;\n\t\t\tif (segmentStart + 6 > bytes.length) return -1;\n\t\t\tif (!hasExifHeader(bytes, segmentStart)) return -1;\n\t\t\treturn segmentStart + 6;\n\t\t}\n\n\t\tif (offset + 4 > bytes.length) return -1;\n\t\tconst length = (bytes[offset + 2] << 8) | bytes[offset + 3];\n\t\toffset += 2 + length;\n\t}\n\n\treturn -1;\n}\n\nfunction findWebpTiffOffset(bytes: Uint8Array): number {\n\tlet offset = 12;\n\twhile (offset + 8 <= bytes.length) {\n\t\tconst chunkId = String.fromCharCode(bytes[offset], bytes[offset + 1], bytes[offset + 2], bytes[offset + 3]);\n\t\tconst chunkSize =\n\t\t\tbytes[offset + 4] | (bytes[offset + 5] << 8) | (bytes[offset + 6] << 16) | (bytes[offset + 7] << 24);\n\t\tconst dataStart = offset + 8;\n\n\t\tif (chunkId === \"EXIF\") {\n\t\t\tif (dataStart + chunkSize > bytes.length) return -1;\n\t\t\t// Some WebP files have \"Exif\\0\\0\" prefix before the TIFF header\n\t\t\tconst tiffStart = chunkSize >= 6 && hasExifHeader(bytes, dataStart) ? dataStart + 6 : dataStart;\n\t\t\treturn tiffStart;\n\t\t}\n\n\t\t// RIFF chunks are padded to even size\n\t\toffset = dataStart + chunkSize + (chunkSize % 2);\n\t}\n\n\treturn -1;\n}\n\nfunction hasExifHeader(bytes: Uint8Array, offset: number): boolean {\n\treturn (\n\t\tbytes[offset] === 0x45 &&\n\t\tbytes[offset + 1] === 0x78 &&\n\t\tbytes[offset + 2] === 0x69 &&\n\t\tbytes[offset + 3] === 0x66 &&\n\t\tbytes[offset + 4] === 0x00 &&\n\t\tbytes[offset + 5] === 0x00\n\t);\n}\n\nfunction getExifOrientation(bytes: Uint8Array): number {\n\tlet tiffOffset = -1;\n\n\t// JPEG: starts with FF D8\n\tif (bytes.length >= 2 && bytes[0] === 0xff && bytes[1] === 0xd8) {\n\t\ttiffOffset = findJpegTiffOffset(bytes);\n\t}\n\t// WebP: starts with RIFF....WEBP\n\telse if (\n\t\tbytes.length >= 12 &&\n\t\tbytes[0] === 0x52 &&\n\t\tbytes[1] === 0x49 &&\n\t\tbytes[2] === 0x46 &&\n\t\tbytes[3] === 0x46 &&\n\t\tbytes[8] === 0x57 &&\n\t\tbytes[9] === 0x45 &&\n\t\tbytes[10] === 0x42 &&\n\t\tbytes[11] === 0x50\n\t) {\n\t\ttiffOffset = findWebpTiffOffset(bytes);\n\t}\n\n\tif (tiffOffset === -1) return 1;\n\treturn readOrientationFromTiff(bytes, tiffOffset);\n}\n\ntype DstIndexFn = (x: number, y: number, w: number, h: number) => number;\n\nfunction rotate90(photon: Photon, image: PhotonImageType, dstIndex: DstIndexFn): PhotonImageType {\n\tconst w = image.get_width();\n\tconst h = image.get_height();\n\tconst src = image.get_raw_pixels();\n\tconst dst = new Uint8Array(src.length);\n\n\tfor (let y = 0; y < h; y++) {\n\t\tfor (let x = 0; x < w; x++) {\n\t\t\tconst srcIdx = (y * w + x) * 4;\n\t\t\tconst dstIdx = dstIndex(x, y, w, h) * 4;\n\t\t\tdst[dstIdx] = src[srcIdx];\n\t\t\tdst[dstIdx + 1] = src[srcIdx + 1];\n\t\t\tdst[dstIdx + 2] = src[srcIdx + 2];\n\t\t\tdst[dstIdx + 3] = src[srcIdx + 3];\n\t\t}\n\t}\n\n\treturn new photon.PhotonImage(dst, h, w);\n}\n\n// Flip orientations mutate in-place. Rotations return a new image (caller must free the old one if different).\nexport function applyExifOrientation(\n\tphoton: Photon,\n\timage: PhotonImageType,\n\toriginalBytes: Uint8Array,\n): PhotonImageType {\n\tconst orientation = getExifOrientation(originalBytes);\n\tif (orientation === 1) return image;\n\n\tswitch (orientation) {\n\t\tcase 2:\n\t\t\tphoton.fliph(image);\n\t\t\treturn image;\n\t\tcase 3:\n\t\t\tphoton.fliph(image);\n\t\t\tphoton.flipv(image);\n\t\t\treturn image;\n\t\tcase 4:\n\t\t\tphoton.flipv(image);\n\t\t\treturn image;\n\t\tcase 5: {\n\t\t\tconst rotated = rotate90(photon, image, (x, y, _w, h) => x * h + (h - 1 - y));\n\t\t\tphoton.fliph(rotated);\n\t\t\treturn rotated;\n\t\t}\n\t\tcase 6:\n\t\t\treturn rotate90(photon, image, (x, y, _w, h) => x * h + (h - 1 - y));\n\t\tcase 7: {\n\t\t\tconst rotated = rotate90(photon, image, (x, y, w, h) => (w - 1 - x) * h + y);\n\t\t\tphoton.fliph(rotated);\n\t\t\treturn rotated;\n\t\t}\n\t\tcase 8:\n\t\t\treturn rotate90(photon, image, (x, y, w, h) => (w - 1 - x) * h + y);\n\t\tdefault:\n\t\t\treturn image;\n\t}\n}\n"]}
@@ -1,8 +0,0 @@
1
- type ParsedFrontmatter<T extends Record<string, unknown>> = {
2
- frontmatter: T;
3
- body: string;
4
- };
5
- export declare const parseFrontmatter: <T extends Record<string, unknown> = Record<string, unknown>>(content: string) => ParsedFrontmatter<T>;
6
- export declare const stripFrontmatter: (content: string) => string;
7
- export {};
8
- //# sourceMappingURL=frontmatter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../src/utils/frontmatter.ts"],"names":[],"mappings":"AAEA,KAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IAC3D,WAAW,EAAE,CAAC,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAsBF,eAAO,MAAM,gBAAgB,GAAI,CAAC,oGASjC,CAAC;AAEF,eAAO,MAAM,gBAAgB,6BAA8D,CAAC","sourcesContent":["import { parse } from \"yaml\";\n\ntype ParsedFrontmatter<T extends Record<string, unknown>> = {\n\tfrontmatter: T;\n\tbody: string;\n};\n\nconst normalizeNewlines = (value: string): string => value.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n\nconst extractFrontmatter = (content: string): { yamlString: string | null; body: string } => {\n\tconst normalized = normalizeNewlines(content);\n\n\tif (!normalized.startsWith(\"---\")) {\n\t\treturn { yamlString: null, body: normalized };\n\t}\n\n\tconst endIndex = normalized.indexOf(\"\\n---\", 3);\n\tif (endIndex === -1) {\n\t\treturn { yamlString: null, body: normalized };\n\t}\n\n\treturn {\n\t\tyamlString: normalized.slice(4, endIndex),\n\t\tbody: normalized.slice(endIndex + 4).trim(),\n\t};\n};\n\nexport const parseFrontmatter = <T extends Record<string, unknown> = Record<string, unknown>>(\n\tcontent: string,\n): ParsedFrontmatter<T> => {\n\tconst { yamlString, body } = extractFrontmatter(content);\n\tif (!yamlString) {\n\t\treturn { frontmatter: {} as T, body };\n\t}\n\tconst parsed = parse(yamlString);\n\treturn { frontmatter: (parsed ?? {}) as T, body };\n};\n\nexport const stripFrontmatter = (content: string): string => parseFrontmatter(content).body;\n"]}
@@ -1,26 +0,0 @@
1
- import { parse } from "yaml";
2
- const normalizeNewlines = (value) => value.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
3
- const extractFrontmatter = (content) => {
4
- const normalized = normalizeNewlines(content);
5
- if (!normalized.startsWith("---")) {
6
- return { yamlString: null, body: normalized };
7
- }
8
- const endIndex = normalized.indexOf("\n---", 3);
9
- if (endIndex === -1) {
10
- return { yamlString: null, body: normalized };
11
- }
12
- return {
13
- yamlString: normalized.slice(4, endIndex),
14
- body: normalized.slice(endIndex + 4).trim(),
15
- };
16
- };
17
- export const parseFrontmatter = (content) => {
18
- const { yamlString, body } = extractFrontmatter(content);
19
- if (!yamlString) {
20
- return { frontmatter: {}, body };
21
- }
22
- const parsed = parse(yamlString);
23
- return { frontmatter: (parsed ?? {}), body };
24
- };
25
- export const stripFrontmatter = (content) => parseFrontmatter(content).body;
26
- //# sourceMappingURL=frontmatter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/utils/frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAO7B,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAEvG,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAA+C,EAAE,CAAC;IAC5F,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAE9C,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC/C,CAAC;IAED,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAChD,IAAI,QAAQ,KAAK,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC/C,CAAC;IAED,OAAO;QACN,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC;QACzC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE;KAC3C,CAAC;AAAA,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC/B,OAAe,EACQ,EAAE,CAAC;IAC1B,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACzD,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,OAAO,EAAE,WAAW,EAAE,EAAO,EAAE,IAAI,EAAE,CAAC;IACvC,CAAC;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACjC,OAAO,EAAE,WAAW,EAAE,CAAC,MAAM,IAAI,EAAE,CAAM,EAAE,IAAI,EAAE,CAAC;AAAA,CAClD,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC","sourcesContent":["import { parse } from \"yaml\";\n\ntype ParsedFrontmatter<T extends Record<string, unknown>> = {\n\tfrontmatter: T;\n\tbody: string;\n};\n\nconst normalizeNewlines = (value: string): string => value.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n\nconst extractFrontmatter = (content: string): { yamlString: string | null; body: string } => {\n\tconst normalized = normalizeNewlines(content);\n\n\tif (!normalized.startsWith(\"---\")) {\n\t\treturn { yamlString: null, body: normalized };\n\t}\n\n\tconst endIndex = normalized.indexOf(\"\\n---\", 3);\n\tif (endIndex === -1) {\n\t\treturn { yamlString: null, body: normalized };\n\t}\n\n\treturn {\n\t\tyamlString: normalized.slice(4, endIndex),\n\t\tbody: normalized.slice(endIndex + 4).trim(),\n\t};\n};\n\nexport const parseFrontmatter = <T extends Record<string, unknown> = Record<string, unknown>>(\n\tcontent: string,\n): ParsedFrontmatter<T> => {\n\tconst { yamlString, body } = extractFrontmatter(content);\n\tif (!yamlString) {\n\t\treturn { frontmatter: {} as T, body };\n\t}\n\tconst parsed = parse(yamlString);\n\treturn { frontmatter: (parsed ?? {}) as T, body };\n};\n\nexport const stripFrontmatter = (content: string): string => parseFrontmatter(content).body;\n"]}
@@ -1,26 +0,0 @@
1
- /**
2
- * Parsed git URL information.
3
- */
4
- export type GitSource = {
5
- /** Always "git" for git sources */
6
- type: "git";
7
- /** Clone URL (always valid for git clone, without ref suffix) */
8
- repo: string;
9
- /** Git host domain (e.g., "github.com") */
10
- host: string;
11
- /** Repository path (e.g., "user/repo") */
12
- path: string;
13
- /** Git ref (branch, tag, commit) if specified */
14
- ref?: string;
15
- /** True if ref was specified (package won't be auto-updated) */
16
- pinned: boolean;
17
- };
18
- /**
19
- * Parse git source into a GitSource.
20
- *
21
- * Rules:
22
- * - With git: prefix, accept all historical shorthand forms.
23
- * - Without git: prefix, only accept explicit protocol URLs.
24
- */
25
- export declare function parseGitUrl(source: string): GitSource | null;
26
- //# sourceMappingURL=git.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACvB,mCAAmC;IACnC,IAAI,EAAE,KAAK,CAAC;IACZ,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,MAAM,EAAE,OAAO,CAAC;CAChB,CAAC;AA4GF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CA0D5D","sourcesContent":["import hostedGitInfo from \"hosted-git-info\";\n\n/**\n * Parsed git URL information.\n */\nexport type GitSource = {\n\t/** Always \"git\" for git sources */\n\ttype: \"git\";\n\t/** Clone URL (always valid for git clone, without ref suffix) */\n\trepo: string;\n\t/** Git host domain (e.g., \"github.com\") */\n\thost: string;\n\t/** Repository path (e.g., \"user/repo\") */\n\tpath: string;\n\t/** Git ref (branch, tag, commit) if specified */\n\tref?: string;\n\t/** True if ref was specified (package won't be auto-updated) */\n\tpinned: boolean;\n};\n\nfunction splitRef(url: string): { repo: string; ref?: string } {\n\tconst scpLikeMatch = url.match(/^git@([^:]+):(.+)$/);\n\tif (scpLikeMatch) {\n\t\tconst pathWithMaybeRef = scpLikeMatch[2] ?? \"\";\n\t\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\n\t\tif (refSeparator < 0) return { repo: url };\n\t\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\n\t\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\n\t\tif (!repoPath || !ref) return { repo: url };\n\t\treturn {\n\t\t\trepo: `git@${scpLikeMatch[1] ?? \"\"}:${repoPath}`,\n\t\t\tref,\n\t\t};\n\t}\n\n\tif (url.includes(\"://\")) {\n\t\ttry {\n\t\t\tconst parsed = new URL(url);\n\t\t\tconst pathWithMaybeRef = parsed.pathname.replace(/^\\/+/, \"\");\n\t\t\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\n\t\t\tif (refSeparator < 0) return { repo: url };\n\t\t\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\n\t\t\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\n\t\t\tif (!repoPath || !ref) return { repo: url };\n\t\t\tparsed.pathname = `/${repoPath}`;\n\t\t\treturn {\n\t\t\t\trepo: parsed.toString().replace(/\\/$/, \"\"),\n\t\t\t\tref,\n\t\t\t};\n\t\t} catch {\n\t\t\treturn { repo: url };\n\t\t}\n\t}\n\n\tconst slashIndex = url.indexOf(\"/\");\n\tif (slashIndex < 0) {\n\t\treturn { repo: url };\n\t}\n\tconst host = url.slice(0, slashIndex);\n\tconst pathWithMaybeRef = url.slice(slashIndex + 1);\n\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\n\tif (refSeparator < 0) {\n\t\treturn { repo: url };\n\t}\n\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\n\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\n\tif (!repoPath || !ref) {\n\t\treturn { repo: url };\n\t}\n\treturn {\n\t\trepo: `${host}/${repoPath}`,\n\t\tref,\n\t};\n}\n\nfunction parseGenericGitUrl(url: string): GitSource | null {\n\tconst { repo: repoWithoutRef, ref } = splitRef(url);\n\tlet repo = repoWithoutRef;\n\tlet host = \"\";\n\tlet path = \"\";\n\n\tconst scpLikeMatch = repoWithoutRef.match(/^git@([^:]+):(.+)$/);\n\tif (scpLikeMatch) {\n\t\thost = scpLikeMatch[1] ?? \"\";\n\t\tpath = scpLikeMatch[2] ?? \"\";\n\t} else if (\n\t\trepoWithoutRef.startsWith(\"https://\") ||\n\t\trepoWithoutRef.startsWith(\"http://\") ||\n\t\trepoWithoutRef.startsWith(\"ssh://\") ||\n\t\trepoWithoutRef.startsWith(\"git://\")\n\t) {\n\t\ttry {\n\t\t\tconst parsed = new URL(repoWithoutRef);\n\t\t\thost = parsed.hostname;\n\t\t\tpath = parsed.pathname.replace(/^\\/+/, \"\");\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t} else {\n\t\tconst slashIndex = repoWithoutRef.indexOf(\"/\");\n\t\tif (slashIndex < 0) {\n\t\t\treturn null;\n\t\t}\n\t\thost = repoWithoutRef.slice(0, slashIndex);\n\t\tpath = repoWithoutRef.slice(slashIndex + 1);\n\t\tif (!host.includes(\".\") && host !== \"localhost\") {\n\t\t\treturn null;\n\t\t}\n\t\trepo = `https://${repoWithoutRef}`;\n\t}\n\n\tconst normalizedPath = path.replace(/\\.git$/, \"\").replace(/^\\/+/, \"\");\n\tif (!host || !normalizedPath || normalizedPath.split(\"/\").length < 2) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\ttype: \"git\",\n\t\trepo,\n\t\thost,\n\t\tpath: normalizedPath,\n\t\tref,\n\t\tpinned: Boolean(ref),\n\t};\n}\n\n/**\n * Parse git source into a GitSource.\n *\n * Rules:\n * - With git: prefix, accept all historical shorthand forms.\n * - Without git: prefix, only accept explicit protocol URLs.\n */\nexport function parseGitUrl(source: string): GitSource | null {\n\tconst trimmed = source.trim();\n\tconst hasGitPrefix = trimmed.startsWith(\"git:\");\n\tconst url = hasGitPrefix ? trimmed.slice(4).trim() : trimmed;\n\n\tif (!hasGitPrefix && !/^(https?|ssh|git):\\/\\//i.test(url)) {\n\t\treturn null;\n\t}\n\n\tconst split = splitRef(url);\n\n\tconst hostedCandidates = [split.ref ? `${split.repo}#${split.ref}` : undefined, url].filter(\n\t\t(value): value is string => Boolean(value),\n\t);\n\tfor (const candidate of hostedCandidates) {\n\t\tconst info = hostedGitInfo.fromUrl(candidate);\n\t\tif (info) {\n\t\t\tif (split.ref && info.project?.includes(\"@\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst useHttpsPrefix =\n\t\t\t\t!split.repo.startsWith(\"http://\") &&\n\t\t\t\t!split.repo.startsWith(\"https://\") &&\n\t\t\t\t!split.repo.startsWith(\"ssh://\") &&\n\t\t\t\t!split.repo.startsWith(\"git://\") &&\n\t\t\t\t!split.repo.startsWith(\"git@\");\n\t\t\treturn {\n\t\t\t\ttype: \"git\",\n\t\t\t\trepo: useHttpsPrefix ? `https://${split.repo}` : split.repo,\n\t\t\t\thost: info.domain || \"\",\n\t\t\t\tpath: `${info.user}/${info.project}`.replace(/\\.git$/, \"\"),\n\t\t\t\tref: info.committish || split.ref || undefined,\n\t\t\t\tpinned: Boolean(info.committish || split.ref),\n\t\t\t};\n\t\t}\n\t}\n\n\tconst httpsCandidates = [split.ref ? `https://${split.repo}#${split.ref}` : undefined, `https://${url}`].filter(\n\t\t(value): value is string => Boolean(value),\n\t);\n\tfor (const candidate of httpsCandidates) {\n\t\tconst info = hostedGitInfo.fromUrl(candidate);\n\t\tif (info) {\n\t\t\tif (split.ref && info.project?.includes(\"@\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttype: \"git\",\n\t\t\t\trepo: `https://${split.repo}`,\n\t\t\t\thost: info.domain || \"\",\n\t\t\t\tpath: `${info.user}/${info.project}`.replace(/\\.git$/, \"\"),\n\t\t\t\tref: info.committish || split.ref || undefined,\n\t\t\t\tpinned: Boolean(info.committish || split.ref),\n\t\t\t};\n\t\t}\n\t}\n\n\treturn parseGenericGitUrl(url);\n}\n"]}
package/dist/utils/git.js DELETED
@@ -1,163 +0,0 @@
1
- import hostedGitInfo from "hosted-git-info";
2
- function splitRef(url) {
3
- const scpLikeMatch = url.match(/^git@([^:]+):(.+)$/);
4
- if (scpLikeMatch) {
5
- const pathWithMaybeRef = scpLikeMatch[2] ?? "";
6
- const refSeparator = pathWithMaybeRef.indexOf("@");
7
- if (refSeparator < 0)
8
- return { repo: url };
9
- const repoPath = pathWithMaybeRef.slice(0, refSeparator);
10
- const ref = pathWithMaybeRef.slice(refSeparator + 1);
11
- if (!repoPath || !ref)
12
- return { repo: url };
13
- return {
14
- repo: `git@${scpLikeMatch[1] ?? ""}:${repoPath}`,
15
- ref,
16
- };
17
- }
18
- if (url.includes("://")) {
19
- try {
20
- const parsed = new URL(url);
21
- const pathWithMaybeRef = parsed.pathname.replace(/^\/+/, "");
22
- const refSeparator = pathWithMaybeRef.indexOf("@");
23
- if (refSeparator < 0)
24
- return { repo: url };
25
- const repoPath = pathWithMaybeRef.slice(0, refSeparator);
26
- const ref = pathWithMaybeRef.slice(refSeparator + 1);
27
- if (!repoPath || !ref)
28
- return { repo: url };
29
- parsed.pathname = `/${repoPath}`;
30
- return {
31
- repo: parsed.toString().replace(/\/$/, ""),
32
- ref,
33
- };
34
- }
35
- catch {
36
- return { repo: url };
37
- }
38
- }
39
- const slashIndex = url.indexOf("/");
40
- if (slashIndex < 0) {
41
- return { repo: url };
42
- }
43
- const host = url.slice(0, slashIndex);
44
- const pathWithMaybeRef = url.slice(slashIndex + 1);
45
- const refSeparator = pathWithMaybeRef.indexOf("@");
46
- if (refSeparator < 0) {
47
- return { repo: url };
48
- }
49
- const repoPath = pathWithMaybeRef.slice(0, refSeparator);
50
- const ref = pathWithMaybeRef.slice(refSeparator + 1);
51
- if (!repoPath || !ref) {
52
- return { repo: url };
53
- }
54
- return {
55
- repo: `${host}/${repoPath}`,
56
- ref,
57
- };
58
- }
59
- function parseGenericGitUrl(url) {
60
- const { repo: repoWithoutRef, ref } = splitRef(url);
61
- let repo = repoWithoutRef;
62
- let host = "";
63
- let path = "";
64
- const scpLikeMatch = repoWithoutRef.match(/^git@([^:]+):(.+)$/);
65
- if (scpLikeMatch) {
66
- host = scpLikeMatch[1] ?? "";
67
- path = scpLikeMatch[2] ?? "";
68
- }
69
- else if (repoWithoutRef.startsWith("https://") ||
70
- repoWithoutRef.startsWith("http://") ||
71
- repoWithoutRef.startsWith("ssh://") ||
72
- repoWithoutRef.startsWith("git://")) {
73
- try {
74
- const parsed = new URL(repoWithoutRef);
75
- host = parsed.hostname;
76
- path = parsed.pathname.replace(/^\/+/, "");
77
- }
78
- catch {
79
- return null;
80
- }
81
- }
82
- else {
83
- const slashIndex = repoWithoutRef.indexOf("/");
84
- if (slashIndex < 0) {
85
- return null;
86
- }
87
- host = repoWithoutRef.slice(0, slashIndex);
88
- path = repoWithoutRef.slice(slashIndex + 1);
89
- if (!host.includes(".") && host !== "localhost") {
90
- return null;
91
- }
92
- repo = `https://${repoWithoutRef}`;
93
- }
94
- const normalizedPath = path.replace(/\.git$/, "").replace(/^\/+/, "");
95
- if (!host || !normalizedPath || normalizedPath.split("/").length < 2) {
96
- return null;
97
- }
98
- return {
99
- type: "git",
100
- repo,
101
- host,
102
- path: normalizedPath,
103
- ref,
104
- pinned: Boolean(ref),
105
- };
106
- }
107
- /**
108
- * Parse git source into a GitSource.
109
- *
110
- * Rules:
111
- * - With git: prefix, accept all historical shorthand forms.
112
- * - Without git: prefix, only accept explicit protocol URLs.
113
- */
114
- export function parseGitUrl(source) {
115
- const trimmed = source.trim();
116
- const hasGitPrefix = trimmed.startsWith("git:");
117
- const url = hasGitPrefix ? trimmed.slice(4).trim() : trimmed;
118
- if (!hasGitPrefix && !/^(https?|ssh|git):\/\//i.test(url)) {
119
- return null;
120
- }
121
- const split = splitRef(url);
122
- const hostedCandidates = [split.ref ? `${split.repo}#${split.ref}` : undefined, url].filter((value) => Boolean(value));
123
- for (const candidate of hostedCandidates) {
124
- const info = hostedGitInfo.fromUrl(candidate);
125
- if (info) {
126
- if (split.ref && info.project?.includes("@")) {
127
- continue;
128
- }
129
- const useHttpsPrefix = !split.repo.startsWith("http://") &&
130
- !split.repo.startsWith("https://") &&
131
- !split.repo.startsWith("ssh://") &&
132
- !split.repo.startsWith("git://") &&
133
- !split.repo.startsWith("git@");
134
- return {
135
- type: "git",
136
- repo: useHttpsPrefix ? `https://${split.repo}` : split.repo,
137
- host: info.domain || "",
138
- path: `${info.user}/${info.project}`.replace(/\.git$/, ""),
139
- ref: info.committish || split.ref || undefined,
140
- pinned: Boolean(info.committish || split.ref),
141
- };
142
- }
143
- }
144
- const httpsCandidates = [split.ref ? `https://${split.repo}#${split.ref}` : undefined, `https://${url}`].filter((value) => Boolean(value));
145
- for (const candidate of httpsCandidates) {
146
- const info = hostedGitInfo.fromUrl(candidate);
147
- if (info) {
148
- if (split.ref && info.project?.includes("@")) {
149
- continue;
150
- }
151
- return {
152
- type: "git",
153
- repo: `https://${split.repo}`,
154
- host: info.domain || "",
155
- path: `${info.user}/${info.project}`.replace(/\.git$/, ""),
156
- ref: info.committish || split.ref || undefined,
157
- pinned: Boolean(info.committish || split.ref),
158
- };
159
- }
160
- }
161
- return parseGenericGitUrl(url);
162
- }
163
- //# sourceMappingURL=git.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAoB5C,SAAS,QAAQ,CAAC,GAAW,EAAkC;IAC9D,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACrD,IAAI,YAA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C,WAAW,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,WAAW,GAAG,EAAE,CAAC,CAAC,MAAM,CAC9G,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAC1C,CAAC;IACF,KAAK,MAAM,SAAS,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,IAAI,EAAE,CAAC;YACV,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9C,SAAS;YACV,CAAC;YACD,OAAO;gBACN,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,WAAW,KAAK,CAAC,IAAI,EAAE;gBAC7B,IAAI,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;gBACvB,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;gBAC1D,GAAG,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,GAAG,IAAI,SAAS;gBAC9C,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,GAAG,CAAC;aAC7C,CAAC;QACH,CAAC;IACF,CAAC;IAED,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAAA,CAC/B","sourcesContent":["import hostedGitInfo from \"hosted-git-info\";\n\n/**\n * Parsed git URL information.\n */\nexport type GitSource = {\n\t/** Always \"git\" for git sources */\n\ttype: \"git\";\n\t/** Clone URL (always valid for git clone, without ref suffix) */\n\trepo: string;\n\t/** Git host domain (e.g., \"github.com\") */\n\thost: string;\n\t/** Repository path (e.g., \"user/repo\") */\n\tpath: string;\n\t/** Git ref (branch, tag, commit) if specified */\n\tref?: string;\n\t/** True if ref was specified (package won't be auto-updated) */\n\tpinned: boolean;\n};\n\nfunction splitRef(url: string): { repo: string; ref?: string } {\n\tconst scpLikeMatch = url.match(/^git@([^:]+):(.+)$/);\n\tif (scpLikeMatch) {\n\t\tconst pathWithMaybeRef = scpLikeMatch[2] ?? \"\";\n\t\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\n\t\tif (refSeparator < 0) return { repo: url };\n\t\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\n\t\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\n\t\tif (!repoPath || !ref) return { repo: url };\n\t\treturn {\n\t\t\trepo: `git@${scpLikeMatch[1] ?? \"\"}:${repoPath}`,\n\t\t\tref,\n\t\t};\n\t}\n\n\tif (url.includes(\"://\")) {\n\t\ttry {\n\t\t\tconst parsed = new URL(url);\n\t\t\tconst pathWithMaybeRef = parsed.pathname.replace(/^\\/+/, \"\");\n\t\t\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\n\t\t\tif (refSeparator < 0) return { repo: url };\n\t\t\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\n\t\t\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\n\t\t\tif (!repoPath || !ref) return { repo: url };\n\t\t\tparsed.pathname = `/${repoPath}`;\n\t\t\treturn {\n\t\t\t\trepo: parsed.toString().replace(/\\/$/, \"\"),\n\t\t\t\tref,\n\t\t\t};\n\t\t} catch {\n\t\t\treturn { repo: url };\n\t\t}\n\t}\n\n\tconst slashIndex = url.indexOf(\"/\");\n\tif (slashIndex < 0) {\n\t\treturn { repo: url };\n\t}\n\tconst host = url.slice(0, slashIndex);\n\tconst pathWithMaybeRef = url.slice(slashIndex + 1);\n\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\n\tif (refSeparator < 0) {\n\t\treturn { repo: url };\n\t}\n\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\n\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\n\tif (!repoPath || !ref) {\n\t\treturn { repo: url };\n\t}\n\treturn {\n\t\trepo: `${host}/${repoPath}`,\n\t\tref,\n\t};\n}\n\nfunction parseGenericGitUrl(url: string): GitSource | null {\n\tconst { repo: repoWithoutRef, ref } = splitRef(url);\n\tlet repo = repoWithoutRef;\n\tlet host = \"\";\n\tlet path = \"\";\n\n\tconst scpLikeMatch = repoWithoutRef.match(/^git@([^:]+):(.+)$/);\n\tif (scpLikeMatch) {\n\t\thost = scpLikeMatch[1] ?? \"\";\n\t\tpath = scpLikeMatch[2] ?? \"\";\n\t} else if (\n\t\trepoWithoutRef.startsWith(\"https://\") ||\n\t\trepoWithoutRef.startsWith(\"http://\") ||\n\t\trepoWithoutRef.startsWith(\"ssh://\") ||\n\t\trepoWithoutRef.startsWith(\"git://\")\n\t) {\n\t\ttry {\n\t\t\tconst parsed = new URL(repoWithoutRef);\n\t\t\thost = parsed.hostname;\n\t\t\tpath = parsed.pathname.replace(/^\\/+/, \"\");\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t} else {\n\t\tconst slashIndex = repoWithoutRef.indexOf(\"/\");\n\t\tif (slashIndex < 0) {\n\t\t\treturn null;\n\t\t}\n\t\thost = repoWithoutRef.slice(0, slashIndex);\n\t\tpath = repoWithoutRef.slice(slashIndex + 1);\n\t\tif (!host.includes(\".\") && host !== \"localhost\") {\n\t\t\treturn null;\n\t\t}\n\t\trepo = `https://${repoWithoutRef}`;\n\t}\n\n\tconst normalizedPath = path.replace(/\\.git$/, \"\").replace(/^\\/+/, \"\");\n\tif (!host || !normalizedPath || normalizedPath.split(\"/\").length < 2) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\ttype: \"git\",\n\t\trepo,\n\t\thost,\n\t\tpath: normalizedPath,\n\t\tref,\n\t\tpinned: Boolean(ref),\n\t};\n}\n\n/**\n * Parse git source into a GitSource.\n *\n * Rules:\n * - With git: prefix, accept all historical shorthand forms.\n * - Without git: prefix, only accept explicit protocol URLs.\n */\nexport function parseGitUrl(source: string): GitSource | null {\n\tconst trimmed = source.trim();\n\tconst hasGitPrefix = trimmed.startsWith(\"git:\");\n\tconst url = hasGitPrefix ? trimmed.slice(4).trim() : trimmed;\n\n\tif (!hasGitPrefix && !/^(https?|ssh|git):\\/\\//i.test(url)) {\n\t\treturn null;\n\t}\n\n\tconst split = splitRef(url);\n\n\tconst hostedCandidates = [split.ref ? `${split.repo}#${split.ref}` : undefined, url].filter(\n\t\t(value): value is string => Boolean(value),\n\t);\n\tfor (const candidate of hostedCandidates) {\n\t\tconst info = hostedGitInfo.fromUrl(candidate);\n\t\tif (info) {\n\t\t\tif (split.ref && info.project?.includes(\"@\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst useHttpsPrefix =\n\t\t\t\t!split.repo.startsWith(\"http://\") &&\n\t\t\t\t!split.repo.startsWith(\"https://\") &&\n\t\t\t\t!split.repo.startsWith(\"ssh://\") &&\n\t\t\t\t!split.repo.startsWith(\"git://\") &&\n\t\t\t\t!split.repo.startsWith(\"git@\");\n\t\t\treturn {\n\t\t\t\ttype: \"git\",\n\t\t\t\trepo: useHttpsPrefix ? `https://${split.repo}` : split.repo,\n\t\t\t\thost: info.domain || \"\",\n\t\t\t\tpath: `${info.user}/${info.project}`.replace(/\\.git$/, \"\"),\n\t\t\t\tref: info.committish || split.ref || undefined,\n\t\t\t\tpinned: Boolean(info.committish || split.ref),\n\t\t\t};\n\t\t}\n\t}\n\n\tconst httpsCandidates = [split.ref ? `https://${split.repo}#${split.ref}` : undefined, `https://${url}`].filter(\n\t\t(value): value is string => Boolean(value),\n\t);\n\tfor (const candidate of httpsCandidates) {\n\t\tconst info = hostedGitInfo.fromUrl(candidate);\n\t\tif (info) {\n\t\t\tif (split.ref && info.project?.includes(\"@\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttype: \"git\",\n\t\t\t\trepo: `https://${split.repo}`,\n\t\t\t\thost: info.domain || \"\",\n\t\t\t\tpath: `${info.user}/${info.project}`.replace(/\\.git$/, \"\"),\n\t\t\t\tref: info.committish || split.ref || undefined,\n\t\t\t\tpinned: Boolean(info.committish || split.ref),\n\t\t\t};\n\t\t}\n\t}\n\n\treturn parseGenericGitUrl(url);\n}\n"]}
@@ -1,9 +0,0 @@
1
- /**
2
- * Convert image to PNG format for terminal display.
3
- * Kitty graphics protocol requires PNG format (f=100).
4
- */
5
- export declare function convertToPng(base64Data: string, mimeType: string): Promise<{
6
- data: string;
7
- mimeType: string;
8
- } | null>;
9
- //# sourceMappingURL=image-convert.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image-convert.d.ts","sourceRoot":"","sources":["../../src/utils/image-convert.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAsB,YAAY,CACjC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CA8BpD","sourcesContent":["import { applyExifOrientation } from \"./exif-orientation.js\";\nimport { loadPhoton } from \"./photon.js\";\n\n/**\n * Convert image to PNG format for terminal display.\n * Kitty graphics protocol requires PNG format (f=100).\n */\nexport async function convertToPng(\n\tbase64Data: string,\n\tmimeType: string,\n): Promise<{ data: string; mimeType: string } | null> {\n\t// Already PNG, no conversion needed\n\tif (mimeType === \"image/png\") {\n\t\treturn { data: base64Data, mimeType };\n\t}\n\n\tconst photon = await loadPhoton();\n\tif (!photon) {\n\t\t// Photon not available, can't convert\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst bytes = new Uint8Array(Buffer.from(base64Data, \"base64\"));\n\t\tconst rawImage = photon.PhotonImage.new_from_byteslice(bytes);\n\t\tconst image = applyExifOrientation(photon, rawImage, bytes);\n\t\tif (image !== rawImage) rawImage.free();\n\t\ttry {\n\t\t\tconst pngBuffer = image.get_bytes();\n\t\t\treturn {\n\t\t\t\tdata: Buffer.from(pngBuffer).toString(\"base64\"),\n\t\t\t\tmimeType: \"image/png\",\n\t\t\t};\n\t\t} finally {\n\t\t\timage.free();\n\t\t}\n\t} catch {\n\t\t// Conversion failed\n\t\treturn null;\n\t}\n}\n"]}
@@ -1,39 +0,0 @@
1
- import { applyExifOrientation } from "./exif-orientation.js";
2
- import { loadPhoton } from "./photon.js";
3
- /**
4
- * Convert image to PNG format for terminal display.
5
- * Kitty graphics protocol requires PNG format (f=100).
6
- */
7
- export async function convertToPng(base64Data, mimeType) {
8
- // Already PNG, no conversion needed
9
- if (mimeType === "image/png") {
10
- return { data: base64Data, mimeType };
11
- }
12
- const photon = await loadPhoton();
13
- if (!photon) {
14
- // Photon not available, can't convert
15
- return null;
16
- }
17
- try {
18
- const bytes = new Uint8Array(Buffer.from(base64Data, "base64"));
19
- const rawImage = photon.PhotonImage.new_from_byteslice(bytes);
20
- const image = applyExifOrientation(photon, rawImage, bytes);
21
- if (image !== rawImage)
22
- rawImage.free();
23
- try {
24
- const pngBuffer = image.get_bytes();
25
- return {
26
- data: Buffer.from(pngBuffer).toString("base64"),
27
- mimeType: "image/png",
28
- };
29
- }
30
- finally {
31
- image.free();
32
- }
33
- }
34
- catch {
35
- // Conversion failed
36
- return null;
37
- }
38
- }
39
- //# sourceMappingURL=image-convert.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image-convert.js","sourceRoot":"","sources":["../../src/utils/image-convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,UAAkB,EAClB,QAAgB,EACqC;IACrD,oCAAoC;IACpC,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;IACvC,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;IAClC,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,sCAAsC;QACtC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,CAAC;QACJ,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC9D,MAAM,KAAK,GAAG,oBAAoB,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC5D,IAAI,KAAK,KAAK,QAAQ;YAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,IAAI,CAAC;YACJ,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACpC,OAAO;gBACN,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAC/C,QAAQ,EAAE,WAAW;aACrB,CAAC;QACH,CAAC;gBAAS,CAAC;YACV,KAAK,CAAC,IAAI,EAAE,CAAC;QACd,CAAC;IACF,CAAC;IAAC,MAAM,CAAC;QACR,oBAAoB;QACpB,OAAO,IAAI,CAAC;IACb,CAAC;AAAA,CACD","sourcesContent":["import { applyExifOrientation } from \"./exif-orientation.js\";\nimport { loadPhoton } from \"./photon.js\";\n\n/**\n * Convert image to PNG format for terminal display.\n * Kitty graphics protocol requires PNG format (f=100).\n */\nexport async function convertToPng(\n\tbase64Data: string,\n\tmimeType: string,\n): Promise<{ data: string; mimeType: string } | null> {\n\t// Already PNG, no conversion needed\n\tif (mimeType === \"image/png\") {\n\t\treturn { data: base64Data, mimeType };\n\t}\n\n\tconst photon = await loadPhoton();\n\tif (!photon) {\n\t\t// Photon not available, can't convert\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst bytes = new Uint8Array(Buffer.from(base64Data, \"base64\"));\n\t\tconst rawImage = photon.PhotonImage.new_from_byteslice(bytes);\n\t\tconst image = applyExifOrientation(photon, rawImage, bytes);\n\t\tif (image !== rawImage) rawImage.free();\n\t\ttry {\n\t\t\tconst pngBuffer = image.get_bytes();\n\t\t\treturn {\n\t\t\t\tdata: Buffer.from(pngBuffer).toString(\"base64\"),\n\t\t\t\tmimeType: \"image/png\",\n\t\t\t};\n\t\t} finally {\n\t\t\timage.free();\n\t\t}\n\t} catch {\n\t\t// Conversion failed\n\t\treturn null;\n\t}\n}\n"]}
@@ -1,36 +0,0 @@
1
- import type { ImageContent } from "@mariozechner/pi-ai";
2
- export interface ImageResizeOptions {
3
- maxWidth?: number;
4
- maxHeight?: number;
5
- maxBytes?: number;
6
- jpegQuality?: number;
7
- }
8
- export interface ResizedImage {
9
- data: string;
10
- mimeType: string;
11
- originalWidth: number;
12
- originalHeight: number;
13
- width: number;
14
- height: number;
15
- wasResized: boolean;
16
- }
17
- /**
18
- * Resize an image to fit within the specified max dimensions and encoded file size.
19
- * Returns null if the image cannot be resized below maxBytes.
20
- *
21
- * Uses Photon (Rust/WASM) for image processing. If Photon is not available,
22
- * returns null.
23
- *
24
- * Strategy for staying under maxBytes:
25
- * 1. First resize to maxWidth/maxHeight
26
- * 2. Try both PNG and JPEG formats, pick the smaller one
27
- * 3. If still too large, try JPEG with decreasing quality
28
- * 4. If still too large, progressively reduce dimensions until 1x1
29
- */
30
- export declare function resizeImage(img: ImageContent, options?: ImageResizeOptions): Promise<ResizedImage | null>;
31
- /**
32
- * Format a dimension note for resized images.
33
- * This helps the model understand the coordinate mapping.
34
- */
35
- export declare function formatDimensionNote(result: ResizedImage): string | undefined;
36
- //# sourceMappingURL=image-resize.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image-resize.d.ts","sourceRoot":"","sources":["../../src/utils/image-resize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAIxD,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;CACpB;AA2BD;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAuG/G;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAO5E","sourcesContent":["import type { ImageContent } from \"@mariozechner/pi-ai\";\nimport { applyExifOrientation } from \"./exif-orientation.js\";\nimport { loadPhoton } from \"./photon.js\";\n\nexport interface ImageResizeOptions {\n\tmaxWidth?: number; // Default: 2000\n\tmaxHeight?: number; // Default: 2000\n\tmaxBytes?: number; // Default: 4.5MB of base64 payload (below Anthropic's 5MB limit)\n\tjpegQuality?: number; // Default: 80\n}\n\nexport interface ResizedImage {\n\tdata: string; // base64\n\tmimeType: string;\n\toriginalWidth: number;\n\toriginalHeight: number;\n\twidth: number;\n\theight: number;\n\twasResized: boolean;\n}\n\n// 4.5MB of base64 payload. Provides headroom below Anthropic's 5MB limit.\nconst DEFAULT_MAX_BYTES = 4.5 * 1024 * 1024;\n\nconst DEFAULT_OPTIONS: Required<ImageResizeOptions> = {\n\tmaxWidth: 2000,\n\tmaxHeight: 2000,\n\tmaxBytes: DEFAULT_MAX_BYTES,\n\tjpegQuality: 80,\n};\n\ninterface EncodedCandidate {\n\tdata: string;\n\tencodedSize: number;\n\tmimeType: string;\n}\n\nfunction encodeCandidate(buffer: Uint8Array, mimeType: string): EncodedCandidate {\n\tconst data = Buffer.from(buffer).toString(\"base64\");\n\treturn {\n\t\tdata,\n\t\tencodedSize: Buffer.byteLength(data, \"utf-8\"),\n\t\tmimeType,\n\t};\n}\n\n/**\n * Resize an image to fit within the specified max dimensions and encoded file size.\n * Returns null if the image cannot be resized below maxBytes.\n *\n * Uses Photon (Rust/WASM) for image processing. If Photon is not available,\n * returns null.\n *\n * Strategy for staying under maxBytes:\n * 1. First resize to maxWidth/maxHeight\n * 2. Try both PNG and JPEG formats, pick the smaller one\n * 3. If still too large, try JPEG with decreasing quality\n * 4. If still too large, progressively reduce dimensions until 1x1\n */\nexport async function resizeImage(img: ImageContent, options?: ImageResizeOptions): Promise<ResizedImage | null> {\n\tconst opts = { ...DEFAULT_OPTIONS, ...options };\n\tconst inputBuffer = Buffer.from(img.data, \"base64\");\n\tconst inputBase64Size = Buffer.byteLength(img.data, \"utf-8\");\n\n\tconst photon = await loadPhoton();\n\tif (!photon) {\n\t\treturn null;\n\t}\n\n\tlet image: ReturnType<typeof photon.PhotonImage.new_from_byteslice> | undefined;\n\ttry {\n\t\tconst inputBytes = new Uint8Array(inputBuffer);\n\t\tconst rawImage = photon.PhotonImage.new_from_byteslice(inputBytes);\n\t\timage = applyExifOrientation(photon, rawImage, inputBytes);\n\t\tif (image !== rawImage) rawImage.free();\n\n\t\tconst originalWidth = image.get_width();\n\t\tconst originalHeight = image.get_height();\n\t\tconst format = img.mimeType?.split(\"/\")[1] ?? \"png\";\n\n\t\t// Check if already within all limits (dimensions AND encoded size)\n\t\tif (originalWidth <= opts.maxWidth && originalHeight <= opts.maxHeight && inputBase64Size < opts.maxBytes) {\n\t\t\treturn {\n\t\t\t\tdata: img.data,\n\t\t\t\tmimeType: img.mimeType ?? `image/${format}`,\n\t\t\t\toriginalWidth,\n\t\t\t\toriginalHeight,\n\t\t\t\twidth: originalWidth,\n\t\t\t\theight: originalHeight,\n\t\t\t\twasResized: false,\n\t\t\t};\n\t\t}\n\n\t\t// Calculate initial dimensions respecting max limits\n\t\tlet targetWidth = originalWidth;\n\t\tlet targetHeight = originalHeight;\n\n\t\tif (targetWidth > opts.maxWidth) {\n\t\t\ttargetHeight = Math.round((targetHeight * opts.maxWidth) / targetWidth);\n\t\t\ttargetWidth = opts.maxWidth;\n\t\t}\n\t\tif (targetHeight > opts.maxHeight) {\n\t\t\ttargetWidth = Math.round((targetWidth * opts.maxHeight) / targetHeight);\n\t\t\ttargetHeight = opts.maxHeight;\n\t\t}\n\n\t\tfunction tryEncodings(width: number, height: number, jpegQualities: number[]): EncodedCandidate[] {\n\t\t\tconst resized = photon!.resize(image!, width, height, photon!.SamplingFilter.Lanczos3);\n\n\t\t\ttry {\n\t\t\t\tconst candidates: EncodedCandidate[] = [encodeCandidate(resized.get_bytes(), \"image/png\")];\n\t\t\t\tfor (const quality of jpegQualities) {\n\t\t\t\t\tcandidates.push(encodeCandidate(resized.get_bytes_jpeg(quality), \"image/jpeg\"));\n\t\t\t\t}\n\t\t\t\treturn candidates;\n\t\t\t} finally {\n\t\t\t\tresized.free();\n\t\t\t}\n\t\t}\n\n\t\tconst qualitySteps = Array.from(new Set([opts.jpegQuality, 85, 70, 55, 40]));\n\t\tlet currentWidth = targetWidth;\n\t\tlet currentHeight = targetHeight;\n\n\t\twhile (true) {\n\t\t\tconst candidates = tryEncodings(currentWidth, currentHeight, qualitySteps);\n\t\t\tfor (const candidate of candidates) {\n\t\t\t\tif (candidate.encodedSize < opts.maxBytes) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdata: candidate.data,\n\t\t\t\t\t\tmimeType: candidate.mimeType,\n\t\t\t\t\t\toriginalWidth,\n\t\t\t\t\t\toriginalHeight,\n\t\t\t\t\t\twidth: currentWidth,\n\t\t\t\t\t\theight: currentHeight,\n\t\t\t\t\t\twasResized: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (currentWidth === 1 && currentHeight === 1) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst nextWidth = currentWidth === 1 ? 1 : Math.max(1, Math.floor(currentWidth * 0.75));\n\t\t\tconst nextHeight = currentHeight === 1 ? 1 : Math.max(1, Math.floor(currentHeight * 0.75));\n\t\t\tif (nextWidth === currentWidth && nextHeight === currentHeight) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcurrentWidth = nextWidth;\n\t\t\tcurrentHeight = nextHeight;\n\t\t}\n\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t} finally {\n\t\tif (image) {\n\t\t\timage.free();\n\t\t}\n\t}\n}\n\n/**\n * Format a dimension note for resized images.\n * This helps the model understand the coordinate mapping.\n */\nexport function formatDimensionNote(result: ResizedImage): string | undefined {\n\tif (!result.wasResized) {\n\t\treturn undefined;\n\t}\n\n\tconst scale = result.originalWidth / result.width;\n\treturn `[Image: original ${result.originalWidth}x${result.originalHeight}, displayed at ${result.width}x${result.height}. Multiply coordinates by ${scale.toFixed(2)} to map to original image.]`;\n}\n"]}