@tuan_son.dinh/gsd 2.6.2 → 2.7.0

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 (1024) hide show
  1. package/README.md +1 -0
  2. package/dist/cli.js +24 -10
  3. package/dist/loader.js +21 -3
  4. package/dist/logo.d.ts +3 -3
  5. package/dist/logo.js +2 -2
  6. package/dist/onboarding.d.ts +3 -3
  7. package/dist/onboarding.js +3 -4
  8. package/dist/pi-migration.d.ts +5 -1
  9. package/dist/pi-migration.js +19 -2
  10. package/dist/resource-loader.d.ts +2 -1
  11. package/dist/resource-loader.js +60 -4
  12. package/dist/wizard.d.ts +1 -1
  13. package/package.json +12 -6
  14. package/packages/pi-agent-core/dist/agent-loop.d.ts +21 -0
  15. package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -0
  16. package/packages/pi-agent-core/dist/agent-loop.js +308 -0
  17. package/packages/pi-agent-core/dist/agent-loop.js.map +1 -0
  18. package/packages/pi-agent-core/dist/agent.d.ts +162 -0
  19. package/packages/pi-agent-core/dist/agent.d.ts.map +1 -0
  20. package/packages/pi-agent-core/dist/agent.js +399 -0
  21. package/packages/pi-agent-core/dist/agent.js.map +1 -0
  22. package/packages/pi-agent-core/dist/index.d.ts +5 -0
  23. package/packages/pi-agent-core/dist/index.d.ts.map +1 -0
  24. package/packages/pi-agent-core/dist/index.js +9 -0
  25. package/packages/pi-agent-core/dist/index.js.map +1 -0
  26. package/packages/pi-agent-core/dist/proxy.d.ts +85 -0
  27. package/packages/pi-agent-core/dist/proxy.d.ts.map +1 -0
  28. package/packages/pi-agent-core/dist/proxy.js +268 -0
  29. package/packages/pi-agent-core/dist/proxy.js.map +1 -0
  30. package/packages/pi-agent-core/dist/types.d.ts +178 -0
  31. package/packages/pi-agent-core/dist/types.d.ts.map +1 -0
  32. package/packages/pi-agent-core/dist/types.js +2 -0
  33. package/packages/pi-agent-core/dist/types.js.map +1 -0
  34. package/packages/pi-agent-core/package.json +14 -0
  35. package/packages/pi-agent-core/src/agent-loop.ts +417 -0
  36. package/packages/pi-agent-core/src/agent.ts +568 -0
  37. package/packages/pi-agent-core/src/index.ts +8 -0
  38. package/packages/pi-agent-core/src/proxy.ts +340 -0
  39. package/packages/pi-agent-core/src/types.ts +194 -0
  40. package/packages/pi-agent-core/tsconfig.json +27 -0
  41. package/packages/pi-ai/bedrock-provider.d.ts +1 -0
  42. package/packages/pi-ai/bedrock-provider.js +1 -0
  43. package/packages/pi-ai/dist/api-registry.d.ts +20 -0
  44. package/packages/pi-ai/dist/api-registry.d.ts.map +1 -0
  45. package/packages/pi-ai/dist/api-registry.js +44 -0
  46. package/packages/pi-ai/dist/api-registry.js.map +1 -0
  47. package/packages/pi-ai/dist/bedrock-provider.d.ts +5 -0
  48. package/packages/pi-ai/dist/bedrock-provider.d.ts.map +1 -0
  49. package/packages/pi-ai/dist/bedrock-provider.js +6 -0
  50. package/packages/pi-ai/dist/bedrock-provider.js.map +1 -0
  51. package/packages/pi-ai/dist/cli.d.ts +3 -0
  52. package/packages/pi-ai/dist/cli.d.ts.map +1 -0
  53. package/packages/pi-ai/dist/cli.js +116 -0
  54. package/packages/pi-ai/dist/cli.js.map +1 -0
  55. package/packages/pi-ai/dist/env-api-keys.d.ts +9 -0
  56. package/packages/pi-ai/dist/env-api-keys.d.ts.map +1 -0
  57. package/packages/pi-ai/dist/env-api-keys.js +104 -0
  58. package/packages/pi-ai/dist/env-api-keys.js.map +1 -0
  59. package/packages/pi-ai/dist/index.d.ts +23 -0
  60. package/packages/pi-ai/dist/index.d.ts.map +1 -0
  61. package/packages/pi-ai/dist/index.js +21 -0
  62. package/packages/pi-ai/dist/index.js.map +1 -0
  63. package/packages/pi-ai/dist/models.d.ts +24 -0
  64. package/packages/pi-ai/dist/models.d.ts.map +1 -0
  65. package/packages/pi-ai/dist/models.generated.d.ts +13572 -0
  66. package/packages/pi-ai/dist/models.generated.d.ts.map +1 -0
  67. package/packages/pi-ai/dist/models.generated.js +13368 -0
  68. package/packages/pi-ai/dist/models.generated.js.map +1 -0
  69. package/packages/pi-ai/dist/models.js +55 -0
  70. package/packages/pi-ai/dist/models.js.map +1 -0
  71. package/packages/pi-ai/dist/oauth.d.ts +2 -0
  72. package/packages/pi-ai/dist/oauth.d.ts.map +1 -0
  73. package/packages/pi-ai/dist/oauth.js +2 -0
  74. package/packages/pi-ai/dist/oauth.js.map +1 -0
  75. package/packages/pi-ai/dist/providers/amazon-bedrock.d.ts +15 -0
  76. package/packages/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -0
  77. package/packages/pi-ai/dist/providers/amazon-bedrock.js +600 -0
  78. package/packages/pi-ai/dist/providers/amazon-bedrock.js.map +1 -0
  79. package/packages/pi-ai/dist/providers/anthropic.d.ts +33 -0
  80. package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -0
  81. package/packages/pi-ai/dist/providers/anthropic.js +732 -0
  82. package/packages/pi-ai/dist/providers/anthropic.js.map +1 -0
  83. package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts +15 -0
  84. package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -0
  85. package/packages/pi-ai/dist/providers/azure-openai-responses.js +187 -0
  86. package/packages/pi-ai/dist/providers/azure-openai-responses.js.map +1 -0
  87. package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts +8 -0
  88. package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -0
  89. package/packages/pi-ai/dist/providers/github-copilot-headers.js +29 -0
  90. package/packages/pi-ai/dist/providers/github-copilot-headers.js.map +1 -0
  91. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts +74 -0
  92. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -0
  93. package/packages/pi-ai/dist/providers/google-gemini-cli.js +757 -0
  94. package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -0
  95. package/packages/pi-ai/dist/providers/google-shared.d.ts +65 -0
  96. package/packages/pi-ai/dist/providers/google-shared.d.ts.map +1 -0
  97. package/packages/pi-ai/dist/providers/google-shared.js +300 -0
  98. package/packages/pi-ai/dist/providers/google-shared.js.map +1 -0
  99. package/packages/pi-ai/dist/providers/google-vertex.d.ts +15 -0
  100. package/packages/pi-ai/dist/providers/google-vertex.d.ts.map +1 -0
  101. package/packages/pi-ai/dist/providers/google-vertex.js +374 -0
  102. package/packages/pi-ai/dist/providers/google-vertex.js.map +1 -0
  103. package/packages/pi-ai/dist/providers/google.d.ts +13 -0
  104. package/packages/pi-ai/dist/providers/google.d.ts.map +1 -0
  105. package/packages/pi-ai/dist/providers/google.js +355 -0
  106. package/packages/pi-ai/dist/providers/google.js.map +1 -0
  107. package/packages/pi-ai/dist/providers/mistral.d.ts +22 -0
  108. package/packages/pi-ai/dist/providers/mistral.d.ts.map +1 -0
  109. package/packages/pi-ai/dist/providers/mistral.js +498 -0
  110. package/packages/pi-ai/dist/providers/mistral.js.map +1 -0
  111. package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts +9 -0
  112. package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -0
  113. package/packages/pi-ai/dist/providers/openai-codex-responses.js +704 -0
  114. package/packages/pi-ai/dist/providers/openai-codex-responses.js.map +1 -0
  115. package/packages/pi-ai/dist/providers/openai-completions.d.ts +15 -0
  116. package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -0
  117. package/packages/pi-ai/dist/providers/openai-completions.js +705 -0
  118. package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -0
  119. package/packages/pi-ai/dist/providers/openai-responses-shared.d.ts +17 -0
  120. package/packages/pi-ai/dist/providers/openai-responses-shared.d.ts.map +1 -0
  121. package/packages/pi-ai/dist/providers/openai-responses-shared.js +442 -0
  122. package/packages/pi-ai/dist/providers/openai-responses-shared.js.map +1 -0
  123. package/packages/pi-ai/dist/providers/openai-responses.d.ts +13 -0
  124. package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -0
  125. package/packages/pi-ai/dist/providers/openai-responses.js +201 -0
  126. package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -0
  127. package/packages/pi-ai/dist/providers/register-builtins.d.ts +11 -0
  128. package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -0
  129. package/packages/pi-ai/dist/providers/register-builtins.js +138 -0
  130. package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -0
  131. package/packages/pi-ai/dist/providers/simple-options.d.ts +8 -0
  132. package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -0
  133. package/packages/pi-ai/dist/providers/simple-options.js +35 -0
  134. package/packages/pi-ai/dist/providers/simple-options.js.map +1 -0
  135. package/packages/pi-ai/dist/providers/transform-messages.d.ts +8 -0
  136. package/packages/pi-ai/dist/providers/transform-messages.d.ts.map +1 -0
  137. package/packages/pi-ai/dist/providers/transform-messages.js +155 -0
  138. package/packages/pi-ai/dist/providers/transform-messages.js.map +1 -0
  139. package/packages/pi-ai/dist/stream.d.ts +8 -0
  140. package/packages/pi-ai/dist/stream.d.ts.map +1 -0
  141. package/packages/pi-ai/dist/stream.js +27 -0
  142. package/packages/pi-ai/dist/stream.js.map +1 -0
  143. package/packages/pi-ai/dist/types.d.ts +285 -0
  144. package/packages/pi-ai/dist/types.d.ts.map +1 -0
  145. package/packages/pi-ai/dist/types.js +2 -0
  146. package/packages/pi-ai/dist/types.js.map +1 -0
  147. package/packages/pi-ai/dist/utils/event-stream.d.ts +21 -0
  148. package/packages/pi-ai/dist/utils/event-stream.d.ts.map +1 -0
  149. package/packages/pi-ai/dist/utils/event-stream.js +77 -0
  150. package/packages/pi-ai/dist/utils/event-stream.js.map +1 -0
  151. package/packages/pi-ai/dist/utils/hash.d.ts +3 -0
  152. package/packages/pi-ai/dist/utils/hash.d.ts.map +1 -0
  153. package/packages/pi-ai/dist/utils/hash.js +14 -0
  154. package/packages/pi-ai/dist/utils/hash.js.map +1 -0
  155. package/packages/pi-ai/dist/utils/json-parse.d.ts +9 -0
  156. package/packages/pi-ai/dist/utils/json-parse.d.ts.map +1 -0
  157. package/packages/pi-ai/dist/utils/json-parse.js +29 -0
  158. package/packages/pi-ai/dist/utils/json-parse.js.map +1 -0
  159. package/packages/pi-ai/dist/utils/oauth/anthropic.d.ts +17 -0
  160. package/packages/pi-ai/dist/utils/oauth/anthropic.d.ts.map +1 -0
  161. package/packages/pi-ai/dist/utils/oauth/anthropic.js +104 -0
  162. package/packages/pi-ai/dist/utils/oauth/anthropic.js.map +1 -0
  163. package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts +30 -0
  164. package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -0
  165. package/packages/pi-ai/dist/utils/oauth/github-copilot.js +281 -0
  166. package/packages/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -0
  167. package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts +26 -0
  168. package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts.map +1 -0
  169. package/packages/pi-ai/dist/utils/oauth/google-antigravity.js +373 -0
  170. package/packages/pi-ai/dist/utils/oauth/google-antigravity.js.map +1 -0
  171. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts +26 -0
  172. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts.map +1 -0
  173. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js +478 -0
  174. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js.map +1 -0
  175. package/packages/pi-ai/dist/utils/oauth/index.d.ts +61 -0
  176. package/packages/pi-ai/dist/utils/oauth/index.d.ts.map +1 -0
  177. package/packages/pi-ai/dist/utils/oauth/index.js +131 -0
  178. package/packages/pi-ai/dist/utils/oauth/index.js.map +1 -0
  179. package/packages/pi-ai/dist/utils/oauth/openai-codex.d.ts +34 -0
  180. package/packages/pi-ai/dist/utils/oauth/openai-codex.d.ts.map +1 -0
  181. package/packages/pi-ai/dist/utils/oauth/openai-codex.js +380 -0
  182. package/packages/pi-ai/dist/utils/oauth/openai-codex.js.map +1 -0
  183. package/packages/pi-ai/dist/utils/oauth/pkce.d.ts +13 -0
  184. package/packages/pi-ai/dist/utils/oauth/pkce.d.ts.map +1 -0
  185. package/packages/pi-ai/dist/utils/oauth/pkce.js +31 -0
  186. package/packages/pi-ai/dist/utils/oauth/pkce.js.map +1 -0
  187. package/packages/pi-ai/dist/utils/oauth/types.d.ts +47 -0
  188. package/packages/pi-ai/dist/utils/oauth/types.d.ts.map +1 -0
  189. package/packages/pi-ai/dist/utils/oauth/types.js +2 -0
  190. package/packages/pi-ai/dist/utils/oauth/types.js.map +1 -0
  191. package/packages/pi-ai/dist/utils/overflow.d.ts +52 -0
  192. package/packages/pi-ai/dist/utils/overflow.d.ts.map +1 -0
  193. package/packages/pi-ai/dist/utils/overflow.js +117 -0
  194. package/packages/pi-ai/dist/utils/overflow.js.map +1 -0
  195. package/packages/pi-ai/dist/utils/sanitize-unicode.d.ts +22 -0
  196. package/packages/pi-ai/dist/utils/sanitize-unicode.d.ts.map +1 -0
  197. package/packages/pi-ai/dist/utils/sanitize-unicode.js +26 -0
  198. package/packages/pi-ai/dist/utils/sanitize-unicode.js.map +1 -0
  199. package/packages/pi-ai/dist/utils/typebox-helpers.d.ts +17 -0
  200. package/packages/pi-ai/dist/utils/typebox-helpers.d.ts.map +1 -0
  201. package/packages/pi-ai/dist/utils/typebox-helpers.js +21 -0
  202. package/packages/pi-ai/dist/utils/typebox-helpers.js.map +1 -0
  203. package/packages/pi-ai/dist/utils/validation.d.ts +18 -0
  204. package/packages/pi-ai/dist/utils/validation.d.ts.map +1 -0
  205. package/packages/pi-ai/dist/utils/validation.js +72 -0
  206. package/packages/pi-ai/dist/utils/validation.js.map +1 -0
  207. package/packages/pi-ai/package.json +40 -0
  208. package/packages/pi-ai/src/api-registry.ts +98 -0
  209. package/packages/pi-ai/src/bedrock-provider.ts +6 -0
  210. package/packages/pi-ai/src/cli.ts +133 -0
  211. package/packages/pi-ai/src/env-api-keys.ts +129 -0
  212. package/packages/pi-ai/src/index.ts +32 -0
  213. package/packages/pi-ai/src/models.generated.ts +13370 -0
  214. package/packages/pi-ai/src/models.ts +77 -0
  215. package/packages/pi-ai/src/oauth.ts +1 -0
  216. package/packages/pi-ai/src/providers/amazon-bedrock.ts +751 -0
  217. package/packages/pi-ai/src/providers/anthropic.ts +883 -0
  218. package/packages/pi-ai/src/providers/azure-openai-responses.ts +259 -0
  219. package/packages/pi-ai/src/providers/github-copilot-headers.ts +37 -0
  220. package/packages/pi-ai/src/providers/google-gemini-cli.ts +967 -0
  221. package/packages/pi-ai/src/providers/google-shared.ts +313 -0
  222. package/packages/pi-ai/src/providers/google-vertex.ts +485 -0
  223. package/packages/pi-ai/src/providers/google.ts +455 -0
  224. package/packages/pi-ai/src/providers/mistral.ts +582 -0
  225. package/packages/pi-ai/src/providers/openai-codex-responses.ts +875 -0
  226. package/packages/pi-ai/src/providers/openai-completions.ts +820 -0
  227. package/packages/pi-ai/src/providers/openai-responses-shared.ts +496 -0
  228. package/packages/pi-ai/src/providers/openai-responses.ts +262 -0
  229. package/packages/pi-ai/src/providers/register-builtins.ts +186 -0
  230. package/packages/pi-ai/src/providers/simple-options.ts +46 -0
  231. package/packages/pi-ai/src/providers/transform-messages.ts +172 -0
  232. package/packages/pi-ai/src/stream.ts +59 -0
  233. package/packages/pi-ai/src/types.ts +321 -0
  234. package/packages/pi-ai/src/utils/event-stream.ts +87 -0
  235. package/packages/pi-ai/src/utils/hash.ts +13 -0
  236. package/packages/pi-ai/src/utils/json-parse.ts +28 -0
  237. package/packages/pi-ai/src/utils/oauth/anthropic.ts +138 -0
  238. package/packages/pi-ai/src/utils/oauth/github-copilot.ts +381 -0
  239. package/packages/pi-ai/src/utils/oauth/google-antigravity.ts +457 -0
  240. package/packages/pi-ai/src/utils/oauth/google-gemini-cli.ts +599 -0
  241. package/packages/pi-ai/src/utils/oauth/index.ts +162 -0
  242. package/packages/pi-ai/src/utils/oauth/openai-codex.ts +455 -0
  243. package/packages/pi-ai/src/utils/oauth/pkce.ts +34 -0
  244. package/packages/pi-ai/src/utils/oauth/types.ts +59 -0
  245. package/packages/pi-ai/src/utils/overflow.ts +123 -0
  246. package/packages/pi-ai/src/utils/sanitize-unicode.ts +25 -0
  247. package/packages/pi-ai/src/utils/typebox-helpers.ts +24 -0
  248. package/packages/pi-ai/src/utils/validation.ts +84 -0
  249. package/packages/pi-ai/tsconfig.json +27 -0
  250. package/packages/pi-coding-agent/dist/cli/args.d.ts +48 -0
  251. package/packages/pi-coding-agent/dist/cli/args.d.ts.map +1 -0
  252. package/packages/pi-coding-agent/dist/cli/args.js +299 -0
  253. package/packages/pi-coding-agent/dist/cli/args.js.map +1 -0
  254. package/packages/pi-coding-agent/dist/cli/config-selector.d.ts +14 -0
  255. package/packages/pi-coding-agent/dist/cli/config-selector.d.ts.map +1 -0
  256. package/packages/pi-coding-agent/dist/cli/config-selector.js +31 -0
  257. package/packages/pi-coding-agent/dist/cli/config-selector.js.map +1 -0
  258. package/packages/pi-coding-agent/dist/cli/file-processor.d.ts +15 -0
  259. package/packages/pi-coding-agent/dist/cli/file-processor.d.ts.map +1 -0
  260. package/packages/pi-coding-agent/dist/cli/file-processor.js +79 -0
  261. package/packages/pi-coding-agent/dist/cli/file-processor.js.map +1 -0
  262. package/packages/pi-coding-agent/dist/cli/list-models.d.ts +9 -0
  263. package/packages/pi-coding-agent/dist/cli/list-models.d.ts.map +1 -0
  264. package/packages/pi-coding-agent/dist/cli/list-models.js +92 -0
  265. package/packages/pi-coding-agent/dist/cli/list-models.js.map +1 -0
  266. package/packages/pi-coding-agent/dist/cli/session-picker.d.ts +9 -0
  267. package/packages/pi-coding-agent/dist/cli/session-picker.d.ts.map +1 -0
  268. package/packages/pi-coding-agent/dist/cli/session-picker.js +34 -0
  269. package/packages/pi-coding-agent/dist/cli/session-picker.js.map +1 -0
  270. package/packages/pi-coding-agent/dist/cli.d.ts +3 -0
  271. package/packages/pi-coding-agent/dist/cli.d.ts.map +1 -0
  272. package/packages/pi-coding-agent/dist/cli.js +16 -0
  273. package/packages/pi-coding-agent/dist/cli.js.map +1 -0
  274. package/packages/pi-coding-agent/dist/config.d.ts +68 -0
  275. package/packages/pi-coding-agent/dist/config.d.ts.map +1 -0
  276. package/packages/pi-coding-agent/dist/config.js +203 -0
  277. package/packages/pi-coding-agent/dist/config.js.map +1 -0
  278. package/packages/pi-coding-agent/dist/core/agent-session.d.ts +618 -0
  279. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -0
  280. package/packages/pi-coding-agent/dist/core/agent-session.js +2481 -0
  281. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -0
  282. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +134 -0
  283. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -0
  284. package/packages/pi-coding-agent/dist/core/auth-storage.js +415 -0
  285. package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -0
  286. package/packages/pi-coding-agent/dist/core/bash-executor.d.ts +47 -0
  287. package/packages/pi-coding-agent/dist/core/bash-executor.d.ts.map +1 -0
  288. package/packages/pi-coding-agent/dist/core/bash-executor.js +212 -0
  289. package/packages/pi-coding-agent/dist/core/bash-executor.js.map +1 -0
  290. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts +86 -0
  291. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  292. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js +242 -0
  293. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js.map +1 -0
  294. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts +121 -0
  295. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -0
  296. package/packages/pi-coding-agent/dist/core/compaction/compaction.js +610 -0
  297. package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -0
  298. package/packages/pi-coding-agent/dist/core/compaction/index.d.ts +7 -0
  299. package/packages/pi-coding-agent/dist/core/compaction/index.d.ts.map +1 -0
  300. package/packages/pi-coding-agent/dist/core/compaction/index.js +7 -0
  301. package/packages/pi-coding-agent/dist/core/compaction/index.js.map +1 -0
  302. package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts +38 -0
  303. package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts.map +1 -0
  304. package/packages/pi-coding-agent/dist/core/compaction/utils.js +153 -0
  305. package/packages/pi-coding-agent/dist/core/compaction/utils.js.map +1 -0
  306. package/packages/pi-coding-agent/dist/core/defaults.d.ts +3 -0
  307. package/packages/pi-coding-agent/dist/core/defaults.d.ts.map +1 -0
  308. package/packages/pi-coding-agent/dist/core/defaults.js +2 -0
  309. package/packages/pi-coding-agent/dist/core/defaults.js.map +1 -0
  310. package/packages/pi-coding-agent/dist/core/diagnostics.d.ts +15 -0
  311. package/packages/pi-coding-agent/dist/core/diagnostics.d.ts.map +1 -0
  312. package/packages/pi-coding-agent/dist/core/diagnostics.js +2 -0
  313. package/packages/pi-coding-agent/dist/core/diagnostics.js.map +1 -0
  314. package/packages/pi-coding-agent/dist/core/event-bus.d.ts +9 -0
  315. package/packages/pi-coding-agent/dist/core/event-bus.d.ts.map +1 -0
  316. package/packages/pi-coding-agent/dist/core/event-bus.js +25 -0
  317. package/packages/pi-coding-agent/dist/core/event-bus.js.map +1 -0
  318. package/packages/pi-coding-agent/dist/core/exec.d.ts +29 -0
  319. package/packages/pi-coding-agent/dist/core/exec.d.ts.map +1 -0
  320. package/packages/pi-coding-agent/dist/core/exec.js +71 -0
  321. package/packages/pi-coding-agent/dist/core/exec.js.map +1 -0
  322. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts +22 -0
  323. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  324. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js +249 -0
  325. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js.map +1 -0
  326. package/packages/pi-coding-agent/dist/core/export-html/index.d.ts +37 -0
  327. package/packages/pi-coding-agent/dist/core/export-html/index.d.ts.map +1 -0
  328. package/packages/pi-coding-agent/dist/core/export-html/index.js +223 -0
  329. package/packages/pi-coding-agent/dist/core/export-html/index.js.map +1 -0
  330. package/packages/pi-coding-agent/dist/core/export-html/template.css +971 -0
  331. package/packages/pi-coding-agent/dist/core/export-html/template.html +54 -0
  332. package/packages/pi-coding-agent/dist/core/export-html/template.js +1583 -0
  333. package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.d.ts +38 -0
  334. package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  335. package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.js +70 -0
  336. package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.js.map +1 -0
  337. package/packages/pi-coding-agent/dist/core/export-html/vendor/.gitkeep +0 -0
  338. package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +11 -0
  339. package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -0
  340. package/packages/pi-coding-agent/dist/core/extensions/index.js +9 -0
  341. package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -0
  342. package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts +25 -0
  343. package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -0
  344. package/packages/pi-coding-agent/dist/core/extensions/loader.js +426 -0
  345. package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -0
  346. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +147 -0
  347. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -0
  348. package/packages/pi-coding-agent/dist/core/extensions/runner.js +672 -0
  349. package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -0
  350. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +1040 -0
  351. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -0
  352. package/packages/pi-coding-agent/dist/core/extensions/types.js +35 -0
  353. package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -0
  354. package/packages/pi-coding-agent/dist/core/extensions/wrapper.d.ts +27 -0
  355. package/packages/pi-coding-agent/dist/core/extensions/wrapper.d.ts.map +1 -0
  356. package/packages/pi-coding-agent/dist/core/extensions/wrapper.js +102 -0
  357. package/packages/pi-coding-agent/dist/core/extensions/wrapper.js.map +1 -0
  358. package/packages/pi-coding-agent/dist/core/footer-data-provider.d.ts +32 -0
  359. package/packages/pi-coding-agent/dist/core/footer-data-provider.d.ts.map +1 -0
  360. package/packages/pi-coding-agent/dist/core/footer-data-provider.js +134 -0
  361. package/packages/pi-coding-agent/dist/core/footer-data-provider.js.map +1 -0
  362. package/packages/pi-coding-agent/dist/core/index.d.ts +9 -0
  363. package/packages/pi-coding-agent/dist/core/index.d.ts.map +1 -0
  364. package/packages/pi-coding-agent/dist/core/index.js +9 -0
  365. package/packages/pi-coding-agent/dist/core/index.js.map +1 -0
  366. package/packages/pi-coding-agent/dist/core/keybindings.d.ts +55 -0
  367. package/packages/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -0
  368. package/packages/pi-coding-agent/dist/core/keybindings.js +151 -0
  369. package/packages/pi-coding-agent/dist/core/keybindings.js.map +1 -0
  370. package/packages/pi-coding-agent/dist/core/messages.d.ts +77 -0
  371. package/packages/pi-coding-agent/dist/core/messages.d.ts.map +1 -0
  372. package/packages/pi-coding-agent/dist/core/messages.js +123 -0
  373. package/packages/pi-coding-agent/dist/core/messages.js.map +1 -0
  374. package/packages/pi-coding-agent/dist/core/model-registry.d.ts +113 -0
  375. package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -0
  376. package/packages/pi-coding-agent/dist/core/model-registry.js +537 -0
  377. package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -0
  378. package/packages/pi-coding-agent/dist/core/model-resolver.d.ts +104 -0
  379. package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -0
  380. package/packages/pi-coding-agent/dist/core/model-resolver.js +462 -0
  381. package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -0
  382. package/packages/pi-coding-agent/dist/core/package-manager.d.ts +156 -0
  383. package/packages/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -0
  384. package/packages/pi-coding-agent/dist/core/package-manager.js +1442 -0
  385. package/packages/pi-coding-agent/dist/core/package-manager.js.map +1 -0
  386. package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts +50 -0
  387. package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts.map +1 -0
  388. package/packages/pi-coding-agent/dist/core/prompt-templates.js +251 -0
  389. package/packages/pi-coding-agent/dist/core/prompt-templates.js.map +1 -0
  390. package/packages/pi-coding-agent/dist/core/resolve-config-value.d.ts +17 -0
  391. package/packages/pi-coding-agent/dist/core/resolve-config-value.d.ts.map +1 -0
  392. package/packages/pi-coding-agent/dist/core/resolve-config-value.js +59 -0
  393. package/packages/pi-coding-agent/dist/core/resolve-config-value.js.map +1 -0
  394. package/packages/pi-coding-agent/dist/core/resource-loader.d.ts +184 -0
  395. package/packages/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -0
  396. package/packages/pi-coding-agent/dist/core/resource-loader.js +633 -0
  397. package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -0
  398. package/packages/pi-coding-agent/dist/core/sdk.d.ts +90 -0
  399. package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -0
  400. package/packages/pi-coding-agent/dist/core/sdk.js +242 -0
  401. package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -0
  402. package/packages/pi-coding-agent/dist/core/session-manager.d.ts +323 -0
  403. package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -0
  404. package/packages/pi-coding-agent/dist/core/session-manager.js +1094 -0
  405. package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -0
  406. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +232 -0
  407. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -0
  408. package/packages/pi-coding-agent/dist/core/settings-manager.js +682 -0
  409. package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -0
  410. package/packages/pi-coding-agent/dist/core/skills.d.ts +58 -0
  411. package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -0
  412. package/packages/pi-coding-agent/dist/core/skills.js +364 -0
  413. package/packages/pi-coding-agent/dist/core/skills.js.map +1 -0
  414. package/packages/pi-coding-agent/dist/core/slash-commands.d.ts +15 -0
  415. package/packages/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -0
  416. package/packages/pi-coding-agent/dist/core/slash-commands.js +22 -0
  417. package/packages/pi-coding-agent/dist/core/slash-commands.js.map +1 -0
  418. package/packages/pi-coding-agent/dist/core/system-prompt.d.ts +28 -0
  419. package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -0
  420. package/packages/pi-coding-agent/dist/core/system-prompt.js +159 -0
  421. package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -0
  422. package/packages/pi-coding-agent/dist/core/timings.d.ts +7 -0
  423. package/packages/pi-coding-agent/dist/core/timings.d.ts.map +1 -0
  424. package/packages/pi-coding-agent/dist/core/timings.js +25 -0
  425. package/packages/pi-coding-agent/dist/core/timings.js.map +1 -0
  426. package/packages/pi-coding-agent/dist/core/tools/bash.d.ts +55 -0
  427. package/packages/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -0
  428. package/packages/pi-coding-agent/dist/core/tools/bash.js +269 -0
  429. package/packages/pi-coding-agent/dist/core/tools/bash.js.map +1 -0
  430. package/packages/pi-coding-agent/dist/core/tools/edit-diff.d.ts +63 -0
  431. package/packages/pi-coding-agent/dist/core/tools/edit-diff.d.ts.map +1 -0
  432. package/packages/pi-coding-agent/dist/core/tools/edit-diff.js +243 -0
  433. package/packages/pi-coding-agent/dist/core/tools/edit-diff.js.map +1 -0
  434. package/packages/pi-coding-agent/dist/core/tools/edit.d.ts +39 -0
  435. package/packages/pi-coding-agent/dist/core/tools/edit.d.ts.map +1 -0
  436. package/packages/pi-coding-agent/dist/core/tools/edit.js +146 -0
  437. package/packages/pi-coding-agent/dist/core/tools/edit.js.map +1 -0
  438. package/packages/pi-coding-agent/dist/core/tools/find.d.ts +39 -0
  439. package/packages/pi-coding-agent/dist/core/tools/find.d.ts.map +1 -0
  440. package/packages/pi-coding-agent/dist/core/tools/find.js +206 -0
  441. package/packages/pi-coding-agent/dist/core/tools/find.js.map +1 -0
  442. package/packages/pi-coding-agent/dist/core/tools/grep.d.ts +45 -0
  443. package/packages/pi-coding-agent/dist/core/tools/grep.d.ts.map +1 -0
  444. package/packages/pi-coding-agent/dist/core/tools/grep.js +239 -0
  445. package/packages/pi-coding-agent/dist/core/tools/grep.js.map +1 -0
  446. package/packages/pi-coding-agent/dist/core/tools/index.d.ts +73 -0
  447. package/packages/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -0
  448. package/packages/pi-coding-agent/dist/core/tools/index.js +61 -0
  449. package/packages/pi-coding-agent/dist/core/tools/index.js.map +1 -0
  450. package/packages/pi-coding-agent/dist/core/tools/ls.d.ts +40 -0
  451. package/packages/pi-coding-agent/dist/core/tools/ls.d.ts.map +1 -0
  452. package/packages/pi-coding-agent/dist/core/tools/ls.js +118 -0
  453. package/packages/pi-coding-agent/dist/core/tools/ls.js.map +1 -0
  454. package/packages/pi-coding-agent/dist/core/tools/path-utils.d.ts +8 -0
  455. package/packages/pi-coding-agent/dist/core/tools/path-utils.d.ts.map +1 -0
  456. package/packages/pi-coding-agent/dist/core/tools/path-utils.js +81 -0
  457. package/packages/pi-coding-agent/dist/core/tools/path-utils.js.map +1 -0
  458. package/packages/pi-coding-agent/dist/core/tools/read.d.ts +39 -0
  459. package/packages/pi-coding-agent/dist/core/tools/read.d.ts.map +1 -0
  460. package/packages/pi-coding-agent/dist/core/tools/read.js +166 -0
  461. package/packages/pi-coding-agent/dist/core/tools/read.js.map +1 -0
  462. package/packages/pi-coding-agent/dist/core/tools/truncate.d.ts +70 -0
  463. package/packages/pi-coding-agent/dist/core/tools/truncate.d.ts.map +1 -0
  464. package/packages/pi-coding-agent/dist/core/tools/truncate.js +205 -0
  465. package/packages/pi-coding-agent/dist/core/tools/truncate.js.map +1 -0
  466. package/packages/pi-coding-agent/dist/core/tools/write.d.ts +29 -0
  467. package/packages/pi-coding-agent/dist/core/tools/write.d.ts.map +1 -0
  468. package/packages/pi-coding-agent/dist/core/tools/write.js +78 -0
  469. package/packages/pi-coding-agent/dist/core/tools/write.js.map +1 -0
  470. package/packages/pi-coding-agent/dist/index.d.ts +27 -0
  471. package/packages/pi-coding-agent/dist/index.d.ts.map +1 -0
  472. package/packages/pi-coding-agent/dist/index.js +42 -0
  473. package/packages/pi-coding-agent/dist/index.js.map +1 -0
  474. package/packages/pi-coding-agent/dist/main.d.ts +8 -0
  475. package/packages/pi-coding-agent/dist/main.d.ts.map +1 -0
  476. package/packages/pi-coding-agent/dist/main.js +691 -0
  477. package/packages/pi-coding-agent/dist/main.js.map +1 -0
  478. package/packages/pi-coding-agent/dist/migrations.d.ts +33 -0
  479. package/packages/pi-coding-agent/dist/migrations.d.ts.map +1 -0
  480. package/packages/pi-coding-agent/dist/migrations.js +261 -0
  481. package/packages/pi-coding-agent/dist/migrations.js.map +1 -0
  482. package/packages/pi-coding-agent/dist/modes/index.d.ts +9 -0
  483. package/packages/pi-coding-agent/dist/modes/index.d.ts.map +1 -0
  484. package/packages/pi-coding-agent/dist/modes/index.js +8 -0
  485. package/packages/pi-coding-agent/dist/modes/index.js.map +1 -0
  486. package/packages/pi-coding-agent/dist/modes/interactive/components/armin.d.ts +34 -0
  487. package/packages/pi-coding-agent/dist/modes/interactive/components/armin.d.ts.map +1 -0
  488. package/packages/pi-coding-agent/dist/modes/interactive/components/armin.js +329 -0
  489. package/packages/pi-coding-agent/dist/modes/interactive/components/armin.js.map +1 -0
  490. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts +16 -0
  491. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  492. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js +92 -0
  493. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -0
  494. package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts +35 -0
  495. package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  496. package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.js +156 -0
  497. package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.js.map +1 -0
  498. package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
  499. package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  500. package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.js +48 -0
  501. package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  502. package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
  503. package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  504. package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js +42 -0
  505. package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  506. package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
  507. package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  508. package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js +43 -0
  509. package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  510. package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts +71 -0
  511. package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  512. package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.js +470 -0
  513. package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.js.map +1 -0
  514. package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  515. package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  516. package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js +28 -0
  517. package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  518. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.d.ts +21 -0
  519. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  520. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.js +63 -0
  521. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.js.map +1 -0
  522. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.d.ts +20 -0
  523. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  524. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.js +74 -0
  525. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.js.map +1 -0
  526. package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.d.ts +23 -0
  527. package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
  528. package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.js +138 -0
  529. package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.js.map +1 -0
  530. package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts +12 -0
  531. package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts.map +1 -0
  532. package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js +133 -0
  533. package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js.map +1 -0
  534. package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  535. package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  536. package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js +20 -0
  537. package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  538. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts +20 -0
  539. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  540. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.js +106 -0
  541. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.js.map +1 -0
  542. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts +23 -0
  543. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  544. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js +55 -0
  545. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js.map +1 -0
  546. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.d.ts +24 -0
  547. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  548. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.js +71 -0
  549. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.js.map +1 -0
  550. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts +26 -0
  551. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -0
  552. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +196 -0
  553. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -0
  554. package/packages/pi-coding-agent/dist/modes/interactive/components/index.d.ts +32 -0
  555. package/packages/pi-coding-agent/dist/modes/interactive/components/index.d.ts.map +1 -0
  556. package/packages/pi-coding-agent/dist/modes/interactive/components/index.js +33 -0
  557. package/packages/pi-coding-agent/dist/modes/interactive/components/index.js.map +1 -0
  558. package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.d.ts +41 -0
  559. package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  560. package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js +61 -0
  561. package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  562. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts +42 -0
  563. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  564. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +139 -0
  565. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -0
  566. package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts +47 -0
  567. package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  568. package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js +259 -0
  569. package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js.map +1 -0
  570. package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
  571. package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  572. package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.js +92 -0
  573. package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  574. package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
  575. package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  576. package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.js +271 -0
  577. package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  578. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
  579. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  580. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js +155 -0
  581. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  582. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts +95 -0
  583. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  584. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js +825 -0
  585. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js.map +1 -0
  586. package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts +58 -0
  587. package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  588. package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +295 -0
  589. package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -0
  590. package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  591. package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  592. package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.js +34 -0
  593. package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  594. package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
  595. package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  596. package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js +45 -0
  597. package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  598. package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  599. package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  600. package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.js +44 -0
  601. package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.js.map +1 -0
  602. package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
  603. package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  604. package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js +46 -0
  605. package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  606. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +77 -0
  607. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  608. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +773 -0
  609. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -0
  610. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts +87 -0
  611. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  612. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js +1026 -0
  613. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js.map +1 -0
  614. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
  615. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  616. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.js +110 -0
  617. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  618. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts +9 -0
  619. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  620. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js +27 -0
  621. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js.map +1 -0
  622. package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  623. package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  624. package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.js +33 -0
  625. package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  626. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +330 -0
  627. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  628. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +3755 -0
  629. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -0
  630. package/packages/pi-coding-agent/dist/modes/interactive/theme/dark.json +86 -0
  631. package/packages/pi-coding-agent/dist/modes/interactive/theme/light.json +85 -0
  632. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +335 -0
  633. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +78 -0
  634. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  635. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +944 -0
  636. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -0
  637. package/packages/pi-coding-agent/dist/modes/print-mode.d.ts +28 -0
  638. package/packages/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -0
  639. package/packages/pi-coding-agent/dist/modes/print-mode.js +101 -0
  640. package/packages/pi-coding-agent/dist/modes/print-mode.js.map +1 -0
  641. package/packages/pi-coding-agent/dist/modes/rpc/jsonl.d.ts +17 -0
  642. package/packages/pi-coding-agent/dist/modes/rpc/jsonl.d.ts.map +1 -0
  643. package/packages/pi-coding-agent/dist/modes/rpc/jsonl.js +49 -0
  644. package/packages/pi-coding-agent/dist/modes/rpc/jsonl.js.map +1 -0
  645. package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.d.ts +217 -0
  646. package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  647. package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.js +400 -0
  648. package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.js.map +1 -0
  649. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts +20 -0
  650. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  651. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +509 -0
  652. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -0
  653. package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts +409 -0
  654. package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  655. package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.js +8 -0
  656. package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.js.map +1 -0
  657. package/packages/pi-coding-agent/dist/utils/changelog.d.ts +21 -0
  658. package/packages/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -0
  659. package/packages/pi-coding-agent/dist/utils/changelog.js +87 -0
  660. package/packages/pi-coding-agent/dist/utils/changelog.js.map +1 -0
  661. package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts +11 -0
  662. package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts.map +1 -0
  663. package/packages/pi-coding-agent/dist/utils/clipboard-image.js +162 -0
  664. package/packages/pi-coding-agent/dist/utils/clipboard-image.js.map +1 -0
  665. package/packages/pi-coding-agent/dist/utils/clipboard-native.d.ts +7 -0
  666. package/packages/pi-coding-agent/dist/utils/clipboard-native.d.ts.map +1 -0
  667. package/packages/pi-coding-agent/dist/utils/clipboard-native.js +14 -0
  668. package/packages/pi-coding-agent/dist/utils/clipboard-native.js.map +1 -0
  669. package/packages/pi-coding-agent/dist/utils/clipboard.d.ts +2 -0
  670. package/packages/pi-coding-agent/dist/utils/clipboard.d.ts.map +1 -0
  671. package/packages/pi-coding-agent/dist/utils/clipboard.js +67 -0
  672. package/packages/pi-coding-agent/dist/utils/clipboard.js.map +1 -0
  673. package/packages/pi-coding-agent/dist/utils/frontmatter.d.ts +8 -0
  674. package/packages/pi-coding-agent/dist/utils/frontmatter.d.ts.map +1 -0
  675. package/packages/pi-coding-agent/dist/utils/frontmatter.js +26 -0
  676. package/packages/pi-coding-agent/dist/utils/frontmatter.js.map +1 -0
  677. package/packages/pi-coding-agent/dist/utils/git.d.ts +26 -0
  678. package/packages/pi-coding-agent/dist/utils/git.d.ts.map +1 -0
  679. package/packages/pi-coding-agent/dist/utils/git.js +163 -0
  680. package/packages/pi-coding-agent/dist/utils/git.js.map +1 -0
  681. package/packages/pi-coding-agent/dist/utils/image-convert.d.ts +9 -0
  682. package/packages/pi-coding-agent/dist/utils/image-convert.d.ts.map +1 -0
  683. package/packages/pi-coding-agent/dist/utils/image-convert.js +35 -0
  684. package/packages/pi-coding-agent/dist/utils/image-convert.js.map +1 -0
  685. package/packages/pi-coding-agent/dist/utils/image-resize.d.ts +36 -0
  686. package/packages/pi-coding-agent/dist/utils/image-resize.d.ts.map +1 -0
  687. package/packages/pi-coding-agent/dist/utils/image-resize.js +181 -0
  688. package/packages/pi-coding-agent/dist/utils/image-resize.js.map +1 -0
  689. package/packages/pi-coding-agent/dist/utils/mime.d.ts +2 -0
  690. package/packages/pi-coding-agent/dist/utils/mime.d.ts.map +1 -0
  691. package/packages/pi-coding-agent/dist/utils/mime.js +26 -0
  692. package/packages/pi-coding-agent/dist/utils/mime.js.map +1 -0
  693. package/packages/pi-coding-agent/dist/utils/photon.d.ts +21 -0
  694. package/packages/pi-coding-agent/dist/utils/photon.d.ts.map +1 -0
  695. package/packages/pi-coding-agent/dist/utils/photon.js +121 -0
  696. package/packages/pi-coding-agent/dist/utils/photon.js.map +1 -0
  697. package/packages/pi-coding-agent/dist/utils/shell.d.ts +26 -0
  698. package/packages/pi-coding-agent/dist/utils/shell.d.ts.map +1 -0
  699. package/packages/pi-coding-agent/dist/utils/shell.js +186 -0
  700. package/packages/pi-coding-agent/dist/utils/shell.js.map +1 -0
  701. package/packages/pi-coding-agent/dist/utils/sleep.d.ts +5 -0
  702. package/packages/pi-coding-agent/dist/utils/sleep.d.ts.map +1 -0
  703. package/packages/pi-coding-agent/dist/utils/sleep.js +17 -0
  704. package/packages/pi-coding-agent/dist/utils/sleep.js.map +1 -0
  705. package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts +3 -0
  706. package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts.map +1 -0
  707. package/packages/pi-coding-agent/dist/utils/tools-manager.js +251 -0
  708. package/packages/pi-coding-agent/dist/utils/tools-manager.js.map +1 -0
  709. package/packages/pi-coding-agent/package.json +55 -0
  710. package/packages/pi-coding-agent/src/cli/args.ts +316 -0
  711. package/packages/pi-coding-agent/src/cli/config-selector.ts +52 -0
  712. package/packages/pi-coding-agent/src/cli/file-processor.ts +96 -0
  713. package/packages/pi-coding-agent/src/cli/list-models.ts +104 -0
  714. package/packages/pi-coding-agent/src/cli/session-picker.ts +51 -0
  715. package/packages/pi-coding-agent/src/cli.ts +18 -0
  716. package/packages/pi-coding-agent/src/config.ts +241 -0
  717. package/packages/pi-coding-agent/src/core/agent-session.ts +3050 -0
  718. package/packages/pi-coding-agent/src/core/auth-storage.ts +489 -0
  719. package/packages/pi-coding-agent/src/core/bash-executor.ts +278 -0
  720. package/packages/pi-coding-agent/src/core/compaction/branch-summarization.ts +352 -0
  721. package/packages/pi-coding-agent/src/core/compaction/compaction.ts +813 -0
  722. package/packages/pi-coding-agent/src/core/compaction/index.ts +7 -0
  723. package/packages/pi-coding-agent/src/core/compaction/utils.ts +170 -0
  724. package/packages/pi-coding-agent/src/core/defaults.ts +3 -0
  725. package/packages/pi-coding-agent/src/core/diagnostics.ts +15 -0
  726. package/packages/pi-coding-agent/src/core/event-bus.ts +33 -0
  727. package/packages/pi-coding-agent/src/core/exec.ts +104 -0
  728. package/packages/pi-coding-agent/src/core/export-html/ansi-to-html.ts +258 -0
  729. package/packages/pi-coding-agent/src/core/export-html/index.ts +306 -0
  730. package/packages/pi-coding-agent/src/core/export-html/template.css +971 -0
  731. package/packages/pi-coding-agent/src/core/export-html/template.html +54 -0
  732. package/packages/pi-coding-agent/src/core/export-html/template.js +1583 -0
  733. package/packages/pi-coding-agent/src/core/export-html/tool-renderer.ts +114 -0
  734. package/packages/pi-coding-agent/src/core/export-html/vendor/.gitkeep +0 -0
  735. package/packages/pi-coding-agent/src/core/extensions/index.ts +171 -0
  736. package/packages/pi-coding-agent/src/core/extensions/loader.ts +545 -0
  737. package/packages/pi-coding-agent/src/core/extensions/runner.ts +884 -0
  738. package/packages/pi-coding-agent/src/core/extensions/types.ts +1411 -0
  739. package/packages/pi-coding-agent/src/core/extensions/wrapper.ts +118 -0
  740. package/packages/pi-coding-agent/src/core/footer-data-provider.ts +144 -0
  741. package/packages/pi-coding-agent/src/core/index.ts +61 -0
  742. package/packages/pi-coding-agent/src/core/keybindings.ts +211 -0
  743. package/packages/pi-coding-agent/src/core/messages.ts +195 -0
  744. package/packages/pi-coding-agent/src/core/model-registry.ts +694 -0
  745. package/packages/pi-coding-agent/src/core/model-resolver.ts +594 -0
  746. package/packages/pi-coding-agent/src/core/package-manager.ts +1794 -0
  747. package/packages/pi-coding-agent/src/core/prompt-templates.ts +299 -0
  748. package/packages/pi-coding-agent/src/core/resolve-config-value.ts +64 -0
  749. package/packages/pi-coding-agent/src/core/resource-loader.ts +868 -0
  750. package/packages/pi-coding-agent/src/core/sdk.ts +373 -0
  751. package/packages/pi-coding-agent/src/core/session-manager.ts +1410 -0
  752. package/packages/pi-coding-agent/src/core/settings-manager.ts +942 -0
  753. package/packages/pi-coding-agent/src/core/skills.ts +459 -0
  754. package/packages/pi-coding-agent/src/core/slash-commands.ts +38 -0
  755. package/packages/pi-coding-agent/src/core/system-prompt.ts +218 -0
  756. package/packages/pi-coding-agent/src/core/timings.ts +25 -0
  757. package/packages/pi-coding-agent/src/core/tools/bash.ts +347 -0
  758. package/packages/pi-coding-agent/src/core/tools/edit-diff.ts +308 -0
  759. package/packages/pi-coding-agent/src/core/tools/edit.ts +227 -0
  760. package/packages/pi-coding-agent/src/core/tools/find.ts +273 -0
  761. package/packages/pi-coding-agent/src/core/tools/grep.ts +346 -0
  762. package/packages/pi-coding-agent/src/core/tools/index.ts +139 -0
  763. package/packages/pi-coding-agent/src/core/tools/ls.ts +170 -0
  764. package/packages/pi-coding-agent/src/core/tools/path-utils.ts +94 -0
  765. package/packages/pi-coding-agent/src/core/tools/read.ts +222 -0
  766. package/packages/pi-coding-agent/src/core/tools/truncate.ts +265 -0
  767. package/packages/pi-coding-agent/src/core/tools/write.ts +118 -0
  768. package/packages/pi-coding-agent/src/index.ts +333 -0
  769. package/packages/pi-coding-agent/src/main.ts +821 -0
  770. package/packages/pi-coding-agent/src/migrations.ts +295 -0
  771. package/packages/pi-coding-agent/src/modes/index.ts +9 -0
  772. package/packages/pi-coding-agent/src/modes/interactive/components/armin.ts +382 -0
  773. package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +115 -0
  774. package/packages/pi-coding-agent/src/modes/interactive/components/bash-execution.ts +210 -0
  775. package/packages/pi-coding-agent/src/modes/interactive/components/bordered-loader.ts +66 -0
  776. package/packages/pi-coding-agent/src/modes/interactive/components/branch-summary-message.ts +58 -0
  777. package/packages/pi-coding-agent/src/modes/interactive/components/compaction-summary-message.ts +59 -0
  778. package/packages/pi-coding-agent/src/modes/interactive/components/config-selector.ts +592 -0
  779. package/packages/pi-coding-agent/src/modes/interactive/components/countdown-timer.ts +38 -0
  780. package/packages/pi-coding-agent/src/modes/interactive/components/custom-editor.ts +80 -0
  781. package/packages/pi-coding-agent/src/modes/interactive/components/custom-message.ts +99 -0
  782. package/packages/pi-coding-agent/src/modes/interactive/components/daxnuts.ts +164 -0
  783. package/packages/pi-coding-agent/src/modes/interactive/components/diff.ts +147 -0
  784. package/packages/pi-coding-agent/src/modes/interactive/components/dynamic-border.ts +25 -0
  785. package/packages/pi-coding-agent/src/modes/interactive/components/extension-editor.ts +147 -0
  786. package/packages/pi-coding-agent/src/modes/interactive/components/extension-input.ts +85 -0
  787. package/packages/pi-coding-agent/src/modes/interactive/components/extension-selector.ts +107 -0
  788. package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +216 -0
  789. package/packages/pi-coding-agent/src/modes/interactive/components/index.ts +32 -0
  790. package/packages/pi-coding-agent/src/modes/interactive/components/keybinding-hints.ts +66 -0
  791. package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +174 -0
  792. package/packages/pi-coding-agent/src/modes/interactive/components/model-selector.ts +329 -0
  793. package/packages/pi-coding-agent/src/modes/interactive/components/oauth-selector.ts +121 -0
  794. package/packages/pi-coding-agent/src/modes/interactive/components/scoped-models-selector.ts +346 -0
  795. package/packages/pi-coding-agent/src/modes/interactive/components/session-selector-search.ts +194 -0
  796. package/packages/pi-coding-agent/src/modes/interactive/components/session-selector.ts +1019 -0
  797. package/packages/pi-coding-agent/src/modes/interactive/components/settings-selector.ts +421 -0
  798. package/packages/pi-coding-agent/src/modes/interactive/components/show-images-selector.ts +45 -0
  799. package/packages/pi-coding-agent/src/modes/interactive/components/skill-invocation-message.ts +55 -0
  800. package/packages/pi-coding-agent/src/modes/interactive/components/theme-selector.ts +62 -0
  801. package/packages/pi-coding-agent/src/modes/interactive/components/thinking-selector.ts +64 -0
  802. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +916 -0
  803. package/packages/pi-coding-agent/src/modes/interactive/components/tree-selector.ts +1184 -0
  804. package/packages/pi-coding-agent/src/modes/interactive/components/user-message-selector.ts +143 -0
  805. package/packages/pi-coding-agent/src/modes/interactive/components/user-message.ts +32 -0
  806. package/packages/pi-coding-agent/src/modes/interactive/components/visual-truncate.ts +50 -0
  807. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +4464 -0
  808. package/packages/pi-coding-agent/src/modes/interactive/theme/dark.json +86 -0
  809. package/packages/pi-coding-agent/src/modes/interactive/theme/light.json +85 -0
  810. package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.json +335 -0
  811. package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +1105 -0
  812. package/packages/pi-coding-agent/src/modes/print-mode.ts +124 -0
  813. package/packages/pi-coding-agent/src/modes/rpc/jsonl.ts +58 -0
  814. package/packages/pi-coding-agent/src/modes/rpc/rpc-client.ts +505 -0
  815. package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +638 -0
  816. package/packages/pi-coding-agent/src/modes/rpc/rpc-types.ts +263 -0
  817. package/packages/pi-coding-agent/src/utils/changelog.ts +99 -0
  818. package/packages/pi-coding-agent/src/utils/clipboard-image.ts +207 -0
  819. package/packages/pi-coding-agent/src/utils/clipboard-native.ts +21 -0
  820. package/packages/pi-coding-agent/src/utils/clipboard.ts +62 -0
  821. package/packages/pi-coding-agent/src/utils/frontmatter.ts +39 -0
  822. package/packages/pi-coding-agent/src/utils/git.ts +192 -0
  823. package/packages/pi-coding-agent/src/utils/image-convert.ts +38 -0
  824. package/packages/pi-coding-agent/src/utils/image-resize.ts +231 -0
  825. package/packages/pi-coding-agent/src/utils/mime.ts +30 -0
  826. package/packages/pi-coding-agent/src/utils/photon.ts +139 -0
  827. package/packages/pi-coding-agent/src/utils/shell.ts +202 -0
  828. package/packages/pi-coding-agent/src/utils/sleep.ts +18 -0
  829. package/packages/pi-coding-agent/src/utils/tools-manager.ts +286 -0
  830. package/packages/pi-coding-agent/tsconfig.json +27 -0
  831. package/packages/pi-tui/dist/autocomplete.d.ts +50 -0
  832. package/packages/pi-tui/dist/autocomplete.d.ts.map +1 -0
  833. package/packages/pi-tui/dist/autocomplete.js +593 -0
  834. package/packages/pi-tui/dist/autocomplete.js.map +1 -0
  835. package/packages/pi-tui/dist/components/box.d.ts +22 -0
  836. package/packages/pi-tui/dist/components/box.d.ts.map +1 -0
  837. package/packages/pi-tui/dist/components/box.js +99 -0
  838. package/packages/pi-tui/dist/components/box.js.map +1 -0
  839. package/packages/pi-tui/dist/components/cancellable-loader.d.ts +22 -0
  840. package/packages/pi-tui/dist/components/cancellable-loader.d.ts.map +1 -0
  841. package/packages/pi-tui/dist/components/cancellable-loader.js +36 -0
  842. package/packages/pi-tui/dist/components/cancellable-loader.js.map +1 -0
  843. package/packages/pi-tui/dist/components/editor.d.ts +219 -0
  844. package/packages/pi-tui/dist/components/editor.d.ts.map +1 -0
  845. package/packages/pi-tui/dist/components/editor.js +1693 -0
  846. package/packages/pi-tui/dist/components/editor.js.map +1 -0
  847. package/packages/pi-tui/dist/components/image.d.ts +28 -0
  848. package/packages/pi-tui/dist/components/image.d.ts.map +1 -0
  849. package/packages/pi-tui/dist/components/image.js +61 -0
  850. package/packages/pi-tui/dist/components/image.js.map +1 -0
  851. package/packages/pi-tui/dist/components/input.d.ts +37 -0
  852. package/packages/pi-tui/dist/components/input.d.ts.map +1 -0
  853. package/packages/pi-tui/dist/components/input.js +443 -0
  854. package/packages/pi-tui/dist/components/input.js.map +1 -0
  855. package/packages/pi-tui/dist/components/loader.d.ts +21 -0
  856. package/packages/pi-tui/dist/components/loader.d.ts.map +1 -0
  857. package/packages/pi-tui/dist/components/loader.js +46 -0
  858. package/packages/pi-tui/dist/components/loader.js.map +1 -0
  859. package/packages/pi-tui/dist/components/markdown.d.ts +95 -0
  860. package/packages/pi-tui/dist/components/markdown.d.ts.map +1 -0
  861. package/packages/pi-tui/dist/components/markdown.js +641 -0
  862. package/packages/pi-tui/dist/components/markdown.js.map +1 -0
  863. package/packages/pi-tui/dist/components/select-list.d.ts +32 -0
  864. package/packages/pi-tui/dist/components/select-list.d.ts.map +1 -0
  865. package/packages/pi-tui/dist/components/select-list.js +148 -0
  866. package/packages/pi-tui/dist/components/select-list.js.map +1 -0
  867. package/packages/pi-tui/dist/components/settings-list.d.ts +50 -0
  868. package/packages/pi-tui/dist/components/settings-list.d.ts.map +1 -0
  869. package/packages/pi-tui/dist/components/settings-list.js +177 -0
  870. package/packages/pi-tui/dist/components/settings-list.js.map +1 -0
  871. package/packages/pi-tui/dist/components/spacer.d.ts +12 -0
  872. package/packages/pi-tui/dist/components/spacer.d.ts.map +1 -0
  873. package/packages/pi-tui/dist/components/spacer.js +22 -0
  874. package/packages/pi-tui/dist/components/spacer.js.map +1 -0
  875. package/packages/pi-tui/dist/components/text.d.ts +19 -0
  876. package/packages/pi-tui/dist/components/text.d.ts.map +1 -0
  877. package/packages/pi-tui/dist/components/text.js +81 -0
  878. package/packages/pi-tui/dist/components/text.js.map +1 -0
  879. package/packages/pi-tui/dist/components/truncated-text.d.ts +13 -0
  880. package/packages/pi-tui/dist/components/truncated-text.d.ts.map +1 -0
  881. package/packages/pi-tui/dist/components/truncated-text.js +48 -0
  882. package/packages/pi-tui/dist/components/truncated-text.js.map +1 -0
  883. package/packages/pi-tui/dist/editor-component.d.ts +39 -0
  884. package/packages/pi-tui/dist/editor-component.d.ts.map +1 -0
  885. package/packages/pi-tui/dist/editor-component.js +2 -0
  886. package/packages/pi-tui/dist/editor-component.js.map +1 -0
  887. package/packages/pi-tui/dist/fuzzy.d.ts +16 -0
  888. package/packages/pi-tui/dist/fuzzy.d.ts.map +1 -0
  889. package/packages/pi-tui/dist/fuzzy.js +107 -0
  890. package/packages/pi-tui/dist/fuzzy.js.map +1 -0
  891. package/packages/pi-tui/dist/index.d.ts +23 -0
  892. package/packages/pi-tui/dist/index.d.ts.map +1 -0
  893. package/packages/pi-tui/dist/index.js +32 -0
  894. package/packages/pi-tui/dist/index.js.map +1 -0
  895. package/packages/pi-tui/dist/keybindings.d.ts +39 -0
  896. package/packages/pi-tui/dist/keybindings.d.ts.map +1 -0
  897. package/packages/pi-tui/dist/keybindings.js +116 -0
  898. package/packages/pi-tui/dist/keybindings.js.map +1 -0
  899. package/packages/pi-tui/dist/keys.d.ts +170 -0
  900. package/packages/pi-tui/dist/keys.d.ts.map +1 -0
  901. package/packages/pi-tui/dist/keys.js +1046 -0
  902. package/packages/pi-tui/dist/keys.js.map +1 -0
  903. package/packages/pi-tui/dist/kill-ring.d.ts +28 -0
  904. package/packages/pi-tui/dist/kill-ring.d.ts.map +1 -0
  905. package/packages/pi-tui/dist/kill-ring.js +46 -0
  906. package/packages/pi-tui/dist/kill-ring.js.map +1 -0
  907. package/packages/pi-tui/dist/stdin-buffer.d.ts +48 -0
  908. package/packages/pi-tui/dist/stdin-buffer.d.ts.map +1 -0
  909. package/packages/pi-tui/dist/stdin-buffer.js +316 -0
  910. package/packages/pi-tui/dist/stdin-buffer.js.map +1 -0
  911. package/packages/pi-tui/dist/terminal-image.d.ts +68 -0
  912. package/packages/pi-tui/dist/terminal-image.d.ts.map +1 -0
  913. package/packages/pi-tui/dist/terminal-image.js +288 -0
  914. package/packages/pi-tui/dist/terminal-image.js.map +1 -0
  915. package/packages/pi-tui/dist/terminal.d.ts +85 -0
  916. package/packages/pi-tui/dist/terminal.d.ts.map +1 -0
  917. package/packages/pi-tui/dist/terminal.js +271 -0
  918. package/packages/pi-tui/dist/terminal.js.map +1 -0
  919. package/packages/pi-tui/dist/tui.d.ts +220 -0
  920. package/packages/pi-tui/dist/tui.d.ts.map +1 -0
  921. package/packages/pi-tui/dist/tui.js +976 -0
  922. package/packages/pi-tui/dist/tui.js.map +1 -0
  923. package/packages/pi-tui/dist/undo-stack.d.ts +17 -0
  924. package/packages/pi-tui/dist/undo-stack.d.ts.map +1 -0
  925. package/packages/pi-tui/dist/undo-stack.js +27 -0
  926. package/packages/pi-tui/dist/undo-stack.js.map +1 -0
  927. package/packages/pi-tui/dist/utils.d.ts +78 -0
  928. package/packages/pi-tui/dist/utils.d.ts.map +1 -0
  929. package/packages/pi-tui/dist/utils.js +817 -0
  930. package/packages/pi-tui/dist/utils.js.map +1 -0
  931. package/packages/pi-tui/package.json +21 -0
  932. package/packages/pi-tui/src/autocomplete.ts +736 -0
  933. package/packages/pi-tui/src/components/box.ts +137 -0
  934. package/packages/pi-tui/src/components/cancellable-loader.ts +40 -0
  935. package/packages/pi-tui/src/components/editor.ts +2035 -0
  936. package/packages/pi-tui/src/components/image.ts +104 -0
  937. package/packages/pi-tui/src/components/input.ts +521 -0
  938. package/packages/pi-tui/src/components/loader.ts +55 -0
  939. package/packages/pi-tui/src/components/markdown.ts +806 -0
  940. package/packages/pi-tui/src/components/select-list.ts +188 -0
  941. package/packages/pi-tui/src/components/settings-list.ts +250 -0
  942. package/packages/pi-tui/src/components/spacer.ts +28 -0
  943. package/packages/pi-tui/src/components/text.ts +106 -0
  944. package/packages/pi-tui/src/components/truncated-text.ts +65 -0
  945. package/packages/pi-tui/src/editor-component.ts +74 -0
  946. package/packages/pi-tui/src/fuzzy.ts +133 -0
  947. package/packages/pi-tui/src/index.ts +93 -0
  948. package/packages/pi-tui/src/keybindings.ts +189 -0
  949. package/packages/pi-tui/src/keys.ts +1255 -0
  950. package/packages/pi-tui/src/kill-ring.ts +46 -0
  951. package/packages/pi-tui/src/stdin-buffer.ts +386 -0
  952. package/packages/pi-tui/src/terminal-image.ts +381 -0
  953. package/packages/pi-tui/src/terminal.ts +349 -0
  954. package/packages/pi-tui/src/tui.ts +1212 -0
  955. package/packages/pi-tui/src/undo-stack.ts +28 -0
  956. package/packages/pi-tui/src/utils.ts +905 -0
  957. package/packages/pi-tui/tsconfig.json +27 -0
  958. package/pkg/dist/modes/interactive/theme/dark.json +6 -6
  959. package/pkg/dist/modes/interactive/theme/light.json +6 -5
  960. package/pkg/dist/modes/interactive/theme/theme.d.ts +2 -2
  961. package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  962. package/pkg/dist/modes/interactive/theme/theme.js +1 -6
  963. package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
  964. package/scripts/postinstall.js +2 -17
  965. package/src/resources/extensions/ask-user-questions.ts +2 -2
  966. package/src/resources/extensions/bg-shell/index.ts +4 -4
  967. package/src/resources/extensions/browser-tools/index.ts +3 -3
  968. package/src/resources/extensions/context7/index.ts +3 -3
  969. package/src/resources/extensions/get-secrets-from-user.ts +331 -59
  970. package/src/resources/extensions/google-search/index.ts +20 -7
  971. package/src/resources/extensions/gsd/activity-log.ts +1 -1
  972. package/src/resources/extensions/gsd/auto.ts +106 -21
  973. package/src/resources/extensions/gsd/commands.ts +2 -2
  974. package/src/resources/extensions/gsd/dashboard-overlay.ts +2 -2
  975. package/src/resources/extensions/gsd/docs/preferences-reference.md +45 -1
  976. package/src/resources/extensions/gsd/doctor.ts +23 -4
  977. package/src/resources/extensions/gsd/files.ts +115 -1
  978. package/src/resources/extensions/gsd/git-service.ts +64 -111
  979. package/src/resources/extensions/gsd/guided-flow.ts +3 -2
  980. package/src/resources/extensions/gsd/index.ts +18 -7
  981. package/src/resources/extensions/gsd/metrics.ts +1 -1
  982. package/src/resources/extensions/gsd/migrate/command.ts +1 -1
  983. package/src/resources/extensions/gsd/preferences.ts +72 -10
  984. package/src/resources/extensions/gsd/prompts/guided-plan-milestone.md +4 -0
  985. package/src/resources/extensions/gsd/prompts/plan-milestone.md +17 -0
  986. package/src/resources/extensions/gsd/session-forensics.ts +19 -6
  987. package/src/resources/extensions/gsd/skill-discovery.ts +1 -1
  988. package/src/resources/extensions/gsd/templates/secrets-manifest.md +22 -0
  989. package/src/resources/extensions/gsd/tests/auto-secrets-gate.test.ts +196 -0
  990. package/src/resources/extensions/gsd/tests/collect-from-manifest.test.ts +469 -0
  991. package/src/resources/extensions/gsd/tests/doctor-fixlevel.test.ts +170 -0
  992. package/src/resources/extensions/gsd/tests/git-service.test.ts +43 -0
  993. package/src/resources/extensions/gsd/tests/manifest-status.test.ts +283 -0
  994. package/src/resources/extensions/gsd/tests/parsers.test.ts +401 -65
  995. package/src/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +2 -1
  996. package/src/resources/extensions/gsd/tests/secure-env-collect.test.ts +185 -0
  997. package/src/resources/extensions/gsd/types.ts +27 -0
  998. package/src/resources/extensions/gsd/worktree-command.ts +2 -2
  999. package/src/resources/extensions/mac-tools/index.ts +2 -2
  1000. package/src/resources/extensions/mcporter/index.ts +3 -3
  1001. package/src/resources/extensions/remote-questions/remote-command.ts +3 -3
  1002. package/src/resources/extensions/search-the-web/command-search-provider.ts +2 -2
  1003. package/src/resources/extensions/search-the-web/index.ts +1 -1
  1004. package/src/resources/extensions/search-the-web/provider.ts +1 -1
  1005. package/src/resources/extensions/search-the-web/tool-fetch-page.ts +3 -3
  1006. package/src/resources/extensions/search-the-web/tool-llm-context.ts +4 -4
  1007. package/src/resources/extensions/search-the-web/tool-search.ts +4 -4
  1008. package/src/resources/extensions/shared/confirm-ui.ts +3 -3
  1009. package/src/resources/extensions/shared/interview-ui.ts +3 -3
  1010. package/src/resources/extensions/shared/next-action-ui.ts +3 -3
  1011. package/src/resources/extensions/shared/progress-widget.ts +2 -2
  1012. package/src/resources/extensions/shared/thinking-widget.ts +3 -3
  1013. package/src/resources/extensions/shared/ui.ts +4 -4
  1014. package/src/resources/extensions/shared/wizard-ui.ts +4 -4
  1015. package/src/resources/extensions/slash-commands/audit.ts +1 -1
  1016. package/src/resources/extensions/slash-commands/clear.ts +1 -1
  1017. package/src/resources/extensions/slash-commands/create-extension.ts +2 -2
  1018. package/src/resources/extensions/slash-commands/create-slash-command.ts +2 -2
  1019. package/src/resources/extensions/slash-commands/index.ts +1 -1
  1020. package/src/resources/extensions/subagent/agents.ts +1 -1
  1021. package/src/resources/extensions/subagent/index.ts +5 -5
  1022. package/src/resources/extensions/voice/index.ts +3 -3
  1023. package/patches/@mariozechner+pi-coding-agent+0.57.1.patch +0 -78
  1024. package/patches/@mariozechner+pi-tui+0.57.1.patch +0 -47
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,gFAAgF;AAChF,8BAA8B;AAC9B,gFAAgF;AAEhF,IAAI,oBAAoB,GAAG,KAAK,CAAC;AAEjC;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAe;IACrD,oBAAoB,GAAG,MAAM,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACpC,OAAO,oBAAoB,CAAC;AAC7B,CAAC;AA6HD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;IAClB,eAAe;IACf,MAAM,EAAE,QAAiB;IACzB,GAAG,EAAE,KAAc;IACnB,KAAK,EAAE,OAAgB;IACvB,MAAM,EAAE,QAAiB;IACzB,GAAG,EAAE,KAAc;IACnB,KAAK,EAAE,OAAgB;IACvB,SAAS,EAAE,WAAoB;IAC/B,MAAM,EAAE,QAAiB;IACzB,MAAM,EAAE,QAAiB;IACzB,KAAK,EAAE,OAAgB;IACvB,IAAI,EAAE,MAAe;IACrB,G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AC;QAAE,OAAO,SAAS,CAAC;IAC5E,IAAI,QAAQ,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IAElE,iDAAiD;IACjD,IAAI,kBAAkB,GAAG,SAAS,CAAC;IACnC,IAAI,QAAQ,GAAG,SAAS,CAAC,KAAK,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QAClE,kBAAkB,GAAG,UAAU,CAAC;IACjC,CAAC;IACD,iDAAiD;IACjD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,kBAAkB,GAAG,EAAE;QAAE,OAAO,SAAS,CAAC;IAEtF,IAAI,CAAC;QACJ,OAAO,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["/**\n * Keyboard input handling for terminal applications.\n *\n * Supports both legacy terminal sequences and Kitty keyboard protocol.\n * See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/\n * Reference: https://github.com/sst/opentui/blob/7da92b4088aebfe27b9f691c04163a48821e49fd/packages/core/src/lib/parse.keypress.ts\n *\n * Symbol keys are also supported, however some ctrl+symbol combos\n * overlap with ASCII codes, e.g. ctrl+[ = ESC.\n * See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/#legacy-ctrl-mapping-of-ascii-keys\n * Those can still be * used for ctrl+shift combos\n *\n * API:\n * - matchesKey(data, keyId) - Check if input matches a key identifier\n * - parseKey(data) - Parse input and return the key identifier\n * - Key - Helper object for creating typed key identifiers\n * - setKittyProtocolActive(active) - Set global Kitty protocol state\n * - isKittyProtocolActive() - Query global Kitty protocol state\n */\n\n// =============================================================================\n// Global Kitty Protocol State\n// =============================================================================\n\nlet _kittyProtocolActive = false;\n\n/**\n * Set the global Kitty keyboard protocol state.\n * Called by ProcessTerminal after detecting protocol support.\n */\nexport function setKittyProtocolActive(active: boolean): void {\n\t_kittyProtocolActive = active;\n}\n\n/**\n * Query whether Kitty keyboard protocol is currently active.\n */\nexport function isKittyProtocolActive(): boolean {\n\treturn _kittyProtocolActive;\n}\n\n// =============================================================================\n// Type-Safe Key Identifiers\n// =============================================================================\n\ntype Letter =\n\t| \"a\"\n\t| \"b\"\n\t| \"c\"\n\t| \"d\"\n\t| \"e\"\n\t| \"f\"\n\t| \"g\"\n\t| \"h\"\n\t| \"i\"\n\t| \"j\"\n\t| \"k\"\n\t| \"l\"\n\t| \"m\"\n\t| \"n\"\n\t| \"o\"\n\t| \"p\"\n\t| \"q\"\n\t| \"r\"\n\t| \"s\"\n\t| \"t\"\n\t| \"u\"\n\t| \"v\"\n\t| \"w\"\n\t| \"x\"\n\t| \"y\"\n\t| \"z\";\n\ntype Digit = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\";\n\ntype SymbolKey =\n\t| \"`\"\n\t| \"-\"\n\t| \"=\"\n\t| \"[\"\n\t| \"]\"\n\t| \"\\\\\"\n\t| \";\"\n\t| \"'\"\n\t| \",\"\n\t| \".\"\n\t| \"/\"\n\t| \"!\"\n\t| \"@\"\n\t| \"#\"\n\t| \"$\"\n\t| \"%\"\n\t| \"^\"\n\t| \"&\"\n\t| \"*\"\n\t| \"(\"\n\t| \")\"\n\t| \"_\"\n\t| \"+\"\n\t| \"|\"\n\t| \"~\"\n\t| \"{\"\n\t| \"}\"\n\t| \":\"\n\t| \"<\"\n\t| \">\"\n\t| \"?\";\n\ntype SpecialKey =\n\t| \"escape\"\n\t| \"esc\"\n\t| \"enter\"\n\t| \"return\"\n\t| \"tab\"\n\t| \"space\"\n\t| \"backspace\"\n\t| \"delete\"\n\t| \"insert\"\n\t| \"clear\"\n\t| \"home\"\n\t| \"end\"\n\t| \"pageUp\"\n\t| \"pageDown\"\n\t| \"up\"\n\t| \"down\"\n\t| \"left\"\n\t| \"right\"\n\t| \"f1\"\n\t| \"f2\"\n\t| \"f3\"\n\t| \"f4\"\n\t| \"f5\"\n\t| \"f6\"\n\t| \"f7\"\n\t| \"f8\"\n\t| \"f9\"\n\t| \"f10\"\n\t| \"f11\"\n\t| \"f12\";\n\ntype BaseKey = Letter | Digit | SymbolKey | SpecialKey;\n\n/**\n * Union type of all valid key identifiers.\n * Provides autocomplete and catches typos at compile time.\n */\nexport type KeyId =\n\t| BaseKey\n\t| `ctrl+${BaseKey}`\n\t| `shift+${BaseKey}`\n\t| `alt+${BaseKey}`\n\t| `ctrl+shift+${BaseKey}`\n\t| `shift+ctrl+${BaseKey}`\n\t| `ctrl+alt+${BaseKey}`\n\t| `alt+ctrl+${BaseKey}`\n\t| `shift+alt+${BaseKey}`\n\t| `alt+shift+${BaseKey}`\n\t| `ctrl+shift+alt+${BaseKey}`\n\t| `ctrl+alt+shift+${BaseKey}`\n\t| `shift+ctrl+alt+${BaseKey}`\n\t| `shift+alt+ctrl+${BaseKey}`\n\t| `alt+ctrl+shift+${BaseKey}`\n\t| `alt+shift+ctrl+${BaseKey}`;\n\n/**\n * Helper object for creating typed key identifiers with autocomplete.\n *\n * Usage:\n * - Key.escape, Key.enter, Key.tab, etc. for special keys\n * - Key.backtick, Key.comma, Key.period, etc. for symbol keys\n * - Key.ctrl(\"c\"), Key.alt(\"x\") for single modifier\n * - Key.ctrlShift(\"p\"), Key.ctrlAlt(\"x\") for combined modifiers\n */\nexport const Key = {\n\t// Special keys\n\tescape: \"escape\" as const,\n\tesc: \"esc\" as const,\n\tenter: \"enter\" as const,\n\treturn: \"return\" as const,\n\ttab: \"tab\" as const,\n\tspace: \"space\" as const,\n\tbackspace: \"backspace\" as const,\n\tdelete: \"delete\" as const,\n\tinsert: \"insert\" as const,\n\tclear: \"clear\" as const,\n\thome: \"home\" as const,\n\tend: \"end\" as const,\n\tpageUp: \"pageUp\" as const,\n\tpageDown: \"pageDown\" as const,\n\tup: \"up\" as const,\n\tdown: \"down\" as const,\n\tleft: \"left\" as const,\n\tright: \"right\" as const,\n\tf1: \"f1\" as const,\n\tf2: \"f2\" as const,\n\tf3: \"f3\" as const,\n\tf4: \"f4\" as const,\n\tf5: \"f5\" as const,\n\tf6: \"f6\" as const,\n\tf7: \"f7\" as const,\n\tf8: \"f8\" as const,\n\tf9: \"f9\" as const,\n\tf10: \"f10\" as const,\n\tf11: \"f11\" as const,\n\tf12: \"f12\" as const,\n\n\t// Symbol keys\n\tbacktick: \"`\" as const,\n\thyphen: \"-\" as const,\n\tequals: \"=\" as const,\n\tleftbracket: \"[\" as const,\n\trightbracket: \"]\" as const,\n\tbackslash: \"\\\\\" as const,\n\tsemicolon: \";\" as const,\n\tquote: \"'\" as const,\n\tcomma: \",\" as const,\n\tperiod: \".\" as const,\n\tslash: \"/\" as const,\n\texclamation: \"!\" as const,\n\tat: \"@\" as const,\n\thash: \"#\" as const,\n\tdollar: \"$\" as const,\n\tpercent: \"%\" as const,\n\tcaret: \"^\" as const,\n\tampersand: \"&\" as const,\n\tasterisk: \"*\" as const,\n\tleftparen: \"(\" as const,\n\trightparen: \")\" as const,\n\tunderscore: \"_\" as const,\n\tplus: \"+\" as const,\n\tpipe: \"|\" as const,\n\ttilde: \"~\" as const,\n\tleftbrace: \"{\" as const,\n\trightbrace: \"}\" as const,\n\tcolon: \":\" as const,\n\tlessthan: \"<\" as const,\n\tgreaterthan: \">\" as const,\n\tquestion: \"?\" as const,\n\n\t// Single modifiers\n\tctrl: <K extends BaseKey>(key: K): `ctrl+${K}` => `ctrl+${key}`,\n\tshift: <K extends BaseKey>(key: K): `shift+${K}` => `shift+${key}`,\n\talt: <K extends BaseKey>(key: K): `alt+${K}` => `alt+${key}`,\n\n\t// Combined modifiers\n\tctrlShift: <K extends BaseKey>(key: K): `ctrl+shift+${K}` => `ctrl+shift+${key}`,\n\tshiftCtrl: <K extends BaseKey>(key: K): `shift+ctrl+${K}` => `shift+ctrl+${key}`,\n\tctrlAlt: <K extends BaseKey>(key: K): `ctrl+alt+${K}` => `ctrl+alt+${key}`,\n\taltCtrl: <K extends BaseKey>(key: K): `alt+ctrl+${K}` => `alt+ctrl+${key}`,\n\tshiftAlt: <K extends BaseKey>(key: K): `shift+alt+${K}` => `shift+alt+${key}`,\n\taltShift: <K extends BaseKey>(key: K): `alt+shift+${K}` => `alt+shift+${key}`,\n\n\t// Triple modifiers\n\tctrlShiftAlt: <K extends BaseKey>(key: K): `ctrl+shift+alt+${K}` => `ctrl+shift+alt+${key}`,\n} as const;\n\n// =============================================================================\n// Constants\n// =============================================================================\n\nconst SYMBOL_KEYS = new Set([\n\t\"`\",\n\t\"-\",\n\t\"=\",\n\t\"[\",\n\t\"]\",\n\t\"\\\\\",\n\t\";\",\n\t\"'\",\n\t\",\",\n\t\".\",\n\t\"/\",\n\t\"!\",\n\t\"@\",\n\t\"#\",\n\t\"$\",\n\t\"%\",\n\t\"^\",\n\t\"&\",\n\t\"*\",\n\t\"(\",\n\t\")\",\n\t\"_\",\n\t\"+\",\n\t\"|\",\n\t\"~\",\n\t\"{\",\n\t\"}\",\n\t\":\",\n\t\"<\",\n\t\">\",\n\t\"?\",\n]);\n\nconst MODIFIERS = {\n\tshift: 1,\n\talt: 2,\n\tctrl: 4,\n} as const;\n\nconst LOCK_MASK = 64 + 128; // Caps Lock + Num Lock\n\nconst CODEPOINTS = {\n\tescape: 27,\n\ttab: 9,\n\tenter: 13,\n\tspace: 32,\n\tbackspace: 127,\n\tkpEnter: 57414, // Numpad Enter (Kitty protocol)\n} as const;\n\nconst ARROW_CODEPOINTS = {\n\tup: -1,\n\tdown: -2,\n\tright: -3,\n\tleft: -4,\n} as const;\n\nconst FUNCTIONAL_CODEPOINTS = {\n\tdelete: -10,\n\tinsert: -11,\n\tpageUp: -12,\n\tpageDown: -13,\n\thome: -14,\n\tend: -15,\n} as const;\n\nconst LEGACY_KEY_SEQUENCES = {\n\tup: [\"\\x1b[A\", \"\\x1bOA\"],\n\tdown: [\"\\x1b[B\", \"\\x1bOB\"],\n\tright: [\"\\x1b[C\", \"\\x1bOC\"],\n\tleft: [\"\\x1b[D\", \"\\x1bOD\"],\n\thome: [\"\\x1b[H\", \"\\x1bOH\", \"\\x1b[1~\", \"\\x1b[7~\"],\n\tend: [\"\\x1b[F\", \"\\x1bOF\", \"\\x1b[4~\", \"\\x1b[8~\"],\n\tinsert: [\"\\x1b[2~\"],\n\tdelete: [\"\\x1b[3~\"],\n\tpageUp: [\"\\x1b[5~\", \"\\x1b[[5~\"],\n\tpageDown: [\"\\x1b[6~\", \"\\x1b[[6~\"],\n\tclear: [\"\\x1b[E\", \"\\x1bOE\"],\n\tf1: [\"\\x1bOP\", \"\\x1b[11~\", \"\\x1b[[A\"],\n\tf2: [\"\\x1bOQ\", \"\\x1b[12~\", \"\\x1b[[B\"],\n\tf3: [\"\\x1bOR\", \"\\x1b[13~\", \"\\x1b[[C\"],\n\tf4: [\"\\x1bOS\", \"\\x1b[14~\", \"\\x1b[[D\"],\n\tf5: [\"\\x1b[15~\", \"\\x1b[[E\"],\n\tf6: [\"\\x1b[17~\"],\n\tf7: [\"\\x1b[18~\"],\n\tf8: [\"\\x1b[19~\"],\n\tf9: [\"\\x1b[20~\"],\n\tf10: [\"\\x1b[21~\"],\n\tf11: [\"\\x1b[23~\"],\n\tf12: [\"\\x1b[24~\"],\n} as const;\n\nconst LEGACY_SHIFT_SEQUENCES = {\n\tup: [\"\\x1b[a\"],\n\tdown: [\"\\x1b[b\"],\n\tright: [\"\\x1b[c\"],\n\tleft: [\"\\x1b[d\"],\n\tclear: [\"\\x1b[e\"],\n\tinsert: [\"\\x1b[2$\"],\n\tdelete: [\"\\x1b[3$\"],\n\tpageUp: [\"\\x1b[5$\"],\n\tpageDown: [\"\\x1b[6$\"],\n\thome: [\"\\x1b[7$\"],\n\tend: [\"\\x1b[8$\"],\n} as const;\n\nconst LEGACY_CTRL_SEQUENCES = {\n\tup: [\"\\x1bOa\"],\n\tdown: [\"\\x1bOb\"],\n\tright: [\"\\x1bOc\"],\n\tleft: [\"\\x1bOd\"],\n\tclear: [\"\\x1bOe\"],\n\tinsert: [\"\\x1b[2^\"],\n\tdelete: [\"\\x1b[3^\"],\n\tpageUp: [\"\\x1b[5^\"],\n\tpageDown: [\"\\x1b[6^\"],\n\thome: [\"\\x1b[7^\"],\n\tend: [\"\\x1b[8^\"],\n} as const;\n\nconst LEGACY_SEQUENCE_KEY_IDS: Record<string, KeyId> = {\n\t\"\\x1bOA\": \"up\",\n\t\"\\x1bOB\": \"down\",\n\t\"\\x1bOC\": \"right\",\n\t\"\\x1bOD\": \"left\",\n\t\"\\x1bOH\": \"home\",\n\t\"\\x1bOF\": \"end\",\n\t\"\\x1b[E\": \"clear\",\n\t\"\\x1bOE\": \"clear\",\n\t\"\\x1bOe\": \"ctrl+clear\",\n\t\"\\x1b[e\": \"shift+clear\",\n\t\"\\x1b[2~\": \"insert\",\n\t\"\\x1b[2$\": \"shift+insert\",\n\t\"\\x1b[2^\": \"ctrl+insert\",\n\t\"\\x1b[3$\": \"shift+delete\",\n\t\"\\x1b[3^\": \"ctrl+delete\",\n\t\"\\x1b[[5~\": \"pageUp\",\n\t\"\\x1b[[6~\": \"pageDown\",\n\t\"\\x1b[a\": \"shift+up\",\n\t\"\\x1b[b\": \"shift+down\",\n\t\"\\x1b[c\": \"shift+right\",\n\t\"\\x1b[d\": \"shift+left\",\n\t\"\\x1bOa\": \"ctrl+up\",\n\t\"\\x1bOb\": \"ctrl+down\",\n\t\"\\x1bOc\": \"ctrl+right\",\n\t\"\\x1bOd\": \"ctrl+left\",\n\t\"\\x1b[5$\": \"shift+pageUp\",\n\t\"\\x1b[6$\": \"shift+pageDown\",\n\t\"\\x1b[7$\": \"shift+home\",\n\t\"\\x1b[8$\": \"shift+end\",\n\t\"\\x1b[5^\": \"ctrl+pageUp\",\n\t\"\\x1b[6^\": \"ctrl+pageDown\",\n\t\"\\x1b[7^\": \"ctrl+home\",\n\t\"\\x1b[8^\": \"ctrl+end\",\n\t\"\\x1bOP\": \"f1\",\n\t\"\\x1bOQ\": \"f2\",\n\t\"\\x1bOR\": \"f3\",\n\t\"\\x1bOS\": \"f4\",\n\t\"\\x1b[11~\": \"f1\",\n\t\"\\x1b[12~\": \"f2\",\n\t\"\\x1b[13~\": \"f3\",\n\t\"\\x1b[14~\": \"f4\",\n\t\"\\x1b[[A\": \"f1\",\n\t\"\\x1b[[B\": \"f2\",\n\t\"\\x1b[[C\": \"f3\",\n\t\"\\x1b[[D\": \"f4\",\n\t\"\\x1b[[E\": \"f5\",\n\t\"\\x1b[15~\": \"f5\",\n\t\"\\x1b[17~\": \"f6\",\n\t\"\\x1b[18~\": \"f7\",\n\t\"\\x1b[19~\": \"f8\",\n\t\"\\x1b[20~\": \"f9\",\n\t\"\\x1b[21~\": \"f10\",\n\t\"\\x1b[23~\": \"f11\",\n\t\"\\x1b[24~\": \"f12\",\n\t\"\\x1bb\": \"alt+left\",\n\t\"\\x1bf\": \"alt+right\",\n\t\"\\x1bp\": \"alt+up\",\n\t\"\\x1bn\": \"alt+down\",\n} as const;\n\ntype LegacyModifierKey = keyof typeof LEGACY_SHIFT_SEQUENCES;\n\nconst matchesLegacySequence = (data: string, sequences: readonly string[]): boolean => sequences.includes(data);\n\nconst matchesLegacyModifierSequence = (data: string, key: LegacyModifierKey, modifier: number): boolean => {\n\tif (modifier === MODIFIERS.shift) {\n\t\treturn matchesLegacySequence(data, LEGACY_SHIFT_SEQUENCES[key]);\n\t}\n\tif (modifier === MODIFIERS.ctrl) {\n\t\treturn matchesLegacySequence(data, LEGACY_CTRL_SEQUENCES[key]);\n\t}\n\treturn false;\n};\n\n// =============================================================================\n// Kitty Protocol Parsing\n// =============================================================================\n\n/**\n * Event types from Kitty keyboard protocol (flag 2)\n * 1 = key press, 2 = key repeat, 3 = key release\n */\nexport type KeyEventType = \"press\" | \"repeat\" | \"release\";\n\ninterface ParsedKittySequence {\n\tcodepoint: number;\n\tshiftedKey?: number; // Shifted version of the key (when shift is pressed)\n\tbaseLayoutKey?: number; // Key in standard PC-101 layout (for non-Latin layouts)\n\tmodifier: number;\n\teventType: KeyEventType;\n}\n\ninterface ParsedModifyOtherKeysSequence {\n\tcodepoint: number;\n\tmodifier: number;\n}\n\n// Store the last parsed event type for isKeyRelease() to query\nlet _lastEventType: KeyEventType = \"press\";\n\n/**\n * Check if the last parsed key event was a key release.\n * Only meaningful when Kitty keyboard protocol with flag 2 is active.\n */\nexport function isKeyRelease(data: string): boolean {\n\t// Don't treat bracketed paste content as key release, even if it contains\n\t// patterns like \":3F\" (e.g., bluetooth MAC addresses like \"90:62:3F:A5\").\n\t// Terminal.ts re-wraps paste content with bracketed paste markers before\n\t// passing to TUI, so pasted data will always contain \\x1b[200~.\n\tif (data.includes(\"\\x1b[200~\")) {\n\t\treturn false;\n\t}\n\n\t// Quick check: release events with flag 2 contain \":3\"\n\t// Format: \\x1b[<codepoint>;<modifier>:3u\n\tif (\n\t\tdata.includes(\":3u\") ||\n\t\tdata.includes(\":3~\") ||\n\t\tdata.includes(\":3A\") ||\n\t\tdata.includes(\":3B\") ||\n\t\tdata.includes(\":3C\") ||\n\t\tdata.includes(\":3D\") ||\n\t\tdata.includes(\":3H\") ||\n\t\tdata.includes(\":3F\")\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n/**\n * Check if the last parsed key event was a key repeat.\n * Only meaningful when Kitty keyboard protocol with flag 2 is active.\n */\nexport function isKeyRepeat(data: string): boolean {\n\t// Don't treat bracketed paste content as key repeat, even if it contains\n\t// patterns like \":2F\". See isKeyRelease() for details.\n\tif (data.includes(\"\\x1b[200~\")) {\n\t\treturn false;\n\t}\n\n\tif (\n\t\tdata.includes(\":2u\") ||\n\t\tdata.includes(\":2~\") ||\n\t\tdata.includes(\":2A\") ||\n\t\tdata.includes(\":2B\") ||\n\t\tdata.includes(\":2C\") ||\n\t\tdata.includes(\":2D\") ||\n\t\tdata.includes(\":2H\") ||\n\t\tdata.includes(\":2F\")\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction parseEventType(eventTypeStr: string | undefined): KeyEventType {\n\tif (!eventTypeStr) return \"press\";\n\tconst eventType = parseInt(eventTypeStr, 10);\n\tif (eventType === 2) return \"repeat\";\n\tif (eventType === 3) return \"release\";\n\treturn \"press\";\n}\n\nfunction parseKittySequence(data: string): ParsedKittySequence | null {\n\t// CSI u format with alternate keys (flag 4):\n\t// \\x1b[<codepoint>u\n\t// \\x1b[<codepoint>;<mod>u\n\t// \\x1b[<codepoint>;<mod>:<event>u\n\t// \\x1b[<codepoint>:<shifted>;<mod>u\n\t// \\x1b[<codepoint>:<shifted>:<base>;<mod>u\n\t// \\x1b[<codepoint>::<base>;<mod>u (no shifted key, only base)\n\t//\n\t// With flag 2, event type is appended after modifier colon: 1=press, 2=repeat, 3=release\n\t// With flag 4, alternate keys are appended after codepoint with colons\n\tconst csiUMatch = data.match(/^\\x1b\\[(\\d+)(?::(\\d*))?(?::(\\d+))?(?:;(\\d+))?(?::(\\d+))?u$/);\n\tif (csiUMatch) {\n\t\tconst codepoint = parseInt(csiUMatch[1]!, 10);\n\t\tconst shiftedKey = csiUMatch[2] && csiUMatch[2].length > 0 ? parseInt(csiUMatch[2], 10) : undefined;\n\t\tconst baseLayoutKey = csiUMatch[3] ? parseInt(csiUMatch[3], 10) : undefined;\n\t\tconst modValue = csiUMatch[4] ? parseInt(csiUMatch[4], 10) : 1;\n\t\tconst eventType = parseEventType(csiUMatch[5]);\n\t\t_lastEventType = eventType;\n\t\treturn { codepoint, shiftedKey, baseLayoutKey, modifier: modValue - 1, eventType };\n\t}\n\n\t// Arrow keys with modifier: \\x1b[1;<mod>A/B/C/D or \\x1b[1;<mod>:<event>A/B/C/D\n\tconst arrowMatch = data.match(/^\\x1b\\[1;(\\d+)(?::(\\d+))?([ABCD])$/);\n\tif (arrowMatch) {\n\t\tconst modValue = parseInt(arrowMatch[1]!, 10);\n\t\tconst eventType = parseEventType(arrowMatch[2]);\n\t\tconst arrowCodes: Record<string, number> = { A: -1, B: -2, C: -3, D: -4 };\n\t\t_lastEventType = eventType;\n\t\treturn { codepoint: arrowCodes[arrowMatch[3]!]!, modifier: modValue - 1, eventType };\n\t}\n\n\t// Functional keys: \\x1b[<num>~ or \\x1b[<num>;<mod>~ or \\x1b[<num>;<mod>:<event>~\n\tconst funcMatch = data.match(/^\\x1b\\[(\\d+)(?:;(\\d+))?(?::(\\d+))?~$/);\n\tif (funcMatch) {\n\t\tconst keyNum = parseInt(funcMatch[1]!, 10);\n\t\tconst modValue = funcMatch[2] ? parseInt(funcMatch[2], 10) : 1;\n\t\tconst eventType = parseEventType(funcMatch[3]);\n\t\tconst funcCodes: Record<number, number> = {\n\t\t\t2: FUNCTIONAL_CODEPOINTS.insert,\n\t\t\t3: FUNCTIONAL_CODEPOINTS.delete,\n\t\t\t5: FUNCTIONAL_CODEPOINTS.pageUp,\n\t\t\t6: FUNCTIONAL_CODEPOINTS.pageDown,\n\t\t\t7: FUNCTIONAL_CODEPOINTS.home,\n\t\t\t8: FUNCTIONAL_CODEPOINTS.end,\n\t\t};\n\t\tconst codepoint = funcCodes[keyNum];\n\t\tif (codepoint !== undefined) {\n\t\t\t_lastEventType = eventType;\n\t\t\treturn { codepoint, modifier: modValue - 1, eventType };\n\t\t}\n\t}\n\n\t// Home/End with modifier: \\x1b[1;<mod>H/F or \\x1b[1;<mod>:<event>H/F\n\tconst homeEndMatch = data.match(/^\\x1b\\[1;(\\d+)(?::(\\d+))?([HF])$/);\n\tif (homeEndMatch) {\n\t\tconst modValue = parseInt(homeEndMatch[1]!, 10);\n\t\tconst eventType = parseEventType(homeEndMatch[2]);\n\t\tconst codepoint = homeEndMatch[3] === \"H\" ? FUNCTIONAL_CODEPOINTS.home : FUNCTIONAL_CODEPOINTS.end;\n\t\t_lastEventType = eventType;\n\t\treturn { codepoint, modifier: modValue - 1, eventType };\n\t}\n\n\treturn null;\n}\n\nfunction matchesKittySequence(data: string, expectedCodepoint: number, expectedModifier: number): boolean {\n\tconst parsed = parseKittySequence(data);\n\tif (!parsed) return false;\n\tconst actualMod = parsed.modifier & ~LOCK_MASK;\n\tconst expectedMod = expectedModifier & ~LOCK_MASK;\n\n\t// Check if modifiers match\n\tif (actualMod !== expectedMod) return false;\n\n\t// Primary match: codepoint matches directly\n\tif (parsed.codepoint === expectedCodepoint) return true;\n\n\t// Alternate match: use base layout key for non-Latin keyboard layouts.\n\t// This allows Ctrl+С (Cyrillic) to match Ctrl+c (Latin) when terminal reports\n\t// the base layout key (the key in standard PC-101 layout).\n\t//\n\t// Only fall back to base layout key when the codepoint is NOT already a\n\t// recognized Latin letter (a-z) or symbol (e.g., /, -, [, ;, etc.).\n\t// When the codepoint is a recognized key, it is authoritative regardless\n\t// of physical key position. This prevents remapped layouts (Dvorak, Colemak,\n\t// xremap, etc.) from causing false matches: both letters and symbols move\n\t// to different physical positions, so Ctrl+K could falsely match Ctrl+V\n\t// (letter remapping) and Ctrl+/ could falsely match Ctrl+[ (symbol remapping)\n\t// if the base layout key were always considered.\n\tif (parsed.baseLayoutKey !== undefined && parsed.baseLayoutKey === expectedCodepoint) {\n\t\tconst cp = parsed.codepoint;\n\t\tconst isLatinLetter = cp >= 97 && cp <= 122; // a-z\n\t\tconst isKnownSymbol = SYMBOL_KEYS.has(String.fromCharCode(cp));\n\t\tif (!isLatinLetter && !isKnownSymbol) return true;\n\t}\n\n\treturn false;\n}\n\nfunction parseModifyOtherKeysSequence(data: string): ParsedModifyOtherKeysSequence | null {\n\tconst match = data.match(/^\\x1b\\[27;(\\d+);(\\d+)~$/);\n\tif (!match) return null;\n\tconst modValue = parseInt(match[1]!, 10);\n\tconst codepoint = parseInt(match[2]!, 10);\n\treturn { codepoint, modifier: modValue - 1 };\n}\n\n/**\n * Match xterm modifyOtherKeys format: CSI 27 ; modifiers ; keycode ~\n * This is used by terminals when Kitty protocol is not enabled.\n * Modifier values are 1-indexed: 2=shift, 3=alt, 5=ctrl, etc.\n */\nfunction matchesModifyOtherKeys(data: string, expectedKeycode: number, expectedModifier: number): boolean {\n\tconst parsed = parseModifyOtherKeysSequence(data);\n\tif (!parsed) return false;\n\treturn parsed.codepoint === expectedKeycode && parsed.modifier === expectedModifier;\n}\n\n// =============================================================================\n// Generic Key Matching\n// =============================================================================\n\n/**\n * Get the control character for a key.\n * Uses the universal formula: code & 0x1f (mask to lower 5 bits)\n *\n * Works for:\n * - Letters a-z → 1-26\n * - Symbols [\\]_ → 27, 28, 29, 31\n * - Also maps - to same as _ (same physical key on US keyboards)\n */\nfunction rawCtrlChar(key: string): string | null {\n\tconst char = key.toLowerCase();\n\tconst code = char.charCodeAt(0);\n\tif ((code >= 97 && code <= 122) || char === \"[\" || char === \"\\\\\" || char === \"]\" || char === \"_\") {\n\t\treturn String.fromCharCode(code & 0x1f);\n\t}\n\t// Handle - as _ (same physical key on US keyboards)\n\tif (char === \"-\") {\n\t\treturn String.fromCharCode(31); // Same as Ctrl+_\n\t}\n\treturn null;\n}\n\nfunction isDigitKey(key: string): boolean {\n\treturn key >= \"0\" && key <= \"9\";\n}\n\nfunction matchesPrintableModifyOtherKeys(data: string, expectedKeycode: number, expectedModifier: number): boolean {\n\tif (expectedModifier === 0) return false;\n\treturn matchesModifyOtherKeys(data, expectedKeycode, expectedModifier);\n}\n\nfunction formatKeyNameWithModifiers(keyName: string, modifier: number): string | undefined {\n\tconst mods: string[] = [];\n\tconst effectiveMod = modifier & ~LOCK_MASK;\n\tconst supportedModifierMask = MODIFIERS.shift | MODIFIERS.ctrl | MODIFIERS.alt;\n\tif ((effectiveMod & ~supportedModifierMask) !== 0) return undefined;\n\tif (effectiveMod & MODIFIERS.shift) mods.push(\"shift\");\n\tif (effectiveMod & MODIFIERS.ctrl) mods.push(\"ctrl\");\n\tif (effectiveMod & MODIFIERS.alt) mods.push(\"alt\");\n\treturn mods.length > 0 ? `${mods.join(\"+\")}+${keyName}` : keyName;\n}\n\nfunction parseKeyId(keyId: string): { key: string; ctrl: boolean; shift: boolean; alt: boolean } | null {\n\tconst parts = keyId.toLowerCase().split(\"+\");\n\tconst key = parts[parts.length - 1];\n\tif (!key) return null;\n\treturn {\n\t\tkey,\n\t\tctrl: parts.includes(\"ctrl\"),\n\t\tshift: parts.includes(\"shift\"),\n\t\talt: parts.includes(\"alt\"),\n\t};\n}\n\n/**\n * Match input data against a key identifier string.\n *\n * Supported key identifiers:\n * - Single keys: \"escape\", \"tab\", \"enter\", \"backspace\", \"delete\", \"home\", \"end\", \"space\"\n * - Arrow keys: \"up\", \"down\", \"left\", \"right\"\n * - Ctrl combinations: \"ctrl+c\", \"ctrl+z\", etc.\n * - Shift combinations: \"shift+tab\", \"shift+enter\"\n * - Alt combinations: \"alt+enter\", \"alt+backspace\"\n * - Combined modifiers: \"shift+ctrl+p\", \"ctrl+alt+x\"\n *\n * Use the Key helper for autocomplete: Key.ctrl(\"c\"), Key.escape, Key.ctrlShift(\"p\")\n *\n * @param data - Raw input data from terminal\n * @param keyId - Key identifier (e.g., \"ctrl+c\", \"escape\", Key.ctrl(\"c\"))\n */\nexport function matchesKey(data: string, keyId: KeyId): boolean {\n\tconst parsed = parseKeyId(keyId);\n\tif (!parsed) return false;\n\n\tconst { key, ctrl, shift, alt } = parsed;\n\tlet modifier = 0;\n\tif (shift) modifier |= MODIFIERS.shift;\n\tif (alt) modifier |= MODIFIERS.alt;\n\tif (ctrl) modifier |= MODIFIERS.ctrl;\n\n\tswitch (key) {\n\t\tcase \"escape\":\n\t\tcase \"esc\":\n\t\t\tif (modifier !== 0) return false;\n\t\t\treturn data === \"\\x1b\" || matchesKittySequence(data, CODEPOINTS.escape, 0);\n\n\t\tcase \"space\":\n\t\t\tif (!_kittyProtocolActive) {\n\t\t\t\tif (ctrl && !alt && !shift && data === \"\\x00\") {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (alt && !ctrl && !shift && data === \"\\x1b \") {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn data === \" \" || matchesKittySequence(data, CODEPOINTS.space, 0);\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, CODEPOINTS.space, modifier);\n\n\t\tcase \"tab\":\n\t\t\tif (shift && !ctrl && !alt) {\n\t\t\t\treturn data === \"\\x1b[Z\" || matchesKittySequence(data, CODEPOINTS.tab, MODIFIERS.shift);\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn data === \"\\t\" || matchesKittySequence(data, CODEPOINTS.tab, 0);\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, CODEPOINTS.tab, modifier);\n\n\t\tcase \"enter\":\n\t\tcase \"return\":\n\t\t\tif (shift && !ctrl && !alt) {\n\t\t\t\t// CSI u sequences (standard Kitty protocol)\n\t\t\t\tif (\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.enter, MODIFIERS.shift) ||\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.kpEnter, MODIFIERS.shift)\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t// xterm modifyOtherKeys format (fallback when Kitty protocol not enabled)\n\t\t\t\tif (matchesModifyOtherKeys(data, CODEPOINTS.enter, MODIFIERS.shift)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t// When Kitty protocol is active, legacy sequences are custom terminal mappings\n\t\t\t\t// \\x1b\\r = Kitty's \"map shift+enter send_text all \\e\\r\"\n\t\t\t\t// \\n = Ghostty's \"keybind = shift+enter=text:\\n\"\n\t\t\t\tif (_kittyProtocolActive) {\n\t\t\t\t\treturn data === \"\\x1b\\r\" || data === \"\\n\";\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (alt && !ctrl && !shift) {\n\t\t\t\t// CSI u sequences (standard Kitty protocol)\n\t\t\t\tif (\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.enter, MODIFIERS.alt) ||\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.kpEnter, MODIFIERS.alt)\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t// xterm modifyOtherKeys format (fallback when Kitty protocol not enabled)\n\t\t\t\tif (matchesModifyOtherKeys(data, CODEPOINTS.enter, MODIFIERS.alt)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t// \\x1b\\r is alt+enter only in legacy mode (no Kitty protocol)\n\t\t\t\t// When Kitty protocol is active, alt+enter comes as CSI u sequence\n\t\t\t\tif (!_kittyProtocolActive) {\n\t\t\t\t\treturn data === \"\\x1b\\r\";\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tdata === \"\\r\" ||\n\t\t\t\t\t(!_kittyProtocolActive && data === \"\\n\") ||\n\t\t\t\t\tdata === \"\\x1bOM\" || // SS3 M (numpad enter in some terminals)\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.enter, 0) ||\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.kpEnter, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, CODEPOINTS.enter, modifier) ||\n\t\t\t\tmatchesKittySequence(data, CODEPOINTS.kpEnter, modifier) ||\n\t\t\t\tmatchesModifyOtherKeys(data, CODEPOINTS.enter, modifier)\n\t\t\t);\n\n\t\tcase \"backspace\":\n\t\t\tif (alt && !ctrl && !shift) {\n\t\t\t\tif (data === \"\\x1b\\x7f\" || data === \"\\x1b\\b\") {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn matchesKittySequence(data, CODEPOINTS.backspace, MODIFIERS.alt);\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn data === \"\\x7f\" || data === \"\\x08\" || matchesKittySequence(data, CODEPOINTS.backspace, 0);\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, CODEPOINTS.backspace, modifier);\n\n\t\tcase \"insert\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.insert) ||\n\t\t\t\t\tmatchesKittySequence(data, FUNCTIONAL_CODEPOINTS.insert, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"insert\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.insert, modifier);\n\n\t\tcase \"delete\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.delete) ||\n\t\t\t\t\tmatchesKittySequence(data, FUNCTIONAL_CODEPOINTS.delete, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"delete\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.delete, modifier);\n\n\t\tcase \"clear\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.clear);\n\t\t\t}\n\t\t\treturn matchesLegacyModifierSequence(data, \"clear\", modifier);\n\n\t\tcase \"home\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.home) ||\n\t\t\t\t\tmatchesKittySequence(data, FUNCTIONAL_CODEPOINTS.home, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"home\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.home, modifier);\n\n\t\tcase \"end\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.end) ||\n\t\t\t\t\tmatchesKittySequence(data, FUNCTIONAL_CODEPOINTS.end, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"end\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.end, modifier);\n\n\t\tcase \"pageup\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.pageUp) ||\n\t\t\t\t\tmatchesKittySequence(data, FUNCTIONAL_CODEPOINTS.pageUp, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"pageUp\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.pageUp, modifier);\n\n\t\tcase \"pagedown\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.pageDown) ||\n\t\t\t\t\tmatchesKittySequence(data, FUNCTIONAL_CODEPOINTS.pageDown, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"pageDown\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.pageDown, modifier);\n\n\t\tcase \"up\":\n\t\t\tif (alt && !ctrl && !shift) {\n\t\t\t\treturn data === \"\\x1bp\" || matchesKittySequence(data, ARROW_CODEPOINTS.up, MODIFIERS.alt);\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.up) ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.up, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"up\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, ARROW_CODEPOINTS.up, modifier);\n\n\t\tcase \"down\":\n\t\t\tif (alt && !ctrl && !shift) {\n\t\t\t\treturn data === \"\\x1bn\" || matchesKittySequence(data, ARROW_CODEPOINTS.down, MODIFIERS.alt);\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.down) ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.down, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"down\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, ARROW_CODEPOINTS.down, modifier);\n\n\t\tcase \"left\":\n\t\t\tif (alt && !ctrl && !shift) {\n\t\t\t\treturn (\n\t\t\t\t\tdata === \"\\x1b[1;3D\" ||\n\t\t\t\t\t(!_kittyProtocolActive && data === \"\\x1bB\") ||\n\t\t\t\t\tdata === \"\\x1bb\" ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.left, MODIFIERS.alt)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (ctrl && !alt && !shift) {\n\t\t\t\treturn (\n\t\t\t\t\tdata === \"\\x1b[1;5D\" ||\n\t\t\t\t\tmatchesLegacyModifierSequence(data, \"left\", MODIFIERS.ctrl) ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.left, MODIFIERS.ctrl)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.left) ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.left, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"left\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, ARROW_CODEPOINTS.left, modifier);\n\n\t\tcase \"right\":\n\t\t\tif (alt && !ctrl && !shift) {\n\t\t\t\treturn (\n\t\t\t\t\tdata === \"\\x1b[1;3C\" ||\n\t\t\t\t\t(!_kittyProtocolActive && data === \"\\x1bF\") ||\n\t\t\t\t\tdata === \"\\x1bf\" ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.right, MODIFIERS.alt)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (ctrl && !alt && !shift) {\n\t\t\t\treturn (\n\t\t\t\t\tdata === \"\\x1b[1;5C\" ||\n\t\t\t\t\tmatchesLegacyModifierSequence(data, \"right\", MODIFIERS.ctrl) ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.right, MODIFIERS.ctrl)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.right) ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.right, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"right\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, ARROW_CODEPOINTS.right, modifier);\n\n\t\tcase \"f1\":\n\t\tcase \"f2\":\n\t\tcase \"f3\":\n\t\tcase \"f4\":\n\t\tcase \"f5\":\n\t\tcase \"f6\":\n\t\tcase \"f7\":\n\t\tcase \"f8\":\n\t\tcase \"f9\":\n\t\tcase \"f10\":\n\t\tcase \"f11\":\n\t\tcase \"f12\": {\n\t\t\tif (modifier !== 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst functionKey = key as keyof typeof LEGACY_KEY_SEQUENCES;\n\t\t\treturn matchesLegacySequence(data, LEGACY_KEY_SEQUENCES[functionKey]);\n\t\t}\n\t}\n\n\t// Handle single letter/digit keys and symbols\n\tif (key.length === 1 && ((key >= \"a\" && key <= \"z\") || isDigitKey(key) || SYMBOL_KEYS.has(key))) {\n\t\tconst codepoint = key.charCodeAt(0);\n\t\tconst rawCtrl = rawCtrlChar(key);\n\t\tconst isLetter = key >= \"a\" && key <= \"z\";\n\t\tconst isDigit = isDigitKey(key);\n\n\t\tif (ctrl && alt && !shift && !_kittyProtocolActive && rawCtrl) {\n\t\t\t// Legacy: ctrl+alt+key is ESC followed by the control character\n\t\t\treturn data === `\\x1b${rawCtrl}`;\n\t\t}\n\n\t\tif (alt && !ctrl && !shift && !_kittyProtocolActive && (isLetter || isDigit)) {\n\t\t\t// Legacy: alt+letter/digit is ESC followed by the key\n\t\t\tif (data === `\\x1b${key}`) return true;\n\t\t}\n\n\t\tif (ctrl && !shift && !alt) {\n\t\t\t// Legacy: ctrl+key sends the control character\n\t\t\tif (rawCtrl && data === rawCtrl) return true;\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, codepoint, MODIFIERS.ctrl) ||\n\t\t\t\tmatchesPrintableModifyOtherKeys(data, codepoint, MODIFIERS.ctrl)\n\t\t\t);\n\t\t}\n\n\t\tif (ctrl && shift && !alt) {\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, codepoint, MODIFIERS.shift + MODIFIERS.ctrl) ||\n\t\t\t\tmatchesPrintableModifyOtherKeys(data, codepoint, MODIFIERS.shift + MODIFIERS.ctrl)\n\t\t\t);\n\t\t}\n\n\t\tif (shift && !ctrl && !alt) {\n\t\t\t// Legacy: shift+letter produces uppercase\n\t\t\tif (isLetter && data === key.toUpperCase()) return true;\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, codepoint, MODIFIERS.shift) ||\n\t\t\t\tmatchesPrintableModifyOtherKeys(data, codepoint, MODIFIERS.shift)\n\t\t\t);\n\t\t}\n\n\t\tif (modifier !== 0) {\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, codepoint, modifier) ||\n\t\t\t\tmatchesPrintableModifyOtherKeys(data, codepoint, modifier)\n\t\t\t);\n\t\t}\n\n\t\t// Check both raw char and Kitty sequence (needed for release events)\n\t\treturn data === key || matchesKittySequence(data, codepoint, 0);\n\t}\n\n\treturn false;\n}\n\n/**\n * Parse input data and return the key identifier if recognized.\n *\n * @param data - Raw input data from terminal\n * @returns Key identifier string (e.g., \"ctrl+c\") or undefined\n */\nfunction formatParsedKey(codepoint: number, modifier: number, baseLayoutKey?: number): string | undefined {\n\t// Use base layout key only when codepoint is not a recognized Latin\n\t// letter (a-z), digit (0-9), or symbol (/, -, [, ;, etc.). For those,\n\t// the codepoint is authoritative regardless of physical key position.\n\t// This prevents remapped layouts (Dvorak, Colemak, xremap, etc.) from\n\t// reporting the wrong key name based on the QWERTY physical position.\n\tconst isLatinLetter = codepoint >= 97 && codepoint <= 122; // a-z\n\tconst isDigit = codepoint >= 48 && codepoint <= 57; // 0-9\n\tconst isKnownSymbol = SYMBOL_KEYS.has(String.fromCharCode(codepoint));\n\tconst effectiveCodepoint = isLatinLetter || isDigit || isKnownSymbol ? codepoint : (baseLayoutKey ?? codepoint);\n\n\tlet keyName: string | undefined;\n\tif (effectiveCodepoint === CODEPOINTS.escape) keyName = \"escape\";\n\telse if (effectiveCodepoint === CODEPOINTS.tab) keyName = \"tab\";\n\telse if (effectiveCodepoint === CODEPOINTS.enter || effectiveCodepoint === CODEPOINTS.kpEnter) keyName = \"enter\";\n\telse if (effectiveCodepoint === CODEPOINTS.space) keyName = \"space\";\n\telse if (effectiveCodepoint === CODEPOINTS.backspace) keyName = \"backspace\";\n\telse if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.delete) keyName = \"delete\";\n\telse if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.insert) keyName = \"insert\";\n\telse if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.home) keyName = \"home\";\n\telse if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.end) keyName = \"end\";\n\telse if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.pageUp) keyName = \"pageUp\";\n\telse if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.pageDown) keyName = \"pageDown\";\n\telse if (effectiveCodepoint === ARROW_CODEPOINTS.up) keyName = \"up\";\n\telse if (effectiveCodepoint === ARROW_CODEPOINTS.down) keyName = \"down\";\n\telse if (effectiveCodepoint === ARROW_CODEPOINTS.left) keyName = \"left\";\n\telse if (effectiveCodepoint === ARROW_CODEPOINTS.right) keyName = \"right\";\n\telse if (effectiveCodepoint >= 48 && effectiveCodepoint <= 57) keyName = String.fromCharCode(effectiveCodepoint);\n\telse if (effectiveCodepoint >= 97 && effectiveCodepoint <= 122) keyName = String.fromCharCode(effectiveCodepoint);\n\telse if (SYMBOL_KEYS.has(String.fromCharCode(effectiveCodepoint))) keyName = String.fromCharCode(effectiveCodepoint);\n\n\tif (!keyName) return undefined;\n\treturn formatKeyNameWithModifiers(keyName, modifier);\n}\n\nexport function parseKey(data: string): string | undefined {\n\tconst kitty = parseKittySequence(data);\n\tif (kitty) {\n\t\treturn formatParsedKey(kitty.codepoint, kitty.modifier, kitty.baseLayoutKey);\n\t}\n\n\tconst modifyOtherKeys = parseModifyOtherKeysSequence(data);\n\tif (modifyOtherKeys) {\n\t\treturn formatParsedKey(modifyOtherKeys.codepoint, modifyOtherKeys.modifier);\n\t}\n\n\t// Mode-aware legacy sequences\n\t// When Kitty protocol is active, ambiguous sequences are interpreted as custom terminal mappings:\n\t// - \\x1b\\r = shift+enter (Kitty mapping), not alt+enter\n\t// - \\n = shift+enter (Ghostty mapping)\n\tif (_kittyProtocolActive) {\n\t\tif (data === \"\\x1b\\r\" || data === \"\\n\") return \"shift+enter\";\n\t}\n\n\tconst legacySequenceKeyId = LEGACY_SEQUENCE_KEY_IDS[data];\n\tif (legacySequenceKeyId) return legacySequenceKeyId;\n\n\t// Legacy sequences (used when Kitty protocol is not active, or for unambiguous sequences)\n\tif (data === \"\\x1b\") return \"escape\";\n\tif (data === \"\\x1c\") return \"ctrl+\\\\\";\n\tif (data === \"\\x1d\") return \"ctrl+]\";\n\tif (data === \"\\x1f\") return \"ctrl+-\";\n\tif (data === \"\\x1b\\x1b\") return \"ctrl+alt+[\";\n\tif (data === \"\\x1b\\x1c\") return \"ctrl+alt+\\\\\";\n\tif (data === \"\\x1b\\x1d\") return \"ctrl+alt+]\";\n\tif (data === \"\\x1b\\x1f\") return \"ctrl+alt+-\";\n\tif (data === \"\\t\") return \"tab\";\n\tif (data === \"\\r\" || (!_kittyProtocolActive && data === \"\\n\") || data === \"\\x1bOM\") return \"enter\";\n\tif (data === \"\\x00\") return \"ctrl+space\";\n\tif (data === \" \") return \"space\";\n\tif (data === \"\\x7f\" || data === \"\\x08\") return \"backspace\";\n\tif (data === \"\\x1b[Z\") return \"shift+tab\";\n\tif (!_kittyProtocolActive && data === \"\\x1b\\r\") return \"alt+enter\";\n\tif (!_kittyProtocolActive && data === \"\\x1b \") return \"alt+space\";\n\tif (data === \"\\x1b\\x7f\" || data === \"\\x1b\\b\") return \"alt+backspace\";\n\tif (!_kittyProtocolActive && data === \"\\x1bB\") return \"alt+left\";\n\tif (!_kittyProtocolActive && data === \"\\x1bF\") return \"alt+right\";\n\tif (!_kittyProtocolActive && data.length === 2 && data[0] === \"\\x1b\") {\n\t\tconst code = data.charCodeAt(1);\n\t\tif (code >= 1 && code <= 26) {\n\t\t\treturn `ctrl+alt+${String.fromCharCode(code + 96)}`;\n\t\t}\n\t\t// Legacy alt+letter/digit (ESC followed by the key)\n\t\tif ((code >= 97 && code <= 122) || (code >= 48 && code <= 57)) {\n\t\t\treturn `alt+${String.fromCharCode(code)}`;\n\t\t}\n\t}\n\tif (data === \"\\x1b[A\") return \"up\";\n\tif (data === \"\\x1b[B\") return \"down\";\n\tif (data === \"\\x1b[C\") return \"right\";\n\tif (data === \"\\x1b[D\") return \"left\";\n\tif (data === \"\\x1b[H\" || data === \"\\x1bOH\") return \"home\";\n\tif (data === \"\\x1b[F\" || data === \"\\x1bOF\") return \"end\";\n\tif (data === \"\\x1b[3~\") return \"delete\";\n\tif (data === \"\\x1b[5~\") return \"pageUp\";\n\tif (data === \"\\x1b[6~\") return \"pageDown\";\n\n\t// Raw Ctrl+letter\n\tif (data.length === 1) {\n\t\tconst code = data.charCodeAt(0);\n\t\tif (code >= 1 && code <= 26) {\n\t\t\treturn `ctrl+${String.fromCharCode(code + 96)}`;\n\t\t}\n\t\tif (code >= 32 && code <= 126) {\n\t\t\treturn data;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n// =============================================================================\n// Kitty CSI-u Printable Decoding\n// =============================================================================\n\nconst KITTY_CSI_U_REGEX = /^\\x1b\\[(\\d+)(?::(\\d*))?(?::(\\d+))?(?:;(\\d+))?(?::(\\d+))?u$/;\nconst KITTY_PRINTABLE_ALLOWED_MODIFIERS = MODIFIERS.shift | LOCK_MASK;\n\n/**\n * Decode a Kitty CSI-u sequence into a printable character, if applicable.\n *\n * When Kitty keyboard protocol flag 1 (disambiguate) is active, terminals send\n * CSI-u sequences for all keys, including plain printable characters. This\n * function extracts the printable character from such sequences.\n *\n * Only accepts plain or Shift-modified keys. Rejects Ctrl, Alt, and unsupported\n * modifier combinations (those are handled by keybinding matching instead).\n * Prefers the shifted keycode when Shift is held and a shifted key is reported.\n *\n * @param data - Raw input data from terminal\n * @returns The printable character, or undefined if not a printable CSI-u sequence\n */\nexport function decodeKittyPrintable(data: string): string | undefined {\n\tconst match = data.match(KITTY_CSI_U_REGEX);\n\tif (!match) return undefined;\n\n\t// CSI-u groups: <codepoint>[:<shifted>[:<base>]];<mod>[:<event>]u\n\tconst codepoint = Number.parseInt(match[1] ?? \"\", 10);\n\tif (!Number.isFinite(codepoint)) return undefined;\n\n\tconst shiftedKey = match[2] && match[2].length > 0 ? Number.parseInt(match[2], 10) : undefined;\n\tconst modValue = match[4] ? Number.parseInt(match[4], 10) : 1;\n\t// Modifiers are 1-indexed in CSI-u; normalize to our bitmask.\n\tconst modifier = Number.isFinite(modValue) ? modValue - 1 : 0;\n\n\t// Only accept printable CSI-u input for plain or Shift-modified text keys.\n\t// Reject unsupported modifier bits (e.g. Super/Meta) to avoid inserting\n\t// characters from modifier-only terminal events.\n\tif ((modifier & ~KITTY_PRINTABLE_ALLOWED_MODIFIERS) !== 0) return undefined;\n\tif (modifier & (MODIFIERS.alt | MODIFIERS.ctrl)) return undefined;\n\n\t// Prefer the shifted keycode when Shift is held.\n\tlet effectiveCodepoint = codepoint;\n\tif (modifier & MODIFIERS.shift && typeof shiftedKey === \"number\") {\n\t\teffectiveCodepoint = shiftedKey;\n\t}\n\t// Drop control characters or invalid codepoints.\n\tif (!Number.isFinite(effectiveCodepoint) || effectiveCodepoint < 32) return undefined;\n\n\ttry {\n\t\treturn String.fromCodePoint(effectiveCodepoint);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Ring buffer for Emacs-style kill/yank operations.
3
+ *
4
+ * Tracks killed (deleted) text entries. Consecutive kills can accumulate
5
+ * into a single entry. Supports yank (paste most recent) and yank-pop
6
+ * (cycle through older entries).
7
+ */
8
+ export declare class KillRing {
9
+ private ring;
10
+ /**
11
+ * Add text to the kill ring.
12
+ *
13
+ * @param text - The killed text to add
14
+ * @param opts - Push options
15
+ * @param opts.prepend - If accumulating, prepend (backward deletion) or append (forward deletion)
16
+ * @param opts.accumulate - Merge with the most recent entry instead of creating a new one
17
+ */
18
+ push(text: string, opts: {
19
+ prepend: boolean;
20
+ accumulate?: boolean;
21
+ }): void;
22
+ /** Get most recent entry without modifying the ring. */
23
+ peek(): string | undefined;
24
+ /** Move last entry to front (for yank-pop cycling). */
25
+ rotate(): void;
26
+ get length(): number;
27
+ }
28
+ //# sourceMappingURL=kill-ring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kill-ring.d.ts","sourceRoot":"","sources":["../src/kill-ring.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,QAAQ;IACpB,OAAO,CAAC,IAAI,CAAgB;IAE5B;;;;;;;OAOG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IAW1E,wDAAwD;IACxD,IAAI,IAAI,MAAM,GAAG,SAAS;IAI1B,uDAAuD;IACvD,MAAM,IAAI,IAAI;IAOd,IAAI,MAAM,IAAI,MAAM,CAEnB;CACD"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Ring buffer for Emacs-style kill/yank operations.
3
+ *
4
+ * Tracks killed (deleted) text entries. Consecutive kills can accumulate
5
+ * into a single entry. Supports yank (paste most recent) and yank-pop
6
+ * (cycle through older entries).
7
+ */
8
+ export class KillRing {
9
+ constructor() {
10
+ this.ring = [];
11
+ }
12
+ /**
13
+ * Add text to the kill ring.
14
+ *
15
+ * @param text - The killed text to add
16
+ * @param opts - Push options
17
+ * @param opts.prepend - If accumulating, prepend (backward deletion) or append (forward deletion)
18
+ * @param opts.accumulate - Merge with the most recent entry instead of creating a new one
19
+ */
20
+ push(text, opts) {
21
+ if (!text)
22
+ return;
23
+ if (opts.accumulate && this.ring.length > 0) {
24
+ const last = this.ring.pop();
25
+ this.ring.push(opts.prepend ? text + last : last + text);
26
+ }
27
+ else {
28
+ this.ring.push(text);
29
+ }
30
+ }
31
+ /** Get most recent entry without modifying the ring. */
32
+ peek() {
33
+ return this.ring.length > 0 ? this.ring[this.ring.length - 1] : undefined;
34
+ }
35
+ /** Move last entry to front (for yank-pop cycling). */
36
+ rotate() {
37
+ if (this.ring.length > 1) {
38
+ const last = this.ring.pop();
39
+ this.ring.unshift(last);
40
+ }
41
+ }
42
+ get length() {
43
+ return this.ring.length;
44
+ }
45
+ }
46
+ //# sourceMappingURL=kill-ring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kill-ring.js","sourceRoot":"","sources":["../src/kill-ring.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,OAAO,QAAQ;IAArB;QACS,SAAI,GAAa,EAAE,CAAC;IAqC7B,CAAC;IAnCA;;;;;;;OAOG;IACH,IAAI,CAAC,IAAY,EAAE,IAAgD;QAClE,IAAI,CAAC,IAAI;YAAE,OAAO;QAElB,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAG,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACF,CAAC;IAED,wDAAwD;IACxD,IAAI;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3E,CAAC;IAED,uDAAuD;IACvD,MAAM;QACL,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAG,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;IACF,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IACzB,CAAC;CACD","sourcesContent":["/**\n * Ring buffer for Emacs-style kill/yank operations.\n *\n * Tracks killed (deleted) text entries. Consecutive kills can accumulate\n * into a single entry. Supports yank (paste most recent) and yank-pop\n * (cycle through older entries).\n */\nexport class KillRing {\n\tprivate ring: string[] = [];\n\n\t/**\n\t * Add text to the kill ring.\n\t *\n\t * @param text - The killed text to add\n\t * @param opts - Push options\n\t * @param opts.prepend - If accumulating, prepend (backward deletion) or append (forward deletion)\n\t * @param opts.accumulate - Merge with the most recent entry instead of creating a new one\n\t */\n\tpush(text: string, opts: { prepend: boolean; accumulate?: boolean }): void {\n\t\tif (!text) return;\n\n\t\tif (opts.accumulate && this.ring.length > 0) {\n\t\t\tconst last = this.ring.pop()!;\n\t\t\tthis.ring.push(opts.prepend ? text + last : last + text);\n\t\t} else {\n\t\t\tthis.ring.push(text);\n\t\t}\n\t}\n\n\t/** Get most recent entry without modifying the ring. */\n\tpeek(): string | undefined {\n\t\treturn this.ring.length > 0 ? this.ring[this.ring.length - 1] : undefined;\n\t}\n\n\t/** Move last entry to front (for yank-pop cycling). */\n\trotate(): void {\n\t\tif (this.ring.length > 1) {\n\t\t\tconst last = this.ring.pop()!;\n\t\t\tthis.ring.unshift(last);\n\t\t}\n\t}\n\n\tget length(): number {\n\t\treturn this.ring.length;\n\t}\n}\n"]}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * StdinBuffer buffers input and emits complete sequences.
3
+ *
4
+ * This is necessary because stdin data events can arrive in partial chunks,
5
+ * especially for escape sequences like mouse events. Without buffering,
6
+ * partial sequences can be misinterpreted as regular keypresses.
7
+ *
8
+ * For example, the mouse SGR sequence `\x1b[<35;20;5m` might arrive as:
9
+ * - Event 1: `\x1b`
10
+ * - Event 2: `[<35`
11
+ * - Event 3: `;20;5m`
12
+ *
13
+ * The buffer accumulates these until a complete sequence is detected.
14
+ * Call the `process()` method to feed input data.
15
+ *
16
+ * Based on code from OpenTUI (https://github.com/anomalyco/opentui)
17
+ * MIT License - Copyright (c) 2025 opentui
18
+ */
19
+ import { EventEmitter } from "events";
20
+ export type StdinBufferOptions = {
21
+ /**
22
+ * Maximum time to wait for sequence completion (default: 10ms)
23
+ * After this time, the buffer is flushed even if incomplete
24
+ */
25
+ timeout?: number;
26
+ };
27
+ export type StdinBufferEventMap = {
28
+ data: [string];
29
+ paste: [string];
30
+ };
31
+ /**
32
+ * Buffers stdin input and emits complete sequences via the 'data' event.
33
+ * Handles partial escape sequences that arrive across multiple chunks.
34
+ */
35
+ export declare class StdinBuffer extends EventEmitter<StdinBufferEventMap> {
36
+ private buffer;
37
+ private timeout;
38
+ private readonly timeoutMs;
39
+ private pasteMode;
40
+ private pasteBuffer;
41
+ constructor(options?: StdinBufferOptions);
42
+ process(data: string | Buffer): void;
43
+ flush(): string[];
44
+ clear(): void;
45
+ getBuffer(): string;
46
+ destroy(): void;
47
+ }
48
+ //# sourceMappingURL=stdin-buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdin-buffer.d.ts","sourceRoot":"","sources":["../src/stdin-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AA8MtC,MAAM,MAAM,kBAAkB,GAAG;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;IACf,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,qBAAa,WAAY,SAAQ,YAAY,CAAC,mBAAmB,CAAC;IACjE,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,OAAO,CAA8C;IAC7D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,WAAW,CAAc;gBAErB,OAAO,GAAE,kBAAuB;IAKrC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAmG3C,KAAK,IAAI,MAAM,EAAE;IAejB,KAAK,IAAI,IAAI;IAUb,SAAS,IAAI,MAAM;IAInB,OAAO,IAAI,IAAI;CAGf"}
@@ -0,0 +1,316 @@
1
+ /**
2
+ * StdinBuffer buffers input and emits complete sequences.
3
+ *
4
+ * This is necessary because stdin data events can arrive in partial chunks,
5
+ * especially for escape sequences like mouse events. Without buffering,
6
+ * partial sequences can be misinterpreted as regular keypresses.
7
+ *
8
+ * For example, the mouse SGR sequence `\x1b[<35;20;5m` might arrive as:
9
+ * - Event 1: `\x1b`
10
+ * - Event 2: `[<35`
11
+ * - Event 3: `;20;5m`
12
+ *
13
+ * The buffer accumulates these until a complete sequence is detected.
14
+ * Call the `process()` method to feed input data.
15
+ *
16
+ * Based on code from OpenTUI (https://github.com/anomalyco/opentui)
17
+ * MIT License - Copyright (c) 2025 opentui
18
+ */
19
+ import { EventEmitter } from "events";
20
+ const ESC = "\x1b";
21
+ const BRACKETED_PASTE_START = "\x1b[200~";
22
+ const BRACKETED_PASTE_END = "\x1b[201~";
23
+ /**
24
+ * Check if a string is a complete escape sequence or needs more data
25
+ */
26
+ function isCompleteSequence(data) {
27
+ if (!data.startsWith(ESC)) {
28
+ return "not-escape";
29
+ }
30
+ if (data.length === 1) {
31
+ return "incomplete";
32
+ }
33
+ const afterEsc = data.slice(1);
34
+ // CSI sequences: ESC [
35
+ if (afterEsc.startsWith("[")) {
36
+ // Check for old-style mouse sequence: ESC[M + 3 bytes
37
+ if (afterEsc.startsWith("[M")) {
38
+ // Old-style mouse needs ESC[M + 3 bytes = 6 total
39
+ return data.length >= 6 ? "complete" : "incomplete";
40
+ }
41
+ return isCompleteCsiSequence(data);
42
+ }
43
+ // OSC sequences: ESC ]
44
+ if (afterEsc.startsWith("]")) {
45
+ return isCompleteOscSequence(data);
46
+ }
47
+ // DCS sequences: ESC P ... ESC \ (includes XTVersion responses)
48
+ if (afterEsc.startsWith("P")) {
49
+ return isCompleteDcsSequence(data);
50
+ }
51
+ // APC sequences: ESC _ ... ESC \ (includes Kitty graphics responses)
52
+ if (afterEsc.startsWith("_")) {
53
+ return isCompleteApcSequence(data);
54
+ }
55
+ // SS3 sequences: ESC O
56
+ if (afterEsc.startsWith("O")) {
57
+ // ESC O followed by a single character
58
+ return afterEsc.length >= 2 ? "complete" : "incomplete";
59
+ }
60
+ // Meta key sequences: ESC followed by a single character
61
+ if (afterEsc.length === 1) {
62
+ return "complete";
63
+ }
64
+ // Unknown escape sequence - treat as complete
65
+ return "complete";
66
+ }
67
+ /**
68
+ * Check if CSI sequence is complete
69
+ * CSI sequences: ESC [ ... followed by a final byte (0x40-0x7E)
70
+ */
71
+ function isCompleteCsiSequence(data) {
72
+ if (!data.startsWith(`${ESC}[`)) {
73
+ return "complete";
74
+ }
75
+ // Need at least ESC [ and one more character
76
+ if (data.length < 3) {
77
+ return "incomplete";
78
+ }
79
+ const payload = data.slice(2);
80
+ // CSI sequences end with a byte in the range 0x40-0x7E (@-~)
81
+ // This includes all letters and several special characters
82
+ const lastChar = payload[payload.length - 1];
83
+ const lastCharCode = lastChar.charCodeAt(0);
84
+ if (lastCharCode >= 0x40 && lastCharCode <= 0x7e) {
85
+ // Special handling for SGR mouse sequences
86
+ // Format: ESC[<B;X;Ym or ESC[<B;X;YM
87
+ if (payload.startsWith("<")) {
88
+ // Must have format: <digits;digits;digits[Mm]
89
+ const mouseMatch = /^<\d+;\d+;\d+[Mm]$/.test(payload);
90
+ if (mouseMatch) {
91
+ return "complete";
92
+ }
93
+ // If it ends with M or m but doesn't match the pattern, still incomplete
94
+ if (lastChar === "M" || lastChar === "m") {
95
+ // Check if we have the right structure
96
+ const parts = payload.slice(1, -1).split(";");
97
+ if (parts.length === 3 && parts.every((p) => /^\d+$/.test(p))) {
98
+ return "complete";
99
+ }
100
+ }
101
+ return "incomplete";
102
+ }
103
+ return "complete";
104
+ }
105
+ return "incomplete";
106
+ }
107
+ /**
108
+ * Check if OSC sequence is complete
109
+ * OSC sequences: ESC ] ... ST (where ST is ESC \ or BEL)
110
+ */
111
+ function isCompleteOscSequence(data) {
112
+ if (!data.startsWith(`${ESC}]`)) {
113
+ return "complete";
114
+ }
115
+ // OSC sequences end with ST (ESC \) or BEL (\x07)
116
+ if (data.endsWith(`${ESC}\\`) || data.endsWith("\x07")) {
117
+ return "complete";
118
+ }
119
+ return "incomplete";
120
+ }
121
+ /**
122
+ * Check if DCS (Device Control String) sequence is complete
123
+ * DCS sequences: ESC P ... ST (where ST is ESC \)
124
+ * Used for XTVersion responses like ESC P >| ... ESC \
125
+ */
126
+ function isCompleteDcsSequence(data) {
127
+ if (!data.startsWith(`${ESC}P`)) {
128
+ return "complete";
129
+ }
130
+ // DCS sequences end with ST (ESC \)
131
+ if (data.endsWith(`${ESC}\\`)) {
132
+ return "complete";
133
+ }
134
+ return "incomplete";
135
+ }
136
+ /**
137
+ * Check if APC (Application Program Command) sequence is complete
138
+ * APC sequences: ESC _ ... ST (where ST is ESC \)
139
+ * Used for Kitty graphics responses like ESC _ G ... ESC \
140
+ */
141
+ function isCompleteApcSequence(data) {
142
+ if (!data.startsWith(`${ESC}_`)) {
143
+ return "complete";
144
+ }
145
+ // APC sequences end with ST (ESC \)
146
+ if (data.endsWith(`${ESC}\\`)) {
147
+ return "complete";
148
+ }
149
+ return "incomplete";
150
+ }
151
+ /**
152
+ * Split accumulated buffer into complete sequences
153
+ */
154
+ function extractCompleteSequences(buffer) {
155
+ const sequences = [];
156
+ let pos = 0;
157
+ while (pos < buffer.length) {
158
+ const remaining = buffer.slice(pos);
159
+ // Try to extract a sequence starting at this position
160
+ if (remaining.startsWith(ESC)) {
161
+ // Find the end of this escape sequence
162
+ let seqEnd = 1;
163
+ while (seqEnd <= remaining.length) {
164
+ const candidate = remaining.slice(0, seqEnd);
165
+ const status = isCompleteSequence(candidate);
166
+ if (status === "complete") {
167
+ sequences.push(candidate);
168
+ pos += seqEnd;
169
+ break;
170
+ }
171
+ else if (status === "incomplete") {
172
+ seqEnd++;
173
+ }
174
+ else {
175
+ // Should not happen when starting with ESC
176
+ sequences.push(candidate);
177
+ pos += seqEnd;
178
+ break;
179
+ }
180
+ }
181
+ if (seqEnd > remaining.length) {
182
+ return { sequences, remainder: remaining };
183
+ }
184
+ }
185
+ else {
186
+ // Not an escape sequence - take a single character
187
+ sequences.push(remaining[0]);
188
+ pos++;
189
+ }
190
+ }
191
+ return { sequences, remainder: "" };
192
+ }
193
+ /**
194
+ * Buffers stdin input and emits complete sequences via the 'data' event.
195
+ * Handles partial escape sequences that arrive across multiple chunks.
196
+ */
197
+ export class StdinBuffer extends EventEmitter {
198
+ constructor(options = {}) {
199
+ super();
200
+ this.buffer = "";
201
+ this.timeout = null;
202
+ this.pasteMode = false;
203
+ this.pasteBuffer = "";
204
+ this.timeoutMs = options.timeout ?? 10;
205
+ }
206
+ process(data) {
207
+ // Clear any pending timeout
208
+ if (this.timeout) {
209
+ clearTimeout(this.timeout);
210
+ this.timeout = null;
211
+ }
212
+ // Handle high-byte conversion (for compatibility with parseKeypress)
213
+ // If buffer has single byte > 127, convert to ESC + (byte - 128)
214
+ let str;
215
+ if (Buffer.isBuffer(data)) {
216
+ if (data.length === 1 && data[0] > 127) {
217
+ const byte = data[0] - 128;
218
+ str = `\x1b${String.fromCharCode(byte)}`;
219
+ }
220
+ else {
221
+ str = data.toString();
222
+ }
223
+ }
224
+ else {
225
+ str = data;
226
+ }
227
+ if (str.length === 0 && this.buffer.length === 0) {
228
+ this.emit("data", "");
229
+ return;
230
+ }
231
+ this.buffer += str;
232
+ if (this.pasteMode) {
233
+ this.pasteBuffer += this.buffer;
234
+ this.buffer = "";
235
+ const endIndex = this.pasteBuffer.indexOf(BRACKETED_PASTE_END);
236
+ if (endIndex !== -1) {
237
+ const pastedContent = this.pasteBuffer.slice(0, endIndex);
238
+ const remaining = this.pasteBuffer.slice(endIndex + BRACKETED_PASTE_END.length);
239
+ this.pasteMode = false;
240
+ this.pasteBuffer = "";
241
+ this.emit("paste", pastedContent);
242
+ if (remaining.length > 0) {
243
+ this.process(remaining);
244
+ }
245
+ }
246
+ return;
247
+ }
248
+ const startIndex = this.buffer.indexOf(BRACKETED_PASTE_START);
249
+ if (startIndex !== -1) {
250
+ if (startIndex > 0) {
251
+ const beforePaste = this.buffer.slice(0, startIndex);
252
+ const result = extractCompleteSequences(beforePaste);
253
+ for (const sequence of result.sequences) {
254
+ this.emit("data", sequence);
255
+ }
256
+ }
257
+ this.buffer = this.buffer.slice(startIndex + BRACKETED_PASTE_START.length);
258
+ this.pasteMode = true;
259
+ this.pasteBuffer = this.buffer;
260
+ this.buffer = "";
261
+ const endIndex = this.pasteBuffer.indexOf(BRACKETED_PASTE_END);
262
+ if (endIndex !== -1) {
263
+ const pastedContent = this.pasteBuffer.slice(0, endIndex);
264
+ const remaining = this.pasteBuffer.slice(endIndex + BRACKETED_PASTE_END.length);
265
+ this.pasteMode = false;
266
+ this.pasteBuffer = "";
267
+ this.emit("paste", pastedContent);
268
+ if (remaining.length > 0) {
269
+ this.process(remaining);
270
+ }
271
+ }
272
+ return;
273
+ }
274
+ const result = extractCompleteSequences(this.buffer);
275
+ this.buffer = result.remainder;
276
+ for (const sequence of result.sequences) {
277
+ this.emit("data", sequence);
278
+ }
279
+ if (this.buffer.length > 0) {
280
+ this.timeout = setTimeout(() => {
281
+ const flushed = this.flush();
282
+ for (const sequence of flushed) {
283
+ this.emit("data", sequence);
284
+ }
285
+ }, this.timeoutMs);
286
+ }
287
+ }
288
+ flush() {
289
+ if (this.timeout) {
290
+ clearTimeout(this.timeout);
291
+ this.timeout = null;
292
+ }
293
+ if (this.buffer.length === 0) {
294
+ return [];
295
+ }
296
+ const sequences = [this.buffer];
297
+ this.buffer = "";
298
+ return sequences;
299
+ }
300
+ clear() {
301
+ if (this.timeout) {
302
+ clearTimeout(this.timeout);
303
+ this.timeout = null;
304
+ }
305
+ this.buffer = "";
306
+ this.pasteMode = false;
307
+ this.pasteBuffer = "";
308
+ }
309
+ getBuffer() {
310
+ return this.buffer;
311
+ }
312
+ destroy() {
313
+ this.clear();
314
+ }
315
+ }
316
+ //# sourceMappingURL=stdin-buffer.js.map