@herbertgao/pi-extensions 2026.8.14 → 2026.9.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 (270) hide show
  1. package/README.md +19 -13
  2. package/THIRD_PARTY_NOTICES.md +26 -1
  3. package/node_modules/@czottmann/pi-automode/CHANGELOG.md +8 -1
  4. package/node_modules/@czottmann/pi-automode/README.md +4 -0
  5. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/classifier.ts +71 -9
  6. package/node_modules/@czottmann/pi-automode/package.json +1 -1
  7. package/node_modules/@herbertgao/pi-bark/LICENSE +21 -0
  8. package/node_modules/@herbertgao/pi-bark/README.md +44 -0
  9. package/node_modules/@herbertgao/pi-bark/assets/pi-icon.png +0 -0
  10. package/node_modules/@herbertgao/pi-bark/package.json +53 -0
  11. package/node_modules/@herbertgao/pi-bark/src/index.ts +178 -0
  12. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +20 -0
  13. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +46 -3
  14. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +55 -17
  15. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/packets.ts +6 -0
  16. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +5 -0
  17. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/result.ts +34 -30
  18. package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
  19. package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +2 -2
  20. package/node_modules/@narumitw/pi-btw/README.md +129 -88
  21. package/node_modules/@narumitw/pi-btw/dist/index.ts +283 -59
  22. package/node_modules/@narumitw/pi-btw/dist/index.ts.map +3 -3
  23. package/node_modules/@narumitw/pi-btw/package.json +5 -8
  24. package/node_modules/@narumitw/pi-btw/src/btw.ts +31 -26
  25. package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +264 -24
  26. package/node_modules/@narumitw/pi-btw/src/menu.ts +34 -2
  27. package/node_modules/@narumitw/pi-btw/src/settings.ts +16 -0
  28. package/node_modules/@narumitw/pi-btw/src/text.ts +18 -0
  29. package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +5 -16
  30. package/node_modules/@narumitw/pi-caffeinate/LICENSE +21 -0
  31. package/node_modules/@narumitw/pi-caffeinate/README.md +224 -0
  32. package/node_modules/@narumitw/pi-caffeinate/dist/index.ts +1112 -0
  33. package/node_modules/@narumitw/pi-caffeinate/dist/index.ts.map +7 -0
  34. package/node_modules/@narumitw/pi-caffeinate/package.json +53 -0
  35. package/node_modules/@narumitw/pi-caffeinate/src/caffeinate.ts +811 -0
  36. package/node_modules/@narumitw/pi-caffeinate/src/dbus-inhibit.ts +153 -0
  37. package/node_modules/@narumitw/pi-caffeinate/src/index.ts +1 -0
  38. package/node_modules/@narumitw/pi-caffeinate/src/inhibitor-process.ts +43 -0
  39. package/node_modules/@narumitw/pi-caffeinate/src/inhibitors.ts +167 -0
  40. package/node_modules/@narumitw/pi-caffeinate/src/settings.ts +202 -0
  41. package/node_modules/@tifan/pi-handoff/README.md +39 -13
  42. package/node_modules/@tifan/pi-handoff/package.json +2 -2
  43. package/node_modules/@tifan/pi-handoff/src/index.ts +166 -5
  44. package/node_modules/@tifan/pi-recap/README.md +1 -1
  45. package/node_modules/@tifan/pi-recap/package.json +2 -2
  46. package/node_modules/@tifan/pi-recap/src/index.ts +15 -0
  47. package/node_modules/@tifan/pi-rename/README.md +42 -21
  48. package/node_modules/@tifan/pi-rename/package.json +1 -1
  49. package/node_modules/@tifan/pi-rename/src/index.ts +62 -11
  50. package/node_modules/@tifan/pi-rename/src/language.ts +18 -0
  51. package/node_modules/@tifan/pi-rename/src/models.ts +69 -13
  52. package/node_modules/@tifan/pi-rename/src/naming.ts +36 -7
  53. package/node_modules/@tifan/pi-rename/src/sanitize.ts +22 -14
  54. package/node_modules/pi-lens/CHANGELOG.md +320 -0
  55. package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +79 -0
  56. package/node_modules/pi-lens/dist/clients/actionable-warnings-logger.js +16 -1
  57. package/node_modules/pi-lens/dist/clients/ast-grep-client.js +13 -6
  58. package/node_modules/pi-lens/dist/clients/availability-probe-flight.js +12 -0
  59. package/node_modules/pi-lens/dist/clients/biome-client.js +7 -0
  60. package/node_modules/pi-lens/dist/clients/blocker-freshness.js +20 -0
  61. package/node_modules/pi-lens/dist/clients/bounded-telemetry.js +56 -19
  62. package/node_modules/pi-lens/dist/clients/build-identity.js +95 -0
  63. package/node_modules/pi-lens/dist/clients/bus-publish.js +3 -0
  64. package/node_modules/pi-lens/dist/clients/cache/rule-cache.js +2 -1
  65. package/node_modules/pi-lens/dist/clients/cache-observability.js +2 -1
  66. package/node_modules/pi-lens/dist/clients/cascade-logger.js +15 -1
  67. package/node_modules/pi-lens/dist/clients/dead-code-client.js +14 -11
  68. package/node_modules/pi-lens/dist/clients/degradation-ledger.js +56 -4
  69. package/node_modules/pi-lens/dist/clients/demoted-finding-render.js +14 -0
  70. package/node_modules/pi-lens/dist/clients/dependency-checker.js +20 -3
  71. package/node_modules/pi-lens/dist/clients/deps/minimatch.js +1 -1
  72. package/node_modules/pi-lens/dist/clients/dispatch/collect-later-tier.js +39 -0
  73. package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +150 -9
  74. package/node_modules/pi-lens/dist/clients/dispatch/fact-store.js +231 -9
  75. package/node_modules/pi-lens/dist/clients/dispatch/integration.js +205 -100
  76. package/node_modules/pi-lens/dist/clients/dispatch/pending-runner-findings.js +87 -0
  77. package/node_modules/pi-lens/dist/clients/dispatch/plan.js +21 -5
  78. package/node_modules/pi-lens/dist/clients/dispatch/runners/ast-grep-napi.js +174 -55
  79. package/node_modules/pi-lens/dist/clients/dispatch/runners/eslint.js +5 -1
  80. package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-lint.js +16 -3
  81. package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-render.js +54 -9
  82. package/node_modules/pi-lens/dist/clients/dispatch/runners/index.js +1 -3
  83. package/node_modules/pi-lens/dist/clients/dispatch/runners/lsp.js +37 -1
  84. package/node_modules/pi-lens/dist/clients/dispatch/runners/markdownlint.js +4 -1
  85. package/node_modules/pi-lens/dist/clients/dispatch/runners/oxlint.js +11 -4
  86. package/node_modules/pi-lens/dist/clients/dispatch/runners/psscriptanalyzer.js +4 -0
  87. package/node_modules/pi-lens/dist/clients/dispatch/runners/rust-clippy.js +8 -3
  88. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +76 -25
  89. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/spawn-outcome.js +4 -0
  90. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/tool-failure.js +19 -7
  91. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/toolchain-availability.js +7 -13
  92. package/node_modules/pi-lens/dist/clients/dispatch/runners/yaml-rule-parser.js +51 -17
  93. package/node_modules/pi-lens/dist/clients/event-loop-monitor.js +66 -1
  94. package/node_modules/pi-lens/dist/clients/file-utils.js +157 -7
  95. package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +5 -0
  96. package/node_modules/pi-lens/dist/clients/formatters.js +28 -3
  97. package/node_modules/pi-lens/dist/clients/git-guard.js +197 -47
  98. package/node_modules/pi-lens/dist/clients/git-tracked-ignore.js +32 -1
  99. package/node_modules/pi-lens/dist/clients/govulncheck-client.js +5 -1
  100. package/node_modules/pi-lens/dist/clients/gzip-stage-write.js +7 -0
  101. package/node_modules/pi-lens/dist/clients/installer/index.js +131 -34
  102. package/node_modules/pi-lens/dist/clients/installer/managed-tool-refresh.js +3 -1
  103. package/node_modules/pi-lens/dist/clients/instance-reaper.js +4 -13
  104. package/node_modules/pi-lens/dist/clients/instance-registry-lock.js +145 -0
  105. package/node_modules/pi-lens/dist/clients/instance-registry.js +432 -122
  106. package/node_modules/pi-lens/dist/clients/jscpd-client.js +6 -1
  107. package/node_modules/pi-lens/dist/clients/language-profile.js +4 -2
  108. package/node_modules/pi-lens/dist/clients/latency-logger.js +19 -1
  109. package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +8 -0
  110. package/node_modules/pi-lens/dist/clients/lens-map.js +3 -1
  111. package/node_modules/pi-lens/dist/clients/lsp/cascade-tier.js +4 -0
  112. package/node_modules/pi-lens/dist/clients/lsp/client.js +516 -31
  113. package/node_modules/pi-lens/dist/clients/lsp/config.js +25 -2
  114. package/node_modules/pi-lens/dist/clients/lsp/diagnostic-binding.js +9 -4
  115. package/node_modules/pi-lens/dist/clients/lsp/index.js +509 -182
  116. package/node_modules/pi-lens/dist/clients/lsp/jvm-runtime.js +5 -0
  117. package/node_modules/pi-lens/dist/clients/lsp/launch.js +36 -8
  118. package/node_modules/pi-lens/dist/clients/lsp/pending-aux-coverage.js +116 -4
  119. package/node_modules/pi-lens/dist/clients/lsp/server.js +142 -13
  120. package/node_modules/pi-lens/dist/clients/lsp/session-roots.js +99 -0
  121. package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-cache.js +16 -6
  122. package/node_modules/pi-lens/dist/clients/lsp/workspace-sweep-hold.js +32 -23
  123. package/node_modules/pi-lens/dist/clients/lsp-mutation.js +16 -2
  124. package/node_modules/pi-lens/dist/clients/mcp/analyze.js +12 -6
  125. package/node_modules/pi-lens/dist/clients/mcp/session.js +14 -1
  126. package/node_modules/pi-lens/dist/clients/memory-sampler.js +23 -1
  127. package/node_modules/pi-lens/dist/clients/message-end-attribution.js +30 -0
  128. package/node_modules/pi-lens/dist/clients/metrics-history.js +21 -4
  129. package/node_modules/pi-lens/dist/clients/opaque-mutation-scan.js +232 -18
  130. package/node_modules/pi-lens/dist/clients/package-manager.js +6 -18
  131. package/node_modules/pi-lens/dist/clients/path-keyed-map.js +14 -1
  132. package/node_modules/pi-lens/dist/clients/path-utils.js +32 -0
  133. package/node_modules/pi-lens/dist/clients/pipeline.js +0 -8
  134. package/node_modules/pi-lens/dist/clients/process-singletons.js +210 -0
  135. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/madge.js +2 -1
  136. package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +10 -4
  137. package/node_modules/pi-lens/dist/clients/project-snapshot.js +33 -11
  138. package/node_modules/pi-lens/dist/clients/read-guard-logger.js +24 -2
  139. package/node_modules/pi-lens/dist/clients/read-guard.js +74 -7
  140. package/node_modules/pi-lens/dist/clients/recent-touches.js +17 -5
  141. package/node_modules/pi-lens/dist/clients/review-graph/builder.js +639 -62
  142. package/node_modules/pi-lens/dist/clients/review-graph/tsconfig-paths.js +5 -1
  143. package/node_modules/pi-lens/dist/clients/review-graph-logger.js +21 -1
  144. package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +68 -0
  145. package/node_modules/pi-lens/dist/clients/runtime-session.js +30 -12
  146. package/node_modules/pi-lens/dist/clients/runtime-tool-call.js +15 -0
  147. package/node_modules/pi-lens/dist/clients/runtime-tool-result.js +106 -7
  148. package/node_modules/pi-lens/dist/clients/runtime-turn.js +242 -27
  149. package/node_modules/pi-lens/dist/clients/safe-spawn.js +158 -18
  150. package/node_modules/pi-lens/dist/clients/security-scan-client.js +48 -17
  151. package/node_modules/pi-lens/dist/clients/session-lifecycle.js +238 -42
  152. package/node_modules/pi-lens/dist/clients/sg-runner.js +27 -15
  153. package/node_modules/pi-lens/dist/clients/shared-checkout-guard.js +338 -0
  154. package/node_modules/pi-lens/dist/clients/spawn-output-cap.js +37 -0
  155. package/node_modules/pi-lens/dist/clients/spawn-timeout-cooldown.js +15 -1
  156. package/node_modules/pi-lens/dist/clients/startup-scan.js +6 -7
  157. package/node_modules/pi-lens/dist/clients/startup-timing.js +69 -4
  158. package/node_modules/pi-lens/dist/clients/string-utils.js +20 -0
  159. package/node_modules/pi-lens/dist/clients/test-runner-client.js +419 -88
  160. package/node_modules/pi-lens/dist/clients/tool-policy.js +1 -1
  161. package/node_modules/pi-lens/dist/clients/tree-sitter-client.js +11 -5
  162. package/node_modules/pi-lens/dist/clients/tree-sitter-logger.js +17 -1
  163. package/node_modules/pi-lens/dist/clients/warm-attach.js +8 -10
  164. package/node_modules/pi-lens/dist/clients/word-index-logger.js +13 -1
  165. package/node_modules/pi-lens/dist/clients/word-index-store.js +448 -0
  166. package/node_modules/pi-lens/dist/clients/word-index.js +582 -104
  167. package/node_modules/pi-lens/dist/clients/workspace-topology.js +17 -0
  168. package/node_modules/pi-lens/dist/clients/zizmor-config.js +26 -6
  169. package/node_modules/pi-lens/dist/index.js +11243 -6651
  170. package/node_modules/pi-lens/dist/mcp/build-staleness.js +8 -7
  171. package/node_modules/pi-lens/dist/mcp/cli.js +3 -1
  172. package/node_modules/pi-lens/dist/mcp/server.js +6 -1
  173. package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +4 -0
  174. package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +14 -5
  175. package/node_modules/pi-lens/dist/tools/lsp-navigation.js +3 -1
  176. package/node_modules/pi-lens/docs/agent-guide.md +4 -2
  177. package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +41 -10
  178. package/node_modules/pi-lens/docs/astplayground.md +26 -17
  179. package/node_modules/pi-lens/package.json +5 -1
  180. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/c-no-malloc-free-test.yml +20 -0
  181. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/cpp-no-malloc-free-test.yml +25 -0
  182. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/cpp-no-printf-test.yml +19 -0
  183. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/go-no-fmt-println-test.yml +19 -0
  184. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/go-no-panic-in-lib-test.yml +17 -0
  185. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/go-no-underscore-func-name-test.yml +18 -0
  186. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/go-prefer-errors-is-test.yml +15 -0
  187. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/go-prefer-string-builder-test.yml +21 -0
  188. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/hyphenated-svg-attribute-test.yml +11 -0
  189. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-no-lateinit-test.yml +17 -0
  190. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-no-nullable-boolean-test.yml +15 -0
  191. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-no-println-test.yml +19 -0
  192. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-no-unnecessary-let-test.yml +7 -0
  193. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-no-unsafe-cast-test.yml +7 -0
  194. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-no-var-test.yml +7 -0
  195. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-prefer-data-class-test.yml +25 -0
  196. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-prefer-is-empty-test.yml +11 -0
  197. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-important-test.yml +21 -0
  198. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-raw-types-test.yml +30 -0
  199. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-string-concat-in-loop-test.yml +100 -0
  200. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-system-out-println-test.yml +7 -0
  201. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/prefer-string-is-empty-test.yml +7 -0
  202. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/python-optional-type-test.yml +9 -0
  203. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/reducible-list-comprehension-test.yml +11 -0
  204. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/ruby-symbol-to-proc-candidate-test.yml +10 -0
  205. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/rust-no-chars-enumerate-test.yml +7 -0
  206. package/node_modules/pi-lens/rules/ast-grep-rules/rules/c-no-malloc-free.yml +39 -0
  207. package/node_modules/pi-lens/rules/ast-grep-rules/rules/cpp-no-malloc-free.yml +45 -0
  208. package/node_modules/pi-lens/rules/ast-grep-rules/rules/cpp-no-printf.yml +41 -0
  209. package/node_modules/pi-lens/rules/ast-grep-rules/rules/go-no-fmt-println.yml +43 -0
  210. package/node_modules/pi-lens/rules/ast-grep-rules/rules/go-no-panic-in-lib.yml +41 -0
  211. package/node_modules/pi-lens/rules/ast-grep-rules/rules/go-no-underscore-func-name.yml +35 -0
  212. package/node_modules/pi-lens/rules/ast-grep-rules/rules/go-prefer-errors-is.yml +40 -0
  213. package/node_modules/pi-lens/rules/ast-grep-rules/rules/go-prefer-string-builder.yml +43 -0
  214. package/node_modules/pi-lens/rules/ast-grep-rules/rules/hyphenated-svg-attribute.yml +32 -0
  215. package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-no-lateinit.yml +37 -0
  216. package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-no-nullable-boolean.yml +33 -0
  217. package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-no-println.yml +42 -0
  218. package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-no-unnecessary-let.yml +28 -0
  219. package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-no-unsafe-cast.yml +28 -0
  220. package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-no-var.yml +35 -0
  221. package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-prefer-data-class.yml +66 -0
  222. package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-prefer-is-empty.yml +35 -0
  223. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-important.yml +21 -0
  224. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-raw-types.yml +33 -0
  225. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-string-concat-in-loop.yml +90 -0
  226. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-system-out-println.yml +16 -0
  227. package/node_modules/pi-lens/rules/ast-grep-rules/rules/prefer-string-is-empty.yml +11 -0
  228. package/node_modules/pi-lens/rules/ast-grep-rules/rules/python-optional-type.yml +22 -0
  229. package/node_modules/pi-lens/rules/ast-grep-rules/rules/reducible-list-comprehension.yml +29 -0
  230. package/node_modules/pi-lens/rules/ast-grep-rules/rules/ruby-symbol-to-proc-candidate.yml +25 -0
  231. package/node_modules/pi-lens/rules/ast-grep-rules/rules/rust-no-chars-enumerate.yml +19 -0
  232. package/node_modules/pi-mcp-adapter/CHANGELOG.md +42 -0
  233. package/node_modules/pi-mcp-adapter/README.md +15 -15
  234. package/node_modules/pi-mcp-adapter/commands.ts +59 -22
  235. package/node_modules/pi-mcp-adapter/config.ts +18 -4
  236. package/node_modules/pi-mcp-adapter/direct-tools.ts +26 -6
  237. package/node_modules/pi-mcp-adapter/dist/config.d.ts +4 -0
  238. package/node_modules/pi-mcp-adapter/dist/config.js +13 -4
  239. package/node_modules/pi-mcp-adapter/dist/config.js.map +1 -1
  240. package/node_modules/pi-mcp-adapter/dist/types.d.ts +12 -4
  241. package/node_modules/pi-mcp-adapter/dist/types.js.map +1 -1
  242. package/node_modules/pi-mcp-adapter/error-signal.ts +15 -4
  243. package/node_modules/pi-mcp-adapter/errors.ts +141 -0
  244. package/node_modules/pi-mcp-adapter/host-html-template.ts +58 -5
  245. package/node_modules/pi-mcp-adapter/index.ts +2 -3
  246. package/node_modules/pi-mcp-adapter/init.ts +5 -0
  247. package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +105 -32
  248. package/node_modules/pi-mcp-adapter/mcp-panel.ts +30 -9
  249. package/node_modules/pi-mcp-adapter/mcp-setup-panel.ts +66 -28
  250. package/node_modules/pi-mcp-adapter/mcp-status.ts +2 -0
  251. package/node_modules/pi-mcp-adapter/package.json +2 -1
  252. package/node_modules/pi-mcp-adapter/proxy-modes.ts +88 -25
  253. package/node_modules/pi-mcp-adapter/sandbox-proxy-template.ts +217 -0
  254. package/node_modules/pi-mcp-adapter/server-manager.ts +343 -6
  255. package/node_modules/pi-mcp-adapter/skills/mcp-scripting/SKILL.md +1 -0
  256. package/node_modules/pi-mcp-adapter/types.ts +19 -4
  257. package/node_modules/pi-mcp-adapter/ui-resource-handler.ts +18 -2
  258. package/node_modules/pi-mcp-adapter/ui-server.ts +179 -54
  259. package/node_modules/pi-mcp-adapter/ui-session.ts +28 -8
  260. package/node_modules/pi-web-access/CHANGELOG.md +20 -0
  261. package/node_modules/pi-web-access/README.md +15 -2
  262. package/node_modules/pi-web-access/extract.ts +57 -12
  263. package/node_modules/pi-web-access/github-extract.ts +47 -3
  264. package/node_modules/pi-web-access/index.ts +1 -1
  265. package/node_modules/pi-web-access/package.json +1 -1
  266. package/node_modules/pi-web-access/page-query.ts +61 -8
  267. package/package.json +21 -17
  268. package/node_modules/@tifan/pi-titlebar-spinner/README.md +0 -24
  269. package/node_modules/@tifan/pi-titlebar-spinner/package.json +0 -39
  270. package/node_modules/@tifan/pi-titlebar-spinner/src/index.ts +0 -49
