@code-yeongyu/senpi 2026.8.22 → 2026.8.24

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 (230) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/bun-runtime.d.ts +58 -0
  3. package/dist/bun-runtime.d.ts.map +1 -0
  4. package/dist/bun-runtime.js +163 -0
  5. package/dist/bun-runtime.js.map +1 -0
  6. package/dist/cli.js +45 -2
  7. package/dist/cli.js.map +1 -1
  8. package/dist/core/agent-abort-provenance.d.ts +5 -5
  9. package/dist/core/agent-abort-provenance.d.ts.map +1 -1
  10. package/dist/core/agent-abort-provenance.js +3 -0
  11. package/dist/core/agent-abort-provenance.js.map +1 -1
  12. package/dist/core/agent-session.d.ts +10 -2
  13. package/dist/core/agent-session.d.ts.map +1 -1
  14. package/dist/core/agent-session.js +85 -26
  15. package/dist/core/agent-session.js.map +1 -1
  16. package/dist/core/agent-settled-delivery.d.ts +13 -1
  17. package/dist/core/agent-settled-delivery.d.ts.map +1 -1
  18. package/dist/core/agent-settled-delivery.js +33 -2
  19. package/dist/core/agent-settled-delivery.js.map +1 -1
  20. package/dist/core/extensions/builtin/goal/agent-end-continuation.d.ts.map +1 -1
  21. package/dist/core/extensions/builtin/goal/agent-end-continuation.js +10 -0
  22. package/dist/core/extensions/builtin/goal/agent-end-continuation.js.map +1 -1
  23. package/dist/core/extensions/builtin/goal/cache-warm-renderer.d.ts.map +1 -1
  24. package/dist/core/extensions/builtin/goal/cache-warm-renderer.js +2 -3
  25. package/dist/core/extensions/builtin/goal/cache-warm-renderer.js.map +1 -1
  26. package/dist/core/extensions/builtin/goal/cache-warm.d.ts +6 -0
  27. package/dist/core/extensions/builtin/goal/cache-warm.d.ts.map +1 -1
  28. package/dist/core/extensions/builtin/goal/cache-warm.js +43 -0
  29. package/dist/core/extensions/builtin/goal/cache-warm.js.map +1 -1
  30. package/dist/core/extensions/builtin/goal/continuation.d.ts +1 -1
  31. package/dist/core/extensions/builtin/goal/continuation.d.ts.map +1 -1
  32. package/dist/core/extensions/builtin/goal/continuation.js +1 -1
  33. package/dist/core/extensions/builtin/goal/continuation.js.map +1 -1
  34. package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
  35. package/dist/core/extensions/builtin/goal/index.js +0 -8
  36. package/dist/core/extensions/builtin/goal/index.js.map +1 -1
  37. package/dist/core/extensions/builtin/goal/monitor-continuation-types.d.ts +1 -0
  38. package/dist/core/extensions/builtin/goal/monitor-continuation-types.d.ts.map +1 -1
  39. package/dist/core/extensions/builtin/goal/monitor-continuation-types.js.map +1 -1
  40. package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts +2 -1
  41. package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
  42. package/dist/core/extensions/builtin/goal/monitor-continuation.js +31 -3
  43. package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
  44. package/dist/core/extensions/builtin/goal/wait-ticker.d.ts.map +1 -1
  45. package/dist/core/extensions/builtin/goal/wait-ticker.js +14 -9
  46. package/dist/core/extensions/builtin/goal/wait-ticker.js.map +1 -1
  47. package/dist/core/extensions/builtin/webfetch/webfetch/fetcher.d.ts.map +1 -1
  48. package/dist/core/extensions/builtin/webfetch/webfetch/fetcher.js +5 -23
  49. package/dist/core/extensions/builtin/webfetch/webfetch/fetcher.js.map +1 -1
  50. package/dist/core/extensions/builtin/webfetch/webfetch/response-body.d.ts +11 -0
  51. package/dist/core/extensions/builtin/webfetch/webfetch/response-body.d.ts.map +1 -0
  52. package/dist/core/extensions/builtin/webfetch/webfetch/response-body.js +54 -0
  53. package/dist/core/extensions/builtin/webfetch/webfetch/response-body.js.map +1 -0
  54. package/dist/core/model-config-schema.d.ts +12 -12
  55. package/dist/core/model-config-schema.js +2 -2
  56. package/dist/core/model-config-schema.js.map +1 -1
  57. package/dist/core/model-resolver.js +2 -2
  58. package/dist/core/model-resolver.js.map +1 -1
  59. package/dist/core/session-work-barrier.d.ts.map +1 -1
  60. package/dist/core/session-work-barrier.js +38 -1
  61. package/dist/core/session-work-barrier.js.map +1 -1
  62. package/dist/core/tools/read.d.ts.map +1 -1
  63. package/dist/core/tools/read.js +5 -0
  64. package/dist/core/tools/read.js.map +1 -1
  65. package/dist/modes/interactive/aborted-error-label.d.ts +2 -1
  66. package/dist/modes/interactive/aborted-error-label.d.ts.map +1 -1
  67. package/dist/modes/interactive/aborted-error-label.js +20 -5
  68. package/dist/modes/interactive/aborted-error-label.js.map +1 -1
  69. package/dist/modes/interactive/components/status-indicator.d.ts +3 -0
  70. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  71. package/dist/modes/interactive/components/status-indicator.js +7 -1
  72. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  73. package/dist/modes/interactive/interactive-mode.d.ts +2 -0
  74. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  75. package/dist/modes/interactive/interactive-mode.js +50 -10
  76. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  77. package/dist/modes/interactive/streaming-reveal.d.ts +8 -0
  78. package/dist/modes/interactive/streaming-reveal.d.ts.map +1 -1
  79. package/dist/modes/interactive/streaming-reveal.js +12 -0
  80. package/dist/modes/interactive/streaming-reveal.js.map +1 -1
  81. package/dist/senpi +45 -2
  82. package/docs/AGENTS.md +3 -1
  83. package/examples/AGENTS.md +21 -6
  84. package/examples/extensions/AGENTS.md +50 -0
  85. package/node_modules/@anthropic-ai/claude-agent-sdk/bridge.mjs +90 -88
  86. package/node_modules/@anthropic-ai/claude-agent-sdk/browser-sdk.js +40 -40
  87. package/node_modules/@anthropic-ai/claude-agent-sdk/manifest.json +20 -21
  88. package/node_modules/@anthropic-ai/claude-agent-sdk/manifest.zst.json +24 -25
  89. package/node_modules/@anthropic-ai/claude-agent-sdk/package.json +2 -2
  90. package/node_modules/@anthropic-ai/claude-agent-sdk/sdk-tools.d.ts +102 -5
  91. package/node_modules/@anthropic-ai/claude-agent-sdk/sdk.d.ts +31 -15
  92. package/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs +80 -78
  93. package/node_modules/@aws-sdk/client-bedrock-runtime/dist-cjs/index.js +1 -1
  94. package/node_modules/@aws-sdk/client-bedrock-runtime/package.json +13 -13
  95. package/node_modules/@aws-sdk/core/package.json +5 -5
  96. package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
  97. package/node_modules/@aws-sdk/credential-provider-http/package.json +7 -7
  98. package/node_modules/@aws-sdk/credential-provider-ini/package.json +12 -12
  99. package/node_modules/@aws-sdk/credential-provider-login/package.json +6 -6
  100. package/node_modules/@aws-sdk/credential-provider-node/package.json +10 -10
  101. package/node_modules/@aws-sdk/credential-provider-process/package.json +5 -5
  102. package/node_modules/@aws-sdk/credential-provider-sso/package.json +7 -7
  103. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +6 -6
  104. package/node_modules/@aws-sdk/eventstream-handler-node/package.json +4 -4
  105. package/node_modules/@aws-sdk/middleware-eventstream/package.json +4 -4
  106. package/node_modules/@aws-sdk/middleware-websocket/package.json +6 -6
  107. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  108. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  109. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  110. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  111. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  112. package/node_modules/@aws-sdk/nested-clients/package.json +8 -8
  113. package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +3 -3
  114. package/node_modules/@aws-sdk/token-providers/package.json +6 -6
  115. package/node_modules/@aws-sdk/types/package.json +2 -2
  116. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  117. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +46 -0
  118. package/node_modules/@code-yeongyu/senpi-codemode/README.md +5 -0
  119. package/node_modules/@code-yeongyu/senpi-codemode/package.json +5 -5
  120. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/eval-notifier.ts +16 -4
  121. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/runtime-factory.ts +4 -1
  122. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/runtime-info.ts +41 -0
  123. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +9 -3
  124. package/node_modules/@code-yeongyu/senpi-codemode/src/interpreters/detect.ts +17 -4
  125. package/node_modules/@code-yeongyu/senpi-codemode/src/interpreters/resolve-command.ts +68 -0
  126. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/AGENTS.md +40 -0
  127. package/node_modules/@code-yeongyu/senpi-codemode/src/timeouts/idle-timeout.ts +33 -4
  128. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/AGENTS.md +40 -0
  129. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-runtime.ts +5 -1
  130. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-manager.ts +1 -1
  131. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-notification.ts +3 -8
  132. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-notification-queue.ts +2 -6
  133. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +3 -0
  134. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +2 -0
  135. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/render.ts +60 -3
  136. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/runtime-label.ts +49 -0
  137. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +13 -0
  138. package/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
  139. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts +5 -1
  140. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts.map +1 -1
  141. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js +13 -5
  142. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
  143. package/node_modules/@earendil-works/pi-ai/dist/cursor/composer-prompt.d.ts +27 -0
  144. package/node_modules/@earendil-works/pi-ai/dist/cursor/composer-prompt.d.ts.map +1 -0
  145. package/node_modules/@earendil-works/pi-ai/dist/cursor/composer-prompt.js +54 -0
  146. package/node_modules/@earendil-works/pi-ai/dist/cursor/composer-prompt.js.map +1 -0
  147. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  148. package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  149. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  150. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opengateway.json +1 -1
  151. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  152. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  153. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/markers.d.ts +4 -0
  154. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/markers.d.ts.map +1 -1
  155. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/markers.js +14 -0
  156. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/markers.js.map +1 -1
  157. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/recovery-stream.d.ts.map +1 -1
  158. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/recovery-stream.js +65 -35
  159. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/recovery-stream.js.map +1 -1
  160. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/thinking-recovery.d.ts.map +1 -1
  161. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/thinking-recovery.js +40 -12
  162. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/thinking-recovery.js.map +1 -1
  163. package/node_modules/@earendil-works/pi-ai/package.json +4 -4
  164. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  165. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  166. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
  167. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +7 -4
  168. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
  169. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  170. package/node_modules/@smithy/signature-v4/dist-cjs/index.js +19 -7
  171. package/node_modules/@smithy/signature-v4/dist-es/HeaderFormatter.js +4 -1
  172. package/node_modules/@smithy/signature-v4/dist-es/getCanonicalQuery.js +4 -1
  173. package/node_modules/@smithy/signature-v4/dist-es/getPayloadHash.js +4 -1
  174. package/node_modules/@smithy/signature-v4/dist-es/headerUtil.js +10 -3
  175. package/node_modules/@smithy/signature-v4/dist-es/moveHeadersToQuery.js +4 -1
  176. package/node_modules/@smithy/signature-v4/dist-es/prepareRequest.js +4 -1
  177. package/node_modules/@smithy/signature-v4/package.json +2 -2
  178. package/node_modules/typebox/build/format/email.mjs +1 -1
  179. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
  180. package/node_modules/typebox/build/format/json_pointer.d.mts +2 -2
  181. package/node_modules/typebox/build/format/json_pointer.mjs +2 -2
  182. package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +2 -2
  183. package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +2 -2
  184. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  185. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  186. package/node_modules/typebox/build/system/memory/assign.mjs +2 -1
  187. package/node_modules/typebox/build/system/memory/create.mjs +3 -4
  188. package/node_modules/typebox/build/system/memory/discard.mjs +2 -2
  189. package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
  190. package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
  191. package/node_modules/typebox/build/system/memory/update.mjs +3 -2
  192. package/node_modules/typebox/package.json +1 -1
  193. package/package.json +36 -36
  194. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/LICENSE +0 -201
  195. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/README.md +0 -62
  196. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +0 -154
  197. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/constants.js +0 -2
  198. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromEnvSigningName.js +0 -16
  199. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromSso.js +0 -80
  200. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromStatic.js +0 -8
  201. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/getNewSsoOidcToken.js +0 -11
  202. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/getSsoOidcClient.js +0 -10
  203. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/index.js +0 -4
  204. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/nodeProvider.js +0 -5
  205. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/validateTokenExpiry.js +0 -7
  206. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/validateTokenKey.js +0 -7
  207. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js +0 -8
  208. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/constants.d.ts +0 -8
  209. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/fromEnvSigningName.d.ts +0 -18
  210. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/fromSso.d.ts +0 -12
  211. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/fromStatic.d.ts +0 -9
  212. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/getNewSsoOidcToken.d.ts +0 -8
  213. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/getSsoOidcClient.d.ts +0 -7
  214. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/index.d.ts +0 -7
  215. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/nodeProvider.d.ts +0 -18
  216. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/constants.d.ts +0 -3
  217. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/fromEnvSigningName.d.ts +0 -8
  218. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/fromSso.d.ts +0 -10
  219. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/fromStatic.d.ts +0 -5
  220. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/getNewSsoOidcToken.d.ts +0 -9
  221. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/getSsoOidcClient.d.ts +0 -7
  222. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/index.d.ts +0 -7
  223. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/nodeProvider.d.ts +0 -3
  224. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/validateTokenExpiry.d.ts +0 -2
  225. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/validateTokenKey.d.ts +0 -1
  226. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/ts3.4/writeSSOTokenToFile.d.ts +0 -2
  227. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/validateTokenExpiry.d.ts +0 -5
  228. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/validateTokenKey.d.ts +0 -4
  229. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-types/writeSSOTokenToFile.d.ts +0 -5
  230. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +0 -69
