@undefineds.co/linx 0.3.26 → 0.3.28

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 (362) hide show
  1. package/README.md +4 -3
  2. package/dist/index.js +3 -832
  3. package/dist/index.js.map +1 -1
  4. package/dist/lib/agent-stream-bridge-contract.js +2 -0
  5. package/dist/lib/agent-stream-bridge-contract.js.map +1 -0
  6. package/dist/lib/auto-mode/auth.js +100 -2
  7. package/dist/lib/auto-mode/auth.js.map +1 -1
  8. package/dist/lib/auto-mode/backend-kind.js +13 -0
  9. package/dist/lib/auto-mode/backend-kind.js.map +1 -0
  10. package/dist/lib/auto-mode/display.js +1 -1
  11. package/dist/lib/auto-mode/display.js.map +1 -1
  12. package/dist/lib/auto-mode/format.js +1 -1
  13. package/dist/lib/auto-mode/format.js.map +1 -1
  14. package/dist/lib/auto-mode/hooks/{index.js → registry.js} +1 -1
  15. package/dist/lib/auto-mode/hooks/registry.js.map +1 -0
  16. package/dist/lib/auto-mode/pod-ai.js +1 -14
  17. package/dist/lib/auto-mode/pod-ai.js.map +1 -1
  18. package/dist/lib/auto-mode/pod-approval-store.js +596 -0
  19. package/dist/lib/auto-mode/pod-approval-store.js.map +1 -0
  20. package/dist/lib/auto-mode/pod-approval.js +4 -607
  21. package/dist/lib/auto-mode/pod-approval.js.map +1 -1
  22. package/dist/lib/auto-mode/pod-persistence-builders.js +266 -0
  23. package/dist/lib/auto-mode/pod-persistence-builders.js.map +1 -0
  24. package/dist/lib/auto-mode/pod-persistence.js +1 -281
  25. package/dist/lib/auto-mode/pod-persistence.js.map +1 -1
  26. package/dist/lib/auto-mode/runner.js +41 -378
  27. package/dist/lib/auto-mode/runner.js.map +1 -1
  28. package/dist/lib/auto-mode/runtime.js +25 -0
  29. package/dist/lib/auto-mode/runtime.js.map +1 -0
  30. package/dist/lib/auto-mode/secretary-reaction-window.js +12 -0
  31. package/dist/lib/auto-mode/secretary-reaction-window.js.map +1 -0
  32. package/dist/lib/auto-mode/secretary-runtime-config.js +66 -0
  33. package/dist/lib/auto-mode/secretary-runtime-config.js.map +1 -0
  34. package/dist/lib/auto-mode/secretary.js +2 -64
  35. package/dist/lib/auto-mode/secretary.js.map +1 -1
  36. package/dist/lib/auto-mode/session-log.js +25 -0
  37. package/dist/lib/auto-mode/session-log.js.map +1 -0
  38. package/dist/lib/auto-mode/shell-command.js +172 -0
  39. package/dist/lib/auto-mode/shell-command.js.map +1 -0
  40. package/dist/lib/auto-mode-command.js +2 -1
  41. package/dist/lib/auto-mode-command.js.map +1 -1
  42. package/dist/lib/backend-command-router-contract.js +2 -0
  43. package/dist/lib/backend-command-router-contract.js.map +1 -0
  44. package/dist/lib/{pi-adapter/backend-credentials.js → backend-credentials.js} +8 -8
  45. package/dist/lib/backend-credentials.js.map +1 -0
  46. package/dist/lib/linx-ai-connect-command.js +201 -0
  47. package/dist/lib/linx-ai-connect-command.js.map +1 -0
  48. package/dist/lib/linx-assistant-message-rendering.js +33 -0
  49. package/dist/lib/linx-assistant-message-rendering.js.map +1 -0
  50. package/dist/lib/linx-auto-command-routing.js +53 -0
  51. package/dist/lib/linx-auto-command-routing.js.map +1 -0
  52. package/dist/lib/linx-auto-editor-indicator-host.js +15 -0
  53. package/dist/lib/linx-auto-editor-indicator-host.js.map +1 -0
  54. package/dist/lib/linx-auto-editor-indicator.js +56 -0
  55. package/dist/lib/linx-auto-editor-indicator.js.map +1 -0
  56. package/dist/lib/linx-auto-mode-cli-admission.js +16 -0
  57. package/dist/lib/linx-auto-mode-cli-admission.js.map +1 -0
  58. package/dist/lib/linx-backend-command-router.js +64 -0
  59. package/dist/lib/linx-backend-command-router.js.map +1 -0
  60. package/dist/lib/linx-backend-event-source.js +32 -0
  61. package/dist/lib/linx-backend-event-source.js.map +1 -0
  62. package/dist/lib/linx-chat-completion-projection.js +276 -0
  63. package/dist/lib/linx-chat-completion-projection.js.map +1 -0
  64. package/dist/lib/linx-cloud-errors.js +1 -0
  65. package/dist/lib/linx-cloud-errors.js.map +1 -1
  66. package/dist/lib/linx-cloud-models.js +75 -0
  67. package/dist/lib/linx-cloud-models.js.map +1 -0
  68. package/dist/lib/linx-cloud-runtime-auth.js +146 -0
  69. package/dist/lib/linx-cloud-runtime-auth.js.map +1 -0
  70. package/dist/lib/linx-cloud-runtime-coordinator.js +102 -0
  71. package/dist/lib/linx-cloud-runtime-coordinator.js.map +1 -0
  72. package/dist/lib/linx-codex-plugin-command.js +56 -0
  73. package/dist/lib/linx-codex-plugin-command.js.map +1 -0
  74. package/dist/lib/linx-command-autocomplete.js +123 -0
  75. package/dist/lib/linx-command-autocomplete.js.map +1 -0
  76. package/dist/lib/linx-completion-backend.js +2 -0
  77. package/dist/lib/linx-completion-backend.js.map +1 -0
  78. package/dist/lib/linx-config-command.js +12 -0
  79. package/dist/lib/linx-config-command.js.map +1 -0
  80. package/dist/lib/linx-editor-component-router.js +83 -0
  81. package/dist/lib/linx-editor-component-router.js.map +1 -0
  82. package/dist/lib/linx-extension-ui-context-router.js +43 -0
  83. package/dist/lib/linx-extension-ui-context-router.js.map +1 -0
  84. package/dist/lib/linx-external-open-host.js +8 -0
  85. package/dist/lib/linx-external-open-host.js.map +1 -0
  86. package/dist/lib/linx-external-url.js +16 -0
  87. package/dist/lib/linx-external-url.js.map +1 -0
  88. package/dist/lib/linx-footer-patch.js +52 -0
  89. package/dist/lib/linx-footer-patch.js.map +1 -0
  90. package/dist/lib/linx-input-command-routing.js +65 -0
  91. package/dist/lib/linx-input-command-routing.js.map +1 -0
  92. package/dist/lib/linx-interactive-auth-state-host.js +50 -0
  93. package/dist/lib/linx-interactive-auth-state-host.js.map +1 -0
  94. package/dist/lib/linx-interactive-autocomplete-host.js +32 -0
  95. package/dist/lib/linx-interactive-autocomplete-host.js.map +1 -0
  96. package/dist/lib/linx-interactive-bootstrap.js +66 -0
  97. package/dist/lib/linx-interactive-bootstrap.js.map +1 -0
  98. package/dist/lib/linx-interactive-branding.js +24 -0
  99. package/dist/lib/linx-interactive-branding.js.map +1 -0
  100. package/dist/lib/linx-interactive-chat-text-host.js +16 -0
  101. package/dist/lib/linx-interactive-chat-text-host.js.map +1 -0
  102. package/dist/lib/linx-interactive-command-routing-host.js +31 -0
  103. package/dist/lib/linx-interactive-command-routing-host.js.map +1 -0
  104. package/dist/lib/linx-interactive-command-routing.js +75 -0
  105. package/dist/lib/linx-interactive-command-routing.js.map +1 -0
  106. package/dist/lib/linx-interactive-command-surface.js +16 -0
  107. package/dist/lib/linx-interactive-command-surface.js.map +1 -0
  108. package/dist/lib/linx-interactive-editor-text-host.js +16 -0
  109. package/dist/lib/linx-interactive-editor-text-host.js.map +1 -0
  110. package/dist/lib/linx-interactive-error-display.js +8 -0
  111. package/dist/lib/linx-interactive-error-display.js.map +1 -0
  112. package/dist/lib/linx-interactive-event-router.js +91 -0
  113. package/dist/lib/linx-interactive-event-router.js.map +1 -0
  114. package/dist/lib/linx-interactive-extension-input-host.js +7 -0
  115. package/dist/lib/linx-interactive-extension-input-host.js.map +1 -0
  116. package/dist/lib/linx-interactive-extension-selector-host.js +12 -0
  117. package/dist/lib/linx-interactive-extension-selector-host.js.map +1 -0
  118. package/dist/lib/linx-interactive-header-host.js +14 -0
  119. package/dist/lib/linx-interactive-header-host.js.map +1 -0
  120. package/dist/lib/linx-interactive-lifecycle-host.js +4 -0
  121. package/dist/lib/linx-interactive-lifecycle-host.js.map +1 -0
  122. package/dist/lib/linx-interactive-login-ui-router.js +81 -0
  123. package/dist/lib/linx-interactive-login-ui-router.js.map +1 -0
  124. package/dist/lib/linx-interactive-model-registry-host.js +14 -0
  125. package/dist/lib/linx-interactive-model-registry-host.js.map +1 -0
  126. package/dist/lib/linx-interactive-post-init.js +60 -0
  127. package/dist/lib/linx-interactive-post-init.js.map +1 -0
  128. package/dist/lib/linx-interactive-provider-count-host.js +4 -0
  129. package/dist/lib/linx-interactive-provider-count-host.js.map +1 -0
  130. package/dist/lib/linx-interactive-run-router.js +43 -0
  131. package/dist/lib/linx-interactive-run-router.js.map +1 -0
  132. package/dist/lib/linx-interactive-runtime-host.js +113 -0
  133. package/dist/lib/linx-interactive-runtime-host.js.map +1 -0
  134. package/dist/lib/linx-interactive-selector-host.js +12 -0
  135. package/dist/lib/linx-interactive-selector-host.js.map +1 -0
  136. package/dist/lib/linx-interactive-shell-state.js +215 -0
  137. package/dist/lib/linx-interactive-shell-state.js.map +1 -0
  138. package/dist/lib/linx-interactive-status-display.js +9 -0
  139. package/dist/lib/linx-interactive-status-display.js.map +1 -0
  140. package/dist/lib/linx-interactive-stop-router.js +85 -0
  141. package/dist/lib/linx-interactive-stop-router.js.map +1 -0
  142. package/dist/lib/linx-interactive-streaming-message-host.js +11 -0
  143. package/dist/lib/linx-interactive-streaming-message-host.js.map +1 -0
  144. package/dist/lib/linx-interactive-submit-router.js +63 -0
  145. package/dist/lib/linx-interactive-submit-router.js.map +1 -0
  146. package/dist/lib/linx-interactive-update-router.js +78 -0
  147. package/dist/lib/linx-interactive-update-router.js.map +1 -0
  148. package/dist/lib/linx-interactive-update-state-host.js +43 -0
  149. package/dist/lib/linx-interactive-update-state-host.js.map +1 -0
  150. package/dist/lib/linx-interactive-warning-display.js +4 -0
  151. package/dist/lib/linx-interactive-warning-display.js.map +1 -0
  152. package/dist/lib/linx-interrupt-control-host.js +22 -0
  153. package/dist/lib/linx-interrupt-control-host.js.map +1 -0
  154. package/dist/lib/linx-interrupt-control.js +116 -0
  155. package/dist/lib/linx-interrupt-control.js.map +1 -0
  156. package/dist/lib/linx-login-flow.js +566 -0
  157. package/dist/lib/linx-login-flow.js.map +1 -0
  158. package/dist/lib/linx-models-command.js +71 -0
  159. package/dist/lib/linx-models-command.js.map +1 -0
  160. package/dist/lib/linx-package-command.js +117 -0
  161. package/dist/lib/linx-package-command.js.map +1 -0
  162. package/dist/lib/linx-peer-command-routing.js +20 -0
  163. package/dist/lib/linx-peer-command-routing.js.map +1 -0
  164. package/dist/lib/linx-pi-cli-command.js +121 -0
  165. package/dist/lib/linx-pi-cli-command.js.map +1 -0
  166. package/dist/lib/linx-pi-completion-events.js +101 -0
  167. package/dist/lib/linx-pi-completion-events.js.map +1 -0
  168. package/dist/lib/linx-pi-normalized-event-stream.js +41 -0
  169. package/dist/lib/linx-pi-normalized-event-stream.js.map +1 -0
  170. package/dist/lib/linx-pi-resume-cli-admission.js +21 -0
  171. package/dist/lib/linx-pi-resume-cli-admission.js.map +1 -0
  172. package/dist/lib/linx-pi-runtime-execution.js +67 -0
  173. package/dist/lib/linx-pi-runtime-execution.js.map +1 -0
  174. package/dist/lib/linx-pi-startup-control.js +49 -0
  175. package/dist/lib/linx-pi-startup-control.js.map +1 -0
  176. package/dist/lib/linx-pi-startup-plan.js +103 -0
  177. package/dist/lib/linx-pi-startup-plan.js.map +1 -0
  178. package/dist/lib/linx-pi-stream-errors.js +10 -0
  179. package/dist/lib/linx-pi-stream-errors.js.map +1 -0
  180. package/dist/lib/linx-pod-backed-extension-ui.js +29 -0
  181. package/dist/lib/linx-pod-backed-extension-ui.js.map +1 -0
  182. package/dist/lib/linx-pod-data-session-factory.js +19 -0
  183. package/dist/lib/linx-pod-data-session-factory.js.map +1 -0
  184. package/dist/lib/linx-pod-mirror-runtime-host.js +50 -0
  185. package/dist/lib/linx-pod-mirror-runtime-host.js.map +1 -0
  186. package/dist/lib/linx-pod-mirror-sync-cli-admission.js +18 -0
  187. package/dist/lib/linx-pod-mirror-sync-cli-admission.js.map +1 -0
  188. package/dist/lib/linx-pod-mirror-sync-command.js +30 -0
  189. package/dist/lib/linx-pod-mirror-sync-command.js.map +1 -0
  190. package/dist/lib/{pi-adapter/sync-recovery.js → linx-pod-mirror-sync-recovery.js} +13 -13
  191. package/dist/lib/linx-pod-mirror-sync-recovery.js.map +1 -0
  192. package/dist/lib/{pi-adapter/pod-mirror.js → linx-pod-mirror.js} +63 -40
  193. package/dist/lib/linx-pod-mirror.js.map +1 -0
  194. package/dist/lib/linx-restored-auto-startup.js +21 -0
  195. package/dist/lib/linx-restored-auto-startup.js.map +1 -0
  196. package/dist/lib/linx-resume-output.js +209 -0
  197. package/dist/lib/linx-resume-output.js.map +1 -0
  198. package/dist/lib/linx-retired-command.js +22 -0
  199. package/dist/lib/linx-retired-command.js.map +1 -0
  200. package/dist/lib/linx-rewind-command.js +209 -0
  201. package/dist/lib/linx-rewind-command.js.map +1 -0
  202. package/dist/lib/linx-runtime-adapter-contract.js +2 -0
  203. package/dist/lib/linx-runtime-adapter-contract.js.map +1 -0
  204. package/dist/lib/linx-runtime-adapter-defaults.js +17 -0
  205. package/dist/lib/linx-runtime-adapter-defaults.js.map +1 -0
  206. package/dist/lib/linx-runtime-adapter-dependencies.js +2 -0
  207. package/dist/lib/linx-runtime-adapter-dependencies.js.map +1 -0
  208. package/dist/lib/linx-runtime-agent-session.js +130 -0
  209. package/dist/lib/linx-runtime-agent-session.js.map +1 -0
  210. package/dist/lib/linx-runtime-auth.js +5 -0
  211. package/dist/lib/linx-runtime-auth.js.map +1 -0
  212. package/dist/lib/linx-runtime-backend-composition.js +73 -0
  213. package/dist/lib/linx-runtime-backend-composition.js.map +1 -0
  214. package/dist/lib/linx-runtime-coding-tools.js +58 -0
  215. package/dist/lib/linx-runtime-coding-tools.js.map +1 -0
  216. package/dist/lib/linx-runtime-completion-backend.js +27 -0
  217. package/dist/lib/linx-runtime-completion-backend.js.map +1 -0
  218. package/dist/lib/linx-runtime-oauth-provider.js +57 -0
  219. package/dist/lib/linx-runtime-oauth-provider.js.map +1 -0
  220. package/dist/lib/linx-runtime-provider-registration.js +33 -0
  221. package/dist/lib/linx-runtime-provider-registration.js.map +1 -0
  222. package/dist/lib/linx-runtime-resources.js +167 -0
  223. package/dist/lib/linx-runtime-resources.js.map +1 -0
  224. package/dist/lib/linx-runtime-system-prompt.js +27 -0
  225. package/dist/lib/linx-runtime-system-prompt.js.map +1 -0
  226. package/dist/lib/linx-runtime-thinking.js +21 -0
  227. package/dist/lib/linx-runtime-thinking.js.map +1 -0
  228. package/dist/lib/linx-selector-choice.js +38 -0
  229. package/dist/lib/linx-selector-choice.js.map +1 -0
  230. package/dist/lib/linx-self-update.js +113 -0
  231. package/dist/lib/linx-self-update.js.map +1 -0
  232. package/dist/lib/linx-session-command-routing-host.js +24 -0
  233. package/dist/lib/linx-session-command-routing-host.js.map +1 -0
  234. package/dist/lib/linx-session-command-routing.js +68 -0
  235. package/dist/lib/linx-session-command-routing.js.map +1 -0
  236. package/dist/lib/linx-session-cwd-router.js +15 -0
  237. package/dist/lib/linx-session-cwd-router.js.map +1 -0
  238. package/dist/lib/linx-session-history.js +388 -0
  239. package/dist/lib/linx-session-history.js.map +1 -0
  240. package/dist/lib/{pi-adapter/session.js → linx-session-manager.js} +94 -46
  241. package/dist/lib/linx-session-manager.js.map +1 -0
  242. package/dist/lib/linx-session-metadata.js +55 -0
  243. package/dist/lib/linx-session-metadata.js.map +1 -0
  244. package/dist/lib/linx-session-selector-ui.js +32 -0
  245. package/dist/lib/linx-session-selector-ui.js.map +1 -0
  246. package/dist/lib/linx-session-thinking-capability-router.js +55 -0
  247. package/dist/lib/linx-session-thinking-capability-router.js.map +1 -0
  248. package/dist/lib/linx-session-work-control.js +187 -0
  249. package/dist/lib/linx-session-work-control.js.map +1 -0
  250. package/dist/lib/linx-shell-command-executor.js +41 -0
  251. package/dist/lib/linx-shell-command-executor.js.map +1 -0
  252. package/dist/lib/linx-shell-command-router.js +151 -0
  253. package/dist/lib/linx-shell-command-router.js.map +1 -0
  254. package/dist/lib/{pi-adapter/control-state.js → linx-startup-control-state.js} +6 -6
  255. package/dist/lib/linx-startup-control-state.js.map +1 -0
  256. package/dist/lib/linx-startup-login-policy.js +48 -0
  257. package/dist/lib/linx-startup-login-policy.js.map +1 -0
  258. package/dist/lib/linx-status-line-command.js +382 -0
  259. package/dist/lib/linx-status-line-command.js.map +1 -0
  260. package/dist/lib/{status-line-command.js → linx-status-line-config-command.js} +2 -12
  261. package/dist/lib/linx-status-line-config-command.js.map +1 -0
  262. package/dist/lib/linx-status-line.js +12 -4
  263. package/dist/lib/linx-status-line.js.map +1 -1
  264. package/dist/lib/linx-stream-abort.js +12 -0
  265. package/dist/lib/linx-stream-abort.js.map +1 -0
  266. package/dist/lib/linx-stream-error-formatting.js +54 -0
  267. package/dist/lib/linx-stream-error-formatting.js.map +1 -0
  268. package/dist/lib/linx-submitted-user-message-recording.js +16 -0
  269. package/dist/lib/linx-submitted-user-message-recording.js.map +1 -0
  270. package/dist/lib/linx-symphony-interactive-command.js +493 -0
  271. package/dist/lib/linx-symphony-interactive-command.js.map +1 -0
  272. package/dist/lib/linx-terminal-title-router.js +49 -0
  273. package/dist/lib/linx-terminal-title-router.js.map +1 -0
  274. package/dist/lib/{pi-adapter/theme.js → linx-theme.js} +2 -2
  275. package/dist/lib/linx-theme.js.map +1 -0
  276. package/dist/lib/linx-top-level-command-admission.js +27 -0
  277. package/dist/lib/linx-top-level-command-admission.js.map +1 -0
  278. package/dist/lib/linx-update-notification.js +209 -0
  279. package/dist/lib/linx-update-notification.js.map +1 -0
  280. package/dist/lib/linx-welcome-header.js +148 -0
  281. package/dist/lib/linx-welcome-header.js.map +1 -0
  282. package/dist/lib/linx-workspace-command.js +45 -0
  283. package/dist/lib/linx-workspace-command.js.map +1 -0
  284. package/dist/lib/native-backend-command-router.js +25 -0
  285. package/dist/lib/native-backend-command-router.js.map +1 -0
  286. package/dist/lib/native-backend-proxy.js +2 -0
  287. package/dist/lib/native-backend-proxy.js.map +1 -0
  288. package/dist/lib/native-backend-stream-backend.js +15 -0
  289. package/dist/lib/native-backend-stream-backend.js.map +1 -0
  290. package/dist/lib/oidc-auth.js +2 -4
  291. package/dist/lib/oidc-auth.js.map +1 -1
  292. package/dist/lib/pi-adapter/runtime.js +32 -841
  293. package/dist/lib/pi-adapter/runtime.js.map +1 -1
  294. package/dist/lib/pi-adapter/stream.js +17 -516
  295. package/dist/lib/pi-adapter/stream.js.map +1 -1
  296. package/dist/lib/{pi-adapter/pod-approval.js → pod-backed-extension-ui-context.js} +2 -2
  297. package/dist/lib/pod-backed-extension-ui-context.js.map +1 -0
  298. package/dist/lib/pod-chat-store-runtime.js +38 -0
  299. package/dist/lib/pod-chat-store-runtime.js.map +1 -0
  300. package/dist/lib/pod-chat-store.js +15 -65
  301. package/dist/lib/pod-chat-store.js.map +1 -1
  302. package/dist/lib/{pi-adapter/pod-mirror-mapping.js → pod-mirror-mapping.js} +8 -18
  303. package/dist/lib/pod-mirror-mapping.js.map +1 -0
  304. package/dist/lib/{pi-adapter/pod-native.js → pod-native.js} +1 -1
  305. package/dist/lib/pod-native.js.map +1 -0
  306. package/dist/lib/pod-status-output.js.map +1 -0
  307. package/dist/lib/{pi-adapter/auto-input-controller.js → secretary-auto-input-controller.js} +62 -77
  308. package/dist/lib/secretary-auto-input-controller.js.map +1 -0
  309. package/dist/lib/{pi-adapter/session-control.js → session-control.js} +80 -29
  310. package/dist/lib/session-control.js.map +1 -0
  311. package/dist/lib/shell-lifecycle.js +199 -0
  312. package/dist/lib/shell-lifecycle.js.map +1 -0
  313. package/dist/lib/solid-local-store.js +3 -3
  314. package/dist/lib/solid-local-store.js.map +1 -1
  315. package/dist/lib/symphony/pod-projection.js +1 -31
  316. package/dist/lib/symphony/pod-projection.js.map +1 -1
  317. package/dist/lib/{symphony-command.js → symphony/run.js} +11 -16
  318. package/dist/lib/symphony/run.js.map +1 -0
  319. package/dist/lib/symphony/runtime.js +30 -0
  320. package/dist/lib/symphony/runtime.js.map +1 -0
  321. package/dist/lib/symphony/status.js +242 -0
  322. package/dist/lib/symphony/status.js.map +1 -0
  323. package/dist/linx-cli-app.js +70 -0
  324. package/dist/linx-cli-app.js.map +1 -0
  325. package/dist/linx-cli-runtime-adapter-factory.js +12 -0
  326. package/dist/linx-cli-runtime-adapter-factory.js.map +1 -0
  327. package/dist/plugins/linx-symphony-codex/.codex-plugin/plugin.json +1 -1
  328. package/package.json +1 -1
  329. package/dist/lib/auto-mode/hooks/index.js.map +0 -1
  330. package/dist/lib/auto-mode/index.js +0 -10
  331. package/dist/lib/auto-mode/index.js.map +0 -1
  332. package/dist/lib/codex-plugin/index.js +0 -5
  333. package/dist/lib/codex-plugin/index.js.map +0 -1
  334. package/dist/lib/pi-adapter/auth.js +0 -68
  335. package/dist/lib/pi-adapter/auth.js.map +0 -1
  336. package/dist/lib/pi-adapter/auto-input-controller.js.map +0 -1
  337. package/dist/lib/pi-adapter/backend-command.js +0 -2
  338. package/dist/lib/pi-adapter/backend-command.js.map +0 -1
  339. package/dist/lib/pi-adapter/backend-credentials.js.map +0 -1
  340. package/dist/lib/pi-adapter/branding.js +0 -1188
  341. package/dist/lib/pi-adapter/branding.js.map +0 -1
  342. package/dist/lib/pi-adapter/control-state.js.map +0 -1
  343. package/dist/lib/pi-adapter/index.js +0 -4
  344. package/dist/lib/pi-adapter/index.js.map +0 -1
  345. package/dist/lib/pi-adapter/interactive.js +0 -3191
  346. package/dist/lib/pi-adapter/interactive.js.map +0 -1
  347. package/dist/lib/pi-adapter/pod-approval.js.map +0 -1
  348. package/dist/lib/pi-adapter/pod-mirror-mapping.js.map +0 -1
  349. package/dist/lib/pi-adapter/pod-mirror.js.map +0 -1
  350. package/dist/lib/pi-adapter/pod-native.js.map +0 -1
  351. package/dist/lib/pi-adapter/pod-status-output.js.map +0 -1
  352. package/dist/lib/pi-adapter/pod-tools.js +0 -140
  353. package/dist/lib/pi-adapter/pod-tools.js.map +0 -1
  354. package/dist/lib/pi-adapter/session-control.js.map +0 -1
  355. package/dist/lib/pi-adapter/session.js.map +0 -1
  356. package/dist/lib/pi-adapter/sync-recovery.js.map +0 -1
  357. package/dist/lib/pi-adapter/theme.js.map +0 -1
  358. package/dist/lib/pi-adapter/web-fetch.js +0 -170
  359. package/dist/lib/pi-adapter/web-fetch.js.map +0 -1
  360. package/dist/lib/status-line-command.js.map +0 -1
  361. package/dist/lib/symphony-command.js.map +0 -1
  362. /package/dist/lib/{pi-adapter/pod-status-output.js → pod-status-output.js} +0 -0