@@ -0,0 +1,1112 @@
1
+ // @generated by scripts/build-runtime.mjs; do not edit.
2
+ // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
+
4
+ // src/caffeinate.ts
5
+ import process4 from "node:process";
6
+
7
+ // src/dbus-inhibit.ts
8
+ var SCREENSAVER_BUS_NAME = "org.freedesktop.ScreenSaver";
9
+ var SCREENSAVER_INTERFACE = "org.freedesktop.ScreenSaver";
10
+ var INHIBIT_REASON = "Pi agent is running";
11
+ var INHIBIT_APPLICATION_NAME = "pi-caffeinate";
12
+ var SCREENSAVER_OBJECT_PATHS = ["/org/freedesktop/ScreenSaver", "/ScreenSaver"];
13
+ var DBUS_CALL_TIMEOUT_MS = 2e3;
14
+ async function defaultDbusScreenSaverFactory() {
15
+ const { sessionBus } = await import("dbus-native");
16
+ return new NativeScreenSaverClient(sessionBus());
17
+ }
18
+ var NativeScreenSaverClient = class {
19
+ constructor(bus) {
20
+ this.bus = bus;
21
+ this.bus.connection.on("error", this.handleConnectionError);
22
+ this.bus.connection.on("close", this.handleConnectionClose);
23
+ }
24
+ bus;
25
+ cookie;
26
+ objectPath;
27
+ failureHandler;
28
+ pendingFailure;
29
+ lastConnectionError;
30
+ closing = false;
31
+ handleConnectionError = (error) => {
32
+ this.lastConnectionError = toError(error, "D-Bus session connection failed");
33
+ if (this.cookie !== void 0) this.reportFailure(this.lastConnectionError);
34
+ };
35
+ handleConnectionClose = (error) => {
36
+ if (this.closing || this.cookie === void 0) return;
37
+ this.reportFailure(
38
+ toError(error, this.lastConnectionError?.message ?? "D-Bus session connection closed")
39
+ );
40
+ };
41
+ setFailureHandler(handler) {
42
+ this.failureHandler = handler;
43
+ if (!handler || !this.pendingFailure) return;
44
+ const failure = this.pendingFailure;
45
+ this.pendingFailure = void 0;
46
+ handler(failure);
47
+ }
48
+ async inhibit(reason, signal) {
49
+ let lastError;
50
+ for (const objectPath of SCREENSAVER_OBJECT_PATHS) {
51
+ if (signal?.aborted) throw abortReason(signal);
52
+ try {
53
+ this.cookie = await invoke(
54
+ this.bus,
55
+ {
56
+ destination: SCREENSAVER_BUS_NAME,
57
+ path: objectPath,
58
+ interface: SCREENSAVER_INTERFACE,
59
+ member: "Inhibit",
60
+ signature: "ss",
61
+ body: [INHIBIT_APPLICATION_NAME, reason]
62
+ },
63
+ signal
64
+ );
65
+ this.objectPath = objectPath;
66
+ return;
67
+ } catch (error) {
68
+ if (signal?.aborted) throw abortReason(signal);
69
+ lastError = error;
70
+ }
71
+ }
72
+ throw new Error(`D-Bus idle inhibit failed: ${formatError(lastError)}`, {
73
+ cause: lastError
74
+ });
75
+ }
76
+ async uninhibit() {
77
+ if (this.cookie === void 0 || !this.objectPath) return;
78
+ const cookie = this.cookie;
79
+ this.cookie = void 0;
80
+ const objectPath = this.objectPath;
81
+ this.objectPath = void 0;
82
+ await invoke(this.bus, {
83
+ destination: SCREENSAVER_BUS_NAME,
84
+ path: objectPath,
85
+ interface: SCREENSAVER_INTERFACE,
86
+ member: "UnInhibit",
87
+ signature: "u",
88
+ body: [cookie]
89
+ });
90
+ }
91
+ async close() {
92
+ this.closing = true;
93
+ this.cookie = void 0;
94
+ this.objectPath = void 0;
95
+ this.failureHandler = void 0;
96
+ try {
97
+ await this.bus.close();
98
+ } finally {
99
+ this.bus.connection.off("error", this.handleConnectionError);
100
+ this.bus.connection.off("close", this.handleConnectionClose);
101
+ }
102
+ }
103
+ reportFailure(error) {
104
+ if (this.cookie === void 0) return;
105
+ this.cookie = void 0;
106
+ this.objectPath = void 0;
107
+ if (this.failureHandler) this.failureHandler(error);
108
+ else this.pendingFailure = error;
109
+ }
110
+ };
111
+ function invoke(bus, message, signal) {
112
+ return new Promise((resolve, reject) => {
113
+ bus.invoke(message, { signal, timeout: DBUS_CALL_TIMEOUT_MS }, (error, ...values) => {
114
+ if (error) reject(error);
115
+ else resolve(values[0]);
116
+ });
117
+ });
118
+ }
119
+ function abortReason(signal) {
120
+ return signal.reason ?? new DOMException("D-Bus idle inhibit cancelled", "AbortError");
121
+ }
122
+ function toError(error, fallback) {
123
+ return error instanceof Error ? error : new Error(fallback);
124
+ }
125
+ function formatError(error) {
126
+ if (error instanceof Error) {
127
+ return error.name === "Error" ? error.message : `${error.name}: ${error.message}`;
128
+ }
129
+ return String(error);
130
+ }
131
+
132
+ // src/inhibitor-process.ts
133
+ import { spawn } from "node:child_process";
134
+ import process from "node:process";
135
+ function startInhibitorProcess(command, onError, onUnexpectedExit) {
136
+ const child = spawn(command.command, command.args, {
137
+ detached: false,
138
+ stdio: [command.releaseOnStdinClose ? "pipe" : "ignore", "pipe", "pipe"]
139
+ });
140
+ child.once("error", onError);
141
+ child.once("exit", (code, signal) => onUnexpectedExit(formatExit(code, signal)));
142
+ return child;
143
+ }
144
+ function stopInhibitorProcess(child, command) {
145
+ child.removeAllListeners("exit");
146
+ child.removeAllListeners("error");
147
+ if (child.killed) return;
148
+ if (command?.releaseOnStdinClose && child.stdin && !child.stdin.destroyed) {
149
+ child.stdin.end();
150
+ if (child.exitCode === null && child.signalCode === null) {
151
+ const killTimer = setTimeout(() => {
152
+ if (child.exitCode === null && child.signalCode === null && !child.killed) child.kill();
153
+ }, 2e3);
154
+ killTimer.unref();
155
+ child.once("exit", () => clearTimeout(killTimer));
156
+ }
157
+ } else if (process.platform === "win32") {
158
+ child.kill();
159
+ } else {
160
+ child.kill("SIGTERM");
161
+ }
162
+ }
163
+ function formatExit(code, signal) {
164
+ if (signal) return `signal ${signal}`;
165
+ return `code ${code ?? "unknown"}`;
166
+ }
167
+
168
+ // src/inhibitors.ts
169
+ import { existsSync } from "node:fs";
170
+ import path from "node:path";
171
+ import process2 from "node:process";
172
+ function getInhibitorCommand(mode) {
173
+ const customCommand = process2.env.PI_CAFFEINATE_COMMAND?.trim();
174
+ if (customCommand) {
175
+ const [command, ...args] = splitCommand(customCommand);
176
+ if (command) return { command, args, description: `custom command (${command})`, custom: true };
177
+ }
178
+ if (process2.platform === "darwin") {
179
+ return parentBoundUnixCommand(
180
+ "caffeinate",
181
+ macCaffeinateArgs(mode),
182
+ caffeinateDescription(mode)
183
+ );
184
+ }
185
+ if (process2.platform === "linux") {
186
+ if (isWsl() && commandExists("powershell.exe")) {
187
+ return windowsPowerInhibitorCommand("powershell.exe", mode);
188
+ }
189
+ if (commandExists("systemd-inhibit")) {
190
+ const what = mode === "display" ? "idle:sleep" : "sleep";
191
+ return parentBoundUnixCommand(
192
+ "systemd-inhibit",
193
+ [
194
+ `--what=${what}`,
195
+ "--who=pi-caffeinate",
196
+ "--why=Pi agent is running",
197
+ "--mode=block",
198
+ "sleep",
199
+ "infinity"
200
+ ],
201
+ `systemd-inhibit (${formatMode(mode)})`,
202
+ mode === "display"
203
+ );
204
+ }
205
+ if (commandExists("caffeinate")) {
206
+ return parentBoundUnixCommand(
207
+ "caffeinate",
208
+ macCaffeinateArgs(mode),
209
+ caffeinateDescription(mode),
210
+ mode === "display"
211
+ );
212
+ }
213
+ }
214
+ if (process2.platform === "win32") return windowsPowerInhibitorCommand("powershell.exe", mode);
215
+ return void 0;
216
+ }
217
+ function macCaffeinateArgs(mode) {
218
+ return mode === "sleep" ? ["-ims"] : ["-dimsu"];
219
+ }
220
+ function caffeinateDescription(mode) {
221
+ return `caffeinate (${formatMode(mode)})`;
222
+ }
223
+ function parentBoundUnixCommand(command, args, description, addDbusIdleInhibit = false) {
224
+ return {
225
+ command: "sh",
226
+ args: [
227
+ "-c",
228
+ unixParentBoundScript(),
229
+ "pi-caffeinate-watch",
230
+ String(process2.pid),
231
+ command,
232
+ ...args
233
+ ],
234
+ description,
235
+ ...addDbusIdleInhibit ? { addDbusIdleInhibit: true } : {}
236
+ };
237
+ }
238
+ function unixParentBoundScript() {
239
+ return `parent=$1; shift; "$@" & child=$!; ( while kill -0 "$parent" 2>/dev/null; do sleep 5; done; kill "$child" 2>/dev/null ) & watcher=$!; cleanup() { kill "$watcher" 2>/dev/null; kill "$child" 2>/dev/null; wait "$child" 2>/dev/null; }; trap 'cleanup; exit 0' INT TERM HUP EXIT; wait "$child"; status=$?; kill "$watcher" 2>/dev/null; trap - EXIT; exit "$status"`;
240
+ }
241
+ function commandExists(command) {
242
+ const searchPath = process2.env.PATH ?? "";
243
+ const extensions = process2.platform === "win32" ? ["", ".exe", ".cmd", ".bat"] : [""];
244
+ for (const directory of searchPath.split(process2.platform === "win32" ? ";" : ":")) {
245
+ if (!directory) continue;
246
+ for (const extension of extensions) {
247
+ if (existsSync(path.join(directory, `${command}${extension}`))) return true;
248
+ }
249
+ }
250
+ return false;
251
+ }
252
+ function splitCommand(input) {
253
+ const parts = [];
254
+ let current = "";
255
+ let quote;
256
+ let escaping = false;
257
+ for (const char of input) {
258
+ if (escaping) {
259
+ current += char;
260
+ escaping = false;
261
+ continue;
262
+ }
263
+ if (char === "\\") {
264
+ escaping = true;
265
+ continue;
266
+ }
267
+ if ((char === '"' || char === "'") && !quote) {
268
+ quote = char;
269
+ continue;
270
+ }
271
+ if (char === quote) {
272
+ quote = void 0;
273
+ continue;
274
+ }
275
+ if (/\s/.test(char) && !quote) {
276
+ if (current) {
277
+ parts.push(current);
278
+ current = "";
279
+ }
280
+ continue;
281
+ }
282
+ current += char;
283
+ }
284
+ if (current) parts.push(current);
285
+ return parts;
286
+ }
287
+ function windowsPowerInhibitorCommand(command, mode) {
288
+ return {
289
+ command,
290
+ args: ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", windowsInhibitorScript(mode)],
291
+ description: `PowerShell SetThreadExecutionState (${formatMode(mode)})`,
292
+ releaseOnStdinClose: true
293
+ };
294
+ }
295
+ function windowsInhibitorScript(mode) {
296
+ const flags = mode === "sleep" ? "0x80000001" : "0x80000003";
297
+ return `$ErrorActionPreference = 'Stop'; Add-Type -Namespace Native -Name Power -MemberDefinition '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint esFlags);'; $flags = [uint32]'${flags}'; $release = [uint32]'0x80000000'; $stdin = [Console]::OpenStandardInput(); $buffer = New-Object byte[] 1; $readTask = $stdin.ReadAsync($buffer, 0, 1); try { while ($true) { [Native.Power]::SetThreadExecutionState($flags) | Out-Null; if ($readTask.Wait(30000)) { break } } } finally { [Native.Power]::SetThreadExecutionState($release) | Out-Null }`;
298
+ }
299
+ function isWsl() {
300
+ try {
301
+ return existsSync("/proc/sys/fs/binfmt_misc/WSLInterop");
302
+ } catch {
303
+ return false;
304
+ }
305
+ }
306
+ function formatMode(mode) {
307
+ return mode === "sleep" ? "system-awake" : "display-awake";
308
+ }
309
+
310
+ // src/settings.ts
311
+ import { randomUUID } from "node:crypto";
312
+ import { constants } from "node:fs";
313
+ import { access, lstat, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
314
+ import { dirname, join } from "node:path";
315
+ import process3 from "node:process";
316
+ import { getAgentDir } from "@earendil-works/pi-coding-agent";
317
+ var NEW_SETTINGS_FILE = "pi-caffeinate.json";
318
+ var LEGACY_SETTINGS_FILE = "pi-caffeinate-settings.json";
319
+ var DEFAULT_FILE_OPERATIONS = {
320
+ write: (path2, data) => writeFile(path2, data, "utf8").then(() => void 0),
321
+ rename
322
+ };
323
+ async function loadSettings() {
324
+ await settingsSaveQueue;
325
+ const newPath = settingsFilePath();
326
+ const newSettings = await readSettingsFile(newPath);
327
+ if (newSettings.kind !== "missing") return withLegacyIgnoredNotice(newSettings);
328
+ const legacyPath = legacySettingsFilePath();
329
+ const legacySettings = await readSettingsFile(legacyPath);
330
+ const concurrentlyCreatedSettings = await readSettingsFile(newPath);
331
+ if (concurrentlyCreatedSettings.kind !== "missing") {
332
+ return withLegacyIgnoredNotice(concurrentlyCreatedSettings);
333
+ }
334
+ if (legacySettings.kind === "missing") return { kind: "missing" };
335
+ if (legacySettings.kind === "invalid") return legacySettings;
336
+ return {
337
+ ...legacySettings,
338
+ notice: `Using legacy ${LEGACY_SETTINGS_FILE}; rename it to ${NEW_SETTINGS_FILE}. Future saves write ${NEW_SETTINGS_FILE} without modifying the legacy file.`
339
+ };
340
+ }
341
+ async function readSettingsDocument(filePath) {
342
+ let text;
343
+ try {
344
+ text = await readFile(filePath, "utf8");
345
+ } catch (error) {
346
+ if (isNodeError(error) && error.code === "ENOENT") return { result: { kind: "missing" } };
347
+ return { result: { kind: "invalid", reason: `${filePath}: ${formatError2(error)}` } };
348
+ }
349
+ try {
350
+ const document = JSON.parse(text);
351
+ const settings = normalizeCaffeinateSettings(document);
352
+ if (settings) {
353
+ return {
354
+ result: { kind: "loaded", settings },
355
+ document: { ...document }
356
+ };
357
+ }
358
+ return {
359
+ result: {
360
+ kind: "invalid",
361
+ reason: `${filePath}: expected { "mode": "sleep" | "display", optional "quiet": boolean }`
362
+ }
363
+ };
364
+ } catch (error) {
365
+ return { result: { kind: "invalid", reason: `${filePath}: ${formatError2(error)}` } };
366
+ }
367
+ }
368
+ async function readSettingsFile(filePath) {
369
+ return (await readSettingsDocument(filePath)).result;
370
+ }
371
+ async function withLegacyIgnoredNotice(settings) {
372
+ if (!await fileExists(legacySettingsFilePath())) return settings;
373
+ return {
374
+ ...settings,
375
+ notice: `pi-caffeinate legacy settings ignored: ${legacySettingsFilePath()} exists, but ${settingsFilePath()} takes precedence. Delete ${LEGACY_SETTINGS_FILE} after confirming your settings.`
376
+ };
377
+ }
378
+ async function fileExists(filePath) {
379
+ try {
380
+ await access(filePath, constants.F_OK);
381
+ return true;
382
+ } catch {
383
+ return false;
384
+ }
385
+ }
386
+ async function pathEntryExists(filePath) {
387
+ try {
388
+ await lstat(filePath);
389
+ return true;
390
+ } catch (error) {
391
+ if (isNodeError(error) && error.code === "ENOENT") return false;
392
+ throw error;
393
+ }
394
+ }
395
+ function normalizeCaffeinateSettings(value) {
396
+ if (!value || typeof value !== "object") return void 0;
397
+ const settings = value;
398
+ if (!isCaffeinateMode(settings.mode)) return void 0;
399
+ if (settings.quiet !== void 0 && typeof settings.quiet !== "boolean") return void 0;
400
+ if (settings.updatedAt !== void 0 && typeof settings.updatedAt !== "number") return void 0;
401
+ return {
402
+ mode: settings.mode,
403
+ quiet: settings.quiet ?? false,
404
+ updatedAt: settings.updatedAt ?? 0
405
+ };
406
+ }
407
+ function isCaffeinateMode(value) {
408
+ return value === "sleep" || value === "display";
409
+ }
410
+ var settingsSaveQueue = Promise.resolve();
411
+ function saveSettings(settings, operations = {}) {
412
+ const operation = settingsSaveQueue.then(() => saveSettingsNow(settings, operations));
413
+ settingsSaveQueue = operation.catch(() => void 0);
414
+ return operation;
415
+ }
416
+ async function saveSettingsNow(settings, operations) {
417
+ const filePath = settingsFilePath();
418
+ let current = await readSettingsDocument(filePath);
419
+ const replaceCanonical = current.result.kind !== "missing";
420
+ if (!replaceCanonical) current = await readSettingsDocument(legacySettingsFilePath());
421
+ if (current.result.kind === "invalid") {
422
+ throw new Error(`Cannot save pi-caffeinate settings until you repair ${current.result.reason}`);
423
+ }
424
+ const document = current.document ?? {};
425
+ const quiet = settings.quiet ?? (current.result.kind === "loaded" ? current.result.settings.quiet : false);
426
+ const nextSettings = { mode: settings.mode, quiet, updatedAt: settings.updatedAt };
427
+ const nextDocument = {
428
+ ...document,
429
+ ...nextSettings
430
+ };
431
+ await mkdir(dirname(filePath), { recursive: true });
432
+ const tempFile = `${filePath}.${process3.pid}.${randomUUID()}.tmp`;
433
+ try {
434
+ await (operations.write ?? DEFAULT_FILE_OPERATIONS.write)(
435
+ tempFile,
436
+ `${JSON.stringify(nextDocument, null, 2)}
437
+ `
438
+ );
439
+ if (!replaceCanonical && await pathEntryExists(filePath)) {
440
+ throw new Error(`${NEW_SETTINGS_FILE} was created concurrently; reopen settings and retry.`);
441
+ }
442
+ await (operations.rename ?? DEFAULT_FILE_OPERATIONS.rename)(tempFile, filePath);
443
+ return nextSettings;
444
+ } catch (error) {
445
+ await rm(tempFile, { force: true }).catch(() => void 0);
446
+ throw error;
447
+ }
448
+ }
449
+ function settingsFilePath() {
450
+ return join(agentDir(), NEW_SETTINGS_FILE);
451
+ }
452
+ function legacySettingsFilePath() {
453
+ return join(agentDir(), LEGACY_SETTINGS_FILE);
454
+ }
455
+ function agentDir() {
456
+ return getAgentDir();
457
+ }
458
+ function isNodeError(error) {
459
+ return error instanceof Error && "code" in error;
460
+ }
461
+ function formatError2(error) {
462
+ return error instanceof Error ? error.message : String(error);
463
+ }
464
+
465
+ // src/caffeinate.ts
466
+ var STATUS_KEY = "caffeinate";
467
+ var DISABLED_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
468
+ var DEFAULT_MODE = "display";
469
+ var COMMAND_COMPLETIONS = [
470
+ { value: "display", label: "display", description: "Keep system and display awake" },
471
+ { value: "sleep", label: "sleep", description: "Keep system awake; allow display sleep" },
472
+ { value: "status", label: "status", description: "Show current status" },
473
+ { value: "mode", label: "mode", description: "Choose keep-awake mode" },
474
+ { value: "stop", label: "stop", description: "Release inhibitor for now" },
475
+ { value: "help", label: "help", description: "Show command help" }
476
+ ];
477
+ var MENU_OPTIONS = {
478
+ display: "Keep system and display awake",
479
+ sleep: "Keep system awake; allow display sleep",
480
+ status: "Show current status",
481
+ stop: "Release inhibitor for now",
482
+ help: "Show command help"
483
+ };
484
+ var MODE_OPTIONS = {
485
+ display: "Keep system and display awake",
486
+ sleep: "Keep system awake; allow display sleep"
487
+ };
488
+ var state = {
489
+ activeTurns: 0,
490
+ available: true,
491
+ inhibitorStarting: false,
492
+ disabled: isDisabled(),
493
+ mode: DEFAULT_MODE,
494
+ quiet: false,
495
+ settingsLoaded: false,
496
+ iconWarningShown: false,
497
+ sessionGeneration: 0,
498
+ menuController: new AbortController()
499
+ };
500
+ var dbusFactory = defaultDbusScreenSaverFactory;
501
+ var inhibitSequence = 0;
502
+ function caffeinate(pi, options = {}) {
503
+ dbusFactory = options.dbusFactory ?? defaultDbusScreenSaverFactory;
504
+ pi.on("session_start", async (_event, ctx) => {
505
+ const generation = ++state.sessionGeneration;
506
+ state.currentSession = { generation, ctx };
507
+ replaceMenuController("Caffeinate session replaced");
508
+ state.iconWarningShown = false;
509
+ state.settingsNotice = void 0;
510
+ warnDeprecatedIcon(ctx);
511
+ await loadSettingsIntoState(ctx, generation);
512
+ if (generation !== state.sessionGeneration) return;
513
+ updateStatus(ctx);
514
+ });
515
+ pi.on("agent_start", async (_event, ctx) => {
516
+ const generation = state.sessionGeneration;
517
+ await ensureSettingsLoaded(ctx, generation);
518
+ if (generation !== state.sessionGeneration) return;
519
+ state.activeTurns += 1;
520
+ await startInhibitor(ctx, generation, { notify: !state.quiet });
521
+ });
522
+ pi.on("agent_end", async (_event, ctx) => {
523
+ const generation = state.sessionGeneration;
524
+ state.activeTurns = Math.max(0, state.activeTurns - 1);
525
+ if (state.activeTurns === 0) {
526
+ await stopInhibitor(ctx, "agent finished", { notify: !state.quiet });
527
+ }
528
+ if (generation !== state.sessionGeneration) return;
529
+ updateStatus(ctx);
530
+ });
531
+ pi.on("session_shutdown", async (_event, ctx) => {
532
+ const generation = ++state.sessionGeneration;
533
+ state.currentSession = void 0;
534
+ state.menuController.abort(new DOMException("Caffeinate session shut down", "AbortError"));
535
+ state.activeTurns = 0;
536
+ await stopInhibitor(ctx, "session shutdown", { notify: false });
537
+ await modeOperationQueue;
538
+ if (generation !== state.sessionGeneration) return;
539
+ ctx.ui.setStatus(STATUS_KEY, void 0);
540
+ });
541
+ pi.registerCommand("caffeinate", {
542
+ description: "Open pi-caffeinate keep-awake controls",
543
+ getArgumentCompletions: (prefix) => commandCompletions(prefix),
544
+ handler: async (args, ctx) => {
545
+ const generation = state.sessionGeneration;
546
+ const command = parseCommand(args);
547
+ if (command === "sleep" || command === "display") {
548
+ await setModeAfterSettingsLoad(ctx, command, generation);
549
+ return;
550
+ }
551
+ await ensureSettingsLoaded(ctx, generation);
552
+ if (generation !== state.sessionGeneration) return;
553
+ await handleCaffeinateCommand(args, ctx, generation);
554
+ }
555
+ });
556
+ }
557
+ async function handleCaffeinateCommand(args, ctx, generation) {
558
+ const command = parseCommand(args);
559
+ switch (command) {
560
+ case "menu":
561
+ await showMenu(ctx, generation);
562
+ return;
563
+ case "help":
564
+ ctx.ui.notify(buildCommandGuide(), "info");
565
+ return;
566
+ case "status":
567
+ showStatus(ctx);
568
+ return;
569
+ case "mode":
570
+ await showModeSelector(ctx, generation);
571
+ return;
572
+ case "sleep":
573
+ await setMode(ctx, "sleep", generation);
574
+ return;
575
+ case "display":
576
+ await setMode(ctx, "display", generation);
577
+ return;
578
+ case "stop":
579
+ await stopCaffeinate(ctx, "manual stop", generation);
580
+ return;
581
+ }
582
+ ctx.ui.notify(`Unknown /caffeinate command: ${args.trim()}
583
+
584
+ ${buildCommandGuide()}`, "warning");
585
+ }
586
+ async function showMenu(ctx, generation) {
587
+ await runCaffeinateMenu(ctx, generation, "main");
588
+ }
589
+ async function showModeSelector(ctx, generation) {
590
+ await runCaffeinateMenu(ctx, generation, "mode");
591
+ }
592
+ async function runCaffeinateMenu(ctx, generation, start) {
593
+ if (!ctx.hasUI) {
594
+ throw new Error(
595
+ start === "mode" ? "Mode selection requires TUI or RPC mode. Use /caffeinate sleep or /caffeinate display." : `The pi-caffeinate menu requires TUI or RPC mode.
596
+
597
+ ${buildCommandGuide()}
598
+
599
+ ${describeState()}`
600
+ );
601
+ }
602
+ const menuSignal = state.menuController.signal;
603
+ const isCurrent = () => generation === state.sessionGeneration && !menuSignal.aborted;
604
+ const { defineMenu, runMenu } = await import("@narumitw/pi-tui-kit");
605
+ if (!isCurrent()) return;
606
+ const menu = defineMenu({
607
+ start,
608
+ screens: {
609
+ main: () => ({
610
+ kind: "actions",
611
+ title: "pi-caffeinate controls",
612
+ lines: describeState().split("\n"),
613
+ items: Object.entries(MENU_OPTIONS).map(([id, label]) => ({
614
+ id,
615
+ label,
616
+ action: id
617
+ })),
618
+ hint: "close"
619
+ }),
620
+ mode: () => ({
621
+ kind: "actions",
622
+ title: `pi-caffeinate mode (current: ${formatMode(state.mode)})`,
623
+ items: Object.entries(MODE_OPTIONS).map(([id, label]) => ({
624
+ id,
625
+ label,
626
+ action: id
627
+ })),
628
+ hint: "close"
629
+ })
630
+ },
631
+ actions: {
632
+ display: async () => {
633
+ await setMode(ctx, "display", generation);
634
+ return { kind: "close" };
635
+ },
636
+ sleep: async () => {
637
+ await setMode(ctx, "sleep", generation);
638
+ return { kind: "close" };
639
+ },
640
+ status: async () => {
641
+ showStatus(ctx);
642
+ return { kind: "close" };
643
+ },
644
+ stop: async () => {
645
+ await stopCaffeinate(ctx, "manual stop", generation);
646
+ return { kind: "close" };
647
+ },
648
+ help: async () => {
649
+ ctx.ui.notify(buildCommandGuide(), "info");
650
+ return { kind: "close" };
651
+ }
652
+ }
653
+ });
654
+ await runMenu(ctx, menu, {
655
+ getState: () => void 0,
656
+ signal: menuSignal,
657
+ isCurrent
658
+ });
659
+ }
660
+ function replaceMenuController(reason) {
661
+ state.menuController.abort(new DOMException(reason, "AbortError"));
662
+ state.menuController = new AbortController();
663
+ }
664
+ var modeOperationQueue = Promise.resolve();
665
+ function setModeAfterSettingsLoad(ctx, mode, generation) {
666
+ return enqueueModeOperation(async () => {
667
+ await ensureSettingsLoaded(ctx, generation);
668
+ if (generation !== state.sessionGeneration) return;
669
+ await setModeNow(ctx, mode, generation);
670
+ });
671
+ }
672
+ function setMode(ctx, mode, generation) {
673
+ return enqueueModeOperation(() => setModeNow(ctx, mode, generation));
674
+ }
675
+ function enqueueModeOperation(operation) {
676
+ const queued = modeOperationQueue.then(operation);
677
+ modeOperationQueue = queued.catch(() => void 0);
678
+ return queued;
679
+ }
680
+ async function setModeNow(ctx, mode, generation) {
681
+ if (generation !== state.sessionGeneration) return;
682
+ const previousMode = state.mode;
683
+ const previousQuiet = state.quiet;
684
+ const restartRequired = Boolean(
685
+ hasActiveInhibitor() && previousMode !== mode && !state.command?.custom
686
+ );
687
+ state.settingsError = void 0;
688
+ if (restartRequired) {
689
+ state.mode = mode;
690
+ await stopInhibitor(ctx, "mode changed", { notify: false });
691
+ if (generation !== state.sessionGeneration) return;
692
+ await startInhibitor(ctx, generation, { notify: false });
693
+ if (generation !== state.sessionGeneration) return;
694
+ if (!hasActiveInhibitor()) {
695
+ const applicationError = state.lastError ?? "the inhibitor could not be restarted";
696
+ state.mode = previousMode;
697
+ await startInhibitor(ctx, generation, { notify: false });
698
+ if (generation !== state.sessionGeneration) return;
699
+ const rollbackError = hasActiveInhibitor() ? void 0 : state.lastError ?? "the previous inhibitor could not be restored";
700
+ state.settingsError = rollbackError ? `mode application failed (${applicationError}); runtime rollback failed: ${rollbackError}` : `mode application failed and was rolled back: ${applicationError}`;
701
+ ctx.ui.notify(`pi-caffeinate ${state.settingsError}`, "warning");
702
+ updateStatus(ctx);
703
+ return;
704
+ }
705
+ }
706
+ let savedSettings;
707
+ try {
708
+ savedSettings = await saveSettings({ mode, updatedAt: Date.now() });
709
+ } catch (error) {
710
+ if (generation !== state.sessionGeneration) return;
711
+ let rollbackError;
712
+ if (restartRequired) {
713
+ state.mode = previousMode;
714
+ state.quiet = previousQuiet;
715
+ await stopInhibitor(ctx, "settings save failed", { notify: false });
716
+ if (generation !== state.sessionGeneration) return;
717
+ await startInhibitor(ctx, generation, { notify: false });
718
+ if (generation !== state.sessionGeneration) return;
719
+ if (!hasActiveInhibitor()) {
720
+ rollbackError = state.lastError ?? "the prior inhibitor was not restored";
721
+ }
722
+ }
723
+ state.settingsError = rollbackError ? `settings save failed (${formatError3(error)}); runtime rollback failed: ${rollbackError}` : `settings save failed: ${formatError3(error)}`;
724
+ ctx.ui.notify(
725
+ `pi-caffeinate mode remains ${formatMode(previousMode)}; settings were not saved: ${state.settingsError}`,
726
+ "warning"
727
+ );
728
+ updateStatus(ctx);
729
+ return;
730
+ }
731
+ if (generation !== state.sessionGeneration) return;
732
+ state.mode = mode;
733
+ state.quiet = savedSettings.quiet;
734
+ ctx.ui.notify(`pi-caffeinate mode set to ${formatMode(mode)} and saved.`, "info");
735
+ updateStatus(ctx);
736
+ }
737
+ function showStatus(ctx) {
738
+ ctx.ui.notify(describeState(), statusLevel());
739
+ updateStatus(ctx);
740
+ }
741
+ async function stopCaffeinate(ctx, reason, sessionGeneration) {
742
+ state.activeTurns = 0;
743
+ await stopInhibitor(ctx, reason);
744
+ if (sessionGeneration !== state.sessionGeneration) return;
745
+ updateStatus(ctx);
746
+ }
747
+ function parseCommand(args) {
748
+ const command = args.trim().toLowerCase();
749
+ if (!command) return "menu";
750
+ if (command === "help") return "help";
751
+ if (command === "status") return "status";
752
+ if (command === "mode" || command === "config" || command === "settings") return "mode";
753
+ if (command === "sleep" || command === "system") return "sleep";
754
+ if (command === "display" || command === "screen") return "display";
755
+ if (command === "stop" || command === "off") return "stop";
756
+ return "unknown";
757
+ }
758
+ function commandCompletions(prefix) {
759
+ const normalized = prefix.trimStart().toLowerCase();
760
+ if (/\s/.test(normalized)) return null;
761
+ const matches = COMMAND_COMPLETIONS.filter(
762
+ (completion) => completion.value.startsWith(normalized)
763
+ );
764
+ return matches.length > 0 ? matches : null;
765
+ }
766
+ function buildCommandGuide() {
767
+ return [
768
+ "pi-caffeinate commands:",
769
+ "/caffeinate \u2014 open keep-awake controls",
770
+ "/caffeinate display \u2014 keep the system and display awake",
771
+ "/caffeinate sleep \u2014 keep the system awake while allowing display sleep",
772
+ "/caffeinate status \u2014 show current mode, settings, and inhibitor state",
773
+ "/caffeinate mode \u2014 choose a keep-awake mode",
774
+ "/caffeinate stop \u2014 release the active inhibitor until the next agent run"
775
+ ].join("\n");
776
+ }
777
+ async function startInhibitor(ctx, sessionGeneration, options = {}) {
778
+ if (state.disabled || hasActiveInhibitor() || state.inhibitorStarting) {
779
+ updateStatus(ctx);
780
+ return;
781
+ }
782
+ const token = ++inhibitSequence;
783
+ const command = getInhibitorCommand(state.mode);
784
+ const wantsDbus = !command?.custom && state.mode === "display" && process4.platform === "linux" && (command === void 0 || command.addDbusIdleInhibit === true);
785
+ if (!command && !wantsDbus) {
786
+ state.available = false;
787
+ state.lastError = `No supported sleep inhibitor found for ${process4.platform}.`;
788
+ ctx.ui.notify(state.lastError, "warning");
789
+ updateStatus(ctx);
790
+ return;
791
+ }
792
+ state.inhibitorStarting = true;
793
+ state.inhibitWarning = void 0;
794
+ let child;
795
+ let childError = !command && wantsDbus ? "No supported system sleep inhibitor is available; direct system suspend may remain possible." : void 0;
796
+ let assembling = true;
797
+ const handleChildFailure = (message) => {
798
+ if (!child || token !== inhibitSequence || state.process !== child) return;
799
+ state.process = void 0;
800
+ state.command = void 0;
801
+ if (assembling) {
802
+ childError = message;
803
+ return;
804
+ }
805
+ applyChildFailure(message);
806
+ };
807
+ if (command) {
808
+ try {
809
+ child = startInhibitorProcess(
810
+ command,
811
+ (error) => handleChildFailure(`${command.description} failed: ${error.message}`),
812
+ (exit) => handleChildFailure(`${command.description} exited unexpectedly (${exit}).`)
813
+ );
814
+ state.process = child;
815
+ state.command = command;
816
+ state.startedAt = Date.now();
817
+ } catch (error) {
818
+ childError = `${command.description}: ${formatError3(error)}`;
819
+ }
820
+ }
821
+ let dbus;
822
+ let dbusError;
823
+ if (wantsDbus) {
824
+ const pending = { token, controller: new AbortController() };
825
+ state.pendingDbus = pending;
826
+ try {
827
+ const client = await dbusFactory();
828
+ if (!pendingStartIsCurrent(pending, sessionGeneration)) {
829
+ await client.close().catch(() => void 0);
830
+ await cancelPendingStart(token, child, command);
831
+ return;
832
+ }
833
+ pending.client = client;
834
+ await client.inhibit(INHIBIT_REASON, pending.controller.signal);
835
+ if (!pendingStartIsCurrent(pending, sessionGeneration)) {
836
+ await cancelPendingStart(token, child, command);
837
+ return;
838
+ }
839
+ pending.client = void 0;
840
+ state.pendingDbus = void 0;
841
+ dbus = client;
842
+ } catch (error) {
843
+ const stale = !pendingStartIsCurrent(pending, sessionGeneration) || pending.controller.signal.aborted;
844
+ const pendingClient = takePendingDbusClient(pending);
845
+ await pendingClient?.close().catch(() => void 0);
846
+ if (stale) {
847
+ await cancelPendingStart(token, child, command);
848
+ return;
849
+ }
850
+ dbusError = `D-Bus idle inhibit (${SCREENSAVER_BUS_NAME}): ${formatError3(error)}`;
851
+ }
852
+ }
853
+ assembling = false;
854
+ if (startIsStale(token, sessionGeneration)) {
855
+ await cancelPendingStart(token, child, command);
856
+ await dbus?.close().catch(() => void 0);
857
+ return;
858
+ }
859
+ state.inhibitorStarting = false;
860
+ state.dbus = dbus;
861
+ if (dbus) {
862
+ dbus.setFailureHandler((error) => applyDbusFailure(token, dbus, error));
863
+ if (state.dbus !== dbus) return;
864
+ }
865
+ const failures = [childError, dbusError].filter((failure) => Boolean(failure));
866
+ if (!hasActiveInhibitor()) {
867
+ state.startedAt = void 0;
868
+ state.command = void 0;
869
+ state.available = false;
870
+ state.lastError = failures.join("; ") || `No supported sleep inhibitor found for ${process4.platform}.`;
871
+ ctx.ui.notify(state.lastError, "warning");
872
+ updateStatus(ctx);
873
+ return;
874
+ }
875
+ state.startedAt ??= Date.now();
876
+ state.available = true;
877
+ state.lastError = void 0;
878
+ state.inhibitWarning = failures.length > 0 ? failures.join("; ") : void 0;
879
+ if (state.inhibitWarning) {
880
+ ctx.ui.notify(`pi-caffeinate is partially active: ${state.inhibitWarning}`, "warning");
881
+ } else if (options.notify !== false) {
882
+ ctx.ui.notify(`Keeping computer awake (${statusModeLabel()}).`, "info");
883
+ }
884
+ updateStatus(ctx);
885
+ }
886
+ async function stopInhibitor(ctx, reason, options = {}) {
887
+ inhibitSequence += 1;
888
+ const child = state.process;
889
+ const dbus = state.dbus;
890
+ const dbusCleanup = state.dbusCleanup;
891
+ const pending = state.pendingDbus;
892
+ const command = state.command;
893
+ const wasStarting = state.inhibitorStarting;
894
+ state.process = void 0;
895
+ state.dbus = void 0;
896
+ state.dbusCleanup = void 0;
897
+ state.pendingDbus = void 0;
898
+ state.command = void 0;
899
+ state.startedAt = void 0;
900
+ state.inhibitWarning = void 0;
901
+ state.inhibitorStarting = false;
902
+ dbus?.setFailureHandler(void 0);
903
+ pending?.controller.abort(new DOMException(`Caffeinate stopped: ${reason}`, "AbortError"));
904
+ const pendingClient = pending ? takePendingDbusClient(pending) : void 0;
905
+ if (child) stopInhibitorProcess(child, command);
906
+ if (!child && !dbus && !pendingClient && !wasStarting) {
907
+ await dbusCleanup;
908
+ return;
909
+ }
910
+ if (options.notify !== false) ctx.ui.notify(`Released pi-caffeinate (${reason}).`, "info");
911
+ await Promise.all([dbusCleanup, pendingClient?.close().catch(() => void 0)]);
912
+ if (!dbus) return;
913
+ try {
914
+ await dbus.uninhibit();
915
+ } catch {
916
+ }
917
+ await dbus.close().catch(() => void 0);
918
+ }
919
+ function applyChildFailure(message) {
920
+ if (state.dbus) {
921
+ state.available = true;
922
+ state.lastError = void 0;
923
+ state.inhibitWarning = message;
924
+ } else {
925
+ state.startedAt = void 0;
926
+ state.available = false;
927
+ state.lastError = message;
928
+ state.inhibitWarning = void 0;
929
+ }
930
+ const ctx = currentSessionContext();
931
+ if (!ctx) return;
932
+ ctx.ui.notify(message, "warning");
933
+ updateStatus(ctx);
934
+ }
935
+ function applyDbusFailure(token, client, error) {
936
+ if (token !== inhibitSequence || state.dbus !== client) return;
937
+ client.setFailureHandler(void 0);
938
+ state.dbus = void 0;
939
+ const message = `D-Bus idle inhibit (${SCREENSAVER_BUS_NAME}) failed: ${formatError3(error)}`;
940
+ const notification = state.process ? `pi-caffeinate is partially active: ${message}` : message;
941
+ if (state.process) {
942
+ state.available = true;
943
+ state.lastError = void 0;
944
+ state.inhibitWarning = message;
945
+ } else {
946
+ state.startedAt = void 0;
947
+ state.command = void 0;
948
+ state.available = false;
949
+ state.lastError = [state.inhibitWarning, message].filter(Boolean).join("; ");
950
+ state.inhibitWarning = void 0;
951
+ }
952
+ const cleanup = client.close().catch(() => void 0);
953
+ state.dbusCleanup = cleanup;
954
+ void cleanup.then(() => {
955
+ if (state.dbusCleanup === cleanup) state.dbusCleanup = void 0;
956
+ });
957
+ const ctx = currentSessionContext();
958
+ if (!ctx) return;
959
+ ctx.ui.notify(notification, "warning");
960
+ updateStatus(ctx);
961
+ }
962
+ function currentSessionContext() {
963
+ const session = state.currentSession;
964
+ return session?.generation === state.sessionGeneration ? session.ctx : void 0;
965
+ }
966
+ function hasActiveInhibitor() {
967
+ return Boolean(state.process || state.dbus);
968
+ }
969
+ function startIsStale(token, sessionGeneration) {
970
+ return token !== inhibitSequence || sessionGeneration !== state.sessionGeneration;
971
+ }
972
+ function pendingStartIsCurrent(pending, sessionGeneration) {
973
+ return state.pendingDbus === pending && !pending.controller.signal.aborted && !startIsStale(pending.token, sessionGeneration);
974
+ }
975
+ function takePendingDbusClient(pending) {
976
+ if (state.pendingDbus === pending) state.pendingDbus = void 0;
977
+ const client = pending.client;
978
+ pending.client = void 0;
979
+ return client;
980
+ }
981
+ async function cancelPendingStart(token, child, command) {
982
+ if (token !== inhibitSequence) return;
983
+ inhibitSequence += 1;
984
+ state.inhibitorStarting = false;
985
+ const pending = state.pendingDbus?.token === token ? state.pendingDbus : void 0;
986
+ state.pendingDbus = void 0;
987
+ pending?.controller.abort(new DOMException("Caffeinate start cancelled", "AbortError"));
988
+ const pendingClient = pending ? takePendingDbusClient(pending) : void 0;
989
+ if (child && state.process === child) {
990
+ state.process = void 0;
991
+ state.command = void 0;
992
+ state.startedAt = void 0;
993
+ stopInhibitorProcess(child, command);
994
+ }
995
+ await pendingClient?.close().catch(() => void 0);
996
+ }
997
+ function updateStatus(ctx) {
998
+ if (state.disabled || state.quiet) {
999
+ ctx.ui.setStatus(STATUS_KEY, void 0);
1000
+ return;
1001
+ }
1002
+ if (hasActiveInhibitor()) {
1003
+ ctx.ui.setStatus(STATUS_KEY, withDeprecatedIcon(statusModeLabel()));
1004
+ return;
1005
+ }
1006
+ if (!state.available) {
1007
+ ctx.ui.setStatus(STATUS_KEY, withDeprecatedIcon("unavailable"));
1008
+ return;
1009
+ }
1010
+ ctx.ui.setStatus(STATUS_KEY, void 0);
1011
+ }
1012
+ function describeState() {
1013
+ const customCommand = hasCustomCommand();
1014
+ const lines = [
1015
+ `Mode: ${formatMode(state.mode)}${customCommand ? " (overridden by custom command)" : ""}`,
1016
+ `Quiet mode: ${state.quiet ? "enabled" : "disabled"}`,
1017
+ `Settings: ${settingsFilePath()}`
1018
+ ];
1019
+ if (customCommand) lines.push("Custom command: PI_CAFFEINATE_COMMAND overrides the saved mode.");
1020
+ if (state.settingsNotice) lines.push(`Settings note: ${state.settingsNotice}`);
1021
+ if (state.settingsError) lines.push(`Settings warning: ${state.settingsError}`);
1022
+ if (state.disabled) {
1023
+ lines.unshift("pi-caffeinate is disabled by PI_CAFFEINATE_DISABLED.");
1024
+ return lines.join("\n");
1025
+ }
1026
+ if (hasActiveInhibitor()) {
1027
+ const seconds = state.startedAt ? Math.round((Date.now() - state.startedAt) / 1e3) : 0;
1028
+ const activeParts = [];
1029
+ if (state.dbus) activeParts.push(`D-Bus idle inhibit (${SCREENSAVER_BUS_NAME})`);
1030
+ if (state.process && state.command) activeParts.push(state.command.description);
1031
+ lines.unshift(
1032
+ `pi-caffeinate is active using ${activeParts.join(" + ") || "an inhibitor"} for ${seconds}s.`
1033
+ );
1034
+ if (state.inhibitWarning) lines.push(`Inhibitor warning: ${state.inhibitWarning}`);
1035
+ return lines.join("\n");
1036
+ }
1037
+ if (!state.available) {
1038
+ lines.unshift(`pi-caffeinate is unavailable: ${state.lastError ?? "unknown reason"}`);
1039
+ return lines.join("\n");
1040
+ }
1041
+ lines.unshift(
1042
+ "pi-caffeinate is idle and will keep the computer awake during the next agent run."
1043
+ );
1044
+ return lines.join("\n");
1045
+ }
1046
+ function statusLevel() {
1047
+ return state.available && !state.settingsError && !state.inhibitWarning ? "info" : "warning";
1048
+ }
1049
+ function statusModeLabel() {
1050
+ if (state.command?.custom) return "custom";
1051
+ return formatMode(state.mode);
1052
+ }
1053
+ async function ensureSettingsLoaded(ctx, generation) {
1054
+ if (state.disabled || state.settingsLoaded) return;
1055
+ await loadSettingsIntoState(ctx, generation);
1056
+ }
1057
+ async function loadSettingsIntoState(ctx, generation) {
1058
+ if (state.disabled) {
1059
+ state.settingsLoaded = true;
1060
+ state.settingsError = void 0;
1061
+ state.quiet = false;
1062
+ return;
1063
+ }
1064
+ const settings = await loadSettings();
1065
+ if (generation !== state.sessionGeneration) return;
1066
+ state.settingsLoaded = true;
1067
+ state.settingsError = void 0;
1068
+ if (settings.notice) {
1069
+ state.settingsNotice = settings.notice;
1070
+ ctx.ui.notify(settings.notice, "warning");
1071
+ }
1072
+ if (settings.kind === "loaded") {
1073
+ state.mode = settings.settings.mode;
1074
+ state.quiet = settings.settings.quiet;
1075
+ return;
1076
+ }
1077
+ state.mode = DEFAULT_MODE;
1078
+ state.quiet = false;
1079
+ if (settings.kind === "invalid") {
1080
+ state.settingsError = settings.reason;
1081
+ ctx.ui.notify(
1082
+ `pi-caffeinate settings ignored: ${settings.reason}; using ${formatMode(DEFAULT_MODE)} mode.`,
1083
+ "warning"
1084
+ );
1085
+ }
1086
+ }
1087
+ function formatError3(error) {
1088
+ return error instanceof Error ? error.message : String(error);
1089
+ }
1090
+ function isDisabled() {
1091
+ const value = process4.env.PI_CAFFEINATE_DISABLED?.trim().toLowerCase();
1092
+ return value ? DISABLED_VALUES.has(value) : false;
1093
+ }
1094
+ function hasCustomCommand() {
1095
+ return Boolean(process4.env.PI_CAFFEINATE_COMMAND?.trim());
1096
+ }
1097
+ function withDeprecatedIcon(text) {
1098
+ const icon = process4.env.PI_CAFFEINATE_ICON?.trim();
1099
+ return icon ? `${icon} ${text}` : text;
1100
+ }
1101
+ function warnDeprecatedIcon(ctx) {
1102
+ if (state.iconWarningShown || !process4.env.PI_CAFFEINATE_ICON?.trim()) return;
1103
+ state.iconWarningShown = true;
1104
+ ctx.ui.notify(
1105
+ "PI_CAFFEINATE_ICON is deprecated but still works for now. If you use @narumitw/pi-statusline, move it to pi-statusline.json (extensionStatusIcons.caffeinate).",
1106
+ "warning"
1107
+ );
1108
+ }
1109
+ export {
1110
+ caffeinate as default
1111
+ };
1112
+ //# sourceMappingURL=index.ts.map