@code-yeongyu/senpi 2026.6.4 → 2026.6.10

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 (1142) hide show
  1. package/CHANGELOG.md +64 -1
  2. package/README.md +127 -110
  3. package/dist/bun/cli.d.ts.map +1 -1
  4. package/dist/bun/cli.js.map +1 -1
  5. package/dist/bun/register-bedrock.d.ts.map +1 -1
  6. package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
  7. package/dist/bun/restore-sandbox-env.js.map +1 -1
  8. package/dist/cli/args.d.ts +1 -0
  9. package/dist/cli/args.d.ts.map +1 -1
  10. package/dist/cli/args.js +13 -4
  11. package/dist/cli/args.js.map +1 -1
  12. package/dist/cli/config-selector.d.ts.map +1 -1
  13. package/dist/cli/config-selector.js.map +1 -1
  14. package/dist/cli/file-processor.d.ts.map +1 -1
  15. package/dist/cli/file-processor.js.map +1 -1
  16. package/dist/cli/initial-message.d.ts +1 -1
  17. package/dist/cli/initial-message.d.ts.map +1 -1
  18. package/dist/cli/initial-message.js.map +1 -1
  19. package/dist/cli/list-models.d.ts.map +1 -1
  20. package/dist/cli/list-models.js.map +1 -1
  21. package/dist/cli/project-trust.d.ts +10 -0
  22. package/dist/cli/project-trust.d.ts.map +1 -0
  23. package/dist/cli/project-trust.js +48 -0
  24. package/dist/cli/project-trust.js.map +1 -0
  25. package/dist/cli/session-picker.d.ts.map +1 -1
  26. package/dist/cli/session-picker.js.map +1 -1
  27. package/dist/cli/startup-ui.d.ts +7 -0
  28. package/dist/cli/startup-ui.d.ts.map +1 -0
  29. package/dist/cli/startup-ui.js +59 -0
  30. package/dist/cli/startup-ui.js.map +1 -0
  31. package/dist/cli-main.d.ts.map +1 -1
  32. package/dist/cli-main.js.map +1 -1
  33. package/dist/cli.d.ts.map +1 -1
  34. package/dist/cli.js +10 -1
  35. package/dist/cli.js.map +1 -1
  36. package/dist/config.d.ts.map +1 -1
  37. package/dist/config.js.map +1 -1
  38. package/dist/core/agent-session-runtime.d.ts +3 -1
  39. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  40. package/dist/core/agent-session-runtime.js +4 -9
  41. package/dist/core/agent-session-runtime.js.map +1 -1
  42. package/dist/core/agent-session-services.d.ts +2 -1
  43. package/dist/core/agent-session-services.d.ts.map +1 -1
  44. package/dist/core/agent-session-services.js +2 -2
  45. package/dist/core/agent-session-services.js.map +1 -1
  46. package/dist/core/agent-session.d.ts +33 -0
  47. package/dist/core/agent-session.d.ts.map +1 -1
  48. package/dist/core/agent-session.js +57 -79
  49. package/dist/core/agent-session.js.map +1 -1
  50. package/dist/core/auth-guidance.d.ts.map +1 -1
  51. package/dist/core/auth-guidance.js.map +1 -1
  52. package/dist/core/auth-storage.d.ts +4 -0
  53. package/dist/core/auth-storage.d.ts.map +1 -1
  54. package/dist/core/auth-storage.js +4 -8
  55. package/dist/core/auth-storage.js.map +1 -1
  56. package/dist/core/bash-executor.d.ts.map +1 -1
  57. package/dist/core/bash-executor.js.map +1 -1
  58. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  59. package/dist/core/compaction/branch-summarization.js.map +1 -1
  60. package/dist/core/compaction/compaction.d.ts.map +1 -1
  61. package/dist/core/compaction/compaction.js.map +1 -1
  62. package/dist/core/compaction/index.d.ts.map +1 -1
  63. package/dist/core/compaction/utils.d.ts +1 -1
  64. package/dist/core/compaction/utils.d.ts.map +1 -1
  65. package/dist/core/compaction/utils.js +1 -1
  66. package/dist/core/compaction/utils.js.map +1 -1
  67. package/dist/core/defaults.d.ts.map +1 -1
  68. package/dist/core/diagnostics.d.ts.map +1 -1
  69. package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
  70. package/dist/core/dynamic-prompt/build.js.map +1 -1
  71. package/dist/core/dynamic-prompt/exploration.d.ts.map +1 -1
  72. package/dist/core/dynamic-prompt/exploration.js.map +1 -1
  73. package/dist/core/dynamic-prompt/identity.d.ts.map +1 -1
  74. package/dist/core/dynamic-prompt/identity.js.map +1 -1
  75. package/dist/core/dynamic-prompt/index.d.ts.map +1 -1
  76. package/dist/core/dynamic-prompt/intent-gate.d.ts.map +1 -1
  77. package/dist/core/dynamic-prompt/intent-gate.js.map +1 -1
  78. package/dist/core/dynamic-prompt/parallel-tools.d.ts.map +1 -1
  79. package/dist/core/dynamic-prompt/parallel-tools.js.map +1 -1
  80. package/dist/core/dynamic-prompt/policies.d.ts.map +1 -1
  81. package/dist/core/dynamic-prompt/policies.js.map +1 -1
  82. package/dist/core/dynamic-prompt/style.d.ts.map +1 -1
  83. package/dist/core/dynamic-prompt/style.js.map +1 -1
  84. package/dist/core/dynamic-prompt/tool-categorization.d.ts.map +1 -1
  85. package/dist/core/dynamic-prompt/tool-categorization.js.map +1 -1
  86. package/dist/core/dynamic-prompt/tool-section.d.ts.map +1 -1
  87. package/dist/core/dynamic-prompt/tool-section.js.map +1 -1
  88. package/dist/core/dynamic-prompt/types.d.ts.map +1 -1
  89. package/dist/core/dynamic-prompt/verification.d.ts.map +1 -1
  90. package/dist/core/dynamic-prompt/verification.js.map +1 -1
  91. package/dist/core/event-bus.d.ts.map +1 -1
  92. package/dist/core/event-bus.js.map +1 -1
  93. package/dist/core/exec.d.ts.map +1 -1
  94. package/dist/core/exec.js.map +1 -1
  95. package/dist/core/experimental.d.ts +2 -0
  96. package/dist/core/experimental.d.ts.map +1 -0
  97. package/dist/core/experimental.js +4 -0
  98. package/dist/core/experimental.js.map +1 -0
  99. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  100. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  101. package/dist/core/export-html/index.d.ts.map +1 -1
  102. package/dist/core/export-html/index.js.map +1 -1
  103. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  104. package/dist/core/export-html/tool-renderer.js.map +1 -1
  105. package/dist/core/extensions/builtin/anthropic-bash/index.d.ts.map +1 -1
  106. package/dist/core/extensions/builtin/anthropic-bash/index.js.map +1 -1
  107. package/dist/core/extensions/builtin/anthropic-web-search/index.d.ts.map +1 -1
  108. package/dist/core/extensions/builtin/anthropic-web-search/index.js.map +1 -1
  109. package/dist/core/extensions/builtin/bash-timeout/index.d.ts.map +1 -1
  110. package/dist/core/extensions/builtin/bash-timeout/index.js.map +1 -1
  111. package/dist/core/extensions/builtin/bash-timeout/timeout.d.ts.map +1 -1
  112. package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
  113. package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts.map +1 -1
  114. package/dist/core/extensions/builtin/compaction/checkpoint-state.js.map +1 -1
  115. package/dist/core/extensions/builtin/compaction/circuit-breaker.d.ts.map +1 -1
  116. package/dist/core/extensions/builtin/compaction/circuit-breaker.js.map +1 -1
  117. package/dist/core/extensions/builtin/compaction/context-reduction.d.ts.map +1 -1
  118. package/dist/core/extensions/builtin/compaction/context-reduction.js +1 -1
  119. package/dist/core/extensions/builtin/compaction/context-reduction.js.map +1 -1
  120. package/dist/core/extensions/builtin/compaction/degradation-monitor.d.ts.map +1 -1
  121. package/dist/core/extensions/builtin/compaction/degradation-monitor.js.map +1 -1
  122. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  123. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  124. package/dist/core/extensions/builtin/compaction/openai-remote.d.ts.map +1 -1
  125. package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -1
  126. package/dist/core/extensions/builtin/compaction/overflow-detection.d.ts.map +1 -1
  127. package/dist/core/extensions/builtin/compaction/overflow-detection.js.map +1 -1
  128. package/dist/core/extensions/builtin/compaction/per-turn-cap.d.ts.map +1 -1
  129. package/dist/core/extensions/builtin/compaction/per-turn-cap.js.map +1 -1
  130. package/dist/core/extensions/builtin/compaction/policy.d.ts.map +1 -1
  131. package/dist/core/extensions/builtin/compaction/policy.js.map +1 -1
  132. package/dist/core/extensions/builtin/compaction/prompts.d.ts.map +1 -1
  133. package/dist/core/extensions/builtin/compaction/prompts.js.map +1 -1
  134. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts.map +1 -1
  135. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js.map +1 -1
  136. package/dist/core/extensions/builtin/compaction/restoration-tracker.d.ts.map +1 -1
  137. package/dist/core/extensions/builtin/compaction/restoration-tracker.js.map +1 -1
  138. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  139. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  140. package/dist/core/extensions/builtin/compaction/state.d.ts.map +1 -1
  141. package/dist/core/extensions/builtin/compaction/state.js.map +1 -1
  142. package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts.map +1 -1
  143. package/dist/core/extensions/builtin/compaction/todo-bridge.js.map +1 -1
  144. package/dist/core/extensions/builtin/compaction/tool-truncation.d.ts.map +1 -1
  145. package/dist/core/extensions/builtin/compaction/tool-truncation.js.map +1 -1
  146. package/dist/core/extensions/builtin/diff.d.ts.map +1 -1
  147. package/dist/core/extensions/builtin/diff.js.map +1 -1
  148. package/dist/core/extensions/builtin/files.d.ts.map +1 -1
  149. package/dist/core/extensions/builtin/files.js.map +1 -1
  150. package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts.map +1 -1
  151. package/dist/core/extensions/builtin/gpt-apply-patch/apply.js.map +1 -1
  152. package/dist/core/extensions/builtin/gpt-apply-patch/constants.d.ts.map +1 -1
  153. package/dist/core/extensions/builtin/gpt-apply-patch/constants.js.map +1 -1
  154. package/dist/core/extensions/builtin/gpt-apply-patch/errors.d.ts.map +1 -1
  155. package/dist/core/extensions/builtin/gpt-apply-patch/errors.js +0 -2
  156. package/dist/core/extensions/builtin/gpt-apply-patch/errors.js.map +1 -1
  157. package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts.map +1 -1
  158. package/dist/core/extensions/builtin/gpt-apply-patch/extension.js.map +1 -1
  159. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts.map +1 -1
  160. package/dist/core/extensions/builtin/gpt-apply-patch/params.d.ts.map +1 -1
  161. package/dist/core/extensions/builtin/gpt-apply-patch/params.js.map +1 -1
  162. package/dist/core/extensions/builtin/gpt-apply-patch/parser.d.ts.map +1 -1
  163. package/dist/core/extensions/builtin/gpt-apply-patch/parser.js.map +1 -1
  164. package/dist/core/extensions/builtin/gpt-apply-patch/patch-diff.d.ts.map +1 -1
  165. package/dist/core/extensions/builtin/gpt-apply-patch/patch-diff.js.map +1 -1
  166. package/dist/core/extensions/builtin/gpt-apply-patch/patch-replace.d.ts.map +1 -1
  167. package/dist/core/extensions/builtin/gpt-apply-patch/patch-replace.js.map +1 -1
  168. package/dist/core/extensions/builtin/gpt-apply-patch/preview-format.d.ts.map +1 -1
  169. package/dist/core/extensions/builtin/gpt-apply-patch/preview-format.js.map +1 -1
  170. package/dist/core/extensions/builtin/gpt-apply-patch/preview.d.ts.map +1 -1
  171. package/dist/core/extensions/builtin/gpt-apply-patch/preview.js.map +1 -1
  172. package/dist/core/extensions/builtin/gpt-apply-patch/seek-sequence.d.ts.map +1 -1
  173. package/dist/core/extensions/builtin/gpt-apply-patch/seek-sequence.js.map +1 -1
  174. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.d.ts.map +1 -1
  175. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.js +7 -5
  176. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.js.map +1 -1
  177. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-render.d.ts.map +1 -1
  178. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-render.js.map +1 -1
  179. package/dist/core/extensions/builtin/gpt-apply-patch/text.d.ts.map +1 -1
  180. package/dist/core/extensions/builtin/gpt-apply-patch/text.js.map +1 -1
  181. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts.map +1 -1
  182. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
  183. package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts.map +1 -1
  184. package/dist/core/extensions/builtin/gpt-apply-patch/workspace.d.ts.map +1 -1
  185. package/dist/core/extensions/builtin/gpt-apply-patch/workspace.js.map +1 -1
  186. package/dist/core/extensions/builtin/history-search/filter.d.ts.map +1 -1
  187. package/dist/core/extensions/builtin/history-search/filter.js.map +1 -1
  188. package/dist/core/extensions/builtin/history-search/index.d.ts.map +1 -1
  189. package/dist/core/extensions/builtin/history-search/index.js.map +1 -1
  190. package/dist/core/extensions/builtin/history-search/indexer.d.ts.map +1 -1
  191. package/dist/core/extensions/builtin/history-search/indexer.js.map +1 -1
  192. package/dist/core/extensions/builtin/history-search/overlay.d.ts.map +1 -1
  193. package/dist/core/extensions/builtin/history-search/overlay.js +3 -6
  194. package/dist/core/extensions/builtin/history-search/overlay.js.map +1 -1
  195. package/dist/core/extensions/builtin/history-search/types.d.ts.map +1 -1
  196. package/dist/core/extensions/builtin/index.d.ts.map +1 -1
  197. package/dist/core/extensions/builtin/kimi-web-search/index.d.ts.map +1 -1
  198. package/dist/core/extensions/builtin/kimi-web-search/index.js.map +1 -1
  199. package/dist/core/extensions/builtin/openai-web-search/index.d.ts.map +1 -1
  200. package/dist/core/extensions/builtin/openai-web-search/index.js.map +1 -1
  201. package/dist/core/extensions/builtin/permission-system/arity.d.ts.map +1 -1
  202. package/dist/core/extensions/builtin/permission-system/arity.js.map +1 -1
  203. package/dist/core/extensions/builtin/permission-system/cli.d.ts.map +1 -1
  204. package/dist/core/extensions/builtin/permission-system/cli.js.map +1 -1
  205. package/dist/core/extensions/builtin/permission-system/config.d.ts.map +1 -1
  206. package/dist/core/extensions/builtin/permission-system/config.js.map +1 -1
  207. package/dist/core/extensions/builtin/permission-system/evaluate.d.ts.map +1 -1
  208. package/dist/core/extensions/builtin/permission-system/evaluate.js.map +1 -1
  209. package/dist/core/extensions/builtin/permission-system/events.d.ts.map +1 -1
  210. package/dist/core/extensions/builtin/permission-system/events.js.map +1 -1
  211. package/dist/core/extensions/builtin/permission-system/external-dir.d.ts.map +1 -1
  212. package/dist/core/extensions/builtin/permission-system/external-dir.js.map +1 -1
  213. package/dist/core/extensions/builtin/permission-system/index.d.ts.map +1 -1
  214. package/dist/core/extensions/builtin/permission-system/index.js.map +1 -1
  215. package/dist/core/extensions/builtin/permission-system/non-interactive.d.ts.map +1 -1
  216. package/dist/core/extensions/builtin/permission-system/non-interactive.js.map +1 -1
  217. package/dist/core/extensions/builtin/permission-system/parsers.d.ts.map +1 -1
  218. package/dist/core/extensions/builtin/permission-system/parsers.js +3 -1
  219. package/dist/core/extensions/builtin/permission-system/parsers.js.map +1 -1
  220. package/dist/core/extensions/builtin/permission-system/prompt.d.ts.map +1 -1
  221. package/dist/core/extensions/builtin/permission-system/prompt.js.map +1 -1
  222. package/dist/core/extensions/builtin/permission-system/service.d.ts.map +1 -1
  223. package/dist/core/extensions/builtin/permission-system/service.js +2 -5
  224. package/dist/core/extensions/builtin/permission-system/service.js.map +1 -1
  225. package/dist/core/extensions/builtin/permission-system/settings.d.ts.map +1 -1
  226. package/dist/core/extensions/builtin/permission-system/settings.js.map +1 -1
  227. package/dist/core/extensions/builtin/permission-system/storage.d.ts.map +1 -1
  228. package/dist/core/extensions/builtin/permission-system/storage.js.map +1 -1
  229. package/dist/core/extensions/builtin/permission-system/types.d.ts.map +1 -1
  230. package/dist/core/extensions/builtin/permission-system/types.js +3 -5
  231. package/dist/core/extensions/builtin/permission-system/types.js.map +1 -1
  232. package/dist/core/extensions/builtin/permission-system/wildcard.d.ts.map +1 -1
  233. package/dist/core/extensions/builtin/permission-system/wildcard.js.map +1 -1
  234. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts.map +1 -1
  235. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js.map +1 -1
  236. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts.map +1 -1
  237. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js.map +1 -1
  238. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts.map +1 -1
  239. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js.map +1 -1
  240. package/dist/core/extensions/builtin/prompt-preset/file-operations.d.ts.map +1 -1
  241. package/dist/core/extensions/builtin/prompt-preset/file-operations.js.map +1 -1
  242. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.d.ts.map +1 -1
  243. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js.map +1 -1
  244. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.d.ts.map +1 -1
  245. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js.map +1 -1
  246. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.d.ts.map +1 -1
  247. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js.map +1 -1
  248. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.d.ts.map +1 -1
  249. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
  250. package/dist/core/extensions/builtin/prompt-preset/gpt-5.d.ts.map +1 -1
  251. package/dist/core/extensions/builtin/prompt-preset/gpt-5.js.map +1 -1
  252. package/dist/core/extensions/builtin/prompt-preset/index.d.ts.map +1 -1
  253. package/dist/core/extensions/builtin/prompt-preset/index.js.map +1 -1
  254. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.d.ts.map +1 -1
  255. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js.map +1 -1
  256. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
  257. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
  258. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
  259. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
  260. package/dist/core/extensions/builtin/prompt-url-widget.d.ts.map +1 -1
  261. package/dist/core/extensions/builtin/prompt-url-widget.js.map +1 -1
  262. package/dist/core/extensions/builtin/redraws.d.ts.map +1 -1
  263. package/dist/core/extensions/builtin/redraws.js.map +1 -1
  264. package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
  265. package/dist/core/extensions/builtin/service-tier.js.map +1 -1
  266. package/dist/core/extensions/builtin/session-observer/index.d.ts.map +1 -1
  267. package/dist/core/extensions/builtin/session-observer/index.js.map +1 -1
  268. package/dist/core/extensions/builtin/session-observer/loader.d.ts.map +1 -1
  269. package/dist/core/extensions/builtin/session-observer/loader.js.map +1 -1
  270. package/dist/core/extensions/builtin/session-observer/overlay-format.d.ts.map +1 -1
  271. package/dist/core/extensions/builtin/session-observer/overlay-format.js.map +1 -1
  272. package/dist/core/extensions/builtin/session-observer/overlay.d.ts.map +1 -1
  273. package/dist/core/extensions/builtin/session-observer/overlay.js +13 -18
  274. package/dist/core/extensions/builtin/session-observer/overlay.js.map +1 -1
  275. package/dist/core/extensions/builtin/session-observer/scanner.d.ts.map +1 -1
  276. package/dist/core/extensions/builtin/session-observer/scanner.js.map +1 -1
  277. package/dist/core/extensions/builtin/session-observer/text.d.ts.map +1 -1
  278. package/dist/core/extensions/builtin/session-observer/text.js.map +1 -1
  279. package/dist/core/extensions/builtin/session-observer/transcript-entries.d.ts.map +1 -1
  280. package/dist/core/extensions/builtin/session-observer/transcript-entries.js.map +1 -1
  281. package/dist/core/extensions/builtin/session-observer/transcript-format.d.ts.map +1 -1
  282. package/dist/core/extensions/builtin/session-observer/transcript-format.js.map +1 -1
  283. package/dist/core/extensions/builtin/session-observer/transcript.d.ts.map +1 -1
  284. package/dist/core/extensions/builtin/session-observer/transcript.js.map +1 -1
  285. package/dist/core/extensions/builtin/session-observer/types.d.ts.map +1 -1
  286. package/dist/core/extensions/builtin/system-messages.d.ts.map +1 -1
  287. package/dist/core/extensions/builtin/system-messages.js.map +1 -1
  288. package/dist/core/extensions/builtin/todotools/index.d.ts.map +1 -1
  289. package/dist/core/extensions/builtin/todotools/index.js +0 -2
  290. package/dist/core/extensions/builtin/todotools/index.js.map +1 -1
  291. package/dist/core/extensions/builtin/todotools/prompt.d.ts +1 -1
  292. package/dist/core/extensions/builtin/todotools/prompt.d.ts.map +1 -1
  293. package/dist/core/extensions/builtin/todotools/prompt.js +0 -2
  294. package/dist/core/extensions/builtin/todotools/prompt.js.map +1 -1
  295. package/dist/core/extensions/builtin/todotools/state.d.ts.map +1 -1
  296. package/dist/core/extensions/builtin/todotools/state.js.map +1 -1
  297. package/dist/core/extensions/builtin/todotools/tools/todoread.d.ts.map +1 -1
  298. package/dist/core/extensions/builtin/todotools/tools/todoread.js.map +1 -1
  299. package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts.map +1 -1
  300. package/dist/core/extensions/builtin/todotools/tools/todowrite.js.map +1 -1
  301. package/dist/core/extensions/builtin/tool-pair-guard/index.d.ts.map +1 -1
  302. package/dist/core/extensions/builtin/tool-pair-guard/index.js.map +1 -1
  303. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts.map +1 -1
  304. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js.map +1 -1
  305. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-chat-completions-payload.d.ts.map +1 -1
  306. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-chat-completions-payload.js.map +1 -1
  307. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-responses-payload.d.ts.map +1 -1
  308. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-responses-payload.js.map +1 -1
  309. package/dist/core/extensions/builtin/tps.d.ts.map +1 -1
  310. package/dist/core/extensions/builtin/tps.js.map +1 -1
  311. package/dist/core/extensions/index.d.ts +1 -1
  312. package/dist/core/extensions/index.d.ts.map +1 -1
  313. package/dist/core/extensions/index.js.map +1 -1
  314. package/dist/core/extensions/loader.d.ts +1 -1
  315. package/dist/core/extensions/loader.d.ts.map +1 -1
  316. package/dist/core/extensions/loader.js +4 -4
  317. package/dist/core/extensions/loader.js.map +1 -1
  318. package/dist/core/extensions/runner.d.ts +7 -2
  319. package/dist/core/extensions/runner.d.ts.map +1 -1
  320. package/dist/core/extensions/runner.js +69 -43
  321. package/dist/core/extensions/runner.js.map +1 -1
  322. package/dist/core/extensions/types.d.ts +22 -2
  323. package/dist/core/extensions/types.d.ts.map +1 -1
  324. package/dist/core/extensions/types.js.map +1 -1
  325. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  326. package/dist/core/extensions/wrapper.js.map +1 -1
  327. package/dist/core/footer-data-provider.d.ts.map +1 -1
  328. package/dist/core/footer-data-provider.js +17 -18
  329. package/dist/core/footer-data-provider.js.map +1 -1
  330. package/dist/core/http-dispatcher.d.ts.map +1 -1
  331. package/dist/core/http-dispatcher.js.map +1 -1
  332. package/dist/core/index.d.ts +1 -0
  333. package/dist/core/index.d.ts.map +1 -1
  334. package/dist/core/index.js +1 -0
  335. package/dist/core/index.js.map +1 -1
  336. package/dist/core/keybindings.d.ts +1 -1
  337. package/dist/core/keybindings.d.ts.map +1 -1
  338. package/dist/core/keybindings.js +0 -1
  339. package/dist/core/keybindings.js.map +1 -1
  340. package/dist/core/messages.d.ts.map +1 -1
  341. package/dist/core/messages.js.map +1 -1
  342. package/dist/core/model-registry.d.ts +3 -1
  343. package/dist/core/model-registry.d.ts.map +1 -1
  344. package/dist/core/model-registry.js +30 -13
  345. package/dist/core/model-registry.js.map +1 -1
  346. package/dist/core/model-resolver.d.ts.map +1 -1
  347. package/dist/core/model-resolver.js.map +1 -1
  348. package/dist/core/output-guard.d.ts.map +1 -1
  349. package/dist/core/output-guard.js.map +1 -1
  350. package/dist/core/package-manager.d.ts +1 -0
  351. package/dist/core/package-manager.d.ts.map +1 -1
  352. package/dist/core/package-manager.js +25 -13
  353. package/dist/core/package-manager.js.map +1 -1
  354. package/dist/core/project-trust.d.ts +15 -0
  355. package/dist/core/project-trust.d.ts.map +1 -0
  356. package/dist/core/project-trust.js +58 -0
  357. package/dist/core/project-trust.js.map +1 -0
  358. package/dist/core/prompt-templates.d.ts +2 -1
  359. package/dist/core/prompt-templates.d.ts.map +1 -1
  360. package/dist/core/prompt-templates.js +24 -26
  361. package/dist/core/prompt-templates.js.map +1 -1
  362. package/dist/core/provider-attribution.d.ts.map +1 -1
  363. package/dist/core/provider-attribution.js.map +1 -1
  364. package/dist/core/provider-display-names.d.ts.map +1 -1
  365. package/dist/core/resolve-config-value.d.ts.map +1 -1
  366. package/dist/core/resolve-config-value.js.map +1 -1
  367. package/dist/core/resource-loader.d.ts +14 -2
  368. package/dist/core/resource-loader.d.ts.map +1 -1
  369. package/dist/core/resource-loader.js +117 -74
  370. package/dist/core/resource-loader.js.map +1 -1
  371. package/dist/core/sdk.d.ts.map +1 -1
  372. package/dist/core/sdk.js.map +1 -1
  373. package/dist/core/session-cwd.d.ts.map +1 -1
  374. package/dist/core/session-cwd.js +0 -1
  375. package/dist/core/session-cwd.js.map +1 -1
  376. package/dist/core/session-manager.d.ts +3 -0
  377. package/dist/core/session-manager.d.ts.map +1 -1
  378. package/dist/core/session-manager.js +41 -28
  379. package/dist/core/session-manager.js.map +1 -1
  380. package/dist/core/session-resident-store.d.ts +16 -0
  381. package/dist/core/session-resident-store.d.ts.map +1 -0
  382. package/dist/core/session-resident-store.js +48 -0
  383. package/dist/core/session-resident-store.js.map +1 -0
  384. package/dist/core/session-work-barrier.d.ts.map +1 -1
  385. package/dist/core/session-work-barrier.js +5 -3
  386. package/dist/core/session-work-barrier.js.map +1 -1
  387. package/dist/core/settings-manager.d.ts +14 -2
  388. package/dist/core/settings-manager.d.ts.map +1 -1
  389. package/dist/core/settings-manager.js +86 -46
  390. package/dist/core/settings-manager.js.map +1 -1
  391. package/dist/core/skills.d.ts.map +1 -1
  392. package/dist/core/skills.js.map +1 -1
  393. package/dist/core/slash-commands.d.ts.map +1 -1
  394. package/dist/core/slash-commands.js +1 -0
  395. package/dist/core/slash-commands.js.map +1 -1
  396. package/dist/core/source-info.d.ts.map +1 -1
  397. package/dist/core/source-info.js.map +1 -1
  398. package/dist/core/system-prompt.d.ts.map +1 -1
  399. package/dist/core/system-prompt.js.map +1 -1
  400. package/dist/core/telemetry.d.ts.map +1 -1
  401. package/dist/core/telemetry.js.map +1 -1
  402. package/dist/core/thinking-levels.d.ts.map +1 -1
  403. package/dist/core/thinking-levels.js.map +1 -1
  404. package/dist/core/timings.d.ts.map +1 -1
  405. package/dist/core/timings.js.map +1 -1
  406. package/dist/core/tools/bash.d.ts.map +1 -1
  407. package/dist/core/tools/bash.js +9 -6
  408. package/dist/core/tools/bash.js.map +1 -1
  409. package/dist/core/tools/diff-render.d.ts.map +1 -1
  410. package/dist/core/tools/diff-render.js.map +1 -1
  411. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  412. package/dist/core/tools/edit-diff.js.map +1 -1
  413. package/dist/core/tools/edit.d.ts.map +1 -1
  414. package/dist/core/tools/edit.js.map +1 -1
  415. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  416. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  417. package/dist/core/tools/find.d.ts.map +1 -1
  418. package/dist/core/tools/find.js +1 -1
  419. package/dist/core/tools/find.js.map +1 -1
  420. package/dist/core/tools/grep.d.ts.map +1 -1
  421. package/dist/core/tools/grep.js +1 -1
  422. package/dist/core/tools/grep.js.map +1 -1
  423. package/dist/core/tools/index.d.ts.map +1 -1
  424. package/dist/core/tools/index.js.map +1 -1
  425. package/dist/core/tools/ls.d.ts.map +1 -1
  426. package/dist/core/tools/ls.js +1 -1
  427. package/dist/core/tools/ls.js.map +1 -1
  428. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  429. package/dist/core/tools/output-accumulator.js +12 -18
  430. package/dist/core/tools/output-accumulator.js.map +1 -1
  431. package/dist/core/tools/path-utils.d.ts.map +1 -1
  432. package/dist/core/tools/path-utils.js.map +1 -1
  433. package/dist/core/tools/read.d.ts.map +1 -1
  434. package/dist/core/tools/read.js +1 -1
  435. package/dist/core/tools/read.js.map +1 -1
  436. package/dist/core/tools/render-utils.d.ts.map +1 -1
  437. package/dist/core/tools/render-utils.js.map +1 -1
  438. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  439. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  440. package/dist/core/tools/truncate.d.ts.map +1 -1
  441. package/dist/core/tools/truncate.js.map +1 -1
  442. package/dist/core/tools/write.d.ts.map +1 -1
  443. package/dist/core/tools/write.js +1 -2
  444. package/dist/core/tools/write.js.map +1 -1
  445. package/dist/core/trust-manager.d.ts +31 -0
  446. package/dist/core/trust-manager.d.ts.map +1 -0
  447. package/dist/core/trust-manager.js +186 -0
  448. package/dist/core/trust-manager.js.map +1 -0
  449. package/dist/index.d.ts +5 -4
  450. package/dist/index.d.ts.map +1 -1
  451. package/dist/index.js +2 -1
  452. package/dist/index.js.map +1 -1
  453. package/dist/main.d.ts.map +1 -1
  454. package/dist/main.js +101 -86
  455. package/dist/main.js.map +1 -1
  456. package/dist/migrations.d.ts.map +1 -1
  457. package/dist/migrations.js +39 -34
  458. package/dist/migrations.js.map +1 -1
  459. package/dist/modes/index.d.ts +1 -1
  460. package/dist/modes/index.d.ts.map +1 -1
  461. package/dist/modes/index.js.map +1 -1
  462. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  463. package/dist/modes/interactive/components/armin.js +6 -10
  464. package/dist/modes/interactive/components/armin.js.map +1 -1
  465. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  466. package/dist/modes/interactive/components/assistant-message.js +2 -11
  467. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  468. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  469. package/dist/modes/interactive/components/bash-execution.js +6 -11
  470. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  471. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  472. package/dist/modes/interactive/components/bordered-loader.js +0 -3
  473. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  474. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  475. package/dist/modes/interactive/components/branch-summary-message.js +1 -3
  476. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  477. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  478. package/dist/modes/interactive/components/compaction-summary-message.js +1 -3
  479. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  480. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  481. package/dist/modes/interactive/components/config-selector.js +5 -15
  482. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  483. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  484. package/dist/modes/interactive/components/countdown-timer.js +0 -5
  485. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  486. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  487. package/dist/modes/interactive/components/custom-editor.js +1 -8
  488. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  489. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  490. package/dist/modes/interactive/components/custom-message.js +1 -6
  491. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  492. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  493. package/dist/modes/interactive/components/daxnuts.js +6 -8
  494. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  495. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  496. package/dist/modes/interactive/components/diff.js +2 -2
  497. package/dist/modes/interactive/components/diff.js.map +1 -1
  498. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  499. package/dist/modes/interactive/components/dynamic-border.js +0 -1
  500. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  501. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  502. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  503. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  504. package/dist/modes/interactive/components/extension-editor.js +1 -6
  505. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  506. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  507. package/dist/modes/interactive/components/extension-input.js +2 -8
  508. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  509. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  510. package/dist/modes/interactive/components/extension-selector.js +1 -9
  511. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  512. package/dist/modes/interactive/components/favorite-models-selector.d.ts.map +1 -1
  513. package/dist/modes/interactive/components/favorite-models-selector.js +9 -15
  514. package/dist/modes/interactive/components/favorite-models-selector.js.map +1 -1
  515. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  516. package/dist/modes/interactive/components/footer.js +10 -3
  517. package/dist/modes/interactive/components/footer.js.map +1 -1
  518. package/dist/modes/interactive/components/index.d.ts +1 -0
  519. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  520. package/dist/modes/interactive/components/index.js +1 -0
  521. package/dist/modes/interactive/components/index.js.map +1 -1
  522. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  523. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  524. package/dist/modes/interactive/components/login-dialog.d.ts +1 -0
  525. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  526. package/dist/modes/interactive/components/login-dialog.js +10 -10
  527. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  528. package/dist/modes/interactive/components/model-favorites.d.ts.map +1 -1
  529. package/dist/modes/interactive/components/model-favorites.js.map +1 -1
  530. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  531. package/dist/modes/interactive/components/model-selector.js +9 -22
  532. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  533. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  534. package/dist/modes/interactive/components/oauth-selector.js +3 -12
  535. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  536. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  537. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  538. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  539. package/dist/modes/interactive/components/session-selector.js +33 -58
  540. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  541. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  542. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  543. package/dist/modes/interactive/components/settings-selector.js +20 -4
  544. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  545. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  546. package/dist/modes/interactive/components/show-images-selector.js +0 -1
  547. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  548. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  549. package/dist/modes/interactive/components/skill-invocation-message.js +1 -3
  550. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  551. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  552. package/dist/modes/interactive/components/theme-selector.js +0 -2
  553. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  554. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  555. package/dist/modes/interactive/components/thinking-selector.js +0 -1
  556. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  557. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  558. package/dist/modes/interactive/components/tool-execution.js +35 -32
  559. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  560. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  561. package/dist/modes/interactive/components/tree-selector.js +18 -32
  562. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  563. package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
  564. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
  565. package/dist/modes/interactive/components/trust-selector.js +85 -0
  566. package/dist/modes/interactive/components/trust-selector.js.map +1 -0
  567. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  568. package/dist/modes/interactive/components/user-message-selector.js +3 -6
  569. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  570. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  571. package/dist/modes/interactive/components/user-message.js +0 -1
  572. package/dist/modes/interactive/components/user-message.js.map +1 -1
  573. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  574. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  575. package/dist/modes/interactive/interactive-mode.d.ts +39 -0
  576. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  577. package/dist/modes/interactive/interactive-mode.js +264 -114
  578. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  579. package/dist/modes/interactive/session-info-format.d.ts.map +1 -1
  580. package/dist/modes/interactive/session-info-format.js.map +1 -1
  581. package/dist/modes/interactive/startup-tools.d.ts.map +1 -1
  582. package/dist/modes/interactive/startup-tools.js.map +1 -1
  583. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  584. package/dist/modes/interactive/theme/theme.js +0 -6
  585. package/dist/modes/interactive/theme/theme.js.map +1 -1
  586. package/dist/modes/interactive/working-status.d.ts +2 -0
  587. package/dist/modes/interactive/working-status.d.ts.map +1 -1
  588. package/dist/modes/interactive/working-status.js +34 -0
  589. package/dist/modes/interactive/working-status.js.map +1 -1
  590. package/dist/modes/print-mode.d.ts.map +1 -1
  591. package/dist/modes/print-mode.js.map +1 -1
  592. package/dist/modes/provider-native-rendering.d.ts.map +1 -1
  593. package/dist/modes/provider-native-rendering.js.map +1 -1
  594. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  595. package/dist/modes/rpc/jsonl.js.map +1 -1
  596. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  597. package/dist/modes/rpc/rpc-client.js +7 -8
  598. package/dist/modes/rpc/rpc-client.js.map +1 -1
  599. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  600. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  601. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  602. package/dist/package-manager-cli.d.ts +6 -2
  603. package/dist/package-manager-cli.d.ts.map +1 -1
  604. package/dist/package-manager-cli.js +105 -11
  605. package/dist/package-manager-cli.js.map +1 -1
  606. package/dist/self-update-bootstrap.d.ts.map +1 -1
  607. package/dist/self-update-bootstrap.js.map +1 -1
  608. package/dist/senpi +10 -1
  609. package/dist/utils/ansi.d.ts.map +1 -1
  610. package/dist/utils/ansi.js.map +1 -1
  611. package/dist/utils/changelog.d.ts +1 -0
  612. package/dist/utils/changelog.d.ts.map +1 -1
  613. package/dist/utils/changelog.js +78 -0
  614. package/dist/utils/changelog.js.map +1 -1
  615. package/dist/utils/child-process.d.ts.map +1 -1
  616. package/dist/utils/child-process.js.map +1 -1
  617. package/dist/utils/clipboard-image.d.ts.map +1 -1
  618. package/dist/utils/clipboard-image.js.map +1 -1
  619. package/dist/utils/clipboard-native.d.ts.map +1 -1
  620. package/dist/utils/clipboard-native.js.map +1 -1
  621. package/dist/utils/clipboard.d.ts.map +1 -1
  622. package/dist/utils/clipboard.js.map +1 -1
  623. package/dist/utils/deprecation.d.ts.map +1 -1
  624. package/dist/utils/deprecation.js.map +1 -1
  625. package/dist/utils/exif-orientation.d.ts.map +1 -1
  626. package/dist/utils/exif-orientation.js.map +1 -1
  627. package/dist/utils/frontmatter.d.ts.map +1 -1
  628. package/dist/utils/frontmatter.js.map +1 -1
  629. package/dist/utils/fs-watch.d.ts.map +1 -1
  630. package/dist/utils/fs-watch.js.map +1 -1
  631. package/dist/utils/git.d.ts.map +1 -1
  632. package/dist/utils/git.js.map +1 -1
  633. package/dist/utils/html.d.ts.map +1 -1
  634. package/dist/utils/html.js.map +1 -1
  635. package/dist/utils/image-convert.d.ts.map +1 -1
  636. package/dist/utils/image-convert.js.map +1 -1
  637. package/dist/utils/image-resize-core.d.ts.map +1 -1
  638. package/dist/utils/image-resize-core.js.map +1 -1
  639. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  640. package/dist/utils/image-resize-worker.js.map +1 -1
  641. package/dist/utils/image-resize.d.ts.map +1 -1
  642. package/dist/utils/image-resize.js.map +1 -1
  643. package/dist/utils/json.d.ts.map +1 -1
  644. package/dist/utils/json.js.map +1 -1
  645. package/dist/utils/mime.d.ts.map +1 -1
  646. package/dist/utils/mime.js.map +1 -1
  647. package/dist/utils/open-browser.d.ts.map +1 -1
  648. package/dist/utils/open-browser.js.map +1 -1
  649. package/dist/utils/paths.d.ts.map +1 -1
  650. package/dist/utils/paths.js.map +1 -1
  651. package/dist/utils/photon.d.ts.map +1 -1
  652. package/dist/utils/photon.js.map +1 -1
  653. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  654. package/dist/utils/pi-user-agent.js.map +1 -1
  655. package/dist/utils/shell.d.ts.map +1 -1
  656. package/dist/utils/shell.js.map +1 -1
  657. package/dist/utils/sleep.d.ts.map +1 -1
  658. package/dist/utils/sleep.js.map +1 -1
  659. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  660. package/dist/utils/syntax-highlight.js.map +1 -1
  661. package/dist/utils/tools-manager.d.ts.map +1 -1
  662. package/dist/utils/tools-manager.js.map +1 -1
  663. package/dist/utils/version-check.d.ts.map +1 -1
  664. package/dist/utils/version-check.js.map +1 -1
  665. package/dist/utils/windows-self-update.d.ts.map +1 -1
  666. package/dist/utils/windows-self-update.js.map +1 -1
  667. package/docs/docs.json +4 -0
  668. package/docs/extensions.md +31 -2
  669. package/docs/index.md +1 -0
  670. package/docs/models.md +6 -39
  671. package/docs/packages.md +1 -1
  672. package/docs/prompt-templates.md +9 -2
  673. package/docs/sdk.md +5 -0
  674. package/docs/security.md +55 -0
  675. package/docs/settings.md +13 -0
  676. package/docs/skills.md +3 -3
  677. package/docs/terminal-setup.md +36 -2
  678. package/docs/themes.md +1 -1
  679. package/docs/tmux.md +4 -2
  680. package/docs/usage.md +18 -1
  681. package/examples/extensions/README.md +1 -0
  682. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  683. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  684. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  685. package/examples/extensions/gondolin/package-lock.json +2 -2
  686. package/examples/extensions/gondolin/package.json +1 -1
  687. package/examples/extensions/minimal-mode.ts +6 -6
  688. package/examples/extensions/project-trust.ts +64 -0
  689. package/examples/extensions/sandbox/package-lock.json +2 -2
  690. package/examples/extensions/sandbox/package.json +1 -1
  691. package/examples/extensions/with-deps/package-lock.json +2 -2
  692. package/examples/extensions/with-deps/package.json +1 -1
  693. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  694. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +125 -77
  695. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  696. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +7 -0
  697. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
  698. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +2 -27
  699. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
  700. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
  701. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +7 -20
  702. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
  703. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts.map +1 -1
  704. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js.map +1 -1
  705. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts +1 -1
  706. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -1
  707. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +1 -1
  708. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js.map +1 -1
  709. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts.map +1 -1
  710. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js.map +1 -1
  711. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
  712. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +0 -3
  713. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
  714. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts.map +1 -1
  715. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js.map +1 -1
  716. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.d.ts.map +1 -1
  717. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js.map +1 -1
  718. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts.map +1 -1
  719. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -3
  720. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js.map +1 -1
  721. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts.map +1 -1
  722. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -7
  723. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js.map +1 -1
  724. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts.map +1 -1
  725. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +3 -1
  726. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js.map +1 -1
  727. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts.map +1 -1
  728. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -5
  729. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js.map +1 -1
  730. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts.map +1 -1
  731. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js.map +1 -1
  732. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
  733. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +0 -1
  734. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
  735. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.d.ts.map +1 -1
  736. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.js.map +1 -1
  737. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.d.ts.map +1 -1
  738. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js.map +1 -1
  739. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.d.ts.map +1 -1
  740. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.js.map +1 -1
  741. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
  742. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js +0 -16
  743. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
  744. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -1
  745. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js.map +1 -1
  746. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.d.ts.map +1 -1
  747. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js.map +1 -1
  748. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
  749. package/node_modules/@earendil-works/pi-agent-core/dist/node.d.ts.map +1 -1
  750. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
  751. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  752. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +6 -3
  753. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
  754. package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
  755. package/node_modules/@earendil-works/pi-agent-core/package.json +6 -6
  756. package/node_modules/@earendil-works/pi-ai/README.md +2 -1
  757. package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts.map +1 -1
  758. package/node_modules/@earendil-works/pi-ai/dist/api-registry.js.map +1 -1
  759. package/node_modules/@earendil-works/pi-ai/dist/bedrock-provider.d.ts.map +1 -1
  760. package/node_modules/@earendil-works/pi-ai/dist/cli.d.ts.map +1 -1
  761. package/node_modules/@earendil-works/pi-ai/dist/cli.js.map +1 -1
  762. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
  763. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
  764. package/node_modules/@earendil-works/pi-ai/dist/image-models.d.ts.map +1 -1
  765. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +30 -0
  766. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
  767. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +30 -0
  768. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
  769. package/node_modules/@earendil-works/pi-ai/dist/image-models.js.map +1 -1
  770. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts.map +1 -1
  771. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js.map +1 -1
  772. package/node_modules/@earendil-works/pi-ai/dist/images.d.ts.map +1 -1
  773. package/node_modules/@earendil-works/pi-ai/dist/images.js.map +1 -1
  774. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  775. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
  776. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +533 -131
  777. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  778. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +530 -255
  779. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
  780. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  781. package/node_modules/@earendil-works/pi-ai/dist/oauth.d.ts.map +1 -1
  782. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
  783. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +15 -7
  784. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
  785. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts +1 -1
  786. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  787. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +17 -7
  788. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
  789. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
  790. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +1 -0
  791. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
  792. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.d.ts.map +1 -1
  793. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.js.map +1 -1
  794. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
  795. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
  796. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -1
  797. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.js.map +1 -1
  798. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.d.ts.map +1 -1
  799. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.js.map +1 -1
  800. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.d.ts.map +1 -1
  801. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js.map +1 -1
  802. package/node_modules/@earendil-works/pi-ai/dist/providers/google.d.ts.map +1 -1
  803. package/node_modules/@earendil-works/pi-ai/dist/providers/google.js.map +1 -1
  804. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.d.ts.map +1 -1
  805. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.js.map +1 -1
  806. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts.map +1 -1
  807. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js.map +1 -1
  808. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.d.ts.map +1 -1
  809. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.js +3 -3
  810. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.js.map +1 -1
  811. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -1
  812. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js +0 -7
  813. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js.map +1 -1
  814. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  815. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +5 -4
  816. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js.map +1 -1
  817. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.d.ts.map +1 -1
  818. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.js.map +1 -1
  819. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.d.ts.map +1 -1
  820. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.js +2 -1
  821. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.js.map +1 -1
  822. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
  823. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +3 -2
  824. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js.map +1 -1
  825. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
  826. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.js.map +1 -1
  827. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts +1 -1
  828. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
  829. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js +2 -2
  830. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js.map +1 -1
  831. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.d.ts.map +1 -1
  832. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.js.map +1 -1
  833. package/node_modules/@earendil-works/pi-ai/dist/session-resources.d.ts.map +1 -1
  834. package/node_modules/@earendil-works/pi-ai/dist/session-resources.js.map +1 -1
  835. package/node_modules/@earendil-works/pi-ai/dist/stream.d.ts.map +1 -1
  836. package/node_modules/@earendil-works/pi-ai/dist/stream.js.map +1 -1
  837. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.d.ts.map +1 -1
  838. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js.map +1 -1
  839. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts.map +1 -1
  840. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js.map +1 -1
  841. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts.map +1 -1
  842. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js +10 -8
  843. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js.map +1 -1
  844. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/hermes.d.ts.map +1 -1
  845. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/hermes.js.map +1 -1
  846. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.d.ts.map +1 -1
  847. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js.map +1 -1
  848. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.d.ts.map +1 -1
  849. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js.map +1 -1
  850. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/xml-tool-tag-scanner.d.ts.map +1 -1
  851. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/xml-tool-tag-scanner.js.map +1 -1
  852. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.d.ts.map +1 -1
  853. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js.map +1 -1
  854. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.d.ts.map +1 -1
  855. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js.map +1 -1
  856. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts.map +1 -1
  857. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +6 -2
  858. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  859. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  860. package/node_modules/@earendil-works/pi-ai/dist/utils/abort-signals.d.ts.map +1 -1
  861. package/node_modules/@earendil-works/pi-ai/dist/utils/abort-signals.js.map +1 -1
  862. package/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.d.ts.map +1 -1
  863. package/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.js.map +1 -1
  864. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
  865. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js +3 -7
  866. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js.map +1 -1
  867. package/node_modules/@earendil-works/pi-ai/dist/utils/hash.d.ts.map +1 -1
  868. package/node_modules/@earendil-works/pi-ai/dist/utils/hash.js.map +1 -1
  869. package/node_modules/@earendil-works/pi-ai/dist/utils/headers.d.ts.map +1 -1
  870. package/node_modules/@earendil-works/pi-ai/dist/utils/headers.js.map +1 -1
  871. package/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.d.ts.map +1 -1
  872. package/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.js.map +1 -1
  873. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.d.ts.map +1 -1
  874. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js.map +1 -1
  875. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.d.ts.map +1 -1
  876. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.js.map +1 -1
  877. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.d.ts.map +1 -1
  878. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.js.map +1 -1
  879. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
  880. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -1
  881. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.d.ts.map +1 -1
  882. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js.map +1 -1
  883. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.d.ts.map +1 -1
  884. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.js.map +1 -1
  885. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.d.ts.map +1 -1
  886. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js.map +1 -1
  887. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.d.ts.map +1 -1
  888. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.js.map +1 -1
  889. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.d.ts.map +1 -1
  890. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
  891. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
  892. package/node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.d.ts.map +1 -1
  893. package/node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.js.map +1 -1
  894. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.d.ts.map +1 -1
  895. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js.map +1 -1
  896. package/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.d.ts.map +1 -1
  897. package/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.js.map +1 -1
  898. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.d.ts.map +1 -1
  899. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.js.map +1 -1
  900. package/node_modules/@earendil-works/pi-ai/package.json +5 -5
  901. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +3 -1
  902. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -1
  903. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +0 -3
  904. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -1
  905. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +1 -1
  906. package/node_modules/@earendil-works/pi-tui/dist/components/box.js +1 -6
  907. package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +1 -1
  908. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts.map +1 -1
  909. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js +4 -3
  910. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js.map +1 -1
  911. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +6 -1
  912. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
  913. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +132 -93
  914. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
  915. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
  916. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +0 -8
  917. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
  918. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +1 -1
  919. package/node_modules/@earendil-works/pi-tui/dist/components/input.js +14 -14
  920. package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +1 -1
  921. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +5 -0
  922. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts.map +1 -1
  923. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js +29 -17
  924. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js.map +1 -1
  925. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +1 -1
  926. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +0 -11
  927. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +1 -1
  928. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +1 -1
  929. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +4 -9
  930. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +1 -1
  931. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +1 -1
  932. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +4 -12
  933. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +1 -1
  934. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts.map +1 -1
  935. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js +0 -1
  936. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js.map +1 -1
  937. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +1 -1
  938. package/node_modules/@earendil-works/pi-tui/dist/components/text.js +0 -8
  939. package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +1 -1
  940. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts.map +1 -1
  941. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js +0 -3
  942. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js.map +1 -1
  943. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts.map +1 -1
  944. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts.map +1 -1
  945. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +131 -61
  946. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js.map +1 -1
  947. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  948. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
  949. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +2 -4
  950. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
  951. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +1 -1
  952. package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +1 -1
  953. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts.map +1 -1
  954. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js +3 -1
  955. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js.map +1 -1
  956. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts.map +1 -1
  957. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js.map +1 -1
  958. package/node_modules/@earendil-works/pi-tui/dist/slash-command-autocomplete.d.ts.map +1 -1
  959. package/node_modules/@earendil-works/pi-tui/dist/slash-command-autocomplete.js.map +1 -1
  960. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +1 -1
  961. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +4 -6
  962. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +1 -1
  963. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
  964. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
  965. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +4 -7
  966. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
  967. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +60 -103
  968. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
  969. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  970. package/node_modules/@earendil-works/pi-tui/dist/tui.js +39 -31
  971. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  972. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts.map +1 -1
  973. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js +3 -1
  974. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js.map +1 -1
  975. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -1
  976. package/node_modules/@earendil-works/pi-tui/dist/utils.js +57 -27
  977. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
  978. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts.map +1 -1
  979. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js.map +1 -1
  980. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  981. package/node_modules/@types/node/README.md +3 -3
  982. package/node_modules/@types/node/assert/strict.d.ts +3 -55
  983. package/node_modules/@types/node/assert.d.ts +49 -177
  984. package/node_modules/@types/node/async_hooks.d.ts +151 -43
  985. package/node_modules/@types/node/buffer.buffer.d.ts +2 -8
  986. package/node_modules/@types/node/buffer.d.ts +43 -212
  987. package/node_modules/@types/node/child_process.d.ts +23 -133
  988. package/node_modules/@types/node/cluster.d.ts +238 -384
  989. package/node_modules/@types/node/compatibility/iterators.d.ts +1 -0
  990. package/node_modules/@types/node/console.d.ts +45 -404
  991. package/node_modules/@types/node/constants.d.ts +3 -10
  992. package/node_modules/@types/node/crypto.d.ts +640 -1127
  993. package/node_modules/@types/node/dgram.d.ts +14 -77
  994. package/node_modules/@types/node/diagnostics_channel.d.ts +3 -29
  995. package/node_modules/@types/node/dns/promises.d.ts +4 -10
  996. package/node_modules/@types/node/dns.d.ts +130 -177
  997. package/node_modules/@types/node/domain.d.ts +12 -32
  998. package/node_modules/@types/node/events.d.ts +872 -840
  999. package/node_modules/@types/node/fs/promises.d.ts +193 -20
  1000. package/node_modules/@types/node/fs.d.ts +754 -435
  1001. package/node_modules/@types/node/globals.d.ts +8 -30
  1002. package/node_modules/@types/node/globals.typedarray.d.ts +63 -0
  1003. package/node_modules/@types/node/http.d.ts +363 -305
  1004. package/node_modules/@types/node/http2.d.ts +545 -781
  1005. package/node_modules/@types/node/https.d.ts +64 -243
  1006. package/node_modules/@types/node/index.d.ts +26 -6
  1007. package/node_modules/@types/node/inspector/promises.d.ts +35 -0
  1008. package/node_modules/@types/node/inspector.d.ts +68 -57
  1009. package/node_modules/@types/node/inspector.generated.d.ts +764 -410
  1010. package/node_modules/@types/node/module.d.ts +53 -189
  1011. package/node_modules/@types/node/net.d.ts +101 -207
  1012. package/node_modules/@types/node/os.d.ts +11 -19
  1013. package/node_modules/@types/node/package.json +13 -3
  1014. package/node_modules/@types/node/path/posix.d.ts +8 -0
  1015. package/node_modules/@types/node/path/win32.d.ts +8 -0
  1016. package/node_modules/@types/node/path.d.ts +119 -141
  1017. package/node_modules/@types/node/perf_hooks.d.ts +317 -673
  1018. package/node_modules/@types/node/process.d.ts +277 -157
  1019. package/node_modules/@types/node/punycode.d.ts +3 -31
  1020. package/node_modules/@types/node/querystring.d.ts +3 -16
  1021. package/node_modules/@types/node/quic.d.ts +897 -0
  1022. package/node_modules/@types/node/readline/promises.d.ts +3 -6
  1023. package/node_modules/@types/node/readline.d.ts +65 -152
  1024. package/node_modules/@types/node/repl.d.ts +101 -109
  1025. package/node_modules/@types/node/sea.d.ts +9 -115
  1026. package/node_modules/@types/node/sqlite.d.ts +415 -68
  1027. package/node_modules/@types/node/stream/consumers.d.ts +91 -15
  1028. package/node_modules/@types/node/stream/iter.d.ts +301 -0
  1029. package/node_modules/@types/node/stream/promises.d.ts +136 -15
  1030. package/node_modules/@types/node/stream/web.d.ts +179 -501
  1031. package/node_modules/@types/node/stream.d.ts +577 -490
  1032. package/node_modules/@types/node/string_decoder.d.ts +3 -43
  1033. package/node_modules/@types/node/test/reporters.d.ts +59 -0
  1034. package/node_modules/@types/node/test.d.ts +402 -286
  1035. package/node_modules/@types/node/timers/promises.d.ts +3 -18
  1036. package/node_modules/@types/node/timers.d.ts +3 -141
  1037. package/node_modules/@types/node/tls.d.ts +115 -241
  1038. package/node_modules/@types/node/trace_events.d.ts +3 -97
  1039. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +2 -8
  1040. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  1041. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +2 -0
  1042. package/node_modules/@types/node/ts5.6/index.d.ts +28 -6
  1043. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  1044. package/node_modules/@types/node/ts5.7/index.d.ts +119 -0
  1045. package/node_modules/@types/node/tty.d.ts +57 -40
  1046. package/node_modules/@types/node/url.d.ts +156 -584
  1047. package/node_modules/@types/node/util/types.d.ts +558 -0
  1048. package/node_modules/@types/node/util.d.ts +167 -1096
  1049. package/node_modules/@types/node/v8.d.ts +75 -15
  1050. package/node_modules/@types/node/vm.d.ts +334 -198
  1051. package/node_modules/@types/node/wasi.d.ts +24 -74
  1052. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +27 -2
  1053. package/node_modules/@types/node/web-globals/blob.d.ts +23 -0
  1054. package/node_modules/@types/node/web-globals/console.d.ts +9 -0
  1055. package/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
  1056. package/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
  1057. package/node_modules/@types/node/web-globals/events.d.ts +9 -0
  1058. package/node_modules/@types/node/web-globals/fetch.d.ts +14 -0
  1059. package/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
  1060. package/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
  1061. package/node_modules/@types/node/web-globals/navigator.d.ts +3 -0
  1062. package/node_modules/@types/node/web-globals/performance.d.ts +45 -0
  1063. package/node_modules/@types/node/web-globals/streams.d.ts +115 -0
  1064. package/node_modules/@types/node/web-globals/timers.d.ts +44 -0
  1065. package/node_modules/@types/node/web-globals/url.d.ts +24 -0
  1066. package/node_modules/@types/node/worker_threads.d.ts +280 -393
  1067. package/node_modules/@types/node/zlib/iter.d.ts +131 -0
  1068. package/node_modules/@types/node/zlib.d.ts +7 -165
  1069. package/node_modules/undici-types/agent.d.ts +13 -12
  1070. package/node_modules/undici-types/api.d.ts +26 -26
  1071. package/node_modules/undici-types/balanced-pool.d.ts +13 -12
  1072. package/node_modules/undici-types/cache-interceptor.d.ts +179 -0
  1073. package/node_modules/undici-types/client-stats.d.ts +15 -0
  1074. package/node_modules/undici-types/client.d.ts +34 -19
  1075. package/node_modules/undici-types/connector.d.ts +4 -2
  1076. package/node_modules/undici-types/cookies.d.ts +2 -0
  1077. package/node_modules/undici-types/diagnostics-channel.d.ts +18 -10
  1078. package/node_modules/undici-types/dispatcher.d.ts +127 -104
  1079. package/node_modules/undici-types/env-http-proxy-agent.d.ts +4 -3
  1080. package/node_modules/undici-types/errors.d.ts +82 -54
  1081. package/node_modules/undici-types/eventsource.d.ts +9 -4
  1082. package/node_modules/undici-types/fetch.d.ts +22 -20
  1083. package/node_modules/undici-types/formdata.d.ts +7 -7
  1084. package/node_modules/undici-types/global-dispatcher.d.ts +4 -4
  1085. package/node_modules/undici-types/global-origin.d.ts +5 -5
  1086. package/node_modules/undici-types/h2c-client.d.ts +73 -0
  1087. package/node_modules/undici-types/handlers.d.ts +8 -8
  1088. package/node_modules/undici-types/header.d.ts +157 -1
  1089. package/node_modules/undici-types/index.d.ts +67 -47
  1090. package/node_modules/undici-types/interceptors.d.ts +71 -8
  1091. package/node_modules/undici-types/mock-agent.d.ts +36 -18
  1092. package/node_modules/undici-types/mock-call-history.d.ts +111 -0
  1093. package/node_modules/undici-types/mock-client.d.ts +6 -4
  1094. package/node_modules/undici-types/mock-errors.d.ts +3 -3
  1095. package/node_modules/undici-types/mock-interceptor.d.ts +21 -20
  1096. package/node_modules/undici-types/mock-pool.d.ts +6 -4
  1097. package/node_modules/undici-types/package.json +1 -1
  1098. package/node_modules/undici-types/patch.d.ts +0 -4
  1099. package/node_modules/undici-types/pool-stats.d.ts +8 -8
  1100. package/node_modules/undici-types/pool.d.ts +15 -13
  1101. package/node_modules/undici-types/proxy-agent.d.ts +5 -4
  1102. package/node_modules/undici-types/readable.d.ts +19 -16
  1103. package/node_modules/undici-types/retry-agent.d.ts +1 -1
  1104. package/node_modules/undici-types/retry-handler.d.ts +19 -10
  1105. package/node_modules/undici-types/round-robin-pool.d.ts +41 -0
  1106. package/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  1107. package/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
  1108. package/node_modules/undici-types/util.d.ts +3 -3
  1109. package/node_modules/undici-types/utility.d.ts +7 -0
  1110. package/node_modules/undici-types/webidl.d.ts +148 -29
  1111. package/node_modules/undici-types/websocket.d.ts +48 -10
  1112. package/npm-shrinkwrap.json +21 -21
  1113. package/package.json +13 -12
  1114. package/dist/core/extensions/builtin/todotools/continuation/config.d.ts +0 -10
  1115. package/dist/core/extensions/builtin/todotools/continuation/config.d.ts.map +0 -1
  1116. package/dist/core/extensions/builtin/todotools/continuation/config.js +0 -33
  1117. package/dist/core/extensions/builtin/todotools/continuation/config.js.map +0 -1
  1118. package/dist/core/extensions/builtin/todotools/continuation/index.d.ts +0 -2
  1119. package/dist/core/extensions/builtin/todotools/continuation/index.d.ts.map +0 -1
  1120. package/dist/core/extensions/builtin/todotools/continuation/index.js +0 -2
  1121. package/dist/core/extensions/builtin/todotools/continuation/index.js.map +0 -1
  1122. package/dist/core/extensions/builtin/todotools/continuation/prompt.d.ts +0 -5
  1123. package/dist/core/extensions/builtin/todotools/continuation/prompt.d.ts.map +0 -1
  1124. package/dist/core/extensions/builtin/todotools/continuation/prompt.js +0 -34
  1125. package/dist/core/extensions/builtin/todotools/continuation/prompt.js.map +0 -1
  1126. package/dist/core/extensions/builtin/todotools/continuation/runtime.d.ts +0 -11
  1127. package/dist/core/extensions/builtin/todotools/continuation/runtime.d.ts.map +0 -1
  1128. package/dist/core/extensions/builtin/todotools/continuation/runtime.js +0 -201
  1129. package/dist/core/extensions/builtin/todotools/continuation/runtime.js.map +0 -1
  1130. package/dist/core/extensions/builtin/todotools/settings.d.ts +0 -6
  1131. package/dist/core/extensions/builtin/todotools/settings.d.ts.map +0 -1
  1132. package/dist/core/extensions/builtin/todotools/settings.js +0 -58
  1133. package/dist/core/extensions/builtin/todotools/settings.js.map +0 -1
  1134. package/dist/core/extensions/builtin/todotools/system-messages.d.ts +0 -34
  1135. package/dist/core/extensions/builtin/todotools/system-messages.d.ts.map +0 -1
  1136. package/dist/core/extensions/builtin/todotools/system-messages.js +0 -82
  1137. package/dist/core/extensions/builtin/todotools/system-messages.js.map +0 -1
  1138. package/node_modules/@types/node/compatibility/disposable.d.ts +0 -14
  1139. package/node_modules/@types/node/compatibility/index.d.ts +0 -9
  1140. package/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
  1141. package/node_modules/undici-types/file.d.ts +0 -39
  1142. package/node_modules/undici-types/filereader.d.ts +0 -54