@@ -1 +1 @@
1
- {"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAA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C5B,IAAI,CAAC,gBAAgB,GAAG,WAAW,CAAC,GAAG,EAAE;oBACxC,IAAI,CAAC,QAAQ,CAAC,iCAAiC,CAAC,CAAC;gBAClD,CAAC,EAAE,8BAA8B,CAAC,CAAC;YACpC,CAAC;QACF,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC7B,6BAA6B;YAC7B,IAAI,CAAC,QAAQ,CAAC,gCAAgC,CAAC,CAAC;QACjD,CAAC;IACF,CAAC;IAEO,qBAAqB;QAC5B,IAAI,CAAC,IAAI,CAAC,gBAAgB;YAAE,OAAO,KAAK,CAAC;QACzC,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACrC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAClC,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["import * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { setKittyProtocolActive } from \"./keys.ts\";\nimport { isNativeModifierPressed } from \"./native-modifiers.ts\";\nimport { StdinBuffer } from \"./stdin-buffer.ts\";\n\nconst cjsRequire = createRequire(import.meta.url);\n\nconst TERMINAL_PROGRESS_KEEPALIVE_MS = 1000;\nconst TERMINAL_PROGRESS_ACTIVE_SEQUENCE = \"\\x1b]9;4;3\\x07\";\nconst TERMINAL_PROGRESS_CLEAR_SEQUENCE = \"\\x1b]9;4;0\\x07\";\nconst NATIVE_SHIFT_ENTER_SEQUENCE = \"\\x1b[13;2u\";\nconst DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS = 7;\nconst DEAD_TERMINAL_ERROR_CODES = new Set([\"EIO\", \"EPIPE\", \"ENOTCONN\"]);\nconst KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS = 150;\nconst KITTY_KEYBOARD_PROTOCOL_QUERY = `\\x1b[>${DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS}u\\x1b[?u\\x1b[c`;\n\nexport type KeyboardProtocolNegotiationSequence =\n\t| { type: \"kitty-flags\"; flags: number }\n\t| { type: \"device-attributes\" };\n\nexport function parseKeyboardProtocolNegotiationSequence(\n\tsequence: string,\n): KeyboardProtocolNegotiationSequence | undefined {\n\tconst kittyFlags = sequence.match(/^\\x1b\\[\\?(\\d+)u$/);\n\tif (kittyFlags) {\n\t\treturn { type: \"kitty-flags\", flags: Number.parseInt(kittyFlags[1]!, 10) };\n\t}\n\tif (/^\\x1b\\[\\?[\\d;]*c$/.test(sequence)) {\n\t\treturn { type: \"device-attributes\" };\n\t}\n\treturn undefined;\n}\n\nfunction isKeyboardProtocolNegotiationSequencePrefix(sequence: string): boolean {\n\treturn sequence === \"\\x1b[\" || /^\\x1b\\[\\?[\\d;]*$/.test(sequence);\n}\n\nexport function isAppleTerminalSession(): boolean {\n\treturn process.platform === \"darwin\" && process.env.TERM_PROGRAM === \"Apple_Terminal\";\n}\n\nexport function normalizeNativeShiftEnterInput(\n\tdata: string,\n\tshouldDetectNativeShiftEnter: boolean,\n\tisShiftPressed: boolean,\n): string {\n\tif (shouldDetectNativeShiftEnter && data === \"\\r\" && isShiftPressed) return NATIVE_SHIFT_ENTER_SEQUENCE;\n\treturn data;\n}\n\nexport function normalizeAppleTerminalInput(data: string, isAppleTerminal: boolean, isShiftPressed: boolean): string {\n\treturn normalizeNativeShiftEnterInput(data, isAppleTerminal, isShiftPressed);\n}\n\nexport function keyboardEnhancementEnabled(): boolean {\n\tconst value = process.env.PI_TUI_KEYBOARD_PROTOCOL;\n\tif (value === undefined) return true;\n\treturn ![\"0\", \"false\", \"no\", \"off\"].includes(value.toLowerCase());\n}\n\nfunction isDeadTerminalError(error: unknown): boolean {\n\treturn (\n\t\terror instanceof Error &&\n\t\t\"code\" in error &&\n\t\ttypeof error.code === \"string\" &&\n\t\tDEAD_TERMINAL_ERROR_CODES.has(error.code)\n\t);\n}\n\n/**\n * Minimal terminal interface for TUI\n */\nexport interface Terminal {\n\t// Start the terminal with input and resize handlers\n\tstart(onInput: (data: string) => void, onResize: () => void): void;\n\n\t// Stop the terminal and restore state\n\tstop(): void;\n\n\t/**\n\t * Drain stdin before exiting to prevent Kitty key release events from\n\t * leaking to the parent shell over slow SSH connections.\n\t * @param maxMs - Maximum time to drain (default: 1000ms)\n\t * @param idleMs - Exit early if no input arrives within this time (default: 50ms)\n\t */\n\tdrainInput(maxMs?: number, idleMs?: number): Promise<void>;\n\n\t// Write output to terminal\n\twrite(data: string): void;\n\n\t// Get terminal dimensions\n\tget columns(): number;\n\tget rows(): number;\n\n\t// Whether Kitty keyboard protocol is active\n\tget kittyProtocolActive(): boolean;\n\n\t// Cursor positioning (relative to current position)\n\tmoveBy(lines: number): void; // Move cursor up (negative) or down (positive) by N lines\n\n\t// Cursor visibility\n\thideCursor(): void; // Hide the cursor\n\tshowCursor(): void; // Show the cursor\n\n\t// Clear operations\n\tclearLine(): void; // Clear current line\n\tclearFromCursor(): void; // Clear from cursor to end of screen\n\tclearScreen(): void; // Clear entire screen and move cursor to (0,0)\n\n\t// Title operations\n\tsetTitle(title: string): void; // Set terminal window title\n\n\t// Progress indicator (OSC 9;4)\n\tsetProgress(active: boolean): void;\n}\n\nexport interface ProcessTerminalOptions {\n\t/**\n\t * When set, stdout writes not issued by this terminal are hidden from the\n\t * screen while the terminal is started and forwarded to this handler\n\t * instead. External writes (console.log, libraries) would otherwise\n\t * interleave with frames and desynchronize differential rendering.\n\t */\n\tonExternalStdoutWrite?: (text: string) => void;\n}\n\nconst DEFAULT_ESCAPE_TIMEOUT_MS = 10;\nconst DEFAULT_SSH_ESCAPE_TIMEOUT_MS = 100;\n\n/**\n * Resolve how long to wait for the rest of an escape sequence before\n * dispatching a lone ESC as the Escape key. Legacy Alt+key input is ESC plus\n * another byte, so high-latency transports need a longer reassembly window.\n */\nexport function resolveEscapeTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {\n\tconst configured = Number(env.PI_TUI_ESC_TIMEOUT);\n\tif (Number.isFinite(configured) && configured > 0) {\n\t\treturn configured;\n\t}\n\tif (env.SSH_CONNECTION || env.SSH_TTY) {\n\t\treturn DEFAULT_SSH_ESCAPE_TIMEOUT_MS;\n\t}\n\treturn DEFAULT_ESCAPE_TIMEOUT_MS;\n}\n\n/**\n * Real terminal using process.stdin/stdout\n */\nexport class ProcessTerminal implements Terminal {\n\tprivate wasRaw = false;\n\tprivate onExternalStdoutWrite?: (text: string) => void;\n\tprivate originalStdoutWrite?: typeof process.stdout.write;\n\tprivate rawStdoutWrite?: (data: string) => void;\n\tprivate forwardingExternalWrite = false;\n\tprivate inputHandler?: (data: string) => void;\n\tprivate resizeHandler?: () => void;\n\tprivate _kittyProtocolActive = false;\n\tprivate _modifyOtherKeysActive = false;\n\tprivate keyboardProtocolPushed = false;\n\tprivate keyboardProtocolNegotiationBuffer = \"\";\n\tprivate keyboardProtocolBufferFlushTimer?: ReturnType<typeof setTimeout>;\n\tprivate stdinBuffer?: StdinBuffer;\n\tprivate stdinDataHandler?: (data: string | Buffer) => void;\n\tprivate progressInterval?: ReturnType<typeof setInterval>;\n\tprivate writeLogPath = (() => {\n\t\tconst env = process.env.PI_TUI_WRITE_LOG || \"\";\n\t\tif (!env) return \"\";\n\t\ttry {\n\t\t\tif (fs.statSync(env).isDirectory()) {\n\t\t\t\tconst now = new Date();\n\t\t\t\tconst ts = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}_${String(now.getHours()).padStart(2, \"0\")}-${String(now.getMinutes()).padStart(2, \"0\")}-${String(now.getSeconds()).padStart(2, \"0\")}`;\n\t\t\t\treturn path.join(env, `tui-${ts}-${process.pid}.log`);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Not an existing directory - use as-is (file path)\n\t\t}\n\t\treturn env;\n\t})();\n\n\tconstructor(options?: ProcessTerminalOptions) {\n\t\tthis.onExternalStdoutWrite = options?.onExternalStdoutWrite;\n\t}\n\n\tget kittyProtocolActive(): boolean {\n\t\treturn this._kittyProtocolActive;\n\t}\n\n\tprivate rawWrite(data: string): void {\n\t\tif (this.rawStdoutWrite) {\n\t\t\tthis.rawStdoutWrite(data);\n\t\t\treturn;\n\t\t}\n\t\tprocess.stdout.write(data);\n\t}\n\n\tprivate installExternalStdoutGuard(): void {\n\t\tconst handler = this.onExternalStdoutWrite;\n\t\tif (!handler || this.originalStdoutWrite) {\n\t\t\treturn;\n\t\t}\n\t\tthis.originalStdoutWrite = process.stdout.write;\n\t\tconst rawWrite = process.stdout.write.bind(process.stdout);\n\t\tthis.rawStdoutWrite = rawWrite;\n\n\t\tprocess.stdout.write = ((\n\t\t\tchunk: string | Uint8Array,\n\t\t\tencodingOrCallback?: BufferEncoding | ((error?: Error | null) => void),\n\t\t\tcallback?: (error?: Error | null) => void,\n\t\t): boolean => {\n\t\t\tconst cb = typeof encodingOrCallback === \"function\" ? encodingOrCallback : callback;\n\t\t\tconst encoding = typeof encodingOrCallback === \"string\" ? encodingOrCallback : undefined;\n\t\t\tconst text = typeof chunk === \"string\" ? chunk : Buffer.from(chunk).toString(encoding);\n\t\t\tif (this.forwardingExternalWrite) {\n\t\t\t\trawWrite(text);\n\t\t\t\tcb?.(null);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tthis.forwardingExternalWrite = true;\n\t\t\ttry {\n\t\t\t\thandler(text);\n\t\t\t} catch {\n\t\t\t\trawWrite(text);\n\t\t\t} finally {\n\t\t\t\tthis.forwardingExternalWrite = false;\n\t\t\t}\n\t\t\tcb?.(null);\n\t\t\treturn true;\n\t\t}) as typeof process.stdout.write;\n\t}\n\n\tprivate removeExternalStdoutGuard(): void {\n\t\tif (!this.originalStdoutWrite) {\n\t\t\treturn;\n\t\t}\n\t\tprocess.stdout.write = this.originalStdoutWrite;\n\t\tthis.originalStdoutWrite = undefined;\n\t\tthis.rawStdoutWrite = undefined;\n\t}\n\n\tget modifyOtherKeysActive(): boolean {\n\t\treturn this._modifyOtherKeysActive;\n\t}\n\n\tstart(onInput: (data: string) => void, onResize: () => void): void {\n\t\tthis.installExternalStdoutGuard();\n\t\tthis.inputHandler = onInput;\n\t\tthis.resizeHandler = onResize;\n\n\t\t// Save previous state and enable raw mode\n\t\tthis.wasRaw = process.stdin.isRaw || false;\n\t\tif (process.stdin.setRawMode) {\n\t\t\tprocess.stdin.setRawMode(true);\n\t\t}\n\t\tprocess.stdin.resume();\n\n\t\t// Enable bracketed paste mode - terminal will wrap pastes in \\x1b[200~ ... \\x1b[201~\n\t\tthis.rawWrite(\"\\x1b[?2004h\");\n\n\t\t// Set up resize handler immediately\n\t\tprocess.stdout.on(\"resize\", this.resizeHandler);\n\n\t\t// Refresh terminal dimensions - they may be stale after suspend/resume\n\t\t// (SIGWINCH is lost while process is stopped). Unix only.\n\t\tif (process.platform !== \"win32\") {\n\t\t\tprocess.kill(process.pid, \"SIGWINCH\");\n\t\t}\n\n\t\t// On Windows, enable ENABLE_VIRTUAL_TERMINAL_INPUT so the console sends\n\t\t// VT escape sequences (e.g. \\x1b[Z for Shift+Tab) instead of raw console\n\t\t// events that lose modifier information. Must run AFTER setRawMode(true)\n\t\t// since that resets console mode flags.\n\t\tthis.enableWindowsVTInput();\n\n\t\t// Query Kitty keyboard protocol and fall back to modifyOtherKeys when DA confirms no Kitty response.\n\t\t// See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/\n\t\tthis.queryAndEnableKittyProtocol();\n\t}\n\n\t/**\n\t * Set up StdinBuffer to split batched input into individual sequences.\n\t * This ensures components receive single events, making matchesKey/isKeyRelease work correctly.\n\t *\n\t * Also watches for Kitty protocol response and enables it when detected.\n\t * This is done here (after stdinBuffer parsing) rather than on raw stdin\n\t * to handle the case where the response arrives split across multiple events.\n\t */\n\tprivate setupStdinBuffer(): void {\n\t\tthis.stdinBuffer = new StdinBuffer({ escapeTimeout: resolveEscapeTimeoutMs() });\n\n\t\t// Forward individual sequences to the input handler\n\t\tthis.stdinBuffer.on(\"data\", (sequence) => {\n\t\t\tconst negotiationSequence = this.readKeyboardProtocolNegotiationSequence(sequence);\n\t\t\tif (negotiationSequence === \"pending\") {\n\t\t\t\tthis.scheduleKeyboardProtocolNegotiationBufferFlush();\n\t\t\t\treturn; // Wait briefly for the rest of a split Kitty response.\n\t\t\t}\n\t\t\tif (this.handleKeyboardProtocolNegotiationSequence(negotiationSequence)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.forwardInputSequence(sequence);\n\t\t});\n\n\t\t// Re-wrap paste content with bracketed paste markers for existing editor handling\n\t\tthis.stdinBuffer.on(\"paste\", (content) => {\n\t\t\tif (this.inputHandler) {\n\t\t\t\tthis.inputHandler(`\\x1b[200~${content}\\x1b[201~`);\n\t\t\t}\n\t\t});\n\n\t\t// Handler that pipes stdin data through the buffer\n\t\tthis.stdinDataHandler = (data: string | Buffer) => {\n\t\t\tthis.stdinBuffer!.process(data);\n\t\t};\n\t}\n\n\t/**\n\t * Query terminal for Kitty keyboard protocol support and enable it if available.\n\t *\n\t * Kitty's progressive enhancement detection requires requesting the desired\n\t * flags before querying them. The trailing DA query is a sentinel supported by\n\t * terminals that do not know Kitty keyboard protocol; receiving DA before a\n\t * Kitty response enables modifyOtherKeys fallback without a startup timeout.\n\t *\n\t * The requested flags are:\n\t * - 1 = disambiguate escape codes\n\t * - 2 = report event types (press/repeat/release)\n\t * - 4 = report alternate keys (shifted key, base layout key)\n\t */\n\tprivate queryAndEnableKittyProtocol(): void {\n\t\tthis.setupStdinBuffer();\n\t\tprocess.stdin.on(\"data\", this.stdinDataHandler!);\n\t\tif (!keyboardEnhancementEnabled()) {\n\t\t\treturn;\n\t\t}\n\t\tif (process.env.TMUX !== undefined || process.env.TMUX_PANE !== undefined) {\n\t\t\tthis.enableModifyOtherKeys();\n\t\t}\n\t\tthis.keyboardProtocolPushed = true;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tthis.rawWrite(KITTY_KEYBOARD_PROTOCOL_QUERY);\n\t}\n\n\tprivate handleKeyboardProtocolNegotiationSequence(\n\t\tnegotiationSequence: KeyboardProtocolNegotiationSequence | undefined,\n\t): boolean {\n\t\tif (!negotiationSequence) return false;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tif (negotiationSequence.type === \"kitty-flags\") {\n\t\t\tif (negotiationSequence.flags !== 0) {\n\t\t\t\tthis.disableModifyOtherKeys();\n\t\t\t\tif (!this._kittyProtocolActive) {\n\t\t\t\t\tthis._kittyProtocolActive = true;\n\t\t\t\t\tsetKittyProtocolActive(true);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.enableModifyOtherKeys();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tif (!this._kittyProtocolActive) {\n\t\t\tthis.enableModifyOtherKeys();\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate readKeyboardProtocolNegotiationSequence(\n\t\tsequence: string,\n\t): KeyboardProtocolNegotiationSequence | \"pending\" | undefined {\n\t\tif (this.keyboardProtocolNegotiationBuffer) {\n\t\t\tconst bufferedSequence = this.keyboardProtocolNegotiationBuffer + sequence;\n\t\t\tconst negotiationSequence = parseKeyboardProtocolNegotiationSequence(bufferedSequence);\n\t\t\tif (negotiationSequence) {\n\t\t\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\t\t\treturn negotiationSequence;\n\t\t\t}\n\t\t\tif (isKeyboardProtocolNegotiationSequencePrefix(bufferedSequence)) {\n\t\t\t\tthis.setKeyboardProtocolNegotiationBuffer(bufferedSequence);\n\t\t\t\treturn \"pending\";\n\t\t\t}\n\t\t\tthis.flushKeyboardProtocolNegotiationBufferAsInput();\n\t\t}\n\n\t\tconst negotiationSequence = parseKeyboardProtocolNegotiationSequence(sequence);\n\t\tif (negotiationSequence) return negotiationSequence;\n\t\tif (isKeyboardProtocolNegotiationSequencePrefix(sequence)) {\n\t\t\tthis.setKeyboardProtocolNegotiationBuffer(sequence);\n\t\t\treturn \"pending\";\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate setKeyboardProtocolNegotiationBuffer(sequence: string): void {\n\t\tthis.clearKeyboardProtocolNegotiationBufferFlushTimer();\n\t\tthis.keyboardProtocolNegotiationBuffer = sequence;\n\t}\n\n\tprivate clearKeyboardProtocolNegotiationBuffer(): void {\n\t\tthis.clearKeyboardProtocolNegotiationBufferFlushTimer();\n\t\tthis.keyboardProtocolNegotiationBuffer = \"\";\n\t}\n\n\tprivate flushKeyboardProtocolNegotiationBufferAsInput(): void {\n\t\tif (!this.keyboardProtocolNegotiationBuffer) return;\n\t\tconst sequence = this.keyboardProtocolNegotiationBuffer;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tthis.forwardInputSequence(sequence);\n\t}\n\n\tprivate scheduleKeyboardProtocolNegotiationBufferFlush(): void {\n\t\tif (!this.keyboardProtocolNegotiationBuffer || this.keyboardProtocolBufferFlushTimer) return;\n\t\tthis.keyboardProtocolBufferFlushTimer = setTimeout(() => {\n\t\t\tthis.keyboardProtocolBufferFlushTimer = undefined;\n\t\t\tthis.flushKeyboardProtocolNegotiationBufferAsInput();\n\t\t}, KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS);\n\t}\n\n\tprivate clearKeyboardProtocolNegotiationBufferFlushTimer(): void {\n\t\tif (!this.keyboardProtocolBufferFlushTimer) return;\n\t\tclearTimeout(this.keyboardProtocolBufferFlushTimer);\n\t\tthis.keyboardProtocolBufferFlushTimer = undefined;\n\t}\n\n\tprivate forwardInputSequence(sequence: string): void {\n\t\tif (!this.inputHandler) return;\n\t\tconst shouldDetectNativeShiftEnter =\n\t\t\tsequence === \"\\r\" && (isAppleTerminalSession() || process.platform === \"win32\");\n\t\tconst input = normalizeNativeShiftEnterInput(\n\t\t\tsequence,\n\t\t\tshouldDetectNativeShiftEnter,\n\t\t\tshouldDetectNativeShiftEnter && isNativeModifierPressed(\"shift\"),\n\t\t);\n\t\tthis.inputHandler(input);\n\t}\n\n\tprivate enableModifyOtherKeys(): void {\n\t\tif (this._kittyProtocolActive || this._modifyOtherKeysActive) return;\n\t\tthis.rawWrite(\"\\x1b[>4;2m\");\n\t\tthis._modifyOtherKeysActive = true;\n\t}\n\n\tprivate disableModifyOtherKeys(): void {\n\t\tif (!this._modifyOtherKeysActive) return;\n\t\tthis.rawWrite(\"\\x1b[>4;0m\");\n\t\tthis._modifyOtherKeysActive = false;\n\t}\n\n\t/**\n\t * On Windows, add ENABLE_VIRTUAL_TERMINAL_INPUT (0x0200) to the stdin\n\t * console handle so the terminal sends VT sequences for modified keys\n\t * (e.g. \\x1b[Z for Shift+Tab). Without this, libuv's ReadConsoleInputW\n\t * discards modifier state and Shift+Tab arrives as plain \\t.\n\t */\n\tprivate enableWindowsVTInput(): void {\n\t\tif (process.platform !== \"win32\") return;\n\t\ttry {\n\t\t\tconst arch = process.arch;\n\t\t\tif (arch !== \"x64\" && arch !== \"arm64\") return;\n\n\t\t\t// Dynamic require so non-Windows and bundled/browser paths never load the\n\t\t\t// native helper. In the npm package native/ is next to dist/; in compiled\n\t\t\t// binary archives native/ is copied next to the executable.\n\t\t\tconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\t\t\tconst nativePath = path.join(\"native\", \"win32\", \"prebuilds\", `win32-${arch}`, \"win32-console-mode.node\");\n\t\t\tconst candidates = [\n\t\t\t\tpath.join(moduleDir, \"..\", nativePath),\n\t\t\t\tpath.join(moduleDir, nativePath),\n\t\t\t\tpath.join(path.dirname(process.execPath), nativePath),\n\t\t\t];\n\t\t\tfor (const modulePath of candidates) {\n\t\t\t\ttry {\n\t\t\t\t\tconst helper = cjsRequire(modulePath) as { enableVirtualTerminalInput?: () => boolean };\n\t\t\t\t\thelper.enableVirtualTerminalInput?.();\n\t\t\t\t\treturn;\n\t\t\t\t} catch {\n\t\t\t\t\t// Try the next possible packaging location.\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Native helper not available — Shift+Tab won't be distinguishable from Tab.\n\t\t}\n\t}\n\n\tasync drainInput(maxMs = 1000, idleMs = 50): Promise<void> {\n\t\tconst shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tif (shouldDisableKittyProtocol) {\n\t\t\t// Disable Kitty keyboard protocol first so any late key releases\n\t\t\t// do not generate new Kitty escape sequences.\n\t\t\tthis.rawWrite(\"\\x1b[<u\");\n\t\t\tthis.keyboardProtocolPushed = false;\n\t\t\tthis._kittyProtocolActive = false;\n\t\t\tsetKittyProtocolActive(false);\n\t\t}\n\t\tthis.disableModifyOtherKeys();\n\n\t\tconst previousHandler = this.inputHandler;\n\t\tthis.inputHandler = undefined;\n\n\t\tlet lastDataTime = Date.now();\n\t\tconst onData = () => {\n\t\t\tlastDataTime = Date.now();\n\t\t};\n\n\t\tprocess.stdin.on(\"data\", onData);\n\t\tconst endTime = Date.now() + maxMs;\n\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst now = Date.now();\n\t\t\t\tconst timeLeft = endTime - now;\n\t\t\t\tif (timeLeft <= 0) break;\n\t\t\t\tif (now - lastDataTime >= idleMs) break;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, Math.min(idleMs, timeLeft)));\n\t\t\t}\n\t\t} finally {\n\t\t\tprocess.stdin.removeListener(\"data\", onData);\n\t\t\tthis.inputHandler = previousHandler;\n\t\t}\n\t}\n\n\tstop(): void {\n\t\tif (this.clearProgressInterval()) {\n\t\t\tthis.rawWrite(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n\t\t}\n\n\t\t// Disable bracketed paste mode\n\t\tthis.rawWrite(\"\\x1b[?2004l\");\n\n\t\tconst shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\n\t\t// Disable Kitty keyboard protocol if not already done by drainInput()\n\t\tif (shouldDisableKittyProtocol) {\n\t\t\tthis.rawWrite(\"\\x1b[<u\");\n\t\t\tthis.keyboardProtocolPushed = false;\n\t\t\tthis._kittyProtocolActive = false;\n\t\t\tsetKittyProtocolActive(false);\n\t\t}\n\t\tthis.disableModifyOtherKeys();\n\n\t\t// Clean up StdinBuffer\n\t\tif (this.stdinBuffer) {\n\t\t\tthis.stdinBuffer.destroy();\n\t\t\tthis.stdinBuffer = undefined;\n\t\t}\n\n\t\t// Remove event handlers\n\t\tif (this.stdinDataHandler) {\n\t\t\tprocess.stdin.removeListener(\"data\", this.stdinDataHandler);\n\t\t\tthis.stdinDataHandler = undefined;\n\t\t}\n\t\tthis.inputHandler = undefined;\n\t\tif (this.resizeHandler) {\n\t\t\tprocess.stdout.removeListener(\"resize\", this.resizeHandler);\n\t\t\tthis.resizeHandler = undefined;\n\t\t}\n\n\t\t// Pause stdin to prevent any buffered input (e.g., Ctrl+D) from being\n\t\t// re-interpreted after raw mode is disabled. This fixes a race condition\n\t\t// where Ctrl+D could close the parent shell over SSH.\n\t\tprocess.stdin.pause();\n\n\t\t// Restore raw mode state\n\t\tif (process.stdin.setRawMode) {\n\t\t\ttry {\n\t\t\t\tprocess.stdin.setRawMode(this.wasRaw);\n\t\t\t} catch (error) {\n\t\t\t\tif (!isDeadTerminalError(error)) throw error;\n\t\t\t}\n\t\t}\n\n\t\tthis.removeExternalStdoutGuard();\n\t}\n\n\twrite(data: string): void {\n\t\tthis.rawWrite(data);\n\t\tif (this.writeLogPath) {\n\t\t\ttry {\n\t\t\t\tfs.appendFileSync(this.writeLogPath, data, { encoding: \"utf8\" });\n\t\t\t} catch {\n\t\t\t\t// Ignore logging errors\n\t\t\t}\n\t\t}\n\t}\n\n\tget columns(): number {\n\t\treturn process.stdout.columns || Number(process.env.COLUMNS) || 80;\n\t}\n\n\tget rows(): number {\n\t\treturn process.stdout.rows || Number(process.env.LINES) || 24;\n\t}\n\n\tmoveBy(lines: number): void {\n\t\tif (lines > 0) {\n\t\t\t// Move down\n\t\t\tthis.rawWrite(`\\x1b[${lines}B`);\n\t\t} else if (lines < 0) {\n\t\t\t// Move up\n\t\t\tthis.rawWrite(`\\x1b[${-lines}A`);\n\t\t}\n\t\t// lines === 0: no movement\n\t}\n\n\thideCursor(): void {\n\t\tthis.rawWrite(\"\\x1b[?25l\");\n\t}\n\n\tshowCursor(): void {\n\t\tthis.rawWrite(\"\\x1b[?25h\");\n\t}\n\n\tclearLine(): void {\n\t\tthis.rawWrite(\"\\x1b[K\");\n\t}\n\n\tclearFromCursor(): void {\n\t\tthis.rawWrite(\"\\x1b[J\");\n\t}\n\n\tclearScreen(): void {\n\t\tthis.rawWrite(\"\\x1b[2J\\x1b[H\"); // Clear screen and move to home (1,1)\n\t}\n\n\tsetTitle(title: string): void {\n\t\t// OSC 0;title BEL - set terminal window title. Control characters are\n\t\t// stripped so a title cannot terminate the OSC early and leak the rest\n\t\t// onto the screen.\n\t\tconst sanitizedTitle = title.replace(/[\\u0000-\\u001f\\u007f-\\u009f]/g, \"\");\n\t\tthis.rawWrite(`\\x1b]0;${sanitizedTitle}\\x07`);\n\t}\n\n\tsetProgress(active: boolean): void {\n\t\tif (active) {\n\t\t\t// OSC 9;4;3 - indeterminate progress\n\t\t\tthis.rawWrite(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);\n\t\t\tif (!this.progressInterval) {\n\t\t\t\tthis.progressInterval = setInterval(() => {\n\t\t\t\t\tthis.rawWrite(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);\n\t\t\t\t}, TERMINAL_PROGRESS_KEEPALIVE_MS);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.clearProgressInterval();\n\t\t\t// OSC 9;4;0 - clear progress\n\t\t\tthis.rawWrite(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n\t\t}\n\t}\n\n\tprivate clearProgressInterval(): boolean {\n\t\tif (!this.progressInterval) return false;\n\t\tclearInterval(this.progressInterval);\n\t\tthis.progressInterval = undefined;\n\t\treturn true;\n\t}\n}\n"]}
1
+ {"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.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,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED,eAAe;QACd,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED,WAAW;QACV,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,sCAAsC;IACvE,CAAC;IAED,QAAQ,CAAC,KAAa;QACrB,sEAAsE;QACtE,uEAAuE;QACvE,mBAAmB;QACnB,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC;QAC1E,IAAI,CAAC,QAAQ,CAAC,UAAU,cAAc,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,WAAW,CAAC,MAAe;QAC1B,IAAI,MAAM,EAAE,CAAC;YACZ,qCAAqC;YACrC,IAAI,CAAC,QAAQ,CAAC,iCAAiC,CAAC,CAAC;YACjD,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC5B,IAAI,CAAC,gBAAgB,GAAG,WAAW,CAAC,GAAG,EAAE;oBACxC,IAAI,CAAC,QAAQ,CAAC,iCAAiC,CAAC,CAAC;gBAClD,CAAC,EAAE,8BAA8B,CAAC,CAAC;YACpC,CAAC;QACF,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC7B,6BAA6B;YAC7B,IAAI,CAAC,QAAQ,CAAC,gCAAgC,CAAC,CAAC;QACjD,CAAC;IACF,CAAC;IAEO,qBAAqB;QAC5B,IAAI,CAAC,IAAI,CAAC,gBAAgB;YAAE,OAAO,KAAK,CAAC;QACzC,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACrC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAClC,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["import * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { setKittyProtocolActive } from \"./keys.ts\";\nimport { isNativeModifierPressed } from \"./native-modifiers.ts\";\nimport { StdinBuffer } from \"./stdin-buffer.ts\";\n\nconst cjsRequire = createRequire(import.meta.url);\n\nconst TERMINAL_PROGRESS_KEEPALIVE_MS = 1000;\nconst TERMINAL_PROGRESS_ACTIVE_SEQUENCE = \"\\x1b]9;4;3\\x07\";\nconst TERMINAL_PROGRESS_CLEAR_SEQUENCE = \"\\x1b]9;4;0\\x07\";\nconst NATIVE_SHIFT_ENTER_SEQUENCE = \"\\x1b[13;2u\";\nconst DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS = 7;\nconst DEAD_TERMINAL_ERROR_CODES = new Set([\"EIO\", \"EPIPE\", \"ENOTCONN\"]);\n// Bun's macOS tty shim can report synchronous ioctl EIO as raw positive errno 5 without a string code.\nconst EIO_ERRNO = 5;\nconst KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS = 150;\nconst KITTY_KEYBOARD_PROTOCOL_QUERY = `\\x1b[>${DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS}u\\x1b[?u\\x1b[c`;\n\nexport type KeyboardProtocolNegotiationSequence =\n\t| { type: \"kitty-flags\"; flags: number }\n\t| { type: \"device-attributes\" };\n\nexport function parseKeyboardProtocolNegotiationSequence(\n\tsequence: string,\n): KeyboardProtocolNegotiationSequence | undefined {\n\tconst kittyFlags = sequence.match(/^\\x1b\\[\\?(\\d+)u$/);\n\tif (kittyFlags) {\n\t\treturn { type: \"kitty-flags\", flags: Number.parseInt(kittyFlags[1]!, 10) };\n\t}\n\tif (/^\\x1b\\[\\?[\\d;]*c$/.test(sequence)) {\n\t\treturn { type: \"device-attributes\" };\n\t}\n\treturn undefined;\n}\n\nfunction isKeyboardProtocolNegotiationSequencePrefix(sequence: string): boolean {\n\treturn sequence === \"\\x1b[\" || /^\\x1b\\[\\?[\\d;]*$/.test(sequence);\n}\n\nexport function isAppleTerminalSession(): boolean {\n\treturn process.platform === \"darwin\" && process.env.TERM_PROGRAM === \"Apple_Terminal\";\n}\n\nexport function normalizeNativeShiftEnterInput(\n\tdata: string,\n\tshouldDetectNativeShiftEnter: boolean,\n\tisShiftPressed: boolean,\n): string {\n\tif (shouldDetectNativeShiftEnter && data === \"\\r\" && isShiftPressed) return NATIVE_SHIFT_ENTER_SEQUENCE;\n\treturn data;\n}\n\nexport function normalizeAppleTerminalInput(data: string, isAppleTerminal: boolean, isShiftPressed: boolean): string {\n\treturn normalizeNativeShiftEnterInput(data, isAppleTerminal, isShiftPressed);\n}\n\nexport function keyboardEnhancementEnabled(): boolean {\n\tconst value = process.env.PI_TUI_KEYBOARD_PROTOCOL;\n\tif (value === undefined) return true;\n\treturn ![\"0\", \"false\", \"no\", \"off\"].includes(value.toLowerCase());\n}\n\nfunction isDeadTerminalError(error: unknown): boolean {\n\tif (!(error instanceof Error)) return false;\n\tif (\"code\" in error && typeof error.code === \"string\") return DEAD_TERMINAL_ERROR_CODES.has(error.code);\n\treturn \"errno\" in error && error.errno === EIO_ERRNO;\n}\n\n/**\n * Minimal terminal interface for TUI\n */\nexport interface Terminal {\n\t// Start the terminal with input and resize handlers\n\tstart(onInput: (data: string) => void, onResize: () => void): void;\n\n\t// Stop the terminal and restore state\n\tstop(): void;\n\n\t/**\n\t * Drain stdin before exiting to prevent Kitty key release events from\n\t * leaking to the parent shell over slow SSH connections.\n\t * @param maxMs - Maximum time to drain (default: 1000ms)\n\t * @param idleMs - Exit early if no input arrives within this time (default: 50ms)\n\t */\n\tdrainInput(maxMs?: number, idleMs?: number): Promise<void>;\n\n\t// Write output to terminal\n\twrite(data: string): void;\n\n\t// Get terminal dimensions\n\tget columns(): number;\n\tget rows(): number;\n\n\t// Whether Kitty keyboard protocol is active\n\tget kittyProtocolActive(): boolean;\n\n\t// Cursor positioning (relative to current position)\n\tmoveBy(lines: number): void; // Move cursor up (negative) or down (positive) by N lines\n\n\t// Cursor visibility\n\thideCursor(): void; // Hide the cursor\n\tshowCursor(): void; // Show the cursor\n\n\t// Clear operations\n\tclearLine(): void; // Clear current line\n\tclearFromCursor(): void; // Clear from cursor to end of screen\n\tclearScreen(): void; // Clear entire screen and move cursor to (0,0)\n\n\t// Title operations\n\tsetTitle(title: string): void; // Set terminal window title\n\n\t// Progress indicator (OSC 9;4)\n\tsetProgress(active: boolean): void;\n}\n\nexport interface ProcessTerminalOptions {\n\t/**\n\t * When set, stdout writes not issued by this terminal are hidden from the\n\t * screen while the terminal is started and forwarded to this handler\n\t * instead. External writes (console.log, libraries) would otherwise\n\t * interleave with frames and desynchronize differential rendering.\n\t */\n\tonExternalStdoutWrite?: (text: string) => void;\n}\n\nconst DEFAULT_ESCAPE_TIMEOUT_MS = 10;\nconst DEFAULT_SSH_ESCAPE_TIMEOUT_MS = 100;\n\n/**\n * Resolve how long to wait for the rest of an escape sequence before\n * dispatching a lone ESC as the Escape key. Legacy Alt+key input is ESC plus\n * another byte, so high-latency transports need a longer reassembly window.\n */\nexport function resolveEscapeTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {\n\tconst configured = Number(env.PI_TUI_ESC_TIMEOUT);\n\tif (Number.isFinite(configured) && configured > 0) {\n\t\treturn configured;\n\t}\n\tif (env.SSH_CONNECTION || env.SSH_TTY) {\n\t\treturn DEFAULT_SSH_ESCAPE_TIMEOUT_MS;\n\t}\n\treturn DEFAULT_ESCAPE_TIMEOUT_MS;\n}\n\n/**\n * Real terminal using process.stdin/stdout\n */\nexport class ProcessTerminal implements Terminal {\n\tprivate wasRaw = false;\n\tprivate onExternalStdoutWrite?: (text: string) => void;\n\tprivate originalStdoutWrite?: typeof process.stdout.write;\n\tprivate rawStdoutWrite?: (data: string) => void;\n\tprivate forwardingExternalWrite = false;\n\tprivate inputHandler?: (data: string) => void;\n\tprivate resizeHandler?: () => void;\n\tprivate _kittyProtocolActive = false;\n\tprivate _modifyOtherKeysActive = false;\n\tprivate keyboardProtocolPushed = false;\n\tprivate keyboardProtocolNegotiationBuffer = \"\";\n\tprivate keyboardProtocolBufferFlushTimer?: ReturnType<typeof setTimeout>;\n\tprivate stdinBuffer?: StdinBuffer;\n\tprivate stdinDataHandler?: (data: string | Buffer) => void;\n\tprivate progressInterval?: ReturnType<typeof setInterval>;\n\tprivate writeLogPath = (() => {\n\t\tconst env = process.env.PI_TUI_WRITE_LOG || \"\";\n\t\tif (!env) return \"\";\n\t\ttry {\n\t\t\tif (fs.statSync(env).isDirectory()) {\n\t\t\t\tconst now = new Date();\n\t\t\t\tconst ts = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}_${String(now.getHours()).padStart(2, \"0\")}-${String(now.getMinutes()).padStart(2, \"0\")}-${String(now.getSeconds()).padStart(2, \"0\")}`;\n\t\t\t\treturn path.join(env, `tui-${ts}-${process.pid}.log`);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Not an existing directory - use as-is (file path)\n\t\t}\n\t\treturn env;\n\t})();\n\n\tconstructor(options?: ProcessTerminalOptions) {\n\t\tthis.onExternalStdoutWrite = options?.onExternalStdoutWrite;\n\t}\n\n\tget kittyProtocolActive(): boolean {\n\t\treturn this._kittyProtocolActive;\n\t}\n\n\tprivate rawWrite(data: string): void {\n\t\tif (this.rawStdoutWrite) {\n\t\t\tthis.rawStdoutWrite(data);\n\t\t\treturn;\n\t\t}\n\t\tprocess.stdout.write(data);\n\t}\n\n\tprivate installExternalStdoutGuard(): void {\n\t\tconst handler = this.onExternalStdoutWrite;\n\t\tif (!handler || this.originalStdoutWrite) {\n\t\t\treturn;\n\t\t}\n\t\tthis.originalStdoutWrite = process.stdout.write;\n\t\tconst rawWrite = process.stdout.write.bind(process.stdout);\n\t\tthis.rawStdoutWrite = rawWrite;\n\n\t\tprocess.stdout.write = ((\n\t\t\tchunk: string | Uint8Array,\n\t\t\tencodingOrCallback?: BufferEncoding | ((error?: Error | null) => void),\n\t\t\tcallback?: (error?: Error | null) => void,\n\t\t): boolean => {\n\t\t\tconst cb = typeof encodingOrCallback === \"function\" ? encodingOrCallback : callback;\n\t\t\tconst encoding = typeof encodingOrCallback === \"string\" ? encodingOrCallback : undefined;\n\t\t\tconst text = typeof chunk === \"string\" ? chunk : Buffer.from(chunk).toString(encoding);\n\t\t\tif (this.forwardingExternalWrite) {\n\t\t\t\trawWrite(text);\n\t\t\t\tcb?.(null);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tthis.forwardingExternalWrite = true;\n\t\t\ttry {\n\t\t\t\thandler(text);\n\t\t\t} catch {\n\t\t\t\trawWrite(text);\n\t\t\t} finally {\n\t\t\t\tthis.forwardingExternalWrite = false;\n\t\t\t}\n\t\t\tcb?.(null);\n\t\t\treturn true;\n\t\t}) as typeof process.stdout.write;\n\t}\n\n\tprivate removeExternalStdoutGuard(): void {\n\t\tif (!this.originalStdoutWrite) {\n\t\t\treturn;\n\t\t}\n\t\tprocess.stdout.write = this.originalStdoutWrite;\n\t\tthis.originalStdoutWrite = undefined;\n\t\tthis.rawStdoutWrite = undefined;\n\t}\n\n\tget modifyOtherKeysActive(): boolean {\n\t\treturn this._modifyOtherKeysActive;\n\t}\n\n\tstart(onInput: (data: string) => void, onResize: () => void): void {\n\t\tthis.installExternalStdoutGuard();\n\t\tthis.inputHandler = onInput;\n\t\tthis.resizeHandler = onResize;\n\n\t\t// Save previous state and enable raw mode\n\t\tthis.wasRaw = process.stdin.isRaw || false;\n\t\tif (process.stdin.setRawMode) {\n\t\t\tprocess.stdin.setRawMode(true);\n\t\t}\n\t\tprocess.stdin.resume();\n\n\t\t// Enable bracketed paste mode - terminal will wrap pastes in \\x1b[200~ ... \\x1b[201~\n\t\tthis.rawWrite(\"\\x1b[?2004h\");\n\n\t\t// Set up resize handler immediately\n\t\tprocess.stdout.on(\"resize\", this.resizeHandler);\n\n\t\t// Refresh terminal dimensions - they may be stale after suspend/resume\n\t\t// (SIGWINCH is lost while process is stopped). Unix only.\n\t\tif (process.platform !== \"win32\") {\n\t\t\tprocess.kill(process.pid, \"SIGWINCH\");\n\t\t}\n\n\t\t// On Windows, enable ENABLE_VIRTUAL_TERMINAL_INPUT so the console sends\n\t\t// VT escape sequences (e.g. \\x1b[Z for Shift+Tab) instead of raw console\n\t\t// events that lose modifier information. Must run AFTER setRawMode(true)\n\t\t// since that resets console mode flags.\n\t\tthis.enableWindowsVTInput();\n\n\t\t// Query Kitty keyboard protocol and fall back to modifyOtherKeys when DA confirms no Kitty response.\n\t\t// See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/\n\t\tthis.queryAndEnableKittyProtocol();\n\t}\n\n\t/**\n\t * Set up StdinBuffer to split batched input into individual sequences.\n\t * This ensures components receive single events, making matchesKey/isKeyRelease work correctly.\n\t *\n\t * Also watches for Kitty protocol response and enables it when detected.\n\t * This is done here (after stdinBuffer parsing) rather than on raw stdin\n\t * to handle the case where the response arrives split across multiple events.\n\t */\n\tprivate setupStdinBuffer(): void {\n\t\tthis.stdinBuffer = new StdinBuffer({ escapeTimeout: resolveEscapeTimeoutMs() });\n\n\t\t// Forward individual sequences to the input handler\n\t\tthis.stdinBuffer.on(\"data\", (sequence) => {\n\t\t\tconst negotiationSequence = this.readKeyboardProtocolNegotiationSequence(sequence);\n\t\t\tif (negotiationSequence === \"pending\") {\n\t\t\t\tthis.scheduleKeyboardProtocolNegotiationBufferFlush();\n\t\t\t\treturn; // Wait briefly for the rest of a split Kitty response.\n\t\t\t}\n\t\t\tif (this.handleKeyboardProtocolNegotiationSequence(negotiationSequence)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.forwardInputSequence(sequence);\n\t\t});\n\n\t\t// Re-wrap paste content with bracketed paste markers for existing editor handling\n\t\tthis.stdinBuffer.on(\"paste\", (content) => {\n\t\t\tif (this.inputHandler) {\n\t\t\t\tthis.inputHandler(`\\x1b[200~${content}\\x1b[201~`);\n\t\t\t}\n\t\t});\n\n\t\t// Handler that pipes stdin data through the buffer\n\t\tthis.stdinDataHandler = (data: string | Buffer) => {\n\t\t\tthis.stdinBuffer!.process(data);\n\t\t};\n\t}\n\n\t/**\n\t * Query terminal for Kitty keyboard protocol support and enable it if available.\n\t *\n\t * Kitty's progressive enhancement detection requires requesting the desired\n\t * flags before querying them. The trailing DA query is a sentinel supported by\n\t * terminals that do not know Kitty keyboard protocol; receiving DA before a\n\t * Kitty response enables modifyOtherKeys fallback without a startup timeout.\n\t *\n\t * The requested flags are:\n\t * - 1 = disambiguate escape codes\n\t * - 2 = report event types (press/repeat/release)\n\t * - 4 = report alternate keys (shifted key, base layout key)\n\t */\n\tprivate queryAndEnableKittyProtocol(): void {\n\t\tthis.setupStdinBuffer();\n\t\tprocess.stdin.on(\"data\", this.stdinDataHandler!);\n\t\tif (!keyboardEnhancementEnabled()) {\n\t\t\treturn;\n\t\t}\n\t\tif (process.env.TMUX !== undefined || process.env.TMUX_PANE !== undefined) {\n\t\t\tthis.enableModifyOtherKeys();\n\t\t}\n\t\tthis.keyboardProtocolPushed = true;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tthis.rawWrite(KITTY_KEYBOARD_PROTOCOL_QUERY);\n\t}\n\n\tprivate handleKeyboardProtocolNegotiationSequence(\n\t\tnegotiationSequence: KeyboardProtocolNegotiationSequence | undefined,\n\t): boolean {\n\t\tif (!negotiationSequence) return false;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tif (negotiationSequence.type === \"kitty-flags\") {\n\t\t\tif (negotiationSequence.flags !== 0) {\n\t\t\t\tthis.disableModifyOtherKeys();\n\t\t\t\tif (!this._kittyProtocolActive) {\n\t\t\t\t\tthis._kittyProtocolActive = true;\n\t\t\t\t\tsetKittyProtocolActive(true);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.enableModifyOtherKeys();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tif (!this._kittyProtocolActive) {\n\t\t\tthis.enableModifyOtherKeys();\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate readKeyboardProtocolNegotiationSequence(\n\t\tsequence: string,\n\t): KeyboardProtocolNegotiationSequence | \"pending\" | undefined {\n\t\tif (this.keyboardProtocolNegotiationBuffer) {\n\t\t\tconst bufferedSequence = this.keyboardProtocolNegotiationBuffer + sequence;\n\t\t\tconst negotiationSequence = parseKeyboardProtocolNegotiationSequence(bufferedSequence);\n\t\t\tif (negotiationSequence) {\n\t\t\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\t\t\treturn negotiationSequence;\n\t\t\t}\n\t\t\tif (isKeyboardProtocolNegotiationSequencePrefix(bufferedSequence)) {\n\t\t\t\tthis.setKeyboardProtocolNegotiationBuffer(bufferedSequence);\n\t\t\t\treturn \"pending\";\n\t\t\t}\n\t\t\tthis.flushKeyboardProtocolNegotiationBufferAsInput();\n\t\t}\n\n\t\tconst negotiationSequence = parseKeyboardProtocolNegotiationSequence(sequence);\n\t\tif (negotiationSequence) return negotiationSequence;\n\t\tif (isKeyboardProtocolNegotiationSequencePrefix(sequence)) {\n\t\t\tthis.setKeyboardProtocolNegotiationBuffer(sequence);\n\t\t\treturn \"pending\";\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate setKeyboardProtocolNegotiationBuffer(sequence: string): void {\n\t\tthis.clearKeyboardProtocolNegotiationBufferFlushTimer();\n\t\tthis.keyboardProtocolNegotiationBuffer = sequence;\n\t}\n\n\tprivate clearKeyboardProtocolNegotiationBuffer(): void {\n\t\tthis.clearKeyboardProtocolNegotiationBufferFlushTimer();\n\t\tthis.keyboardProtocolNegotiationBuffer = \"\";\n\t}\n\n\tprivate flushKeyboardProtocolNegotiationBufferAsInput(): void {\n\t\tif (!this.keyboardProtocolNegotiationBuffer) return;\n\t\tconst sequence = this.keyboardProtocolNegotiationBuffer;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tthis.forwardInputSequence(sequence);\n\t}\n\n\tprivate scheduleKeyboardProtocolNegotiationBufferFlush(): void {\n\t\tif (!this.keyboardProtocolNegotiationBuffer || this.keyboardProtocolBufferFlushTimer) return;\n\t\tthis.keyboardProtocolBufferFlushTimer = setTimeout(() => {\n\t\t\tthis.keyboardProtocolBufferFlushTimer = undefined;\n\t\t\tthis.flushKeyboardProtocolNegotiationBufferAsInput();\n\t\t}, KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS);\n\t}\n\n\tprivate clearKeyboardProtocolNegotiationBufferFlushTimer(): void {\n\t\tif (!this.keyboardProtocolBufferFlushTimer) return;\n\t\tclearTimeout(this.keyboardProtocolBufferFlushTimer);\n\t\tthis.keyboardProtocolBufferFlushTimer = undefined;\n\t}\n\n\tprivate forwardInputSequence(sequence: string): void {\n\t\tif (!this.inputHandler) return;\n\t\tconst shouldDetectNativeShiftEnter =\n\t\t\tsequence === \"\\r\" && (isAppleTerminalSession() || process.platform === \"win32\");\n\t\tconst input = normalizeNativeShiftEnterInput(\n\t\t\tsequence,\n\t\t\tshouldDetectNativeShiftEnter,\n\t\t\tshouldDetectNativeShiftEnter && isNativeModifierPressed(\"shift\"),\n\t\t);\n\t\tthis.inputHandler(input);\n\t}\n\n\tprivate enableModifyOtherKeys(): void {\n\t\tif (this._kittyProtocolActive || this._modifyOtherKeysActive) return;\n\t\tthis.rawWrite(\"\\x1b[>4;2m\");\n\t\tthis._modifyOtherKeysActive = true;\n\t}\n\n\tprivate disableModifyOtherKeys(): void {\n\t\tif (!this._modifyOtherKeysActive) return;\n\t\tthis.rawWrite(\"\\x1b[>4;0m\");\n\t\tthis._modifyOtherKeysActive = false;\n\t}\n\n\t/**\n\t * On Windows, add ENABLE_VIRTUAL_TERMINAL_INPUT (0x0200) to the stdin\n\t * console handle so the terminal sends VT sequences for modified keys\n\t * (e.g. \\x1b[Z for Shift+Tab). Without this, libuv's ReadConsoleInputW\n\t * discards modifier state and Shift+Tab arrives as plain \\t.\n\t */\n\tprivate enableWindowsVTInput(): void {\n\t\tif (process.platform !== \"win32\") return;\n\t\ttry {\n\t\t\tconst arch = process.arch;\n\t\t\tif (arch !== \"x64\" && arch !== \"arm64\") return;\n\n\t\t\t// Dynamic require so non-Windows and bundled/browser paths never load the\n\t\t\t// native helper. In the npm package native/ is next to dist/; in compiled\n\t\t\t// binary archives native/ is copied next to the executable.\n\t\t\tconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\t\t\tconst nativePath = path.join(\"native\", \"win32\", \"prebuilds\", `win32-${arch}`, \"win32-console-mode.node\");\n\t\t\tconst candidates = [\n\t\t\t\tpath.join(moduleDir, \"..\", nativePath),\n\t\t\t\tpath.join(moduleDir, nativePath),\n\t\t\t\tpath.join(path.dirname(process.execPath), nativePath),\n\t\t\t];\n\t\t\tfor (const modulePath of candidates) {\n\t\t\t\ttry {\n\t\t\t\t\tconst helper = cjsRequire(modulePath) as { enableVirtualTerminalInput?: () => boolean };\n\t\t\t\t\thelper.enableVirtualTerminalInput?.();\n\t\t\t\t\treturn;\n\t\t\t\t} catch {\n\t\t\t\t\t// Try the next possible packaging location.\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Native helper not available — Shift+Tab won't be distinguishable from Tab.\n\t\t}\n\t}\n\n\tasync drainInput(maxMs = 1000, idleMs = 50): Promise<void> {\n\t\tconst shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\t\tif (shouldDisableKittyProtocol) {\n\t\t\t// Disable Kitty keyboard protocol first so any late key releases\n\t\t\t// do not generate new Kitty escape sequences.\n\t\t\tthis.rawWrite(\"\\x1b[<u\");\n\t\t\tthis.keyboardProtocolPushed = false;\n\t\t\tthis._kittyProtocolActive = false;\n\t\t\tsetKittyProtocolActive(false);\n\t\t}\n\t\tthis.disableModifyOtherKeys();\n\n\t\tconst previousHandler = this.inputHandler;\n\t\tthis.inputHandler = undefined;\n\n\t\tlet lastDataTime = Date.now();\n\t\tconst onData = () => {\n\t\t\tlastDataTime = Date.now();\n\t\t};\n\n\t\tprocess.stdin.on(\"data\", onData);\n\t\tconst endTime = Date.now() + maxMs;\n\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst now = Date.now();\n\t\t\t\tconst timeLeft = endTime - now;\n\t\t\t\tif (timeLeft <= 0) break;\n\t\t\t\tif (now - lastDataTime >= idleMs) break;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, Math.min(idleMs, timeLeft)));\n\t\t\t}\n\t\t} finally {\n\t\t\tprocess.stdin.removeListener(\"data\", onData);\n\t\t\tthis.inputHandler = previousHandler;\n\t\t}\n\t}\n\n\tstop(): void {\n\t\tif (this.clearProgressInterval()) {\n\t\t\tthis.rawWrite(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n\t\t}\n\n\t\t// Disable bracketed paste mode\n\t\tthis.rawWrite(\"\\x1b[?2004l\");\n\n\t\tconst shouldDisableKittyProtocol = this.keyboardProtocolPushed || this._kittyProtocolActive;\n\t\tthis.clearKeyboardProtocolNegotiationBuffer();\n\n\t\t// Disable Kitty keyboard protocol if not already done by drainInput()\n\t\tif (shouldDisableKittyProtocol) {\n\t\t\tthis.rawWrite(\"\\x1b[<u\");\n\t\t\tthis.keyboardProtocolPushed = false;\n\t\t\tthis._kittyProtocolActive = false;\n\t\t\tsetKittyProtocolActive(false);\n\t\t}\n\t\tthis.disableModifyOtherKeys();\n\n\t\t// Clean up StdinBuffer\n\t\tif (this.stdinBuffer) {\n\t\t\tthis.stdinBuffer.destroy();\n\t\t\tthis.stdinBuffer = undefined;\n\t\t}\n\n\t\t// Remove event handlers\n\t\tif (this.stdinDataHandler) {\n\t\t\tprocess.stdin.removeListener(\"data\", this.stdinDataHandler);\n\t\t\tthis.stdinDataHandler = undefined;\n\t\t}\n\t\tthis.inputHandler = undefined;\n\t\tif (this.resizeHandler) {\n\t\t\tprocess.stdout.removeListener(\"resize\", this.resizeHandler);\n\t\t\tthis.resizeHandler = undefined;\n\t\t}\n\n\t\t// Pause stdin to prevent any buffered input (e.g., Ctrl+D) from being\n\t\t// re-interpreted after raw mode is disabled. This fixes a race condition\n\t\t// where Ctrl+D could close the parent shell over SSH.\n\t\tprocess.stdin.pause();\n\n\t\t// Restore raw mode state\n\t\tif (process.stdin.setRawMode) {\n\t\t\ttry {\n\t\t\t\tprocess.stdin.setRawMode(this.wasRaw);\n\t\t\t} catch (error) {\n\t\t\t\tif (!isDeadTerminalError(error)) throw error;\n\t\t\t}\n\t\t}\n\n\t\tthis.removeExternalStdoutGuard();\n\t}\n\n\twrite(data: string): void {\n\t\tthis.rawWrite(data);\n\t\tif (this.writeLogPath) {\n\t\t\ttry {\n\t\t\t\tfs.appendFileSync(this.writeLogPath, data, { encoding: \"utf8\" });\n\t\t\t} catch {\n\t\t\t\t// Ignore logging errors\n\t\t\t}\n\t\t}\n\t}\n\n\tget columns(): number {\n\t\treturn process.stdout.columns || Number(process.env.COLUMNS) || 80;\n\t}\n\n\tget rows(): number {\n\t\treturn process.stdout.rows || Number(process.env.LINES) || 24;\n\t}\n\n\tmoveBy(lines: number): void {\n\t\tif (lines > 0) {\n\t\t\t// Move down\n\t\t\tthis.rawWrite(`\\x1b[${lines}B`);\n\t\t} else if (lines < 0) {\n\t\t\t// Move up\n\t\t\tthis.rawWrite(`\\x1b[${-lines}A`);\n\t\t}\n\t\t// lines === 0: no movement\n\t}\n\n\thideCursor(): void {\n\t\tthis.rawWrite(\"\\x1b[?25l\");\n\t}\n\n\tshowCursor(): void {\n\t\tthis.rawWrite(\"\\x1b[?25h\");\n\t}\n\n\tclearLine(): void {\n\t\tthis.rawWrite(\"\\x1b[K\");\n\t}\n\n\tclearFromCursor(): void {\n\t\tthis.rawWrite(\"\\x1b[J\");\n\t}\n\n\tclearScreen(): void {\n\t\tthis.rawWrite(\"\\x1b[2J\\x1b[H\"); // Clear screen and move to home (1,1)\n\t}\n\n\tsetTitle(title: string): void {\n\t\t// OSC 0;title BEL - set terminal window title. Control characters are\n\t\t// stripped so a title cannot terminate the OSC early and leak the rest\n\t\t// onto the screen.\n\t\tconst sanitizedTitle = title.replace(/[\\u0000-\\u001f\\u007f-\\u009f]/g, \"\");\n\t\tthis.rawWrite(`\\x1b]0;${sanitizedTitle}\\x07`);\n\t}\n\n\tsetProgress(active: boolean): void {\n\t\tif (active) {\n\t\t\t// OSC 9;4;3 - indeterminate progress\n\t\t\tthis.rawWrite(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);\n\t\t\tif (!this.progressInterval) {\n\t\t\t\tthis.progressInterval = setInterval(() => {\n\t\t\t\t\tthis.rawWrite(TERMINAL_PROGRESS_ACTIVE_SEQUENCE);\n\t\t\t\t}, TERMINAL_PROGRESS_KEEPALIVE_MS);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.clearProgressInterval();\n\t\t\t// OSC 9;4;0 - clear progress\n\t\t\tthis.rawWrite(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n\t\t}\n\t}\n\n\tprivate clearProgressInterval(): boolean {\n\t\tif (!this.progressInterval) return false;\n\t\tclearInterval(this.progressInterval);\n\t\tthis.progressInterval = undefined;\n\t\treturn true;\n\t}\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-tui",
3
3
  "private": true,
4
- "version": "2026.8.22",
4
+ "version": "2026.8.24",
5
5
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
@@ -1,11 +1,13 @@
1
- const { fromUtf8, fromHex, toHex, toUint8Array, isArrayBuffer } = require("@smithy/core/serde");
1
+ const { hasOwn, fromUtf8, fromHex, toHex, toUint8Array, isArrayBuffer } = require("@smithy/core/serde");
2
2
  const { normalizeProvider } = require("@smithy/core/client");
3
3
  const { escapeUri, HttpRequest } = require("@smithy/core/protocols");
4
4
 
5
5
  class HeaderFormatter {
6
6
  format(headers) {
7
7
  const chunks = [];
8
- for (const headerName of Object.keys(headers)) {
8
+ for (const headerName in headers) {
9
+ if (!hasOwn(headers, headerName))
10
+ continue;
9
11
  const bytes = fromUtf8(headerName);
10
12
  chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));
11
13
  }
@@ -174,7 +176,9 @@ const MAX_PRESIGNED_TTL = 60 * 60 * 24 * 7;
174
176
  const getCanonicalQuery = ({ query = {} }) => {
175
177
  const keys = [];
176
178
  const serialized = {};
177
- for (const key of Object.keys(query)) {
179
+ for (const key in query) {
180
+ if (!hasOwn(query, key))
181
+ continue;
178
182
  if (key.toLowerCase() === SIGNATURE_HEADER) {
179
183
  continue;
180
184
  }
@@ -341,7 +345,9 @@ const getCanonicalHeaders = ({ headers }, unsignableHeaders, signableHeaders) =>
341
345
  };
342
346
 
343
347
  const getPayloadHash = async ({ headers, body }, hashConstructor) => {
344
- for (const headerName of Object.keys(headers)) {
348
+ for (const headerName in headers) {
349
+ if (!hasOwn(headers, headerName))
350
+ continue;
345
351
  if (headerName.toLowerCase() === SHA256_HEADER) {
346
352
  return headers[headerName];
347
353
  }
@@ -359,7 +365,9 @@ const getPayloadHash = async ({ headers, body }, hashConstructor) => {
359
365
 
360
366
  const hasHeader = (soughtHeader, headers) => {
361
367
  soughtHeader = soughtHeader.toLowerCase();
362
- for (const headerName of Object.keys(headers)) {
368
+ for (const headerName in headers) {
369
+ if (!hasOwn(headers, headerName))
370
+ continue;
363
371
  if (soughtHeader === headerName.toLowerCase()) {
364
372
  return true;
365
373
  }
@@ -369,7 +377,9 @@ const hasHeader = (soughtHeader, headers) => {
369
377
 
370
378
  const moveHeadersToQuery = (request, options = {}) => {
371
379
  const { headers, query = {} } = HttpRequest.clone(request);
372
- for (const name of Object.keys(headers)) {
380
+ for (const name in headers) {
381
+ if (!hasOwn(headers, name))
382
+ continue;
373
383
  const lname = name.toLowerCase();
374
384
  if ((lname.slice(0, 6) === "x-amz-" && !options.unhoistableHeaders?.has(lname)) ||
375
385
  options.hoistableHeaders?.has(lname)) {
@@ -386,7 +396,9 @@ const moveHeadersToQuery = (request, options = {}) => {
386
396
 
387
397
  const prepareRequest = (request) => {
388
398
  request = HttpRequest.clone(request);
389
- for (const headerName of Object.keys(request.headers)) {
399
+ for (const headerName in request.headers) {
400
+ if (!hasOwn(request.headers, headerName))
401
+ continue;
390
402
  if (GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) {
391
403
  delete request.headers[headerName];
392
404
  }
@@ -1,8 +1,11 @@
1
+ import { hasOwn } from "@smithy/core/serde";
1
2
  import { fromHex, fromUtf8, toHex } from "@smithy/core/serde";
2
3
  export class HeaderFormatter {
3
4
  format(headers) {
4
5
  const chunks = [];
5
- for (const headerName of Object.keys(headers)) {
6
+ for (const headerName in headers) {
7
+ if (!hasOwn(headers, headerName))
8
+ continue;
6
9
  const bytes = fromUtf8(headerName);
7
10
  chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));
8
11
  }
@@ -1,9 +1,12 @@
1
+ import { hasOwn } from "@smithy/core/serde";
1
2
  import { escapeUri } from "@smithy/core/protocols";
2
3
  import { SIGNATURE_HEADER } from "./constants";
3
4
  export const getCanonicalQuery = ({ query = {} }) => {
4
5
  const keys = [];
5
6
  const serialized = {};
6
- for (const key of Object.keys(query)) {
7
+ for (const key in query) {
8
+ if (!hasOwn(query, key))
9
+ continue;
7
10
  if (key.toLowerCase() === SIGNATURE_HEADER) {
8
11
  continue;
9
12
  }
@@ -1,7 +1,10 @@
1
+ import { hasOwn } from "@smithy/core/serde";
1
2
  import { isArrayBuffer, toHex, toUint8Array } from "@smithy/core/serde";
2
3
  import { SHA256_HEADER, UNSIGNED_PAYLOAD } from "./constants";
3
4
  export const getPayloadHash = async ({ headers, body }, hashConstructor) => {
4
- for (const headerName of Object.keys(headers)) {
5
+ for (const headerName in headers) {
6
+ if (!hasOwn(headers, headerName))
7
+ continue;
5
8
  if (headerName.toLowerCase() === SHA256_HEADER) {
6
9
  return headers[headerName];
7
10
  }
@@ -1,6 +1,9 @@
1
+ import { hasOwn } from "@smithy/core/serde";
1
2
  export const hasHeader = (soughtHeader, headers) => {
2
3
  soughtHeader = soughtHeader.toLowerCase();
3
- for (const headerName of Object.keys(headers)) {
4
+ for (const headerName in headers) {
5
+ if (!hasOwn(headers, headerName))
6
+ continue;
4
7
  if (soughtHeader === headerName.toLowerCase()) {
5
8
  return true;
6
9
  }
@@ -9,7 +12,9 @@ export const hasHeader = (soughtHeader, headers) => {
9
12
  };
10
13
  export const getHeaderValue = (soughtHeader, headers) => {
11
14
  soughtHeader = soughtHeader.toLowerCase();
12
- for (const headerName of Object.keys(headers)) {
15
+ for (const headerName in headers) {
16
+ if (!hasOwn(headers, headerName))
17
+ continue;
13
18
  if (soughtHeader === headerName.toLowerCase()) {
14
19
  return headers[headerName];
15
20
  }
@@ -18,7 +23,9 @@ export const getHeaderValue = (soughtHeader, headers) => {
18
23
  };
19
24
  export const deleteHeader = (soughtHeader, headers) => {
20
25
  soughtHeader = soughtHeader.toLowerCase();
21
- for (const headerName of Object.keys(headers)) {
26
+ for (const headerName in headers) {
27
+ if (!hasOwn(headers, headerName))
28
+ continue;
22
29
  if (soughtHeader === headerName.toLowerCase()) {
23
30
  delete headers[headerName];
24
31
  }
@@ -1,7 +1,10 @@
1
+ import { hasOwn } from "@smithy/core/serde";
1
2
  import { HttpRequest } from "@smithy/core/protocols";
2
3
  export const moveHeadersToQuery = (request, options = {}) => {
3
4
  const { headers, query = {} } = HttpRequest.clone(request);
4
- for (const name of Object.keys(headers)) {
5
+ for (const name in headers) {
6
+ if (!hasOwn(headers, name))
7
+ continue;
5
8
  const lname = name.toLowerCase();
6
9
  if ((lname.slice(0, 6) === "x-amz-" && !options.unhoistableHeaders?.has(lname)) ||
7
10
  options.hoistableHeaders?.has(lname)) {
@@ -1,8 +1,11 @@
1
+ import { hasOwn } from "@smithy/core/serde";
1
2
  import { HttpRequest } from "@smithy/core/protocols";
2
3
  import { GENERATED_HEADERS } from "./constants";
3
4
  export const prepareRequest = (request) => {
4
5
  request = HttpRequest.clone(request);
5
- for (const headerName of Object.keys(request.headers)) {
6
+ for (const headerName in request.headers) {
7
+ if (!hasOwn(request.headers, headerName))
8
+ continue;
6
9
  if (GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) {
7
10
  delete request.headers[headerName];
8
11
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/signature-v4",
3
- "version": "5.7.2",
3
+ "version": "5.7.3",
4
4
  "description": "A standalone implementation of the AWS Signature V4 request signing algorithm",
5
5
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/signature-v4",
6
6
  "license": "Apache-2.0",
@@ -38,7 +38,7 @@
38
38
  "test:watch": "yarn g:vitest watch"
39
39
  },
40
40
  "dependencies": {
41
- "@smithy/core": "^3.33.2",
41
+ "@smithy/core": "^3.33.3",
42
42
  "@smithy/types": "^4.17.2",
43
43
  "tslib": "^2.6.2"
44
44
  },
@@ -1,4 +1,4 @@
1
- const Email = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\.)*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;
1
+ const Email = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;
2
2
  /**
3
3
  * Returns true if the value is an Email
4
4
  * @specification https://datatracker.ietf.org/doc/html/rfc5322
@@ -1,6 +1,9 @@
1
1
  import * as FormatBidi from './format/bidi.mjs';
2
2
  import * as LabelUnicode from './label/unicode.mjs';
3
3
  import * as LabelPuny from './label/puny.mjs';
4
+ // ------------------------------------------------------------------
5
+ // IsLabel
6
+ // ------------------------------------------------------------------
4
7
  function IsValidLabelLength(value) {
5
8
  return value.length > 0 && value.length <= 63;
6
9
  }
@@ -8,9 +11,24 @@ function IsLabel(value) {
8
11
  return IsValidLabelLength(value) && (LabelPuny.IsPunyLabel(value) ||
9
12
  LabelUnicode.IsUnicodeLabel(value));
10
13
  }
14
+ // ------------------------------------------------------------------
15
+ // NormalizeHostname
16
+ //
17
+ // Normalizes a hostname for label validation. Normalizes for NFC
18
+ // such that equivalent codepoint sequences can be uniformly
19
+ // compared. It also removes codepoints that IDNA mapping ignores,
20
+ // and converts full stop variants to ASCII '.' so the hostname can
21
+ // be split into labels.
22
+ // ------------------------------------------------------------------
11
23
  function NormalizeHostname(value) {
12
- return value.normalize('NFC').replace(/[\u002E\u3002\uFF0E\uFF61]/g, '.');
24
+ return value
25
+ .normalize('NFC')
26
+ .replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu, '') // RE_IGNORED_MAPPING
27
+ .replace(/[\u002E\u3002\uFF0E\uFF61]/g, '.'); // RE_FULL_STOP_MAPPING
13
28
  }
29
+ // ------------------------------------------------------------------
30
+ // IsIdnHostname
31
+ // ------------------------------------------------------------------
14
32
  export function IsIdnHostname(value) {
15
33
  if (value.length === 0 || value.includes(' '))
16
34
  return false;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Returns true if the value is a json pointer
3
- * @specification
4
- * @source ajv-formats
3
+ * @specification https://datatracker.ietf.org/doc/html/rfc6901
4
+ * @source https://github.com/ajv-validator/ajv-formats
5
5
  */
6
6
  export declare function IsJsonPointer(value: string): boolean;
@@ -1,8 +1,8 @@
1
1
  const JsonPointer = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
2
2
  /**
3
3
  * Returns true if the value is a json pointer
4
- * @specification
5
- * @source ajv-formats
4
+ * @specification https://datatracker.ietf.org/doc/html/rfc6901
5
+ * @source https://github.com/ajv-validator/ajv-formats
6
6
  */
7
7
  export function IsJsonPointer(value) {
8
8
  return JsonPointer.test(value);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Returns true if the value is a json pointer uri fragment
3
- * @specification
4
- * @source ajv-formats
3
+ * @specification https://datatracker.ietf.org/doc/html/rfc6901
4
+ * @source https://github.com/ajv-validator/ajv-formats
5
5
  */
6
6
  export declare function IsJsonPointerUriFragment(value: string): boolean;
@@ -1,8 +1,8 @@
1
1
  const JsonPointerUriFragment = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
2
2
  /**
3
3
  * Returns true if the value is a json pointer uri fragment
4
- * @specification
5
- * @source ajv-formats
4
+ * @specification https://datatracker.ietf.org/doc/html/rfc6901
5
+ * @source https://github.com/ajv-validator/ajv-formats
6
6
  */
7
7
  export function IsJsonPointerUriFragment(value) {
8
8
  return JsonPointerUriFragment.test(value);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Returns true if the value is a relative json pointer
3
- * @specification
4
- * @source ajv-formats
3
+ * @specification https://datatracker.ietf.org/doc/html/rfc6901
4
+ * @source https://github.com/ajv-validator/ajv-formats
5
5
  */
6
6
  export declare function IsRelativeJsonPointer(value: string): boolean;
@@ -1,8 +1,8 @@
1
1
  const RelativeJsonPointer = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
2
2
  /**
3
3
  * Returns true if the value is a relative json pointer
4
- * @specification
5
- * @source ajv-formats
4
+ * @specification https://datatracker.ietf.org/doc/html/rfc6901
5
+ * @source https://github.com/ajv-validator/ajv-formats
6
6
  */
7
7
  export function IsRelativeJsonPointer(value) {
8
8
  return RelativeJsonPointer.test(value);
@@ -1,11 +1,12 @@
1
1
  // deno-lint-ignore-file ban-types no-explicit-any
2
2
  // deno-fmt-ignore-file
3
3
  import { Metrics } from './metrics.mjs';
4
+ import { Freeze } from './freeze.mjs';
4
5
  /**
5
6
  * Performs an Object assign using the Left and Right object types. We track this operation as it
6
7
  * creates a new GC handle per assignment.
7
8
  */
8
9
  export function Assign(left, right) {
9
10
  Metrics.assign += 1;
10
- return { ...left, ...right };
11
+ return Freeze({ ...left, ...right });
11
12
  }
@@ -1,7 +1,7 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
- // deno-fmt-ignore-file
3
2
  import { Settings } from '../settings/index.mjs';
4
3
  import { Metrics } from './metrics.mjs';
4
+ import { Freeze } from './freeze.mjs';
5
5
  function MergeHidden(left, right) {
6
6
  for (const key of Object.keys(right)) {
7
7
  Object.defineProperty(left, key, {
@@ -23,8 +23,7 @@ function Merge(left, right) {
23
23
  */
24
24
  export function Create(hidden, enumerable, options = {}) {
25
25
  Metrics.create += 1;
26
- const settings = Settings.Get();
27
26
  const withOptions = Merge(enumerable, options);
28
- const withHidden = settings.enumerableKind ? Merge(withOptions, hidden) : MergeHidden(withOptions, hidden);
29
- return settings.immutableTypes ? Object.freeze(withHidden) : withHidden;
27
+ const withHidden = Settings.Get().enumerableKind ? Merge(withOptions, hidden) : MergeHidden(withOptions, hidden);
28
+ return Freeze(withHidden);
30
29
  }
@@ -1,7 +1,7 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
- // deno-fmt-ignore-file
3
2
  import { Guard } from '../../guard/index.mjs';
4
3
  import { Metrics } from './metrics.mjs';
4
+ import { Freeze } from './freeze.mjs';
5
5
  import { Clone } from './clone.mjs';
6
6
  /** Discards multiple property keys from the given object value */
7
7
  export function Discard(value, propertyKeys) {
@@ -14,5 +14,5 @@ export function Discard(value, propertyKeys) {
14
14
  descriptor.value = Clone(descriptor.value);
15
15
  Object.defineProperty(result, key, descriptor);
16
16
  }
17
- return result;
17
+ return Freeze(result);
18
18
  }
@@ -0,0 +1,4 @@
1
+ type ObjectLike = Record<PropertyKey, any>;
2
+ /** Conditionally freezes the value if `immutableTypes` is true, otherwise no action. */
3
+ export declare function Freeze(value: ObjectLike): ObjectLike;
4
+ export {};
@@ -0,0 +1,6 @@
1
+ // deno-lint-ignore-file no-explicit-any
2
+ import { Settings } from '../settings/index.mjs';
3
+ /** Conditionally freezes the value if `immutableTypes` is true, otherwise no action. */
4
+ export function Freeze(value) {
5
+ return Settings.Get().immutableTypes ? Object.freeze(value) : value;
6
+ }
@@ -1,6 +1,7 @@
1
- // deno-fmt-ignore-file
1
+ // deno-lint-ignore-file no-explicit-any
2
2
  import { Settings } from '../settings/index.mjs';
3
3
  import { Metrics } from './metrics.mjs';
4
+ import { Freeze } from './freeze.mjs';
4
5
  import { Clone } from './clone.mjs';
5
6
  /**
6
7
  * Updates a value with new properties while preserving property enumerability. Use this function to modify
@@ -28,5 +29,5 @@ export function Update(current, hidden, enumerable) {
28
29
  value: enumerable[key]
29
30
  });
30
31
  }
31
- return result;
32
+ return Freeze(result);
32
33
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.3.16",
4
+ "version": "1.3.18",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"