@@ -1,1188 +0,0 @@
1
- import { spawn } from 'node:child_process';
2
- import { basename } from 'node:path';
3
- import { readFileSync } from 'node:fs';
4
- import { keyHint, LoginDialogComponent, rawKeyHint } from '@earendil-works/pi-coding-agent';
5
- import { Text, truncateToWidth, visibleWidth, wrapTextWithAnsi } from '@earendil-works/pi-tui';
6
- import { clearAccountSession } from '../account-session.js';
7
- import { clearCredentials, loadCredentials } from '../credentials-store.js';
8
- import { clearOidcSessionStorage } from '../oidc-session-storage.js';
9
- import { persistSolidClientCredentialsLogin } from '../solid-client-credentials-login.js';
10
- import { extractUsernameFromWebId, resolveProfileDisplayName } from '../profile-identity.js';
11
- import { LINX_TUI_KEYMAP_COMMAND, LINX_TUI_KEYMAP_LABEL, LINX_TUI_LOGIN_COMMAND } from '../linx-tui-contract.js';
12
- import { suppressPodStatusOutput } from './pod-status-output.js';
13
- import { LINX_RUNTIME_MANAGED_AUTH_KEY } from './runtime.js';
14
- import { formatLinxCliErrorMessage } from '../linx-cloud-errors.js';
15
- import { getSolidLinxAgentDir } from '../solid-local-store.js';
16
- export const LINX_AGENT_DIR = getSolidLinxAgentDir();
17
- export const LINX_UPDATE_PACKAGE_NAME = '@undefineds.co/linx';
18
- export const LINX_CHANGELOG_URL = 'https://github.com/undefineds-co/linx-cli/releases';
19
- export const LINX_CLI_VERSION = readLinxCliVersion();
20
- const LINX_AUTH_LOGIN_IN_PROGRESS = Symbol.for('linx.tui.authLoginInProgress');
21
- const LINX_AUTH_LOGIN_ON_INIT = Symbol.for('linx.tui.authLoginOnInit');
22
- const LINX_AUTH_PENDING_RETRY = Symbol.for('linx.tui.authPendingRetry');
23
- const LINX_AUTH_LOGIN_SCHEDULED = Symbol.for('linx.tui.authLoginScheduled');
24
- const LINX_AUTH_REPORTING_ERROR = Symbol.for('linx.tui.authReportingError');
25
- const LINX_UPDATE_IN_PROGRESS = Symbol.for('linx.tui.updateInProgress');
26
- const LINX_UPDATE_CHECK_SCHEDULED = Symbol.for('linx.tui.updateCheckScheduled');
27
- const LINX_DEFERRED_UPDATE_VERSION = Symbol.for('linx.tui.deferredUpdateVersion');
28
- const LINX_SUPPRESS_UPSTREAM_PI_UPDATE = Symbol.for('linx.tui.suppressUpstreamPiUpdate');
29
- const LINX_PROVIDER_ID = 'undefineds';
30
- const AUTH_OPTION_BROWSER = 'Authorize in browser';
31
- const AUTH_OPTION_CLIENT_CREDENTIALS = 'Enter Solid client credentials';
32
- const AUTH_OPTION_EXIT = 'Exit';
33
- const UPDATE_OPTION_INSTALL = 'Install update and restart';
34
- const UPDATE_OPTION_CHANGELOG = 'Open changelog';
35
- const UPDATE_OPTION_LATER = 'Later';
36
- export function applyLinxInteractiveBranding(interactive) {
37
- patchTerminalTitle(interactive);
38
- patchVersionCheck(interactive);
39
- patchUpdateNotification(interactive);
40
- patchNativeOAuthSelectors(interactive);
41
- patchLoginCommand(interactive);
42
- patchAuthExpiredSessionEvents(interactive);
43
- patchAuthExpiredLoginPrompt(interactive);
44
- patchHeader(interactive);
45
- }
46
- export function requestLinxCloudLogin(interactive, reason = 'manual') {
47
- if (!interactive.isInitialized) {
48
- interactive[LINX_AUTH_LOGIN_ON_INIT] = reason;
49
- return;
50
- }
51
- void startLinxCloudLogin(interactive, { reason });
52
- }
53
- function patchTerminalTitle(interactive) {
54
- const original = interactive.updateTerminalTitle?.bind(interactive);
55
- interactive.updateTerminalTitle = function patchedUpdateTerminalTitle() {
56
- original?.();
57
- const cwd = this.sessionManager?.getCwd?.() || process.cwd();
58
- const sessionName = this.sessionManager?.getSessionName?.();
59
- const suffix = sessionName ? `${sessionName} - ${basename(cwd)}` : basename(cwd);
60
- this.ui?.terminal?.setTitle?.(`LinX - ${suffix}`);
61
- };
62
- }
63
- function patchVersionCheck(interactive) {
64
- const originalRun = interactive.run?.bind(interactive);
65
- if (typeof originalRun === 'function') {
66
- interactive.run = async function patchedLinxRun(...args) {
67
- this[LINX_SUPPRESS_UPSTREAM_PI_UPDATE] = true;
68
- return originalRun(...args);
69
- };
70
- }
71
- const originalInit = interactive.init?.bind(interactive);
72
- if (typeof originalInit === 'function') {
73
- interactive.init = async function patchedLinxVersionInit(...args) {
74
- await originalInit(...args);
75
- scheduleLinxVersionCheck(this);
76
- };
77
- }
78
- interactive.checkForNewVersion = async function patchedCheckForNewVersion() {
79
- return checkForNewLinxVersion();
80
- };
81
- }
82
- function patchUpdateNotification(interactive) {
83
- interactive.showNewVersionNotification = function patchedShowNewVersionNotification(newVersion) {
84
- if (this[LINX_SUPPRESS_UPSTREAM_PI_UPDATE]) {
85
- return;
86
- }
87
- const normalizedVersion = normalizeLinxUpdateVersion(newVersion);
88
- if (!normalizedVersion) {
89
- return;
90
- }
91
- requestLinxUpdateNotification(this, normalizedVersion);
92
- };
93
- }
94
- function scheduleLinxVersionCheck(interactive) {
95
- if (interactive[LINX_UPDATE_CHECK_SCHEDULED]) {
96
- return;
97
- }
98
- interactive[LINX_UPDATE_CHECK_SCHEDULED] = true;
99
- queueMicrotask(() => {
100
- void checkForNewLinxVersion()
101
- .then((latest) => {
102
- if (!latest) {
103
- return;
104
- }
105
- requestLinxUpdateNotification(interactive, latest);
106
- })
107
- .catch(() => undefined);
108
- });
109
- }
110
- export async function checkForNewLinxVersion() {
111
- if (process.env.PI_OFFLINE) {
112
- return undefined;
113
- }
114
- try {
115
- const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(LINX_UPDATE_PACKAGE_NAME)}/latest`, {
116
- signal: AbortSignal.timeout(5000),
117
- });
118
- if (!response.ok) {
119
- return undefined;
120
- }
121
- const body = await response.json();
122
- const latest = typeof body.version === 'string' ? body.version.trim() : '';
123
- if (!latest || !isVersionNewer(latest, LINX_CLI_VERSION)) {
124
- return undefined;
125
- }
126
- return latest;
127
- }
128
- catch {
129
- return undefined;
130
- }
131
- }
132
- async function showLinxUpdateSelector(interactive, newVersion) {
133
- if (interactive[LINX_UPDATE_IN_PROGRESS]) {
134
- return;
135
- }
136
- interactive[LINX_UPDATE_IN_PROGRESS] = true;
137
- try {
138
- const title = [
139
- 'LinX update available',
140
- `Current ${LINX_CLI_VERSION} -> latest ${newVersion}`,
141
- 'Choose how to handle this update.',
142
- ].join('\n');
143
- const options = [UPDATE_OPTION_LATER, UPDATE_OPTION_INSTALL, UPDATE_OPTION_CHANGELOG];
144
- const rawSelected = typeof interactive.showExtensionSelector === 'function'
145
- ? await interactive.showExtensionSelector(title, options)
146
- : undefined;
147
- const selected = normalizeSelectorChoice(rawSelected, options);
148
- if (selected === UPDATE_OPTION_INSTALL) {
149
- await installLinxUpdateAndRestart(interactive, newVersion);
150
- return;
151
- }
152
- if (selected === UPDATE_OPTION_CHANGELOG) {
153
- openExternalUrl(LINX_CHANGELOG_URL, interactive);
154
- interactive.showStatus?.(`Opened LinX changelog for ${newVersion}.`);
155
- return;
156
- }
157
- if (!selected) {
158
- showLinxUpdateFallback(interactive, newVersion);
159
- return;
160
- }
161
- interactive.showStatus?.(`Skipped LinX ${newVersion} for now.`);
162
- }
163
- finally {
164
- interactive[LINX_UPDATE_IN_PROGRESS] = false;
165
- }
166
- }
167
- export async function checkAndShowLinxUpdate(interactive, options = {}) {
168
- const latest = await checkForNewLinxVersion();
169
- if (!latest) {
170
- if (options.manual) {
171
- interactive.showStatus?.(`LinX ${LINX_CLI_VERSION} is up to date.`);
172
- interactive.ui?.requestRender?.();
173
- }
174
- return;
175
- }
176
- requestLinxUpdateNotification(interactive, latest, { force: options.manual === true });
177
- }
178
- function requestLinxUpdateNotification(interactive, newVersion, options = {}) {
179
- if (!options.force && shouldDeferLinxUpdateNotification(interactive)) {
180
- interactive[LINX_DEFERRED_UPDATE_VERSION] = newVersion;
181
- return;
182
- }
183
- interactive[LINX_DEFERRED_UPDATE_VERSION] = undefined;
184
- void showLinxUpdateSelector(interactive, newVersion);
185
- }
186
- function replayDeferredLinxUpdateNotification(interactive) {
187
- const version = normalizeLinxUpdateVersion(interactive[LINX_DEFERRED_UPDATE_VERSION]);
188
- if (!version || shouldDeferLinxUpdateNotification(interactive)) {
189
- return;
190
- }
191
- interactive[LINX_DEFERRED_UPDATE_VERSION] = undefined;
192
- void showLinxUpdateSelector(interactive, version);
193
- }
194
- function shouldDeferLinxUpdateNotification(interactive) {
195
- return Boolean(interactive[LINX_AUTH_LOGIN_IN_PROGRESS]
196
- || interactive[LINX_AUTH_LOGIN_ON_INIT]
197
- || interactive[LINX_AUTH_PENDING_RETRY]
198
- || interactive[LINX_AUTH_LOGIN_SCHEDULED]);
199
- }
200
- function normalizeLinxUpdateVersion(value) {
201
- const direct = normalizeNonEmptyString(value);
202
- if (direct) {
203
- return direct;
204
- }
205
- if (!isRecord(value)) {
206
- return undefined;
207
- }
208
- for (const key of ['version', 'latest', 'latestVersion', 'packageVersion', 'newVersion']) {
209
- const nested = normalizeNonEmptyString(value[key]);
210
- if (nested) {
211
- return nested;
212
- }
213
- }
214
- return undefined;
215
- }
216
- async function installLinxUpdateAndRestart(interactive, newVersion) {
217
- interactive.showStatus?.(`Installing LinX ${newVersion}...`);
218
- interactive.ui?.requestRender?.();
219
- try {
220
- await runNpmInstallLatest();
221
- }
222
- catch (error) {
223
- const message = error instanceof Error ? error.message : String(error);
224
- interactive.showError?.(`LinX update failed: ${message}`);
225
- return;
226
- }
227
- interactive.showStatus?.(`LinX ${newVersion} installed. Restarting...`);
228
- interactive.ui?.requestRender?.();
229
- restartCurrentProcess(interactive);
230
- }
231
- function runNpmInstallLatest() {
232
- const npmCommand = process.env.npm_execpath || 'npm';
233
- const args = ['install', '-g', '--omit=peer', `${LINX_UPDATE_PACKAGE_NAME}@latest`];
234
- return new Promise((resolve, reject) => {
235
- const child = spawn(npmCommand, args, {
236
- stdio: ['ignore', 'pipe', 'pipe'],
237
- shell: false,
238
- });
239
- let stderr = '';
240
- child.stderr?.on('data', (chunk) => {
241
- stderr += chunk.toString();
242
- });
243
- child.on('error', reject);
244
- child.on('close', (code) => {
245
- if (code === 0) {
246
- resolve();
247
- return;
248
- }
249
- reject(new Error(stderr.trim() || `npm install exited with code ${code ?? 'unknown'}`));
250
- });
251
- });
252
- }
253
- function restartCurrentProcess(interactive) {
254
- const child = spawn(process.execPath, process.argv.slice(1), {
255
- cwd: process.cwd(),
256
- env: process.env,
257
- stdio: 'inherit',
258
- detached: false,
259
- });
260
- child.on('error', (error) => {
261
- interactive.showError?.(`LinX restart failed: ${error.message}`);
262
- });
263
- interactive.stop?.();
264
- setTimeout(() => process.exit(0), 50);
265
- }
266
- function showLinxUpdateFallback(interactive, newVersion) {
267
- const lines = [
268
- '\x1b[1m\x1b[33mLinX update available\x1b[39m\x1b[22m',
269
- `\x1b[2mCurrent ${LINX_CLI_VERSION} -> latest ${newVersion}\x1b[22m`,
270
- `\x1b[2mRun \x1b[22m\x1b[36mnpm install -g ${LINX_UPDATE_PACKAGE_NAME}@latest\x1b[39m\x1b[2m if this terminal cannot show the update selector.\x1b[22m`,
271
- `\x1b[2mChangelog: \x1b[22m\x1b[36m${LINX_CHANGELOG_URL}\x1b[39m`,
272
- ];
273
- interactive.chatContainer?.addChild?.(new Text(lines.join('\n'), 1, 0));
274
- interactive.ui?.requestRender?.();
275
- }
276
- function patchLoginCommand(interactive) {
277
- const originalSetup = interactive.setupEditorSubmitHandler?.bind(interactive);
278
- if (typeof originalSetup !== 'function') {
279
- return;
280
- }
281
- interactive.setupEditorSubmitHandler = function patchedLinxLoginSetupEditorSubmitHandler() {
282
- originalSetup();
283
- const originalSubmit = this.defaultEditor?.onSubmit?.bind(this.defaultEditor);
284
- if (typeof originalSubmit !== 'function') {
285
- return;
286
- }
287
- this.defaultEditor.onSubmit = async (text) => {
288
- const command = text.trim();
289
- if (command === '/login') {
290
- this.editor?.setText?.('');
291
- await startLinxCloudLogin(this);
292
- return;
293
- }
294
- await originalSubmit(text);
295
- };
296
- };
297
- }
298
- function patchNativeOAuthSelectors(interactive) {
299
- interactive.showOAuthSelector = async function patchedLinxOAuthSelector(mode = 'login') {
300
- if (mode === 'logout') {
301
- const authStorage = this.session?.modelRegistry?.authStorage;
302
- authStorage?.logout?.(LINX_PROVIDER_ID);
303
- authStorage?.setRuntimeApiKey?.(LINX_PROVIDER_ID, '');
304
- clearAccountSession();
305
- clearCredentials();
306
- clearOidcSessionStorage();
307
- await refreshLinxAuthState(this);
308
- this.showStatus?.('Logged out of LinX Cloud.');
309
- return;
310
- }
311
- await startLinxCloudLogin(this, { reason: 'manual' });
312
- };
313
- interactive.showLoginDialog = async function patchedLinxLoginDialog(providerId) {
314
- if (!providerId || providerId === LINX_PROVIDER_ID) {
315
- await startLinxCloudLogin(this, { reason: 'manual' });
316
- return;
317
- }
318
- this.showStatus?.('LinX only supports LinX Cloud authentication in this TUI.');
319
- await startLinxCloudLogin(this, { reason: 'manual' });
320
- };
321
- }
322
- function patchAuthExpiredSessionEvents(interactive) {
323
- const originalHandleEvent = interactive.handleEvent?.bind(interactive);
324
- if (typeof originalHandleEvent !== 'function') {
325
- return;
326
- }
327
- interactive.handleEvent = async function patchedHandleEvent(event) {
328
- const normalizedEvent = normalizeLinxCliErrorEvent(event);
329
- if (eventHasLinxAuthExpiredError(normalizedEvent)) {
330
- showLinxAuthExpiredRecoveryNotice(this);
331
- prepareLinxAuthExpiredRetry(this);
332
- suppressLinxAuthExpiredAssistantError(this);
333
- scheduleLinxCloudLogin(this, 'expired');
334
- return undefined;
335
- }
336
- const result = await originalHandleEvent(normalizedEvent);
337
- return result;
338
- };
339
- }
340
- function patchAuthExpiredLoginPrompt(interactive) {
341
- const originalShowError = interactive.showError?.bind(interactive);
342
- if (typeof originalShowError !== 'function') {
343
- return;
344
- }
345
- interactive.showError = function patchedShowError(errorMessage) {
346
- const text = typeof errorMessage === 'string' ? errorMessage : String(errorMessage);
347
- if (this[LINX_AUTH_REPORTING_ERROR] || !isLinxAuthExpiredError(text)) {
348
- return originalShowError(formatLinxCliErrorMessage(errorMessage));
349
- }
350
- showLinxAuthExpiredRecoveryNotice(this);
351
- prepareLinxAuthExpiredRetry(this);
352
- scheduleLinxCloudLogin(this, 'expired');
353
- return undefined;
354
- };
355
- }
356
- function isLinxAuthExpiredError(text) {
357
- const normalized = stripAnsi(text).toLowerCase();
358
- return normalized.includes('linx cloud login expired')
359
- || normalized.includes('invalid solid token')
360
- || (normalized.includes('chat request failed (401)') && normalized.includes('unauthorized'));
361
- }
362
- function eventHasLinxAuthExpiredError(event) {
363
- if (!isRecord(event)) {
364
- return false;
365
- }
366
- const message = isRecord(event.message) ? event.message : undefined;
367
- const topLevelErrorMessage = typeof event.errorMessage === 'string' ? event.errorMessage : '';
368
- const errorMessage = typeof message?.errorMessage === 'string' ? message.errorMessage : '';
369
- const error = isRecord(event.error) ? event.error : undefined;
370
- const nestedErrorMessage = typeof error?.errorMessage === 'string' ? error.errorMessage : '';
371
- return isLinxAuthExpiredError(`${topLevelErrorMessage}\n${errorMessage}\n${nestedErrorMessage}`);
372
- }
373
- function normalizeLinxCliErrorEvent(event) {
374
- if (typeof event === 'string') {
375
- const normalized = formatLinxCliErrorMessage(event);
376
- return normalized === event ? event : normalized;
377
- }
378
- if (Array.isArray(event)) {
379
- let changed = false;
380
- const next = event.map((item) => {
381
- const normalized = normalizeLinxCliErrorEvent(item);
382
- if (normalized !== item) {
383
- changed = true;
384
- }
385
- return normalized;
386
- });
387
- return changed ? next : event;
388
- }
389
- if (!isRecord(event)) {
390
- return event;
391
- }
392
- let changed = false;
393
- const next = {};
394
- for (const [key, value] of Object.entries(event)) {
395
- const normalized = normalizeLinxCliErrorEvent(value);
396
- next[key] = normalized;
397
- if (normalized !== value) {
398
- changed = true;
399
- }
400
- }
401
- return changed ? { ...event, ...next } : event;
402
- }
403
- function showLinxAuthExpiredRecoveryNotice(interactive) {
404
- interactive.showStatus?.([
405
- 'LinX Cloud login expired.',
406
- 'Your message reached LinX, but the Cloud token was rejected.',
407
- 'Choose a sign-in method below, or run /login if the selector is not visible.',
408
- ].join('\n'));
409
- interactive.ui?.requestRender?.();
410
- }
411
- async function startLinxCloudLogin(interactive, options = {}) {
412
- if (interactive[LINX_AUTH_LOGIN_IN_PROGRESS]) {
413
- return;
414
- }
415
- interactive[LINX_AUTH_LOGIN_IN_PROGRESS] = true;
416
- try {
417
- const authStorage = interactive.session?.modelRegistry?.authStorage;
418
- if (!authStorage) {
419
- prefillLoginCommand(interactive);
420
- return;
421
- }
422
- const reason = options.reason ?? 'manual';
423
- const selected = await selectLinxAuthMethod(interactive, reason);
424
- if (!selected) {
425
- interactive.showStatus?.('LinX Cloud authorization cancelled.');
426
- return;
427
- }
428
- if (selected === AUTH_OPTION_BROWSER) {
429
- if (typeof authStorage.login !== 'function') {
430
- prefillLoginCommand(interactive);
431
- return;
432
- }
433
- await runLinxCloudBrowserLogin(interactive, authStorage, reason);
434
- await refreshLinxAuthState(interactive);
435
- await finishLinxAuthSuccess(interactive, reason, 'Browser authorization complete.');
436
- return;
437
- }
438
- if (selected === AUTH_OPTION_CLIENT_CREDENTIALS) {
439
- await promptForLinxClientCredentials(interactive, reason);
440
- return;
441
- }
442
- if (selected === AUTH_OPTION_EXIT) {
443
- if (reason === 'startup') {
444
- interactive.stop?.();
445
- }
446
- else {
447
- interactive.showStatus?.('LinX Cloud authorization cancelled.');
448
- }
449
- }
450
- }
451
- catch (error) {
452
- const message = error instanceof Error ? error.message : String(error);
453
- reportLinxLoginError(interactive, message);
454
- }
455
- finally {
456
- interactive[LINX_AUTH_LOGIN_IN_PROGRESS] = false;
457
- replayDeferredLinxUpdateNotification(interactive);
458
- }
459
- }
460
- function scheduleLinxCloudLogin(interactive, reason) {
461
- if (interactive[LINX_AUTH_LOGIN_IN_PROGRESS] || interactive[LINX_AUTH_LOGIN_SCHEDULED]) {
462
- return;
463
- }
464
- interactive[LINX_AUTH_LOGIN_SCHEDULED] = true;
465
- setTimeout(() => {
466
- interactive[LINX_AUTH_LOGIN_SCHEDULED] = false;
467
- void startLinxCloudLogin(interactive, { reason });
468
- }, 0);
469
- }
470
- function reportLinxLoginError(interactive, message) {
471
- const rendered = normalizeLinxLoginError(message);
472
- if (interactive[LINX_AUTH_REPORTING_ERROR]) {
473
- interactive.showStatus?.(rendered);
474
- return;
475
- }
476
- interactive[LINX_AUTH_REPORTING_ERROR] = true;
477
- try {
478
- if (typeof interactive.showError === 'function') {
479
- interactive.showError(rendered);
480
- }
481
- else {
482
- interactive.showStatus?.(rendered);
483
- }
484
- }
485
- finally {
486
- interactive[LINX_AUTH_REPORTING_ERROR] = false;
487
- }
488
- }
489
- function normalizeLinxLoginError(message) {
490
- const oidcCallbackError = /^OIDC callback returned\b/i.test(message);
491
- if (oidcCallbackError) {
492
- return `LinX Cloud login failed: ${message}`;
493
- }
494
- if (/server_error/i.test(message)) {
495
- return `LinX Cloud login failed: the identity server rejected this browser login. ${message}`;
496
- }
497
- return `LinX Cloud login failed: ${message}`;
498
- }
499
- async function selectLinxAuthMethod(interactive, reason) {
500
- const title = buildLinxAuthPromptTitle(reason, resolveRuntimeProviderLabel(interactive));
501
- const options = [AUTH_OPTION_BROWSER, AUTH_OPTION_CLIENT_CREDENTIALS, AUTH_OPTION_EXIT];
502
- if (typeof interactive.showExtensionSelector === 'function') {
503
- return normalizeSelectorChoice(await interactive.showExtensionSelector(title, options), options);
504
- }
505
- showLinxAuthFallback(interactive, title, options);
506
- return undefined;
507
- }
508
- function normalizeSelectorChoice(value, options) {
509
- const direct = matchSelectorChoice(value, options);
510
- if (direct) {
511
- return direct;
512
- }
513
- if (!isRecord(value)) {
514
- return undefined;
515
- }
516
- for (const key of ['value', 'label', 'title', 'name', 'display', 'text', 'option', 'id']) {
517
- const match = matchSelectorChoice(value[key], options);
518
- if (match) {
519
- return match;
520
- }
521
- }
522
- return undefined;
523
- }
524
- function matchSelectorChoice(value, options) {
525
- const normalized = normalizeNonEmptyString(value);
526
- if (!normalized) {
527
- return undefined;
528
- }
529
- return options.find((option) => option === normalized)
530
- ?? options.find((option) => stripAnsi(option).trim() === stripAnsi(normalized).trim());
531
- }
532
- function buildLinxAuthPromptTitle(reason, providerLabel) {
533
- if (reason === 'startup') {
534
- return [
535
- 'LinX Cloud login required',
536
- `Connect to ${providerLabel} before using LinX TUI.`,
537
- 'Choose a sign-in method.',
538
- ].join('\n');
539
- }
540
- if (reason === 'expired') {
541
- return [
542
- 'LinX Cloud login expired',
543
- 'Your current Solid token was rejected by LinX Cloud.',
544
- 'Re-authorize or enter Solid client credentials, then retry your message.',
545
- ].join('\n');
546
- }
547
- return [
548
- 'LinX Cloud authorization',
549
- `Choose how LinX should authenticate with ${providerLabel}.`,
550
- ].join('\n');
551
- }
552
- function showLinxAuthFallback(interactive, title, options) {
553
- interactive.chatContainer?.addChild?.(new Text([
554
- `\x1b[1m${title}\x1b[22m`,
555
- '',
556
- ...options.map((option) => `- ${option}`),
557
- '',
558
- 'This terminal build cannot render the LinX auth selector. Run `linx login` in another shell.',
559
- ].join('\n'), 1, 0));
560
- interactive.ui?.requestRender?.();
561
- }
562
- async function promptForLinxClientCredentials(interactive, reason) {
563
- if (typeof interactive.showExtensionInput !== 'function') {
564
- interactive.showError?.('This terminal build cannot collect Solid client credentials inside the TUI.');
565
- return;
566
- }
567
- const credentials = await interactive.showExtensionInput([
568
- reason === 'expired' ? 'Enter Solid client credentials' : 'Use Solid client credentials',
569
- 'This is only for Solid/LinX identity. AI provider keys belong in `linx ai connect`.',
570
- 'Format: client_id:client_secret',
571
- 'Press Escape to cancel.',
572
- ].join('\n'), 'client_id:client_secret');
573
- const trimmed = typeof credentials === 'string' ? credentials.trim() : '';
574
- if (!trimmed) {
575
- interactive.showStatus?.('Solid client credentials entry cancelled.');
576
- return;
577
- }
578
- const result = await resolveSolidClientCredentialsLogin(interactive)(trimmed);
579
- const authStorage = interactive.session?.modelRegistry?.authStorage;
580
- authStorage?.setRuntimeApiKey?.(LINX_PROVIDER_ID, LINX_RUNTIME_MANAGED_AUTH_KEY);
581
- authStorage?.set?.(LINX_PROVIDER_ID, {
582
- type: 'api_key',
583
- key: LINX_RUNTIME_MANAGED_AUTH_KEY,
584
- webId: result.webId,
585
- podUrl: result.podUrl,
586
- });
587
- await refreshLinxAuthState(interactive);
588
- await finishLinxAuthSuccess(interactive, reason, 'Solid client credentials saved to ~/.solid/auth.');
589
- }
590
- function resolveSolidClientCredentialsLogin(interactive) {
591
- const override = interactive?.__linxPersistSolidClientCredentialsLogin ?? interactive?.__linxPersistSolidSecretLogin;
592
- return typeof override === 'function' ? override : persistSolidClientCredentialsLogin;
593
- }
594
- async function finishLinxAuthSuccess(interactive, reason, detail) {
595
- const prefix = authStatusPrefix(reason);
596
- const retryStarted = await retryPendingLinxAuthTurn(interactive, reason);
597
- if (retryStarted) {
598
- interactive.showStatus?.(`${prefix} ${detail} Retrying your message...`);
599
- return;
600
- }
601
- const suffix = reason === 'expired' ? ' Retry your message.' : '';
602
- interactive.showStatus?.(`${prefix} ${detail}${suffix}`);
603
- }
604
- function prepareLinxAuthExpiredRetry(interactive) {
605
- if (interactive[LINX_AUTH_PENDING_RETRY]) {
606
- return;
607
- }
608
- const session = interactive.session;
609
- const sessionManager = session?.sessionManager;
610
- const leafId = typeof sessionManager?.getLeafId === 'function'
611
- ? sessionManager.getLeafId()
612
- : undefined;
613
- const leafEntry = leafId && typeof sessionManager?.getEntry === 'function'
614
- ? sessionManager.getEntry(leafId)
615
- : undefined;
616
- const leafMessage = leafEntry?.type === 'message' ? leafEntry.message : undefined;
617
- const userEntry = findLastUserMessageEntry(sessionManager, leafId);
618
- const promptText = extractUserMessageText(userEntry?.message)
619
- ?? extractUserMessageText(leafMessage)
620
- ?? findLastUserMessageText(session?.state?.messages);
621
- const pending = {
622
- continueFromId: userEntry?.id ?? (leafMessage?.role === 'user' ? leafId : undefined),
623
- promptText,
624
- promptParentId: userEntry?.parentId ?? (leafMessage?.role === 'user' ? leafEntry.parentId : undefined),
625
- };
626
- interactive[LINX_AUTH_PENDING_RETRY] = pending;
627
- // AgentSession persists the assistant error after TUI subscribers run. Restore
628
- // the active branch on the next tick so "continue" never resumes from the
629
- // failed auth assistant message if the user cancels or login fails.
630
- setTimeout(() => {
631
- if (interactive[LINX_AUTH_PENDING_RETRY] === pending) {
632
- restoreLinxRetryBranch(interactive.session, pending.continueFromId);
633
- }
634
- }, 0);
635
- }
636
- function suppressLinxAuthExpiredAssistantError(interactive) {
637
- const streamingComponent = interactive.streamingComponent;
638
- if (streamingComponent) {
639
- interactive.chatContainer?.removeChild?.(streamingComponent);
640
- }
641
- interactive.streamingComponent = undefined;
642
- interactive.streamingMessage = undefined;
643
- interactive.footer?.invalidate?.();
644
- interactive.ui?.requestRender?.();
645
- }
646
- async function retryPendingLinxAuthTurn(interactive, reason) {
647
- if (reason !== 'expired') {
648
- return false;
649
- }
650
- const pending = interactive[LINX_AUTH_PENDING_RETRY];
651
- if (!pending) {
652
- return false;
653
- }
654
- interactive[LINX_AUTH_PENDING_RETRY] = undefined;
655
- const session = interactive.session;
656
- const sessionManager = session?.sessionManager;
657
- if (!session || !sessionManager) {
658
- return false;
659
- }
660
- await session.agent?.waitForIdle?.();
661
- try {
662
- restoreLinxRetryBranch(session, pending.continueFromId);
663
- if (typeof session.agent?.continue === 'function') {
664
- startLinxContinuation(interactive, session, pending);
665
- return true;
666
- }
667
- }
668
- catch (error) {
669
- if (!pending.promptText) {
670
- throw error;
671
- }
672
- }
673
- if (!pending.promptText || typeof session.prompt !== 'function') {
674
- return false;
675
- }
676
- restoreLinxRetryBranch(session, pending.promptParentId);
677
- const promptResult = session.prompt(pending.promptText);
678
- if (isPromiseLike(promptResult)) {
679
- promptResult.catch((error) => {
680
- const message = error instanceof Error ? error.message : String(error);
681
- interactive.showError?.(`LinX Cloud retry failed: ${message}`);
682
- });
683
- }
684
- return true;
685
- }
686
- function startLinxContinuation(interactive, session, pending) {
687
- try {
688
- const result = session.agent.continue();
689
- if (isPromiseLike(result)) {
690
- result.catch((error) => {
691
- void retryLinxPromptFallback(interactive, session, pending, error);
692
- });
693
- }
694
- }
695
- catch (error) {
696
- void retryLinxPromptFallback(interactive, session, pending, error);
697
- }
698
- }
699
- async function retryLinxPromptFallback(interactive, session, pending, cause) {
700
- if (!pending.promptText || typeof session?.prompt !== 'function') {
701
- const message = cause instanceof Error ? cause.message : String(cause);
702
- interactive.showError?.(`LinX Cloud retry failed: ${message}`);
703
- return;
704
- }
705
- try {
706
- restoreLinxRetryBranch(session, pending.promptParentId);
707
- await session.prompt(pending.promptText);
708
- }
709
- catch (error) {
710
- const message = error instanceof Error ? error.message : String(error);
711
- interactive.showError?.(`LinX Cloud retry failed: ${message}`);
712
- }
713
- }
714
- function restoreLinxRetryBranch(session, leafId) {
715
- const sessionManager = session?.sessionManager;
716
- if (!sessionManager) {
717
- return;
718
- }
719
- if (typeof leafId === 'string' && leafId) {
720
- sessionManager.branch?.(leafId);
721
- }
722
- else if (leafId === null) {
723
- sessionManager.resetLeaf?.();
724
- }
725
- const context = sessionManager.buildSessionContext?.();
726
- if (context?.messages && session.agent?.state) {
727
- session.agent.state.messages = context.messages;
728
- }
729
- }
730
- function findLastUserMessageText(messages) {
731
- if (!Array.isArray(messages)) {
732
- return undefined;
733
- }
734
- for (let index = messages.length - 1; index >= 0; index -= 1) {
735
- const text = extractUserMessageText(messages[index]);
736
- if (text) {
737
- return text;
738
- }
739
- }
740
- return undefined;
741
- }
742
- function findLastUserMessageEntry(sessionManager, leafId) {
743
- const branch = typeof sessionManager?.getBranch === 'function' && typeof leafId === 'string'
744
- ? sessionManager.getBranch(leafId)
745
- : undefined;
746
- const entries = Array.isArray(branch) && branch.length > 0
747
- ? branch
748
- : typeof sessionManager?.getEntries === 'function'
749
- ? sessionManager.getEntries()
750
- : [];
751
- if (!Array.isArray(entries)) {
752
- return undefined;
753
- }
754
- for (let index = entries.length - 1; index >= 0; index -= 1) {
755
- const entry = entries[index];
756
- if (isRecord(entry)
757
- && entry.type === 'message'
758
- && typeof entry.id === 'string'
759
- && isRecord(entry.message)
760
- && entry.message.role === 'user') {
761
- return {
762
- id: entry.id,
763
- parentId: normalizeParentId(entry.parentId),
764
- message: entry.message,
765
- };
766
- }
767
- }
768
- return undefined;
769
- }
770
- function normalizeParentId(parentId) {
771
- if (typeof parentId === 'string') {
772
- return parentId;
773
- }
774
- if (parentId === null) {
775
- return null;
776
- }
777
- return undefined;
778
- }
779
- function extractUserMessageText(message) {
780
- if (!isRecord(message) || message.role !== 'user') {
781
- return undefined;
782
- }
783
- const content = message.content;
784
- if (typeof content === 'string') {
785
- return content.trim() || undefined;
786
- }
787
- if (!Array.isArray(content)) {
788
- return undefined;
789
- }
790
- const text = content
791
- .filter((entry) => (isRecord(entry) && entry.type === 'text' && typeof entry.text === 'string'))
792
- .map((entry) => entry.text)
793
- .join('')
794
- .trim();
795
- return text || undefined;
796
- }
797
- async function refreshLinxAuthState(interactive) {
798
- clearLinxAuthPromptOnStart(interactive);
799
- syncRuntimeCredential(interactive);
800
- interactive.session?.modelRegistry?.refresh?.();
801
- await interactive.updateAvailableProviderCount?.();
802
- interactive.ui?.requestRender?.();
803
- }
804
- export const __testRefreshLinxAuthState = refreshLinxAuthState;
805
- function authStatusPrefix(reason) {
806
- if (reason === 'expired') {
807
- return 'LinX Cloud login refreshed.';
808
- }
809
- if (reason === 'startup') {
810
- return 'LinX Cloud connected.';
811
- }
812
- return 'LinX Cloud authorization updated.';
813
- }
814
- async function runLinxCloudLogin(interactive, authStorage, reason) {
815
- await authStorage.login(LINX_PROVIDER_ID, {
816
- forceFresh: true,
817
- onAuth(info) {
818
- showLinxLoginUrl(interactive, info);
819
- openLoginUrl(info.url, interactive);
820
- if (info.instructions) {
821
- interactive.showStatus?.(info.instructions);
822
- }
823
- },
824
- onProgress(message) {
825
- interactive.showStatus?.(message);
826
- interactive.ui?.requestRender?.();
827
- },
828
- onManualCodeInput(signal) {
829
- return promptForLinxManualRedirectUrl(interactive, signal);
830
- },
831
- });
832
- }
833
- async function runLinxCloudBrowserLogin(interactive, authStorage, reason) {
834
- if (canRenderLinxLoginDialog(interactive)) {
835
- await runLinxCloudLoginDialog(interactive, authStorage, reason);
836
- return;
837
- }
838
- await runLinxCloudLogin(interactive, authStorage, reason);
839
- }
840
- function canRenderLinxLoginDialog(interactive) {
841
- return Boolean(interactive.ui
842
- && typeof interactive.editorContainer?.clear === 'function'
843
- && typeof interactive.editorContainer?.addChild === 'function'
844
- && interactive.editor);
845
- }
846
- async function runLinxCloudLoginDialog(interactive, authStorage, reason) {
847
- const dialog = new LoginDialogComponent(interactive.ui, LINX_PROVIDER_ID, () => undefined);
848
- const restoreEditor = () => {
849
- interactive.editorContainer.clear();
850
- interactive.editorContainer.addChild(interactive.editor);
851
- interactive.ui?.setFocus?.(interactive.editor);
852
- interactive.ui?.requestRender?.();
853
- };
854
- interactive.editorContainer.clear();
855
- interactive.editorContainer.addChild(dialog);
856
- interactive.ui?.setFocus?.(dialog);
857
- interactive.ui?.requestRender?.();
858
- let manualRedirectResolve;
859
- let manualRedirectReject;
860
- const manualRedirectPromise = new Promise((resolve, reject) => {
861
- manualRedirectResolve = resolve;
862
- manualRedirectReject = reject;
863
- });
864
- try {
865
- await authStorage.login(LINX_PROVIDER_ID, {
866
- forceFresh: true,
867
- onAuth(info) {
868
- dialog.showAuth(info.url, info.instructions);
869
- dialog.showManualInput('Paste redirect URL below, or complete login in browser:')
870
- .then((value) => {
871
- if (value && manualRedirectResolve) {
872
- manualRedirectResolve(value);
873
- manualRedirectResolve = undefined;
874
- manualRedirectReject = undefined;
875
- }
876
- })
877
- .catch((error) => {
878
- if (manualRedirectReject) {
879
- manualRedirectReject(error);
880
- manualRedirectResolve = undefined;
881
- manualRedirectReject = undefined;
882
- }
883
- });
884
- },
885
- onProgress(message) {
886
- dialog.showProgress(message);
887
- },
888
- onManualCodeInput(signal) {
889
- return waitForLinxDialogManualRedirect(manualRedirectPromise, signal);
890
- },
891
- signal: dialog.signal,
892
- });
893
- }
894
- finally {
895
- restoreEditor();
896
- }
897
- }
898
- function waitForLinxDialogManualRedirect(manualRedirectPromise, signal) {
899
- if (!signal) {
900
- return manualRedirectPromise;
901
- }
902
- if (signal.aborted) {
903
- return Promise.resolve('');
904
- }
905
- return new Promise((resolve, reject) => {
906
- const onAbort = () => resolve('');
907
- signal.addEventListener('abort', onAbort, { once: true });
908
- manualRedirectPromise
909
- .then((value) => {
910
- signal.removeEventListener('abort', onAbort);
911
- resolve(value);
912
- })
913
- .catch((error) => {
914
- signal.removeEventListener('abort', onAbort);
915
- reject(error);
916
- });
917
- });
918
- }
919
- async function promptForLinxManualRedirectUrl(interactive, signal) {
920
- if (typeof interactive.showExtensionInput !== 'function') {
921
- throw new Error('Manual redirect paste is not available in this terminal. Run `linx login` in another shell if the browser callback is blocked.');
922
- }
923
- const redirect = await interactive.showExtensionInput([
924
- 'Paste final redirect URL',
925
- 'If the browser cannot return to this terminal, paste the full callback URL below.',
926
- ].join('\n'), 'http://127.0.0.1:PORT/auth/callback?code=...&state=...&iss=...', signal ? { signal } : undefined);
927
- const trimmed = typeof redirect === 'string' ? redirect.trim() : '';
928
- if (!trimmed) {
929
- throw new Error('Login cancelled');
930
- }
931
- return trimmed;
932
- }
933
- function syncRuntimeCredential(interactive) {
934
- const authStorage = interactive.session?.modelRegistry?.authStorage;
935
- authStorage?.setRuntimeApiKey?.(LINX_PROVIDER_ID, LINX_RUNTIME_MANAGED_AUTH_KEY);
936
- }
937
- function clearLinxAuthPromptOnStart(interactive) {
938
- const candidates = [
939
- interactive,
940
- interactive?.runtimeHost,
941
- interactive?.runtime,
942
- interactive?.session,
943
- ];
944
- for (const candidate of candidates) {
945
- const bridge = candidate?.linxAuthBridge;
946
- if (bridge && typeof bridge === 'object') {
947
- bridge.shouldPromptLoginOnStart = false;
948
- }
949
- }
950
- }
951
- function showLinxLoginUrl(interactive, info) {
952
- const lines = [
953
- '\x1b[1mLinX Cloud authorization\x1b[22m',
954
- 'Complete consent in the browser, then return here.',
955
- '',
956
- `\x1b[36m${info.url}\x1b[39m`,
957
- ];
958
- if (info.instructions) {
959
- lines.push('', `\x1b[2m${info.instructions}\x1b[22m`);
960
- }
961
- interactive.chatContainer?.addChild?.(new Text(lines.join('\n'), 1, 0));
962
- interactive.ui?.requestRender?.();
963
- }
964
- function openLoginUrl(url, interactive) {
965
- openExternalUrl(url, interactive);
966
- }
967
- function openExternalUrl(url, interactive) {
968
- if (typeof interactive.openExternal === 'function') {
969
- interactive.openExternal(url);
970
- return;
971
- }
972
- const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
973
- const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];
974
- const child = spawn(command, args, {
975
- detached: true,
976
- stdio: 'ignore',
977
- shell: false,
978
- });
979
- child.unref();
980
- }
981
- function prefillLoginCommand(interactive) {
982
- interactive.editor?.setText?.('/login');
983
- interactive.ui?.setFocus?.(interactive.editor);
984
- interactive.ui?.requestRender?.();
985
- }
986
- function patchHeader(interactive) {
987
- const originalInit = interactive.init?.bind(interactive);
988
- if (typeof originalInit !== 'function') {
989
- return;
990
- }
991
- interactive.init = async function patchedInit() {
992
- await originalInit();
993
- if (this[LINX_AUTH_LOGIN_ON_INIT]) {
994
- const reason = typeof this[LINX_AUTH_LOGIN_ON_INIT] === 'string'
995
- ? this[LINX_AUTH_LOGIN_ON_INIT]
996
- : 'startup';
997
- this[LINX_AUTH_LOGIN_ON_INIT] = false;
998
- queueMicrotask(() => startLinxCloudLogin(this, { reason }));
999
- }
1000
- const quietStartup = this.options?.verbose ? false : this.settingsManager?.getQuietStartup?.();
1001
- if (quietStartup) {
1002
- return;
1003
- }
1004
- let profileDisplayName = null;
1005
- const replacement = new LinxWelcomeCard(() => buildLinxWelcomeCardState(this, profileDisplayName));
1006
- const currentHeader = this.customHeader ?? this.builtInHeader;
1007
- const index = this.headerContainer?.children?.indexOf?.(currentHeader) ?? -1;
1008
- if (index >= 0) {
1009
- this.headerContainer.children[index] = replacement;
1010
- }
1011
- this.customHeader = replacement;
1012
- this.ui?.requestRender?.();
1013
- this.updateTerminalTitle?.();
1014
- void suppressPodStatusOutput(() => resolveProfileDisplayName())
1015
- .then((displayName) => {
1016
- if (!displayName || displayName === profileDisplayName) {
1017
- return;
1018
- }
1019
- profileDisplayName = displayName;
1020
- replacement.invalidate();
1021
- this.ui?.requestRender?.();
1022
- })
1023
- .catch(() => undefined);
1024
- };
1025
- }
1026
- class LinxWelcomeCard {
1027
- getState;
1028
- constructor(getState) {
1029
- this.getState = getState;
1030
- }
1031
- invalidate() { }
1032
- render(width) {
1033
- const innerWidth = Math.max(20, width - 4);
1034
- const state = this.getState();
1035
- const titleBlock = [
1036
- `\x1b[1mLinX\x1b[22m \x1b[2mv${LINX_CLI_VERSION}\x1b[22m`,
1037
- `\x1b[1mWelcome back, ${state.username}\x1b[22m`,
1038
- ];
1039
- const rows = [
1040
- renderField('WebID', state.webId, innerWidth),
1041
- renderField('Provider', state.provider, innerWidth),
1042
- renderField('Model', state.model, innerWidth),
1043
- renderField('Workspace', state.workspace, innerWidth),
1044
- renderField('Session', state.session, innerWidth),
1045
- '',
1046
- truncateToWidth(`\x1b[2mNext\x1b[22m ${state.next}`, innerWidth),
1047
- ];
1048
- const headerLines = titleBlock.map((line) => truncateToWidth(line, innerWidth));
1049
- const body = [
1050
- ...headerLines.map((line) => padLine(line, innerWidth)),
1051
- padLine('', innerWidth),
1052
- ...rows.flatMap((line) => wrapAndPad(line, innerWidth)),
1053
- ];
1054
- return [
1055
- `┌${'─'.repeat(innerWidth + 2)}┐`,
1056
- ...body.map((line) => `│ ${line} │`),
1057
- `└${'─'.repeat(innerWidth + 2)}┘`,
1058
- ];
1059
- }
1060
- }
1061
- export function buildLinxWelcomeCardState(interactive, profileDisplayName = null) {
1062
- const credentials = loadCredentials();
1063
- const webId = credentials?.webId ?? 'not logged in';
1064
- const workspace = interactive?.sessionManager?.getCwd?.() || process.cwd();
1065
- const sessionId = interactive?.sessionManager?.getSessionId?.();
1066
- const sessionName = interactive?.sessionManager?.getSessionName?.();
1067
- const session = sessionName && sessionId ? `${sessionName} (${formatSessionId(sessionId)})` : formatSessionId(sessionId);
1068
- const model = interactive?.session?.model?.id ?? 'unknown-model';
1069
- return {
1070
- webId,
1071
- username: profileDisplayName ?? extractUsernameFromWebId(webId),
1072
- provider: resolveRuntimeProviderLabel(interactive),
1073
- model,
1074
- workspace,
1075
- session,
1076
- next: [
1077
- safeKeyHint('tui.input.submit', 'send'),
1078
- safeKeyHint('app.model.select', 'model'),
1079
- safeRawKeyHint(LINX_TUI_LOGIN_COMMAND, 'auth'),
1080
- safeRawKeyHint(LINX_TUI_KEYMAP_COMMAND, LINX_TUI_KEYMAP_LABEL),
1081
- ].join(' \x1b[2m·\x1b[22m '),
1082
- };
1083
- }
1084
- function safeKeyHint(keybinding, description) {
1085
- try {
1086
- return keyHint(keybinding, description);
1087
- }
1088
- catch {
1089
- return `\x1b[2m${keybinding}\x1b[22m \x1b[2m${description}\x1b[22m`;
1090
- }
1091
- }
1092
- function safeRawKeyHint(key, description) {
1093
- try {
1094
- return rawKeyHint(key, description);
1095
- }
1096
- catch {
1097
- return `\x1b[2m${key}\x1b[22m \x1b[2m${description}\x1b[22m`;
1098
- }
1099
- }
1100
- function renderField(label, value, width) {
1101
- const prefix = `\x1b[2m${label}\x1b[22m`;
1102
- const paddedPrefix = prefix + ' '.repeat(Math.max(1, 10 - visibleWidth(prefix)));
1103
- return truncateToWidth(`${paddedPrefix} ${value}`, width);
1104
- }
1105
- function wrapAndPad(line, width) {
1106
- if (!line) {
1107
- return [padLine('', width)];
1108
- }
1109
- const wrapped = wrapTextWithAnsi(line, width);
1110
- return wrapped.length > 0
1111
- ? wrapped.map((entry) => padLine(entry, width))
1112
- : [padLine('', width)];
1113
- }
1114
- function formatSessionId(sessionId) {
1115
- if (typeof sessionId !== 'string' || !sessionId.trim()) {
1116
- return 'new session';
1117
- }
1118
- return sessionId.trim();
1119
- }
1120
- function padLine(line, width) {
1121
- const visible = visibleWidth(line);
1122
- if (visible >= width) {
1123
- return truncateToWidth(line, width);
1124
- }
1125
- return `${line}${' '.repeat(width - visible)}`;
1126
- }
1127
- function readLinxCliVersion() {
1128
- try {
1129
- const raw = readFileSync(new URL('../../../package.json', import.meta.url), 'utf-8');
1130
- const pkg = JSON.parse(raw);
1131
- return typeof pkg.version === 'string' && pkg.version.trim() ? pkg.version.trim() : '0.1.0';
1132
- }
1133
- catch {
1134
- return '0.1.0';
1135
- }
1136
- }
1137
- export function isVersionNewer(candidate, current) {
1138
- const candidateVersion = parseSemverLike(candidate);
1139
- const currentVersion = parseSemverLike(current);
1140
- if (!candidateVersion || !currentVersion) {
1141
- return candidate !== current;
1142
- }
1143
- for (const key of ['major', 'minor', 'patch']) {
1144
- if (candidateVersion[key] > currentVersion[key]) {
1145
- return true;
1146
- }
1147
- if (candidateVersion[key] < currentVersion[key]) {
1148
- return false;
1149
- }
1150
- }
1151
- return !candidateVersion.prerelease && currentVersion.prerelease;
1152
- }
1153
- function parseSemverLike(version) {
1154
- const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+.+)?$/.exec(version.trim());
1155
- if (!match) {
1156
- return null;
1157
- }
1158
- return {
1159
- major: Number(match[1]),
1160
- minor: Number(match[2]),
1161
- patch: Number(match[3]),
1162
- prerelease: Boolean(match[4]),
1163
- };
1164
- }
1165
- function resolveRuntimeProviderLabel(interactive) {
1166
- const bridge = interactive?.runtimeHost?.linxAuthBridge ?? interactive?.linxAuthBridge;
1167
- if (bridge?.providerLabel) {
1168
- return bridge.providerLabel;
1169
- }
1170
- return 'LinX Cloud';
1171
- }
1172
- function isRecord(value) {
1173
- return typeof value === 'object' && value !== null;
1174
- }
1175
- function normalizeNonEmptyString(value) {
1176
- if (typeof value !== 'string') {
1177
- return undefined;
1178
- }
1179
- const normalized = value.trim();
1180
- return normalized || undefined;
1181
- }
1182
- function stripAnsi(text) {
1183
- return text.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, '');
1184
- }
1185
- function isPromiseLike(value) {
1186
- return isRecord(value) && typeof value.then === 'function';
1187
- }
1188
- //# sourceMappingURL=branding.js.map