@@ -1,4 +1,82 @@
1
+ import path from "node:path";
1
2
  import { existsSync, readFileSync } from "fs";
3
+ const GITHUB_REPO = "earendil-works/pi";
4
+ const CHANGELOG_LINK_BASE_PATH = "packages/coding-agent";
5
+ const LEGACY_REPO_RE = /^https:\/\/github\.com\/(?:badlogic|earendil-works)\/pi-mono(?=\/|$)/;
6
+ const URL_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
7
+ const INLINE_MARKDOWN_LINK_RE = /(!?\[[^\]\n]+\]\()([^\s)]+)((?:\s+[^)]*)?\))/g;
8
+ function entryVersion(entry) {
9
+ return `${entry.major}.${entry.minor}.${entry.patch}`;
10
+ }
11
+ function normalizeTag(version) {
12
+ const versionString = typeof version === "string" ? version : entryVersion(version);
13
+ return versionString.startsWith("v") ? versionString : `v${versionString}`;
14
+ }
15
+ function splitLocalTarget(target) {
16
+ const hashIndex = target.indexOf("#");
17
+ const beforeHash = hashIndex === -1 ? target : target.slice(0, hashIndex);
18
+ const fragment = hashIndex === -1 ? "" : target.slice(hashIndex);
19
+ const queryIndex = beforeHash.indexOf("?");
20
+ if (queryIndex === -1) {
21
+ return { fragment, pathPart: beforeHash, query: "" };
22
+ }
23
+ return {
24
+ fragment,
25
+ pathPart: beforeHash.slice(0, queryIndex),
26
+ query: beforeHash.slice(queryIndex),
27
+ };
28
+ }
29
+ function normalizePathPart(value) {
30
+ return value.replaceAll("\\", "/");
31
+ }
32
+ function resolveRepositoryPath(targetPath) {
33
+ const normalizedTarget = normalizePathPart(targetPath);
34
+ const joined = normalizedTarget.startsWith("/")
35
+ ? path.posix.normalize(normalizedTarget.replace(/^\/+/, ""))
36
+ : path.posix.normalize(path.posix.join(CHANGELOG_LINK_BASE_PATH, normalizedTarget));
37
+ if (joined === "." || joined.startsWith("../") || joined === "..") {
38
+ return undefined;
39
+ }
40
+ return joined;
41
+ }
42
+ function isDirectoryTarget(originalPath, repositoryPath) {
43
+ if (originalPath.endsWith("/")) {
44
+ return true;
45
+ }
46
+ const basename = path.posix.basename(repositoryPath);
47
+ return !basename.includes(".");
48
+ }
49
+ function normalizeChangelogLinkTarget(target, tag) {
50
+ let canonicalTarget = target.replace(LEGACY_REPO_RE, `https://github.com/${GITHUB_REPO}`);
51
+ const repoUrl = `https://github.com/${GITHUB_REPO}`;
52
+ for (const route of ["blob", "tree"]) {
53
+ for (const branch of ["main", "master"]) {
54
+ const floatingRefPrefix = `${repoUrl}/${route}/${branch}/`;
55
+ if (canonicalTarget.startsWith(floatingRefPrefix)) {
56
+ canonicalTarget = `${repoUrl}/${route}/${tag}/${canonicalTarget.slice(floatingRefPrefix.length)}`;
57
+ }
58
+ }
59
+ }
60
+ if (canonicalTarget.startsWith("#") || canonicalTarget.startsWith("//") || URL_SCHEME_RE.test(canonicalTarget)) {
61
+ return canonicalTarget;
62
+ }
63
+ const { fragment, pathPart, query } = splitLocalTarget(canonicalTarget);
64
+ if (!pathPart) {
65
+ return canonicalTarget;
66
+ }
67
+ const repositoryPath = resolveRepositoryPath(pathPart);
68
+ if (!repositoryPath) {
69
+ return canonicalTarget;
70
+ }
71
+ const route = isDirectoryTarget(pathPart, repositoryPath) ? "tree" : "blob";
72
+ return `https://github.com/${GITHUB_REPO}/${route}/${tag}/${encodeURI(repositoryPath)}${query}${fragment}`;
73
+ }
74
+ export function normalizeChangelogLinks(markdown, version) {
75
+ const tag = normalizeTag(version);
76
+ return markdown.replace(INLINE_MARKDOWN_LINK_RE, (_match, prefix, target, suffix) => {
77
+ return `${prefix}${normalizeChangelogLinkTarget(target, tag)}${suffix}`;
78
+ });
79
+ }
2
80
  /**
3
81
  * Parse changelog entries from CHANGELOG.md
4
82
  * Scans for ## lines and collects content until next ## or EOF
@@ -1 +1 @@
1
- {"version":3,"file":"changelog.js","sourceRoot":"","sources":["../../src/utils/changelog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAS9C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,aAAqB,EAAoB;IACvE,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC;IACX,CAAC;IAED,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACrD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,OAAO,GAAqB,EAAE,CAAC;QAErC,IAAI,YAA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D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\n\nexport interface ChangelogEntry {\n\tmajor: number;\n\tminor: number;\n\tpatch: number;\n\tcontent: string;\n}\n\n/**\n * Parse changelog entries from CHANGELOG.md\n * Scans for ## lines and collects content until next ## or EOF\n */\nexport function parseChangelog(changelogPath: string): ChangelogEntry[] {\n\tif (!existsSync(changelogPath)) {\n\t\treturn [];\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(changelogPath, \"utf-8\");\n\t\tconst lines = content.split(\"\\n\");\n\t\tconst entries: ChangelogEntry[] = [];\n\n\t\tlet currentLines: string[] = [];\n\t\tlet currentVersion: { major: number; minor: number; patch: number } | null = null;\n\n\t\tfor (const line of lines) {\n\t\t\t// Check if this is a version header (## [x.y.z] ...)\n\t\t\tif (line.startsWith(\"## \")) {\n\t\t\t\t// Save previous entry if exists\n\t\t\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\t\t\tentries.push({\n\t\t\t\t\t\t...currentVersion,\n\t\t\t\t\t\tcontent: currentLines.join(\"\\n\").trim(),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Try to parse version from this line\n\t\t\t\tconst versionMatch = line.match(/##\\s+\\[?(\\d+)\\.(\\d+)\\.(\\d+)\\]?/);\n\t\t\t\tif (versionMatch) {\n\t\t\t\t\tcurrentVersion = {\n\t\t\t\t\t\tmajor: Number.parseInt(versionMatch[1], 10),\n\t\t\t\t\t\tminor: Number.parseInt(versionMatch[2], 10),\n\t\t\t\t\t\tpatch: Number.parseInt(versionMatch[3], 10),\n\t\t\t\t\t};\n\t\t\t\t\tcurrentLines = [line];\n\t\t\t\t} else {\n\t\t\t\t\t// Reset if we can't parse version\n\t\t\t\t\tcurrentVersion = null;\n\t\t\t\t\tcurrentLines = [];\n\t\t\t\t}\n\t\t\t} else if (currentVersion) {\n\t\t\t\t// Collect lines for current version\n\t\t\t\tcurrentLines.push(line);\n\t\t\t}\n\t\t}\n\n\t\t// Save last entry\n\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\tentries.push({\n\t\t\t\t...currentVersion,\n\t\t\t\tcontent: currentLines.join(\"\\n\").trim(),\n\t\t\t});\n\t\t}\n\n\t\treturn entries;\n\t} catch (error) {\n\t\tconsole.error(`Warning: Could not parse changelog: ${error}`);\n\t\treturn [];\n\t}\n}\n\n/**\n * Compare versions. Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2\n */\nexport function compareVersions(v1: ChangelogEntry, v2: ChangelogEntry): number {\n\tif (v1.major !== v2.major) return v1.major - v2.major;\n\tif (v1.minor !== v2.minor) return v1.minor - v2.minor;\n\treturn v1.patch - v2.patch;\n}\n\n/**\n * Get entries newer than lastVersion\n */\nexport function getNewEntries(entries: ChangelogEntry[], lastVersion: string): ChangelogEntry[] {\n\t// Parse lastVersion\n\tconst parts = lastVersion.split(\".\").map(Number);\n\tconst last: ChangelogEntry = {\n\t\tmajor: parts[0] || 0,\n\t\tminor: parts[1] || 0,\n\t\tpatch: parts[2] || 0,\n\t\tcontent: \"\",\n\t};\n\n\treturn entries.filter((entry) => compareVersions(entry, last) > 0);\n}\n\n// Re-export getChangelogPath from paths.ts for convenience\nexport { getChangelogPath } from \"../config.ts\";\n"]}
1
+ {"version":3,"file":"changelog.js","sourceRoot":"","sources":["../../src/utils/changelog.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAS9C,MAAM,WAAW,GAAG,mBAAmB,CAAC;AACxC,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AACzD,MAAM,cAAc,GAAG,sEAAsE,CAAC;AAC9F,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAC7C,MAAM,uBAAuB,GAAG,+CAA+C,CAAC;AAEhF,SAAS,YAAY,CAAC,KAAqB;IAC1C,OAAO,GAAG,KAAK,CA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,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,IAAI,GAAmB;QAC5B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QACpB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QACpB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QACpB,OAAO,EAAE,EAAE;KACX,CAAC;IAEF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,2DAA2D;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import path from \"node:path\";\nimport { existsSync, readFileSync } from \"fs\";\n\nexport interface ChangelogEntry {\n\tmajor: number;\n\tminor: number;\n\tpatch: number;\n\tcontent: string;\n}\n\nconst GITHUB_REPO = \"earendil-works/pi\";\nconst CHANGELOG_LINK_BASE_PATH = \"packages/coding-agent\";\nconst LEGACY_REPO_RE = /^https:\\/\\/github\\.com\\/(?:badlogic|earendil-works)\\/pi-mono(?=\\/|$)/;\nconst URL_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;\nconst INLINE_MARKDOWN_LINK_RE = /(!?\\[[^\\]\\n]+\\]\\()([^\\s)]+)((?:\\s+[^)]*)?\\))/g;\n\nfunction entryVersion(entry: ChangelogEntry): string {\n\treturn `${entry.major}.${entry.minor}.${entry.patch}`;\n}\n\nfunction normalizeTag(version: string | ChangelogEntry): string {\n\tconst versionString = typeof version === \"string\" ? version : entryVersion(version);\n\treturn versionString.startsWith(\"v\") ? versionString : `v${versionString}`;\n}\n\nfunction splitLocalTarget(target: string): { fragment: string; pathPart: string; query: string } {\n\tconst hashIndex = target.indexOf(\"#\");\n\tconst beforeHash = hashIndex === -1 ? target : target.slice(0, hashIndex);\n\tconst fragment = hashIndex === -1 ? \"\" : target.slice(hashIndex);\n\tconst queryIndex = beforeHash.indexOf(\"?\");\n\n\tif (queryIndex === -1) {\n\t\treturn { fragment, pathPart: beforeHash, query: \"\" };\n\t}\n\n\treturn {\n\t\tfragment,\n\t\tpathPart: beforeHash.slice(0, queryIndex),\n\t\tquery: beforeHash.slice(queryIndex),\n\t};\n}\n\nfunction normalizePathPart(value: string): string {\n\treturn value.replaceAll(\"\\\\\", \"/\");\n}\n\nfunction resolveRepositoryPath(targetPath: string): string | undefined {\n\tconst normalizedTarget = normalizePathPart(targetPath);\n\tconst joined = normalizedTarget.startsWith(\"/\")\n\t\t? path.posix.normalize(normalizedTarget.replace(/^\\/+/, \"\"))\n\t\t: path.posix.normalize(path.posix.join(CHANGELOG_LINK_BASE_PATH, normalizedTarget));\n\n\tif (joined === \".\" || joined.startsWith(\"../\") || joined === \"..\") {\n\t\treturn undefined;\n\t}\n\n\treturn joined;\n}\n\nfunction isDirectoryTarget(originalPath: string, repositoryPath: string): boolean {\n\tif (originalPath.endsWith(\"/\")) {\n\t\treturn true;\n\t}\n\n\tconst basename = path.posix.basename(repositoryPath);\n\treturn !basename.includes(\".\");\n}\n\nfunction normalizeChangelogLinkTarget(target: string, tag: string): string {\n\tlet canonicalTarget = target.replace(LEGACY_REPO_RE, `https://github.com/${GITHUB_REPO}`);\n\tconst repoUrl = `https://github.com/${GITHUB_REPO}`;\n\n\tfor (const route of [\"blob\", \"tree\"]) {\n\t\tfor (const branch of [\"main\", \"master\"]) {\n\t\t\tconst floatingRefPrefix = `${repoUrl}/${route}/${branch}/`;\n\t\t\tif (canonicalTarget.startsWith(floatingRefPrefix)) {\n\t\t\t\tcanonicalTarget = `${repoUrl}/${route}/${tag}/${canonicalTarget.slice(floatingRefPrefix.length)}`;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (canonicalTarget.startsWith(\"#\") || canonicalTarget.startsWith(\"//\") || URL_SCHEME_RE.test(canonicalTarget)) {\n\t\treturn canonicalTarget;\n\t}\n\n\tconst { fragment, pathPart, query } = splitLocalTarget(canonicalTarget);\n\tif (!pathPart) {\n\t\treturn canonicalTarget;\n\t}\n\n\tconst repositoryPath = resolveRepositoryPath(pathPart);\n\tif (!repositoryPath) {\n\t\treturn canonicalTarget;\n\t}\n\n\tconst route = isDirectoryTarget(pathPart, repositoryPath) ? \"tree\" : \"blob\";\n\treturn `https://github.com/${GITHUB_REPO}/${route}/${tag}/${encodeURI(repositoryPath)}${query}${fragment}`;\n}\n\nexport function normalizeChangelogLinks(markdown: string, version: string | ChangelogEntry): string {\n\tconst tag = normalizeTag(version);\n\treturn markdown.replace(INLINE_MARKDOWN_LINK_RE, (_match, prefix, target, suffix) => {\n\t\treturn `${prefix}${normalizeChangelogLinkTarget(target, tag)}${suffix}`;\n\t});\n}\n\n/**\n * Parse changelog entries from CHANGELOG.md\n * Scans for ## lines and collects content until next ## or EOF\n */\nexport function parseChangelog(changelogPath: string): ChangelogEntry[] {\n\tif (!existsSync(changelogPath)) {\n\t\treturn [];\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(changelogPath, \"utf-8\");\n\t\tconst lines = content.split(\"\\n\");\n\t\tconst entries: ChangelogEntry[] = [];\n\n\t\tlet currentLines: string[] = [];\n\t\tlet currentVersion: { major: number; minor: number; patch: number } | null = null;\n\n\t\tfor (const line of lines) {\n\t\t\t// Check if this is a version header (## [x.y.z] ...)\n\t\t\tif (line.startsWith(\"## \")) {\n\t\t\t\t// Save previous entry if exists\n\t\t\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\t\t\tentries.push({\n\t\t\t\t\t\t...currentVersion,\n\t\t\t\t\t\tcontent: currentLines.join(\"\\n\").trim(),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Try to parse version from this line\n\t\t\t\tconst versionMatch = line.match(/##\\s+\\[?(\\d+)\\.(\\d+)\\.(\\d+)\\]?/);\n\t\t\t\tif (versionMatch) {\n\t\t\t\t\tcurrentVersion = {\n\t\t\t\t\t\tmajor: Number.parseInt(versionMatch[1], 10),\n\t\t\t\t\t\tminor: Number.parseInt(versionMatch[2], 10),\n\t\t\t\t\t\tpatch: Number.parseInt(versionMatch[3], 10),\n\t\t\t\t\t};\n\t\t\t\t\tcurrentLines = [line];\n\t\t\t\t} else {\n\t\t\t\t\t// Reset if we can't parse version\n\t\t\t\t\tcurrentVersion = null;\n\t\t\t\t\tcurrentLines = [];\n\t\t\t\t}\n\t\t\t} else if (currentVersion) {\n\t\t\t\t// Collect lines for current version\n\t\t\t\tcurrentLines.push(line);\n\t\t\t}\n\t\t}\n\n\t\t// Save last entry\n\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\tentries.push({\n\t\t\t\t...currentVersion,\n\t\t\t\tcontent: currentLines.join(\"\\n\").trim(),\n\t\t\t});\n\t\t}\n\n\t\treturn entries;\n\t} catch (error) {\n\t\tconsole.error(`Warning: Could not parse changelog: ${error}`);\n\t\treturn [];\n\t}\n}\n\n/**\n * Compare versions. Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2\n */\nexport function compareVersions(v1: ChangelogEntry, v2: ChangelogEntry): number {\n\tif (v1.major !== v2.major) return v1.major - v2.major;\n\tif (v1.minor !== v2.minor) return v1.minor - v2.minor;\n\treturn v1.patch - v2.patch;\n}\n\n/**\n * Get entries newer than lastVersion\n */\nexport function getNewEntries(entries: ChangelogEntry[], lastVersion: string): ChangelogEntry[] {\n\t// Parse lastVersion\n\tconst parts = lastVersion.split(\".\").map(Number);\n\tconst last: ChangelogEntry = {\n\t\tmajor: parts[0] || 0,\n\t\tminor: parts[1] || 0,\n\t\tpatch: parts[2] || 0,\n\t\tcontent: \"\",\n\t};\n\n\treturn entries.filter((entry) => compareVersions(entry, last) > 0);\n}\n\n// Re-export getChangelogPath from paths.ts for convenience\nexport { getChangelogPath } from \"../config.ts\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"child-process.d.ts","sourceRoot":"","sources":["../../src/utils/child-process.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,mBAAmB,EAGxB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,kCAAkC,EACvC,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,wBAAgB,YAAY,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,0BAA0B,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,GAClE,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACjD,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY,CAAC;AAKnG,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,kCAAkC,GACzC,gBAAgB,CAAC,MAAM,CAAC,CAI1B;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAyE/E","sourcesContent":["import {\n\ttype ChildProcess,\n\ttype ChildProcessByStdio,\n\tspawn as nodeSpawn,\n\tspawnSync as nodeSpawnSync,\n\ttype SpawnOptions,\n\ttype SpawnOptionsWithStdioTuple,\n\ttype SpawnSyncOptionsWithStringEncoding,\n\ttype SpawnSyncReturns,\n\ttype StdioNull,\n\ttype StdioPipe,\n} from \"node:child_process\";\nimport type { Readable } from \"node:stream\";\nimport crossSpawn from \"cross-spawn\";\n\nconst EXIT_STDIO_GRACE_MS = 100;\n\nexport function spawnProcess(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): ChildProcessByStdio<null, Readable, Readable>;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess {\n\treturn process.platform === \"win32\" ? crossSpawn(command, args, options) : nodeSpawn(command, args, options);\n}\n\nexport function spawnProcessSync(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnSyncOptionsWithStringEncoding,\n): SpawnSyncReturns<string> {\n\treturn process.platform === \"win32\"\n\t\t? crossSpawn.sync(command, args, options)\n\t\t: nodeSpawnSync(command, args, options);\n}\n\n/**\n * Wait for a child process to terminate without hanging on inherited stdio handles.\n *\n * On Windows, daemonized descendants can inherit the child's stdout/stderr pipe\n * handles. In that case the child emits `exit`, but `close` can hang forever even\n * though the original process is already gone. We wait briefly for stdio to end,\n * then forcibly stop tracking the inherited handles.\n */\nexport function waitForChildProcess(child: ChildProcess): Promise<number | null> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet settled = false;\n\t\tlet exited = false;\n\t\tlet exitCode: number | null = null;\n\t\tlet postExitTimer: NodeJS.Timeout | undefined;\n\t\tlet stdoutEnded = child.stdout === null;\n\t\tlet stderrEnded = child.stderr === null;\n\n\t\tconst cleanup = () => {\n\t\t\tif (postExitTimer) {\n\t\t\t\tclearTimeout(postExitTimer);\n\t\t\t\tpostExitTimer = undefined;\n\t\t\t}\n\t\t\tchild.removeListener(\"error\", onError);\n\t\t\tchild.removeListener(\"exit\", onExit);\n\t\t\tchild.removeListener(\"close\", onClose);\n\t\t\tchild.stdout?.removeListener(\"end\", onStdoutEnd);\n\t\t\tchild.stderr?.removeListener(\"end\", onStderrEnd);\n\t\t};\n\n\t\tconst finalize = (code: number | null) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\tchild.stdout?.destroy();\n\t\t\tchild.stderr?.destroy();\n\t\t\tresolve(code);\n\t\t};\n\n\t\tconst maybeFinalizeAfterExit = () => {\n\t\t\tif (!exited || settled) return;\n\t\t\tif (stdoutEnded && stderrEnded) {\n\t\t\t\tfinalize(exitCode);\n\t\t\t}\n\t\t};\n\n\t\tconst onStdoutEnd = () => {\n\t\t\tstdoutEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onStderrEnd = () => {\n\t\t\tstderrEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onError = (err: Error) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\treject(err);\n\t\t};\n\n\t\tconst onExit = (code: number | null) => {\n\t\t\texited = true;\n\t\t\texitCode = code;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t\tif (!settled) {\n\t\t\t\tpostExitTimer = setTimeout(() => finalize(code), EXIT_STDIO_GRACE_MS);\n\t\t\t}\n\t\t};\n\n\t\tconst onClose = (code: number | null) => {\n\t\t\tfinalize(code);\n\t\t};\n\n\t\tchild.stdout?.once(\"end\", onStdoutEnd);\n\t\tchild.stderr?.once(\"end\", onStderrEnd);\n\t\tchild.once(\"error\", onError);\n\t\tchild.once(\"exit\", onExit);\n\t\tchild.once(\"close\", onClose);\n\t});\n}\n"]}
1
+ {"version":3,"file":"child-process.d.ts","sourceRoot":"","sources":["../../src/utils/child-process.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,mBAAmB,EAGxB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,kCAAkC,EACvC,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,wBAAgB,YAAY,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,0BAA0B,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,GAClE,mBAAmB,CAAC,IAAI,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AC3B,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAAA,CAC7B,CAAC,CAAC;AAAA,CACH","sourcesContent":["import {\n\ttype ChildProcess,\n\ttype ChildProcessByStdio,\n\tspawn as nodeSpawn,\n\tspawnSync as nodeSpawnSync,\n\ttype SpawnOptions,\n\ttype SpawnOptionsWithStdioTuple,\n\ttype SpawnSyncOptionsWithStringEncoding,\n\ttype SpawnSyncReturns,\n\ttype StdioNull,\n\ttype StdioPipe,\n} from \"node:child_process\";\nimport type { Readable } from \"node:stream\";\nimport crossSpawn from \"cross-spawn\";\n\nconst EXIT_STDIO_GRACE_MS = 100;\n\nexport function spawnProcess(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): ChildProcessByStdio<null, Readable, Readable>;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess {\n\treturn process.platform === \"win32\" ? crossSpawn(command, args, options) : nodeSpawn(command, args, options);\n}\n\nexport function spawnProcessSync(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnSyncOptionsWithStringEncoding,\n): SpawnSyncReturns<string> {\n\treturn process.platform === \"win32\"\n\t\t? crossSpawn.sync(command, args, options)\n\t\t: nodeSpawnSync(command, args, options);\n}\n\n/**\n * Wait for a child process to terminate without hanging on inherited stdio handles.\n *\n * On Windows, daemonized descendants can inherit the child's stdout/stderr pipe\n * handles. In that case the child emits `exit`, but `close` can hang forever even\n * though the original process is already gone. We wait briefly for stdio to end,\n * then forcibly stop tracking the inherited handles.\n */\nexport function waitForChildProcess(child: ChildProcess): Promise<number | null> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet settled = false;\n\t\tlet exited = false;\n\t\tlet exitCode: number | null = null;\n\t\tlet postExitTimer: NodeJS.Timeout | undefined;\n\t\tlet stdoutEnded = child.stdout === null;\n\t\tlet stderrEnded = child.stderr === null;\n\n\t\tconst cleanup = () => {\n\t\t\tif (postExitTimer) {\n\t\t\t\tclearTimeout(postExitTimer);\n\t\t\t\tpostExitTimer = undefined;\n\t\t\t}\n\t\t\tchild.removeListener(\"error\", onError);\n\t\t\tchild.removeListener(\"exit\", onExit);\n\t\t\tchild.removeListener(\"close\", onClose);\n\t\t\tchild.stdout?.removeListener(\"end\", onStdoutEnd);\n\t\t\tchild.stderr?.removeListener(\"end\", onStderrEnd);\n\t\t};\n\n\t\tconst finalize = (code: number | null) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\tchild.stdout?.destroy();\n\t\t\tchild.stderr?.destroy();\n\t\t\tresolve(code);\n\t\t};\n\n\t\tconst maybeFinalizeAfterExit = () => {\n\t\t\tif (!exited || settled) return;\n\t\t\tif (stdoutEnded && stderrEnded) {\n\t\t\t\tfinalize(exitCode);\n\t\t\t}\n\t\t};\n\n\t\tconst onStdoutEnd = () => {\n\t\t\tstdoutEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onStderrEnd = () => {\n\t\t\tstderrEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onError = (err: Error) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\treject(err);\n\t\t};\n\n\t\tconst onExit = (code: number | null) => {\n\t\t\texited = true;\n\t\t\texitCode = code;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t\tif (!settled) {\n\t\t\t\tpostExitTimer = setTimeout(() => finalize(code), EXIT_STDIO_GRACE_MS);\n\t\t\t}\n\t\t};\n\n\t\tconst onClose = (code: number | null) => {\n\t\t\tfinalize(code);\n\t\t};\n\n\t\tchild.stdout?.once(\"end\", onStdoutEnd);\n\t\tchild.stderr?.once(\"end\", onStderrEnd);\n\t\tchild.once(\"error\", onError);\n\t\tchild.once(\"exit\", onExit);\n\t\tchild.once(\"close\", onClose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AC;YACf,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,GAAG,CAAC,CAAC;QACb,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,CAAC,IAAmB,EAAE,EAAE;YACtC,MAAM,GAAG,IAAI,CAAC;YACd,QAAQ,GAAG,IAAI,CAAC;YAChB,sBAAsB,EAAE,CAAC;YACzB,IAAI,CAAC,OAAO,EAAE,CAAC;gBACd,aAAa,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,mBAAmB,CAAC,CAAC;YACvE,CAAC;QACF,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,CAAC,IAAmB,EAAE,EAAE;YACvC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC;QAEF,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACvC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACvC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n\ttype ChildProcess,\n\ttype ChildProcessByStdio,\n\tspawn as nodeSpawn,\n\tspawnSync as nodeSpawnSync,\n\ttype SpawnOptions,\n\ttype SpawnOptionsWithStdioTuple,\n\ttype SpawnSyncOptionsWithStringEncoding,\n\ttype SpawnSyncReturns,\n\ttype StdioNull,\n\ttype StdioPipe,\n} from \"node:child_process\";\nimport type { Readable } from \"node:stream\";\nimport crossSpawn from \"cross-spawn\";\n\nconst EXIT_STDIO_GRACE_MS = 100;\n\nexport function spawnProcess(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): ChildProcessByStdio<null, Readable, Readable>;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess {\n\treturn process.platform === \"win32\" ? crossSpawn(command, args, options) : nodeSpawn(command, args, options);\n}\n\nexport function spawnProcessSync(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnSyncOptionsWithStringEncoding,\n): SpawnSyncReturns<string> {\n\treturn process.platform === \"win32\"\n\t\t? crossSpawn.sync(command, args, options)\n\t\t: nodeSpawnSync(command, args, options);\n}\n\n/**\n * Wait for a child process to terminate without hanging on inherited stdio handles.\n *\n * On Windows, daemonized descendants can inherit the child's stdout/stderr pipe\n * handles. In that case the child emits `exit`, but `close` can hang forever even\n * though the original process is already gone. We wait briefly for stdio to end,\n * then forcibly stop tracking the inherited handles.\n */\nexport function waitForChildProcess(child: ChildProcess): Promise<number | null> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet settled = false;\n\t\tlet exited = false;\n\t\tlet exitCode: number | null = null;\n\t\tlet postExitTimer: NodeJS.Timeout | undefined;\n\t\tlet stdoutEnded = child.stdout === null;\n\t\tlet stderrEnded = child.stderr === null;\n\n\t\tconst cleanup = () => {\n\t\t\tif (postExitTimer) {\n\t\t\t\tclearTimeout(postExitTimer);\n\t\t\t\tpostExitTimer = undefined;\n\t\t\t}\n\t\t\tchild.removeListener(\"error\", onError);\n\t\t\tchild.removeListener(\"exit\", onExit);\n\t\t\tchild.removeListener(\"close\", onClose);\n\t\t\tchild.stdout?.removeListener(\"end\", onStdoutEnd);\n\t\t\tchild.stderr?.removeListener(\"end\", onStderrEnd);\n\t\t};\n\n\t\tconst finalize = (code: number | null) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\tchild.stdout?.destroy();\n\t\t\tchild.stderr?.destroy();\n\t\t\tresolve(code);\n\t\t};\n\n\t\tconst maybeFinalizeAfterExit = () => {\n\t\t\tif (!exited || settled) return;\n\t\t\tif (stdoutEnded && stderrEnded) {\n\t\t\t\tfinalize(exitCode);\n\t\t\t}\n\t\t};\n\n\t\tconst onStdoutEnd = () => {\n\t\t\tstdoutEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onStderrEnd = () => {\n\t\t\tstderrEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onError = (err: Error) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\treject(err);\n\t\t};\n\n\t\tconst onExit = (code: number | null) => {\n\t\t\texited = true;\n\t\t\texitCode = code;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t\tif (!settled) {\n\t\t\t\tpostExitTimer = setTimeout(() => finalize(code), EXIT_STDIO_GRACE_MS);\n\t\t\t}\n\t\t};\n\n\t\tconst onClose = (code: number | null) => {\n\t\t\tfinalize(code);\n\t\t};\n\n\t\tchild.stdout?.once(\"end\", onStdoutEnd);\n\t\tchild.stderr?.once(\"end\", onStderrEnd);\n\t\tchild.once(\"error\", onError);\n\t\tchild.once(\"exit\", onExit);\n\t\tchild.once(\"close\", onClose);\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard-image.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard-image.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CACjB,CAAC;AASF,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAE9E;AAMD,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAazE;AAmND,wBAAsB,kBAAkB,CAAC,OAAO,CAAC,EAAE;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;CAC3B,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CA2CjC","sourcesContent":["import { spawnSync } from \"child_process\";\nimport { randomUUID } from \"crypto\";\nimport { readFileSync, unlinkSync } from \"fs\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\n\nimport { clipboard } from \"./clipboard-native.ts\";\nimport { loadPhoton } from \"./photon.ts\";\n\nexport type ClipboardImage = {\n\tbytes: Uint8Array;\n\tmimeType: string;\n};\n\nconst SUPPORTED_IMAGE_MIME_TYPES = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\"] as const;\n\nconst DEFAULT_LIST_TIMEOUT_MS = 1000;\nconst DEFAULT_READ_TIMEOUT_MS = 3000;\nconst DEFAULT_POWERSHELL_TIMEOUT_MS = 5000;\nconst DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;\n\nexport function isWaylandSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn Boolean(env.WAYLAND_DISPLAY) || env.XDG_SESSION_TYPE === \"wayland\";\n}\n\nfunction baseMimeType(mimeType: string): string {\n\treturn mimeType.split(\";\")[0]?.trim().toLowerCase() ?? mimeType.toLowerCase();\n}\n\nexport function extensionForImageMimeType(mimeType: string): string | null {\n\tswitch (baseMimeType(mimeType)) {\n\t\tcase \"image/png\":\n\t\t\treturn \"png\";\n\t\tcase \"image/jpeg\":\n\t\t\treturn \"jpg\";\n\t\tcase \"image/webp\":\n\t\t\treturn \"webp\";\n\t\tcase \"image/gif\":\n\t\t\treturn \"gif\";\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction selectPreferredImageMimeType(mimeTypes: string[]): string | null {\n\tconst normalized = mimeTypes\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean)\n\t\t.map((t) => ({ raw: t, base: baseMimeType(t) }));\n\n\tfor (const preferred of SUPPORTED_IMAGE_MIME_TYPES) {\n\t\tconst match = normalized.find((t) => t.base === preferred);\n\t\tif (match) {\n\t\t\treturn match.raw;\n\t\t}\n\t}\n\n\tconst anyImage = normalized.find((t) => t.base.startsWith(\"image/\"));\n\treturn anyImage?.raw ?? null;\n}\n\nfunction isSupportedImageMimeType(mimeType: string): boolean {\n\tconst base = baseMimeType(mimeType);\n\treturn SUPPORTED_IMAGE_MIME_TYPES.some((t) => t === base);\n}\n\n/**\n * Convert unsupported image formats to PNG using Photon.\n * Returns null if conversion is unavailable or fails.\n */\nasync function convertToPng(bytes: Uint8Array): Promise<Uint8Array | null> {\n\tconst photon = await loadPhoton();\n\tif (!photon) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst image = photon.PhotonImage.new_from_byteslice(bytes);\n\t\ttry {\n\t\t\treturn image.get_bytes();\n\t\t} finally {\n\t\t\timage.free();\n\t\t}\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction runCommand(\n\tcommand: string,\n\targs: string[],\n\toptions?: { timeoutMs?: number; maxBufferBytes?: number; env?: NodeJS.ProcessEnv },\n): { stdout: Buffer; ok: boolean } {\n\tconst timeoutMs = options?.timeoutMs ?? DEFAULT_READ_TIMEOUT_MS;\n\tconst maxBufferBytes = options?.maxBufferBytes ?? DEFAULT_MAX_BUFFER_BYTES;\n\n\tconst result = spawnSync(command, args, {\n\t\ttimeout: timeoutMs,\n\t\tmaxBuffer: maxBufferBytes,\n\t\tenv: options?.env,\n\t});\n\n\tif (result.error) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tif (result.status !== 0) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tconst stdout = Buffer.isBuffer(result.stdout)\n\t\t? result.stdout\n\t\t: Buffer.from(result.stdout ?? \"\", typeof result.stdout === \"string\" ? \"utf-8\" : undefined);\n\n\treturn { ok: true, stdout };\n}\n\nfunction readClipboardImageViaWlPaste(): ClipboardImage | null {\n\tconst list = runCommand(\"wl-paste\", [\"--list-types\"], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\tif (!list.ok) {\n\t\treturn null;\n\t}\n\n\tconst types = list.stdout\n\t\t.toString(\"utf-8\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean);\n\n\tconst selectedType = selectPreferredImageMimeType(types);\n\tif (!selectedType) {\n\t\treturn null;\n\t}\n\n\tconst data = runCommand(\"wl-paste\", [\"--type\", selectedType, \"--no-newline\"]);\n\tif (!data.ok || data.stdout.length === 0) {\n\t\treturn null;\n\t}\n\n\treturn { bytes: data.stdout, mimeType: baseMimeType(selectedType) };\n}\n\nfunction isWSL(env: NodeJS.ProcessEnv = process.env): boolean {\n\tif (env.WSL_DISTRO_NAME || env.WSLENV) {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tconst release = readFileSync(\"/proc/version\", \"utf-8\");\n\t\treturn /microsoft|wsl/i.test(release);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * On WSL, the Linux clipboard (Wayland/X11) does not receive image data from\n * Windows screenshots (Win+Shift+S). PowerShell can access the Windows clipboard\n * directly, so we use it as a fallback.\n */\nfunction readClipboardImageViaPowerShell(): ClipboardImage | null {\n\tconst tmpFile = join(tmpdir(), `pi-wsl-clip-${randomUUID()}.png`);\n\n\ttry {\n\t\tconst winPathResult = runCommand(\"wslpath\", [\"-w\", tmpFile], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\t\tif (!winPathResult.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst winPath = winPathResult.stdout.toString(\"utf-8\").trim();\n\t\tif (!winPath) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst psQuotedWinPath = winPath.replaceAll(\"'\", \"''\");\n\t\tconst psScript = [\n\t\t\t\"Add-Type -AssemblyName System.Windows.Forms\",\n\t\t\t\"Add-Type -AssemblyName System.Drawing\",\n\t\t\t`$path = '${psQuotedWinPath}'`,\n\t\t\t\"$img = [System.Windows.Forms.Clipboard]::GetImage()\",\n\t\t\t\"if ($img) { $img.Save($path, [System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'ok' } else { Write-Output 'empty' }\",\n\t\t].join(\"; \");\n\n\t\tconst result = runCommand(\"powershell.exe\", [\"-NoProfile\", \"-Command\", psScript], {\n\t\t\ttimeoutMs: DEFAULT_POWERSHELL_TIMEOUT_MS,\n\t\t});\n\t\tif (!result.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst output = result.stdout.toString(\"utf-8\").trim();\n\t\tif (output !== \"ok\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst bytes = readFileSync(tmpFile);\n\t\tif (bytes.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn { bytes: new Uint8Array(bytes), mimeType: \"image/png\" };\n\t} catch {\n\t\treturn null;\n\t} finally {\n\t\ttry {\n\t\t\tunlinkSync(tmpFile);\n\t\t} catch {\n\t\t\t// Ignore cleanup errors.\n\t\t}\n\t}\n}\n\nfunction readClipboardImageViaXclip(): ClipboardImage | null {\n\tconst targets = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", \"TARGETS\", \"-o\"], {\n\t\ttimeoutMs: DEFAULT_LIST_TIMEOUT_MS,\n\t});\n\n\tlet candidateTypes: string[] = [];\n\tif (targets.ok) {\n\t\tcandidateTypes = targets.stdout\n\t\t\t.toString(\"utf-8\")\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((t) => t.trim())\n\t\t\t.filter(Boolean);\n\t}\n\n\tconst preferred = candidateTypes.length > 0 ? selectPreferredImageMimeType(candidateTypes) : null;\n\tconst tryTypes = preferred ? [preferred, ...SUPPORTED_IMAGE_MIME_TYPES] : [...SUPPORTED_IMAGE_MIME_TYPES];\n\n\tfor (const mimeType of tryTypes) {\n\t\tconst data = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", mimeType, \"-o\"]);\n\t\tif (data.ok && data.stdout.length > 0) {\n\t\t\treturn { bytes: data.stdout, mimeType: baseMimeType(mimeType) };\n\t\t}\n\t}\n\n\treturn null;\n}\n\nasync function readClipboardImageViaNativeClipboard(): Promise<ClipboardImage | null> {\n\tif (!clipboard?.hasImage()) {\n\t\treturn null;\n\t}\n\n\tconst imageData = await clipboard.getImageBinary();\n\tif (!imageData || imageData.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst bytes = imageData instanceof Uint8Array ? imageData : Uint8Array.from(imageData);\n\treturn { bytes, mimeType: \"image/png\" };\n}\n\nexport async function readClipboardImage(options?: {\n\tenv?: NodeJS.ProcessEnv;\n\tplatform?: NodeJS.Platform;\n}): Promise<ClipboardImage | null> {\n\tconst env = options?.env ?? process.env;\n\tconst platform = options?.platform ?? process.platform;\n\n\tif (env.TERMUX_VERSION) {\n\t\treturn null;\n\t}\n\n\tlet image: ClipboardImage | null = null;\n\n\tif (platform === \"linux\") {\n\t\tconst wsl = isWSL(env);\n\t\tconst wayland = isWaylandSession(env);\n\n\t\tif (wayland || wsl) {\n\t\t\timage = readClipboardImageViaWlPaste() ?? readClipboardImageViaXclip();\n\t\t}\n\n\t\tif (!image && wsl) {\n\t\t\timage = readClipboardImageViaPowerShell();\n\t\t}\n\n\t\tif (!image && !wayland) {\n\t\t\timage = await readClipboardImageViaNativeClipboard();\n\t\t}\n\t} else {\n\t\timage = await readClipboardImageViaNativeClipboard();\n\t}\n\n\tif (!image) {\n\t\treturn null;\n\t}\n\n\t// Convert unsupported formats (e.g., BMP from WSLg) to PNG\n\tif (!isSupportedImageMimeType(image.mimeType)) {\n\t\tconst pngBytes = await convertToPng(image.bytes);\n\t\tif (!pngBytes) {\n\t\t\treturn null;\n\t\t}\n\t\treturn { bytes: pngBytes, mimeType: \"image/png\" };\n\t}\n\n\treturn image;\n}\n"]}
1
+ {"version":3,"file":"clipboard-image.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard-image.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,MAAM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K,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/C,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACnD,CAAC;IAED,OAAO,KAAK,CAAC;AAAA,CACb","sourcesContent":["import { spawnSync } from \"child_process\";\nimport { randomUUID } from \"crypto\";\nimport { readFileSync, unlinkSync } from \"fs\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\n\nimport { clipboard } from \"./clipboard-native.ts\";\nimport { loadPhoton } from \"./photon.ts\";\n\nexport type ClipboardImage = {\n\tbytes: Uint8Array;\n\tmimeType: string;\n};\n\nconst SUPPORTED_IMAGE_MIME_TYPES = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\"] as const;\n\nconst DEFAULT_LIST_TIMEOUT_MS = 1000;\nconst DEFAULT_READ_TIMEOUT_MS = 3000;\nconst DEFAULT_POWERSHELL_TIMEOUT_MS = 5000;\nconst DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;\n\nexport function isWaylandSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn Boolean(env.WAYLAND_DISPLAY) || env.XDG_SESSION_TYPE === \"wayland\";\n}\n\nfunction baseMimeType(mimeType: string): string {\n\treturn mimeType.split(\";\")[0]?.trim().toLowerCase() ?? mimeType.toLowerCase();\n}\n\nexport function extensionForImageMimeType(mimeType: string): string | null {\n\tswitch (baseMimeType(mimeType)) {\n\t\tcase \"image/png\":\n\t\t\treturn \"png\";\n\t\tcase \"image/jpeg\":\n\t\t\treturn \"jpg\";\n\t\tcase \"image/webp\":\n\t\t\treturn \"webp\";\n\t\tcase \"image/gif\":\n\t\t\treturn \"gif\";\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction selectPreferredImageMimeType(mimeTypes: string[]): string | null {\n\tconst normalized = mimeTypes\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean)\n\t\t.map((t) => ({ raw: t, base: baseMimeType(t) }));\n\n\tfor (const preferred of SUPPORTED_IMAGE_MIME_TYPES) {\n\t\tconst match = normalized.find((t) => t.base === preferred);\n\t\tif (match) {\n\t\t\treturn match.raw;\n\t\t}\n\t}\n\n\tconst anyImage = normalized.find((t) => t.base.startsWith(\"image/\"));\n\treturn anyImage?.raw ?? null;\n}\n\nfunction isSupportedImageMimeType(mimeType: string): boolean {\n\tconst base = baseMimeType(mimeType);\n\treturn SUPPORTED_IMAGE_MIME_TYPES.some((t) => t === base);\n}\n\n/**\n * Convert unsupported image formats to PNG using Photon.\n * Returns null if conversion is unavailable or fails.\n */\nasync function convertToPng(bytes: Uint8Array): Promise<Uint8Array | null> {\n\tconst photon = await loadPhoton();\n\tif (!photon) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst image = photon.PhotonImage.new_from_byteslice(bytes);\n\t\ttry {\n\t\t\treturn image.get_bytes();\n\t\t} finally {\n\t\t\timage.free();\n\t\t}\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction runCommand(\n\tcommand: string,\n\targs: string[],\n\toptions?: { timeoutMs?: number; maxBufferBytes?: number; env?: NodeJS.ProcessEnv },\n): { stdout: Buffer; ok: boolean } {\n\tconst timeoutMs = options?.timeoutMs ?? DEFAULT_READ_TIMEOUT_MS;\n\tconst maxBufferBytes = options?.maxBufferBytes ?? DEFAULT_MAX_BUFFER_BYTES;\n\n\tconst result = spawnSync(command, args, {\n\t\ttimeout: timeoutMs,\n\t\tmaxBuffer: maxBufferBytes,\n\t\tenv: options?.env,\n\t});\n\n\tif (result.error) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tif (result.status !== 0) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tconst stdout = Buffer.isBuffer(result.stdout)\n\t\t? result.stdout\n\t\t: Buffer.from(result.stdout ?? \"\", typeof result.stdout === \"string\" ? \"utf-8\" : undefined);\n\n\treturn { ok: true, stdout };\n}\n\nfunction readClipboardImageViaWlPaste(): ClipboardImage | null {\n\tconst list = runCommand(\"wl-paste\", [\"--list-types\"], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\tif (!list.ok) {\n\t\treturn null;\n\t}\n\n\tconst types = list.stdout\n\t\t.toString(\"utf-8\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean);\n\n\tconst selectedType = selectPreferredImageMimeType(types);\n\tif (!selectedType) {\n\t\treturn null;\n\t}\n\n\tconst data = runCommand(\"wl-paste\", [\"--type\", selectedType, \"--no-newline\"]);\n\tif (!data.ok || data.stdout.length === 0) {\n\t\treturn null;\n\t}\n\n\treturn { bytes: data.stdout, mimeType: baseMimeType(selectedType) };\n}\n\nfunction isWSL(env: NodeJS.ProcessEnv = process.env): boolean {\n\tif (env.WSL_DISTRO_NAME || env.WSLENV) {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tconst release = readFileSync(\"/proc/version\", \"utf-8\");\n\t\treturn /microsoft|wsl/i.test(release);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * On WSL, the Linux clipboard (Wayland/X11) does not receive image data from\n * Windows screenshots (Win+Shift+S). PowerShell can access the Windows clipboard\n * directly, so we use it as a fallback.\n */\nfunction readClipboardImageViaPowerShell(): ClipboardImage | null {\n\tconst tmpFile = join(tmpdir(), `pi-wsl-clip-${randomUUID()}.png`);\n\n\ttry {\n\t\tconst winPathResult = runCommand(\"wslpath\", [\"-w\", tmpFile], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\t\tif (!winPathResult.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst winPath = winPathResult.stdout.toString(\"utf-8\").trim();\n\t\tif (!winPath) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst psQuotedWinPath = winPath.replaceAll(\"'\", \"''\");\n\t\tconst psScript = [\n\t\t\t\"Add-Type -AssemblyName System.Windows.Forms\",\n\t\t\t\"Add-Type -AssemblyName System.Drawing\",\n\t\t\t`$path = '${psQuotedWinPath}'`,\n\t\t\t\"$img = [System.Windows.Forms.Clipboard]::GetImage()\",\n\t\t\t\"if ($img) { $img.Save($path, [System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'ok' } else { Write-Output 'empty' }\",\n\t\t].join(\"; \");\n\n\t\tconst result = runCommand(\"powershell.exe\", [\"-NoProfile\", \"-Command\", psScript], {\n\t\t\ttimeoutMs: DEFAULT_POWERSHELL_TIMEOUT_MS,\n\t\t});\n\t\tif (!result.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst output = result.stdout.toString(\"utf-8\").trim();\n\t\tif (output !== \"ok\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst bytes = readFileSync(tmpFile);\n\t\tif (bytes.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn { bytes: new Uint8Array(bytes), mimeType: \"image/png\" };\n\t} catch {\n\t\treturn null;\n\t} finally {\n\t\ttry {\n\t\t\tunlinkSync(tmpFile);\n\t\t} catch {\n\t\t\t// Ignore cleanup errors.\n\t\t}\n\t}\n}\n\nfunction readClipboardImageViaXclip(): ClipboardImage | null {\n\tconst targets = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", \"TARGETS\", \"-o\"], {\n\t\ttimeoutMs: DEFAULT_LIST_TIMEOUT_MS,\n\t});\n\n\tlet candidateTypes: string[] = [];\n\tif (targets.ok) {\n\t\tcandidateTypes = targets.stdout\n\t\t\t.toString(\"utf-8\")\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((t) => t.trim())\n\t\t\t.filter(Boolean);\n\t}\n\n\tconst preferred = candidateTypes.length > 0 ? selectPreferredImageMimeType(candidateTypes) : null;\n\tconst tryTypes = preferred ? [preferred, ...SUPPORTED_IMAGE_MIME_TYPES] : [...SUPPORTED_IMAGE_MIME_TYPES];\n\n\tfor (const mimeType of tryTypes) {\n\t\tconst data = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", mimeType, \"-o\"]);\n\t\tif (data.ok && data.stdout.length > 0) {\n\t\t\treturn { bytes: data.stdout, mimeType: baseMimeType(mimeType) };\n\t\t}\n\t}\n\n\treturn null;\n}\n\nasync function readClipboardImageViaNativeClipboard(): Promise<ClipboardImage | null> {\n\tif (!clipboard?.hasImage()) {\n\t\treturn null;\n\t}\n\n\tconst imageData = await clipboard.getImageBinary();\n\tif (!imageData || imageData.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst bytes = imageData instanceof Uint8Array ? imageData : Uint8Array.from(imageData);\n\treturn { bytes, mimeType: \"image/png\" };\n}\n\nexport async function readClipboardImage(options?: {\n\tenv?: NodeJS.ProcessEnv;\n\tplatform?: NodeJS.Platform;\n}): Promise<ClipboardImage | null> {\n\tconst env = options?.env ?? process.env;\n\tconst platform = options?.platform ?? process.platform;\n\n\tif (env.TERMUX_VERSION) {\n\t\treturn null;\n\t}\n\n\tlet image: ClipboardImage | null = null;\n\n\tif (platform === \"linux\") {\n\t\tconst wsl = isWSL(env);\n\t\tconst wayland = isWaylandSession(env);\n\n\t\tif (wayland || wsl) {\n\t\t\timage = readClipboardImageViaWlPaste() ?? readClipboardImageViaXclip();\n\t\t}\n\n\t\tif (!image && wsl) {\n\t\t\timage = readClipboardImageViaPowerShell();\n\t\t}\n\n\t\tif (!image && !wayland) {\n\t\t\timage = await readClipboardImageViaNativeClipboard();\n\t\t}\n\t} else {\n\t\timage = await readClipboardImageViaNativeClipboard();\n\t}\n\n\tif (!image) {\n\t\treturn null;\n\t}\n\n\t// Convert unsupported formats (e.g., BMP from WSLg) to PNG\n\tif (!isSupportedImageMimeType(image.mimeType)) {\n\t\tconst pngBytes = await convertToPng(image.bytes);\n\t\tif (!pngBytes) {\n\t\t\treturn null;\n\t\t}\n\t\treturn { bytes: pngBytes, mimeType: \"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AG,CAAC,cAAc,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,KAAK,GAA0B,IAAI,CAAC;IAExC,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACvB,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAEtC,IAAI,OAAO,IAAI,GAAG,EAAE,CAAC;YACpB,KAAK,GAAG,4BAA4B,EAAE,IAAI,0BAA0B,EAAE,CAAC;QACxE,CAAC;QAED,IAAI,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;YACnB,KAAK,GAAG,+BAA+B,EAAE,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;YACxB,KAAK,GAAG,MAAM,oCAAoC,EAAE,CAAC;QACtD,CAAC;IACF,CAAC;SAAM,CAAC;QACP,KAAK,GAAG,MAAM,oCAAoC,EAAE,CAAC;IACtD,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACb,CAAC;IAED,2DAA2D;IAC3D,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/C,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACnD,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { spawnSync } from \"child_process\";\nimport { randomUUID } from \"crypto\";\nimport { readFileSync, unlinkSync } from \"fs\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\n\nimport { clipboard } from \"./clipboard-native.ts\";\nimport { loadPhoton } from \"./photon.ts\";\n\nexport type ClipboardImage = {\n\tbytes: Uint8Array;\n\tmimeType: string;\n};\n\nconst SUPPORTED_IMAGE_MIME_TYPES = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\"] as const;\n\nconst DEFAULT_LIST_TIMEOUT_MS = 1000;\nconst DEFAULT_READ_TIMEOUT_MS = 3000;\nconst DEFAULT_POWERSHELL_TIMEOUT_MS = 5000;\nconst DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;\n\nexport function isWaylandSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn Boolean(env.WAYLAND_DISPLAY) || env.XDG_SESSION_TYPE === \"wayland\";\n}\n\nfunction baseMimeType(mimeType: string): string {\n\treturn mimeType.split(\";\")[0]?.trim().toLowerCase() ?? mimeType.toLowerCase();\n}\n\nexport function extensionForImageMimeType(mimeType: string): string | null {\n\tswitch (baseMimeType(mimeType)) {\n\t\tcase \"image/png\":\n\t\t\treturn \"png\";\n\t\tcase \"image/jpeg\":\n\t\t\treturn \"jpg\";\n\t\tcase \"image/webp\":\n\t\t\treturn \"webp\";\n\t\tcase \"image/gif\":\n\t\t\treturn \"gif\";\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction selectPreferredImageMimeType(mimeTypes: string[]): string | null {\n\tconst normalized = mimeTypes\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean)\n\t\t.map((t) => ({ raw: t, base: baseMimeType(t) }));\n\n\tfor (const preferred of SUPPORTED_IMAGE_MIME_TYPES) {\n\t\tconst match = normalized.find((t) => t.base === preferred);\n\t\tif (match) {\n\t\t\treturn match.raw;\n\t\t}\n\t}\n\n\tconst anyImage = normalized.find((t) => t.base.startsWith(\"image/\"));\n\treturn anyImage?.raw ?? null;\n}\n\nfunction isSupportedImageMimeType(mimeType: string): boolean {\n\tconst base = baseMimeType(mimeType);\n\treturn SUPPORTED_IMAGE_MIME_TYPES.some((t) => t === base);\n}\n\n/**\n * Convert unsupported image formats to PNG using Photon.\n * Returns null if conversion is unavailable or fails.\n */\nasync function convertToPng(bytes: Uint8Array): Promise<Uint8Array | null> {\n\tconst photon = await loadPhoton();\n\tif (!photon) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst image = photon.PhotonImage.new_from_byteslice(bytes);\n\t\ttry {\n\t\t\treturn image.get_bytes();\n\t\t} finally {\n\t\t\timage.free();\n\t\t}\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction runCommand(\n\tcommand: string,\n\targs: string[],\n\toptions?: { timeoutMs?: number; maxBufferBytes?: number; env?: NodeJS.ProcessEnv },\n): { stdout: Buffer; ok: boolean } {\n\tconst timeoutMs = options?.timeoutMs ?? DEFAULT_READ_TIMEOUT_MS;\n\tconst maxBufferBytes = options?.maxBufferBytes ?? DEFAULT_MAX_BUFFER_BYTES;\n\n\tconst result = spawnSync(command, args, {\n\t\ttimeout: timeoutMs,\n\t\tmaxBuffer: maxBufferBytes,\n\t\tenv: options?.env,\n\t});\n\n\tif (result.error) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tif (result.status !== 0) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tconst stdout = Buffer.isBuffer(result.stdout)\n\t\t? result.stdout\n\t\t: Buffer.from(result.stdout ?? \"\", typeof result.stdout === \"string\" ? \"utf-8\" : undefined);\n\n\treturn { ok: true, stdout };\n}\n\nfunction readClipboardImageViaWlPaste(): ClipboardImage | null {\n\tconst list = runCommand(\"wl-paste\", [\"--list-types\"], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\tif (!list.ok) {\n\t\treturn null;\n\t}\n\n\tconst types = list.stdout\n\t\t.toString(\"utf-8\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean);\n\n\tconst selectedType = selectPreferredImageMimeType(types);\n\tif (!selectedType) {\n\t\treturn null;\n\t}\n\n\tconst data = runCommand(\"wl-paste\", [\"--type\", selectedType, \"--no-newline\"]);\n\tif (!data.ok || data.stdout.length === 0) {\n\t\treturn null;\n\t}\n\n\treturn { bytes: data.stdout, mimeType: baseMimeType(selectedType) };\n}\n\nfunction isWSL(env: NodeJS.ProcessEnv = process.env): boolean {\n\tif (env.WSL_DISTRO_NAME || env.WSLENV) {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tconst release = readFileSync(\"/proc/version\", \"utf-8\");\n\t\treturn /microsoft|wsl/i.test(release);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * On WSL, the Linux clipboard (Wayland/X11) does not receive image data from\n * Windows screenshots (Win+Shift+S). PowerShell can access the Windows clipboard\n * directly, so we use it as a fallback.\n */\nfunction readClipboardImageViaPowerShell(): ClipboardImage | null {\n\tconst tmpFile = join(tmpdir(), `pi-wsl-clip-${randomUUID()}.png`);\n\n\ttry {\n\t\tconst winPathResult = runCommand(\"wslpath\", [\"-w\", tmpFile], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\t\tif (!winPathResult.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst winPath = winPathResult.stdout.toString(\"utf-8\").trim();\n\t\tif (!winPath) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst psQuotedWinPath = winPath.replaceAll(\"'\", \"''\");\n\t\tconst psScript = [\n\t\t\t\"Add-Type -AssemblyName System.Windows.Forms\",\n\t\t\t\"Add-Type -AssemblyName System.Drawing\",\n\t\t\t`$path = '${psQuotedWinPath}'`,\n\t\t\t\"$img = [System.Windows.Forms.Clipboard]::GetImage()\",\n\t\t\t\"if ($img) { $img.Save($path, [System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'ok' } else { Write-Output 'empty' }\",\n\t\t].join(\"; \");\n\n\t\tconst result = runCommand(\"powershell.exe\", [\"-NoProfile\", \"-Command\", psScript], {\n\t\t\ttimeoutMs: DEFAULT_POWERSHELL_TIMEOUT_MS,\n\t\t});\n\t\tif (!result.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst output = result.stdout.toString(\"utf-8\").trim();\n\t\tif (output !== \"ok\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst bytes = readFileSync(tmpFile);\n\t\tif (bytes.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn { bytes: new Uint8Array(bytes), mimeType: \"image/png\" };\n\t} catch {\n\t\treturn null;\n\t} finally {\n\t\ttry {\n\t\t\tunlinkSync(tmpFile);\n\t\t} catch {\n\t\t\t// Ignore cleanup errors.\n\t\t}\n\t}\n}\n\nfunction readClipboardImageViaXclip(): ClipboardImage | null {\n\tconst targets = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", \"TARGETS\", \"-o\"], {\n\t\ttimeoutMs: DEFAULT_LIST_TIMEOUT_MS,\n\t});\n\n\tlet candidateTypes: string[] = [];\n\tif (targets.ok) {\n\t\tcandidateTypes = targets.stdout\n\t\t\t.toString(\"utf-8\")\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((t) => t.trim())\n\t\t\t.filter(Boolean);\n\t}\n\n\tconst preferred = candidateTypes.length > 0 ? selectPreferredImageMimeType(candidateTypes) : null;\n\tconst tryTypes = preferred ? [preferred, ...SUPPORTED_IMAGE_MIME_TYPES] : [...SUPPORTED_IMAGE_MIME_TYPES];\n\n\tfor (const mimeType of tryTypes) {\n\t\tconst data = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", mimeType, \"-o\"]);\n\t\tif (data.ok && data.stdout.length > 0) {\n\t\t\treturn { bytes: data.stdout, mimeType: baseMimeType(mimeType) };\n\t\t}\n\t}\n\n\treturn null;\n}\n\nasync function readClipboardImageViaNativeClipboard(): Promise<ClipboardImage | null> {\n\tif (!clipboard?.hasImage()) {\n\t\treturn null;\n\t}\n\n\tconst imageData = await clipboard.getImageBinary();\n\tif (!imageData || imageData.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst bytes = imageData instanceof Uint8Array ? imageData : Uint8Array.from(imageData);\n\treturn { bytes, mimeType: \"image/png\" };\n}\n\nexport async function readClipboardImage(options?: {\n\tenv?: NodeJS.ProcessEnv;\n\tplatform?: NodeJS.Platform;\n}): Promise<ClipboardImage | null> {\n\tconst env = options?.env ?? process.env;\n\tconst platform = options?.platform ?? process.platform;\n\n\tif (env.TERMUX_VERSION) {\n\t\treturn null;\n\t}\n\n\tlet image: ClipboardImage | null = null;\n\n\tif (platform === \"linux\") {\n\t\tconst wsl = isWSL(env);\n\t\tconst wayland = isWaylandSession(env);\n\n\t\tif (wayland || wsl) {\n\t\t\timage = readClipboardImageViaWlPaste() ?? readClipboardImageViaXclip();\n\t\t}\n\n\t\tif (!image && wsl) {\n\t\t\timage = readClipboardImageViaPowerShell();\n\t\t}\n\n\t\tif (!image && !wayland) {\n\t\t\timage = await readClipboardImageViaNativeClipboard();\n\t\t}\n\t} else {\n\t\timage = await readClipboardImageViaNativeClipboard();\n\t}\n\n\tif (!image) {\n\t\treturn null;\n\t}\n\n\t// Convert unsupported formats (e.g., BMP from WSLg) to PNG\n\tif (!isSupportedImageMimeType(image.mimeType)) {\n\t\tconst pngBytes = await convertToPng(image.bytes);\n\t\tif (!pngBytes) {\n\t\t\treturn null;\n\t\t}\n\t\treturn { bytes: pngBytes, mimeType: \"image/png\" };\n\t}\n\n\treturn image;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard-native.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard-native.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,cAAc,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;CAC7C,CAAC;AAEF,KAAK,gBAAgB,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;AAMhD,wBAAgB,mBAAmB,CAClC,QAAQ,GAAE,SAAS,gBAAgB,EAA0C,GAC3E,eAAe,GAAG,IAAI,CASxB;AAED,QAAA,MAAM,SAAS,wBAA2E,CAAC;AAE3F,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { pathToFileURL } from \"url\";\n\nexport type ClipboardModule = {\n\tsetText: (text: string) => Promise<void>;\n\thasImage: () => boolean;\n\tgetImageBinary: () => Promise<Array<number>>;\n};\n\ntype ClipboardRequire = (id: string) => unknown;\n\nconst moduleRequire = createRequire(import.meta.url);\nconst executableDirRequire = createRequire(pathToFileURL(join(dirname(process.execPath), \"package.json\")).href);\nconst hasDisplay = process.platform !== \"linux\" || Boolean(process.env.DISPLAY || process.env.WAYLAND_DISPLAY);\n\nexport function loadClipboardNative(\n\trequires: readonly ClipboardRequire[] = [moduleRequire, executableDirRequire],\n): ClipboardModule | null {\n\tfor (const requireClipboard of requires) {\n\t\ttry {\n\t\t\treturn requireClipboard(\"@mariozechner/clipboard\") as ClipboardModule;\n\t\t} catch {\n\t\t\t// Try the next resolution root.\n\t\t}\n\t}\n\treturn null;\n}\n\nconst clipboard = !process.env.TERMUX_VERSION && hasDisplay ? loadClipboardNative() : null;\n\nexport { clipboard };\n"]}
1
+ {"version":3,"file":"clipboard-native.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard-native.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,cAAc,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;CAC7C,CAAC;AAEF,KAAK,gBAAgB,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;AAMhD,wBAAgB,mBAAmB,CAClC,QAAQ,GAAE,SAAS,gB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createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { pathToFileURL } from \"url\";\n\nexport type ClipboardModule = {\n\tsetText: (text: string) => Promise<void>;\n\thasImage: () => boolean;\n\tgetImageBinary: () => Promise<Array<number>>;\n};\n\ntype ClipboardRequire = (id: string) => unknown;\n\nconst moduleRequire = createRequire(import.meta.url);\nconst executableDirRequire = createRequire(pathToFileURL(join(dirname(process.execPath), \"package.json\")).href);\nconst hasDisplay = process.platform !== \"linux\" || Boolean(process.env.DISPLAY || process.env.WAYLAND_DISPLAY);\n\nexport function loadClipboardNative(\n\trequires: readonly ClipboardRequire[] = [moduleRequire, executableDirRequire],\n): ClipboardModule | null {\n\tfor (const requireClipboard of requires) {\n\t\ttry {\n\t\t\treturn requireClipboard(\"@mariozechner/clipboard\") as ClipboardModule;\n\t\t} catch {\n\t\t\t// Try the next resolution root.\n\t\t}\n\t}\n\treturn null;\n}\n\nconst clipboard = !process.env.TERMUX_VERSION && hasDisplay ? loadClipboardNative() : null;\n\nexport { clipboard };\n"]}
1
+ {"version":3,"file":"clipboard-native.js","sourceRoot":"","sources":["../../src/utils/clipboard-native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAUpC,MAAM,aAAa,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AACrD,MAAM,oBAAoB,GAAG,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAChH,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAE/G,MAAM,UAAU,mBAAmB,CAClC,QAAQ,GAAgC,CAAC,aAAa,EAAE,oBAAoB,CAAC;IAE7E,KAAK,MAAM,gBAAgB,IAAI,QAAQ,EAAE,CAAC;QACzC,IAAI,CAAC;YACJ,OAAO,gBAAgB,CAAC,yBAAyB,CAAoB,CAAC;QACvE,CAAC;QAAC,MAAM,CAAC;YACR,gCAAgC;QACjC,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,UAAU,CAAC,CAAC,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAE3F,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { pathToFileURL } from \"url\";\n\nexport type ClipboardModule = {\n\tsetText: (text: string) => Promise<void>;\n\thasImage: () => boolean;\n\tgetImageBinary: () => Promise<Array<number>>;\n};\n\ntype ClipboardRequire = (id: string) => unknown;\n\nconst moduleRequire = createRequire(import.meta.url);\nconst executableDirRequire = createRequire(pathToFileURL(join(dirname(process.execPath), \"package.json\")).href);\nconst hasDisplay = process.platform !== \"linux\" || Boolean(process.env.DISPLAY || process.env.WAYLAND_DISPLAY);\n\nexport function loadClipboardNative(\n\trequires: readonly ClipboardRequire[] = [moduleRequire, executableDirRequire],\n): ClipboardModule | null {\n\tfor (const requireClipboard of requires) {\n\t\ttry {\n\t\t\treturn requireClipboard(\"@mariozechner/clipboard\") as ClipboardModule;\n\t\t} catch {\n\t\t\t// Try the next resolution root.\n\t\t}\n\t}\n\treturn null;\n}\n\nconst clipboard = !process.env.TERMUX_VERSION && hasDisplay ? loadClipboardNative() : null;\n\nexport { clipboard };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard.ts"],"names":[],"mappings":"AAkCA,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4FjE","sourcesContent":["import { execSync, spawn } from \"child_process\";\nimport { platform } from \"os\";\nimport { isWaylandSession } from \"./clipboard-image.ts\";\nimport { clipboard } from \"./clipboard-native.ts\";\n\ntype NativeClipboardExecOptions = {\n\tinput: string;\n\ttimeout: number;\n\tstdio: [\"pipe\", \"ignore\", \"ignore\"];\n};\n\nfunction copyToX11Clipboard(options: NativeClipboardExecOptions): void {\n\ttry {\n\t\texecSync(\"xclip -selection clipboard\", options);\n\t} catch {\n\t\texecSync(\"xsel --clipboard --input\", options);\n\t}\n}\n\nconst MAX_OSC52_ENCODED_LENGTH = 100_000;\n\nfunction isRemoteSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn Boolean(env.SSH_CONNECTION || env.SSH_CLIENT || env.MOSH_CONNECTION);\n}\n\nfunction emitOsc52(text: string): boolean {\n\tconst encoded = Buffer.from(text).toString(\"base64\");\n\tif (encoded.length > MAX_OSC52_ENCODED_LENGTH) {\n\t\treturn false;\n\t}\n\tprocess.stdout.write(`\\x1b]52;c;${encoded}\\x07`);\n\treturn true;\n}\n\nexport async function copyToClipboard(text: string): Promise<void> {\n\tlet copied = false;\n\n\tconst p = platform();\n\n\t// Prefer direct clipboard writes. Emitting OSC 52 first can make terminals\n\t// write the same native clipboard concurrently with the addon, and very large\n\t// OSC 52 payloads can desynchronize terminal rendering.\n\t//\n\t// On Linux, skip the native addon. The underlying `clipboard-rs` crate is\n\t// X11-only and does not retain selection ownership after `set_text`\n\t// resolves, so on Wayland-only compositors (Hyprland, Niri, ...) and even\n\t// some X11 sessions the call resolves successfully without populating the\n\t// clipboard. The platform tools below (wl-copy, xclip, xsel) properly\n\t// daemonize and keep ownership.\n\ttry {\n\t\tif (clipboard && p !== \"linux\") {\n\t\t\tawait clipboard.setText(text);\n\t\t\tcopied = true;\n\t\t}\n\t} catch {\n\t\t// Fall through to platform-specific clipboard tools.\n\t}\n\n\tconst remote = isRemoteSession();\n\tif (copied && !remote) {\n\t\treturn;\n\t}\n\n\tconst options: NativeClipboardExecOptions = { input: text, timeout: 5000, stdio: [\"pipe\", \"ignore\", \"ignore\"] };\n\n\tif (!copied) {\n\t\ttry {\n\t\t\tif (p === \"darwin\") {\n\t\t\t\texecSync(\"pbcopy\", options);\n\t\t\t\tcopied = true;\n\t\t\t} else if (p === \"win32\") {\n\t\t\t\texecSync(\"clip\", options);\n\t\t\t\tcopied = true;\n\t\t\t} else {\n\t\t\t\t// Linux. Try Termux, Wayland, or X11 clipboard tools.\n\t\t\t\tif (process.env.TERMUX_VERSION) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\texecSync(\"termux-clipboard-set\", options);\n\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Fall back to Wayland or X11 tools.\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!copied) {\n\t\t\t\t\tconst hasWaylandDisplay = Boolean(process.env.WAYLAND_DISPLAY);\n\t\t\t\t\tconst hasX11Display = Boolean(process.env.DISPLAY);\n\t\t\t\t\tconst isWayland = isWaylandSession();\n\t\t\t\t\tif (isWayland && hasWaylandDisplay) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// Verify wl-copy exists (spawn errors are async and won't be caught)\n\t\t\t\t\t\t\texecSync(\"which wl-copy\", { stdio: \"ignore\" });\n\t\t\t\t\t\t\t// wl-copy with execSync hangs due to fork behavior; use spawn instead\n\t\t\t\t\t\t\tconst proc = spawn(\"wl-copy\", [], { stdio: [\"pipe\", \"ignore\", \"ignore\"] });\n\t\t\t\t\t\t\tproc.stdin.on(\"error\", () => {\n\t\t\t\t\t\t\t\t// Ignore EPIPE errors if wl-copy exits early\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tproc.stdin.write(text);\n\t\t\t\t\t\t\tproc.stdin.end();\n\t\t\t\t\t\t\tproc.unref();\n\t\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tif (hasX11Display) {\n\t\t\t\t\t\t\t\tcopyToX11Clipboard(options);\n\t\t\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (hasX11Display) {\n\t\t\t\t\t\tcopyToX11Clipboard(options);\n\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Fall through to OSC 52 fallback.\n\t\t}\n\t}\n\n\tif (remote || !copied) {\n\t\tconst osc52Copied = emitOsc52(text);\n\t\tcopied = copied || osc52Copied;\n\t}\n\n\tif (!copied) {\n\t\tthrow new Error(\"Failed to copy to clipboard\");\n\t}\n}\n"]}
1
+ {"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard.ts"],"names":[],"mappings":"AAkCA,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4FjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../../src/utils/clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAQlD,SAAS,kBAAkB,CAAC,OAAmC,EAAQ;IACtE,IAAI,CAAC;QACJ,QAAQ,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACR,QAAQ,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;AAAA,CACD;AAED,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEzC,SAAS,e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GAAG,EAAE,CAAC;gCAC5B,6CAA6C;4BADhB,CAE7B,CAAC,CAAC;4BACH,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;4BACvB,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;4BACjB,IAAI,CAAC,KAAK,EAAE,CAAC;4BACb,MAAM,GAAG,IAAI,CAAC;wBACf,CAAC;wBAAC,MAAM,CAAC;4BACR,IAAI,aAAa,EAAE,CAAC;gCACnB,kBAAkB,CAAC,OAAO,CAAC,CAAC;gCAC5B,MAAM,GAAG,IAAI,CAAC;4BACf,CAAC;wBACF,CAAC;oBACF,CAAC;yBAAM,IAAI,aAAa,EAAE,CAAC;wBAC1B,kBAAkB,CAAC,OAAO,CAAC,CAAC;wBAC5B,MAAM,GAAG,IAAI,CAAC;oBACf,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAAC,MAAM,CAAC;YACR,mCAAmC;QACpC,CAAC;IACF,CAAC;IAED,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,GAAG,MAAM,IAAI,WAAW,CAAC;IAChC,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAChD,CAAC;AAAA,CACD","sourcesContent":["import { execSync, spawn } from \"child_process\";\nimport { platform } from \"os\";\nimport { isWaylandSession } from \"./clipboard-image.ts\";\nimport { clipboard } from \"./clipboard-native.ts\";\n\ntype NativeClipboardExecOptions = {\n\tinput: string;\n\ttimeout: number;\n\tstdio: [\"pipe\", \"ignore\", \"ignore\"];\n};\n\nfunction copyToX11Clipboard(options: NativeClipboardExecOptions): void {\n\ttry {\n\t\texecSync(\"xclip -selection clipboard\", options);\n\t} catch {\n\t\texecSync(\"xsel --clipboard --input\", options);\n\t}\n}\n\nconst MAX_OSC52_ENCODED_LENGTH = 100_000;\n\nfunction isRemoteSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn Boolean(env.SSH_CONNECTION || env.SSH_CLIENT || env.MOSH_CONNECTION);\n}\n\nfunction emitOsc52(text: string): boolean {\n\tconst encoded = Buffer.from(text).toString(\"base64\");\n\tif (encoded.length > MAX_OSC52_ENCODED_LENGTH) {\n\t\treturn false;\n\t}\n\tprocess.stdout.write(`\\x1b]52;c;${encoded}\\x07`);\n\treturn true;\n}\n\nexport async function copyToClipboard(text: string): Promise<void> {\n\tlet copied = false;\n\n\tconst p = platform();\n\n\t// Prefer direct clipboard writes. Emitting OSC 52 first can make terminals\n\t// write the same native clipboard concurrently with the addon, and very large\n\t// OSC 52 payloads can desynchronize terminal rendering.\n\t//\n\t// On Linux, skip the native addon. The underlying `clipboard-rs` crate is\n\t// X11-only and does not retain selection ownership after `set_text`\n\t// resolves, so on Wayland-only compositors (Hyprland, Niri, ...) and even\n\t// some X11 sessions the call resolves successfully without populating the\n\t// clipboard. The platform tools below (wl-copy, xclip, xsel) properly\n\t// daemonize and keep ownership.\n\ttry {\n\t\tif (clipboard && p !== \"linux\") {\n\t\t\tawait clipboard.setText(text);\n\t\t\tcopied = true;\n\t\t}\n\t} catch {\n\t\t// Fall through to platform-specific clipboard tools.\n\t}\n\n\tconst remote = isRemoteSession();\n\tif (copied && !remote) {\n\t\treturn;\n\t}\n\n\tconst options: NativeClipboardExecOptions = { input: text, timeout: 5000, stdio: [\"pipe\", \"ignore\", \"ignore\"] };\n\n\tif (!copied) {\n\t\ttry {\n\t\t\tif (p === \"darwin\") {\n\t\t\t\texecSync(\"pbcopy\", options);\n\t\t\t\tcopied = true;\n\t\t\t} else if (p === \"win32\") {\n\t\t\t\texecSync(\"clip\", options);\n\t\t\t\tcopied = true;\n\t\t\t} else {\n\t\t\t\t// Linux. Try Termux, Wayland, or X11 clipboard tools.\n\t\t\t\tif (process.env.TERMUX_VERSION) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\texecSync(\"termux-clipboard-set\", options);\n\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Fall back to Wayland or X11 tools.\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!copied) {\n\t\t\t\t\tconst hasWaylandDisplay = Boolean(process.env.WAYLAND_DISPLAY);\n\t\t\t\t\tconst hasX11Display = Boolean(process.env.DISPLAY);\n\t\t\t\t\tconst isWayland = isWaylandSession();\n\t\t\t\t\tif (isWayland && hasWaylandDisplay) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// Verify wl-copy exists (spawn errors are async and won't be caught)\n\t\t\t\t\t\t\texecSync(\"which wl-copy\", { stdio: \"ignore\" });\n\t\t\t\t\t\t\t// wl-copy with execSync hangs due to fork behavior; use spawn instead\n\t\t\t\t\t\t\tconst proc = spawn(\"wl-copy\", [], { stdio: [\"pipe\", \"ignore\", \"ignore\"] });\n\t\t\t\t\t\t\tproc.stdin.on(\"error\", () => {\n\t\t\t\t\t\t\t\t// Ignore EPIPE errors if wl-copy exits early\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tproc.stdin.write(text);\n\t\t\t\t\t\t\tproc.stdin.end();\n\t\t\t\t\t\t\tproc.unref();\n\t\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tif (hasX11Display) {\n\t\t\t\t\t\t\t\tcopyToX11Clipboard(options);\n\t\t\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (hasX11Display) {\n\t\t\t\t\t\tcopyToX11Clipboard(options);\n\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Fall through to OSC 52 fallback.\n\t\t}\n\t}\n\n\tif (remote || !copied) {\n\t\tconst osc52Copied = emitOsc52(text);\n\t\tcopied = copied || osc52Copied;\n\t}\n\n\t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,EAAE,CAAC;QACvB,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,GAAG,MAAM,IAAI,WAAW,CAAC;IAChC,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAChD,CAAC;AACF,CAAC","sourcesContent":["import { execSync, spawn } from \"child_process\";\nimport { platform } from \"os\";\nimport { isWaylandSession } from \"./clipboard-image.ts\";\nimport { clipboard } from \"./clipboard-native.ts\";\n\ntype NativeClipboardExecOptions = {\n\tinput: string;\n\ttimeout: number;\n\tstdio: [\"pipe\", \"ignore\", \"ignore\"];\n};\n\nfunction copyToX11Clipboard(options: NativeClipboardExecOptions): void {\n\ttry {\n\t\texecSync(\"xclip -selection clipboard\", options);\n\t} catch {\n\t\texecSync(\"xsel --clipboard --input\", options);\n\t}\n}\n\nconst MAX_OSC52_ENCODED_LENGTH = 100_000;\n\nfunction isRemoteSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn Boolean(env.SSH_CONNECTION || env.SSH_CLIENT || env.MOSH_CONNECTION);\n}\n\nfunction emitOsc52(text: string): boolean {\n\tconst encoded = Buffer.from(text).toString(\"base64\");\n\tif (encoded.length > MAX_OSC52_ENCODED_LENGTH) {\n\t\treturn false;\n\t}\n\tprocess.stdout.write(`\\x1b]52;c;${encoded}\\x07`);\n\treturn true;\n}\n\nexport async function copyToClipboard(text: string): Promise<void> {\n\tlet copied = false;\n\n\tconst p = platform();\n\n\t// Prefer direct clipboard writes. Emitting OSC 52 first can make terminals\n\t// write the same native clipboard concurrently with the addon, and very large\n\t// OSC 52 payloads can desynchronize terminal rendering.\n\t//\n\t// On Linux, skip the native addon. The underlying `clipboard-rs` crate is\n\t// X11-only and does not retain selection ownership after `set_text`\n\t// resolves, so on Wayland-only compositors (Hyprland, Niri, ...) and even\n\t// some X11 sessions the call resolves successfully without populating the\n\t// clipboard. The platform tools below (wl-copy, xclip, xsel) properly\n\t// daemonize and keep ownership.\n\ttry {\n\t\tif (clipboard && p !== \"linux\") {\n\t\t\tawait clipboard.setText(text);\n\t\t\tcopied = true;\n\t\t}\n\t} catch {\n\t\t// Fall through to platform-specific clipboard tools.\n\t}\n\n\tconst remote = isRemoteSession();\n\tif (copied && !remote) {\n\t\treturn;\n\t}\n\n\tconst options: NativeClipboardExecOptions = { input: text, timeout: 5000, stdio: [\"pipe\", \"ignore\", \"ignore\"] };\n\n\tif (!copied) {\n\t\ttry {\n\t\t\tif (p === \"darwin\") {\n\t\t\t\texecSync(\"pbcopy\", options);\n\t\t\t\tcopied = true;\n\t\t\t} else if (p === \"win32\") {\n\t\t\t\texecSync(\"clip\", options);\n\t\t\t\tcopied = true;\n\t\t\t} else {\n\t\t\t\t// Linux. Try Termux, Wayland, or X11 clipboard tools.\n\t\t\t\tif (process.env.TERMUX_VERSION) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\texecSync(\"termux-clipboard-set\", options);\n\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Fall back to Wayland or X11 tools.\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!copied) {\n\t\t\t\t\tconst hasWaylandDisplay = Boolean(process.env.WAYLAND_DISPLAY);\n\t\t\t\t\tconst hasX11Display = Boolean(process.env.DISPLAY);\n\t\t\t\t\tconst isWayland = isWaylandSession();\n\t\t\t\t\tif (isWayland && hasWaylandDisplay) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// Verify wl-copy exists (spawn errors are async and won't be caught)\n\t\t\t\t\t\t\texecSync(\"which wl-copy\", { stdio: \"ignore\" });\n\t\t\t\t\t\t\t// wl-copy with execSync hangs due to fork behavior; use spawn instead\n\t\t\t\t\t\t\tconst proc = spawn(\"wl-copy\", [], { stdio: [\"pipe\", \"ignore\", \"ignore\"] });\n\t\t\t\t\t\t\tproc.stdin.on(\"error\", () => {\n\t\t\t\t\t\t\t\t// Ignore EPIPE errors if wl-copy exits early\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tproc.stdin.write(text);\n\t\t\t\t\t\t\tproc.stdin.end();\n\t\t\t\t\t\t\tproc.unref();\n\t\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tif (hasX11Display) {\n\t\t\t\t\t\t\t\tcopyToX11Clipboard(options);\n\t\t\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (hasX11Display) {\n\t\t\t\t\t\tcopyToX11Clipboard(options);\n\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Fall through to OSC 52 fallback.\n\t\t}\n\t}\n\n\tif (remote || !copied) {\n\t\tconst osc52Copied = emitOsc52(text);\n\t\tcopied = copied || osc52Copied;\n\t}\n\n\tif (!copied) {\n\t\tthrow new Error(\"Failed to copy to clipboard\");\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"deprecation.d.ts","sourceRoot":"","sources":["../../src/utils/deprecation.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIrD;AAED,2DAA2D;AAC3D,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD","sourcesContent":["import chalk from \"chalk\";\n\nconst emittedDeprecationWarnings = new Set<string>();\n\nexport function warnDeprecation(message: string): void {\n\tif (emittedDeprecationWarnings.has(message)) return;\n\temittedDeprecationWarnings.add(message);\n\tconsole.warn(chalk.yellow(`Deprecation warning: ${message}`));\n}\n\n/** Clear deprecation warning state. Exported for tests. */\nexport function clearDeprecationWarningsForTests(): void {\n\temittedDeprecationWarnings.clear();\n}\n"]}
1
+ {"version":3,"file":"deprecation.d.ts","sourceRoot":"","sources":["../../src/utils/deprecation.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIrD;AAED,2DAA2D;AAC3D,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"deprecation.js","sourceRoot":"","sources":["../../src/utils/deprecation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,0BAA0B,GAAG,IAAI,GAAG,EAAU,CAAC;AAErD,MAAM,UAAU,eAAe,CAAC,OAAe,EAAQ;IACtD,IAAI,0BAA0B,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO;IACpD,0BAA0B,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC,CAAC;AAAA,CAC9D;AAED,2DAA2D;AAC3D,MAAM,UAAU,gCAAgC,GAAS;IACxD,0BAA0B,CAAC,KAAK,EAAE,CAAC;AAAA,CACnC","sourcesContent":["import chalk from \"chalk\";\n\nconst emittedDeprecationWarnings = new Set<string>();\n\nexport function warnDeprecation(message: string): void {\n\tif (emittedDeprecationWarnings.has(message)) return;\n\temittedDeprecationWarnings.add(message);\n\tconsole.warn(chalk.yellow(`Deprecation warning: ${message}`));\n}\n\n/** Clear deprecation warning state. Exported for tests. */\nexport function clearDeprecationWarningsForTests(): void {\n\temittedDeprecationWarnings.clear();\n}\n"]}
1
+ {"version":3,"file":"deprecation.js","sourceRoot":"","sources":["../../src/utils/deprecation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,0BAA0B,GAAG,IAAI,GAAG,EAAU,CAAC;AAErD,MAAM,UAAU,eAAe,CAAC,OAAe;IAC9C,IAAI,0BAA0B,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO;IACpD,0BAA0B,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,gCAAgC;IAC/C,0BAA0B,CAAC,KAAK,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import chalk from \"chalk\";\n\nconst emittedDeprecationWarnings = new Set<string>();\n\nexport function warnDeprecation(message: string): void {\n\tif (emittedDeprecationWarnings.has(message)) return;\n\temittedDeprecationWarnings.add(message);\n\tconsole.warn(chalk.yellow(`Deprecation warning: ${message}`));\n}\n\n/** Clear deprecation warning state. Exported for tests. */\nexport function clearDeprecationWarningsForTests(): void {\n\temittedDeprecationWarnings.clear();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"exif-orientation.d.ts","sourceRoot":"","sources":["../../src/utils/exif-orientation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,KAAK,MAAM,GAAG,cAAc,4BAA4B,CAAC,CAAC;AAgJ1D,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,eAAe,EACtB,aAAa,EAAE,UAAU,GACvB,eAAe,CAgCjB","sourcesContent":["import type { PhotonImageType } from \"./photon.ts\";\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
+ {"version":3,"file":"exif-orientation.d.ts","sourceRoot":"","sources":["../../src/utils/exif-orientation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,KAAK,MAAM,GAAG,cAAc,4BAA4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AK,CAAC;QACd,KAAK,CAAC,EAAE,CAAC;YACR,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC9E,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,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACtE,KAAK,CAAC,EAAE,CAAC;YACR,MAAM,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.ts\";\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
+ {"version":3,"file":"exif-orientation.js","sourceRoot":"","sources":["../../src/utils/exif-orientation.ts"],"names":[],"mappings":"AAIA,SAAS,uBAAuB,CAAC,KAAiB,EAAE,SAAiB;IACpE,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;QACtC,IAAI,EAAE;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAClD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,GAAW,EAAU,EAAE;QACtC,IAAI,EAAE;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACpG,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,CA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AAC,EAAE,CAAC;YACR,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC9E,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,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACtE,KAAK,CAAC,EAAE,CAAC;YACR,MAAM,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;AACF,CAAC","sourcesContent":["import type { PhotonImageType } from \"./photon.ts\";\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 +1 @@
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
+ {"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,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAClF,MAAM,KACb,iBAAiB,CAAC,CAAC,CAOrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAAa,MAAM,KAAG,MAAwC,CAAC"}
@@ -1 +1 @@
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
+ {"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;IAC3F,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;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC/B,OAAe,EACQ,EAAE;IACzB,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;AACnD,CAAC,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 +1 @@
1
- {"version":3,"file":"fs-watch.d.ts","sourceRoot":"","sources":["../../src/utils/fs-watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAS,MAAM,SAAS,CAAC;AAEpE,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAUxE;AAED,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,EAC/B,OAAO,EAAE,MAAM,IAAI,GACjB,SAAS,GAAG,IAAI,CASlB","sourcesContent":["import { type FSWatcher, type WatchListener, watch } from \"node:fs\";\n\nexport const FS_WATCH_RETRY_DELAY_MS = 5000;\n\nexport function closeWatcher(watcher: FSWatcher | null | undefined): void {\n\tif (!watcher) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\twatcher.close();\n\t} catch {\n\t\t// Ignore watcher close errors\n\t}\n}\n\nexport function watchWithErrorHandler(\n\tpath: string,\n\tlistener: WatchListener<string>,\n\tonError: () => void,\n): FSWatcher | null {\n\ttry {\n\t\tconst watcher = watch(path, listener);\n\t\twatcher.on(\"error\", onError);\n\t\treturn watcher;\n\t} catch {\n\t\tonError();\n\t\treturn null;\n\t}\n}\n"]}
1
+ {"version":3,"file":"fs-watch.d.ts","sourceRoot":"","sources":["../../src/utils/fs-watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAS,MAAM,SAAS,CAAC;AAEpE,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAUxE;AAED,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,EAC/B,OAAO,EAAE,MAAM,IAAI,GACjB,SAAS,GAAG,IAAI,CASlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"fs-watch.js","sourceRoot":"","sources":["../../src/utils/fs-watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,EAAE,MAAM,SAAS,CAAC;AAEpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C,MAAM,UAAU,YAAY,CAAC,OAAqC,EAAQ;IACzE,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAO;IACR,CAAC;IAED,IAAI,CAAC;QACJ,OAAO,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACR,8BAA8B;IAC/B,CAAC;AAAA,CACD;AAED,MAAM,UAAU,qBAAqB,CACpC,IAAY,EACZ,QAA+B,EAC/B,OAAmB,EACA;IACnB,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACtC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACb,CAAC;AAAA,CACD","sourcesContent":["import { type FSWatcher, type WatchListener, watch } from \"node:fs\";\n\nexport const FS_WATCH_RETRY_DELAY_MS = 5000;\n\nexport function closeWatcher(watcher: FSWatcher | null | undefined): void {\n\tif (!watcher) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\twatcher.close();\n\t} catch {\n\t\t// Ignore watcher close errors\n\t}\n}\n\nexport function watchWithErrorHandler(\n\tpath: string,\n\tlistener: WatchListener<string>,\n\tonError: () => void,\n): FSWatcher | null {\n\ttry {\n\t\tconst watcher = watch(path, listener);\n\t\twatcher.on(\"error\", onError);\n\t\treturn watcher;\n\t} catch {\n\t\tonError();\n\t\treturn null;\n\t}\n}\n"]}
1
+ {"version":3,"file":"fs-watch.js","sourceRoot":"","sources":["../../src/utils/fs-watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,EAAE,MAAM,SAAS,CAAC;AAEpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C,MAAM,UAAU,YAAY,CAAC,OAAqC;IACjE,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAO;IACR,CAAC;IAED,IAAI,CAAC;QACJ,OAAO,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACR,8BAA8B;IAC/B,CAAC;AACF,CAAC;AAED,MAAM,UAAU,qBAAqB,CACpC,IAAY,EACZ,QAA+B,EAC/B,OAAmB;IAEnB,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACtC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC","sourcesContent":["import { type FSWatcher, type WatchListener, watch } from \"node:fs\";\n\nexport const FS_WATCH_RETRY_DELAY_MS = 5000;\n\nexport function closeWatcher(watcher: FSWatcher | null | undefined): void {\n\tif (!watcher) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\twatcher.close();\n\t} catch {\n\t\t// Ignore watcher close errors\n\t}\n}\n\nexport function watchWithErrorHandler(\n\tpath: string,\n\tlistener: WatchListener<string>,\n\tonError: () => void,\n): FSWatcher | null {\n\ttry {\n\t\tconst watcher = watch(path, listener);\n\t\twatcher.on(\"error\", onError);\n\t\treturn watcher;\n\t} catch {\n\t\tonError();\n\t\treturn null;\n\t}\n}\n"]}
@@ -1 +1 @@
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;AAkJF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAsD5D","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 decodeForValidation(value: string): string | null {\n\ttry {\n\t\treturn decodeURIComponent(value);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction hasUnsafeGitInstallPart(value: string, allowSlash: boolean): boolean {\n\tconst decoded = decodeForValidation(value);\n\tif (decoded === null) {\n\t\treturn true;\n\t}\n\tconst candidates = [value, decoded];\n\tfor (const candidate of candidates) {\n\t\tif (candidate.includes(\"\\0\") || candidate.includes(\"\\\\\") || candidate.startsWith(\"/\")) {\n\t\t\treturn true;\n\t\t}\n\t\tif (!allowSlash && candidate.includes(\"/\")) {\n\t\t\treturn true;\n\t\t}\n\t\tif (candidate.split(\"/\").includes(\"..\")) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction buildGitSource(args: { repo: string; host: string; path: string; ref?: string }): GitSource | null {\n\tif (args.path.startsWith(\"/\")) {\n\t\treturn null;\n\t}\n\tconst normalizedPath = args.path.replace(/\\.git$/, \"\").replace(/^\\/+/, \"\");\n\tif (!args.host || !normalizedPath || normalizedPath.split(\"/\").length < 2) {\n\t\treturn null;\n\t}\n\tif (hasUnsafeGitInstallPart(args.host, false) || hasUnsafeGitInstallPart(normalizedPath, true)) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\ttype: \"git\",\n\t\trepo: args.repo,\n\t\thost: args.host,\n\t\tpath: normalizedPath,\n\t\tref: args.ref,\n\t\tpinned: Boolean(args.ref),\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\treturn buildGitSource({ repo, host, path, ref });\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 buildGitSource({\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}`,\n\t\t\t\tref: info.committish || split.ref || undefined,\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 buildGitSource({\n\t\t\t\trepo: `https://${split.repo}`,\n\t\t\t\thost: info.domain || \"\",\n\t\t\t\tpath: `${info.user}/${info.project}`,\n\t\t\t\tref: info.committish || split.ref || undefined,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn parseGenericGitUrl(url);\n}\n"]}
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;AAkJF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAsD5D"}