aegisone 1.0.34 → 1.0.37

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 (372) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1 -1
  3. package/SOURCE-OFFER.txt +9 -0
  4. package/bin/aegis.js +1 -322
  5. package/package.json +4 -5
  6. package/scripts/bump.mjs +1 -211
  7. package/scripts/bundle.js +1 -129
  8. package/scripts/predist.mjs +1 -976
  9. package/src/child.js +1 -285
  10. package/src/dispatch.js +1 -269
  11. package/src/doctor.js +1 -639
  12. package/src/host.js +1 -111
  13. package/src/iface/paths.js +3 -0
  14. package/src/iface/pty.js +3 -0
  15. package/src/iface/update.js +3 -0
  16. package/src/iface/window.js +3 -0
  17. package/src/permissions.js +1 -383
  18. package/src/probes.js +1 -159
  19. package/src/protocol.js +3 -0
  20. package/src/release.js +1 -409
  21. package/src/selfhost.js +3 -0
  22. package/vendor/cli/package.json +3 -7
  23. package/vendor/cli/scripts/check.mjs +1 -52
  24. package/vendor/cli/scripts/demo.mjs +1 -94
  25. package/vendor/cli/scripts/predist.mjs +1 -75
  26. package/vendor/cli/scripts/runtests.mjs +1 -56
  27. package/vendor/cli/scripts/seal-gate.mjs +1 -74
  28. package/vendor/cli/src/agents.js +1 -139
  29. package/vendor/cli/src/app.js +1 -2957
  30. package/vendor/cli/src/art.js +1 -289
  31. package/vendor/cli/src/chatflow.js +1 -3023
  32. package/vendor/cli/src/checkpoint.js +1 -90
  33. package/vendor/cli/src/clipboard.js +1 -424
  34. package/vendor/cli/src/cloudsync.js +1 -528
  35. package/vendor/cli/src/commands.js +1 -4089
  36. package/vendor/cli/src/config.js +1 -581
  37. package/vendor/cli/src/connect.js +1 -349
  38. package/vendor/cli/src/credentials.js +1 -33
  39. package/vendor/cli/src/deps.js +1 -232
  40. package/vendor/cli/src/devrun.js +1 -187
  41. package/vendor/cli/src/diff.js +1 -333
  42. package/vendor/cli/src/diffview.js +1 -296
  43. package/vendor/cli/src/engine.js +1 -297
  44. package/vendor/cli/src/entitlement.js +1 -355
  45. package/vendor/cli/src/events.js +1 -707
  46. package/vendor/cli/src/export.js +1 -67
  47. package/vendor/cli/src/filepreview.js +1 -153
  48. package/vendor/cli/src/fingerprint.js +1 -592
  49. package/vendor/cli/src/format.js +1 -259
  50. package/vendor/cli/src/fuzzy.js +1 -119
  51. package/vendor/cli/src/history.js +1 -423
  52. package/vendor/cli/src/init.js +1 -175
  53. package/vendor/cli/src/input.js +1 -139
  54. package/vendor/cli/src/keys.js +1 -183
  55. package/vendor/cli/src/markdown.js +1 -306
  56. package/vendor/cli/src/models.js +1 -507
  57. package/vendor/cli/src/naming.js +1 -57
  58. package/vendor/cli/src/overlays.js +1 -462
  59. package/vendor/cli/src/panels.js +1 -1418
  60. package/vendor/cli/src/ping.js +1 -226
  61. package/vendor/cli/src/presence.js +1 -238
  62. package/vendor/cli/src/render.js +1 -516
  63. package/vendor/cli/src/screen.js +1 -518
  64. package/vendor/cli/src/screens.js +1 -896
  65. package/vendor/cli/src/secret.js +1 -59
  66. package/vendor/cli/src/securefs.js +1 -359
  67. package/vendor/cli/src/settings.js +1 -155
  68. package/vendor/cli/src/shared.js +1 -52
  69. package/vendor/cli/src/sharedpaths.js +1 -53
  70. package/vendor/cli/src/signup.js +1 -156
  71. package/vendor/cli/src/summarize.js +1 -95
  72. package/vendor/cli/src/sysdiag.js +1 -585
  73. package/vendor/cli/src/system.js +1 -40
  74. package/vendor/cli/src/theme.js +1 -570
  75. package/vendor/cli/src/title.js +1 -220
  76. package/vendor/cli/src/todos.js +1 -115
  77. package/vendor/cli/src/tokens.js +1 -263
  78. package/vendor/cli/src/topup.js +1 -210
  79. package/vendor/cli/src/update.js +1 -191
  80. package/vendor/cli/vendor/client/aegis.js +1 -2441
  81. package/vendor/cli/vendor/client/attest.js +1 -518
  82. package/vendor/cli/vendor/client/authorship-key.js +1 -410
  83. package/vendor/cli/vendor/client/auto-provision.js +1 -134
  84. package/vendor/cli/vendor/client/brain-catalog.js +1 -268
  85. package/vendor/cli/vendor/client/byok-catalog.js +1 -199
  86. package/vendor/cli/vendor/client/catalog-client.js +1 -487
  87. package/vendor/cli/vendor/client/conversation-export.js +1 -177
  88. package/vendor/cli/vendor/client/credentials.js +1 -494
  89. package/vendor/cli/vendor/client/device-fingerprint.js +1 -141
  90. package/vendor/cli/vendor/client/drive-connect.js +1 -110
  91. package/vendor/cli/vendor/client/drive-upload.js +1 -234
  92. package/vendor/cli/vendor/client/env-file.js +1 -1273
  93. package/vendor/cli/vendor/client/fingerprint.js +1 -1064
  94. package/vendor/cli/vendor/client/foreign-memory.js +1 -669
  95. package/vendor/cli/vendor/client/google-signin.js +1 -133
  96. package/vendor/cli/vendor/client/hooks.js +1 -430
  97. package/vendor/cli/vendor/client/model-discovery.js +1 -373
  98. package/vendor/cli/vendor/client/naming.js +1 -283
  99. package/vendor/cli/vendor/client/platform.js +1 -937
  100. package/vendor/cli/vendor/client/prefs.js +1 -351
  101. package/vendor/cli/vendor/client/presence-constants.js +1 -107
  102. package/vendor/cli/vendor/client/presence.js +1 -438
  103. package/vendor/cli/vendor/client/record-vault.js +3 -1055
  104. package/vendor/cli/vendor/client/session-store.js +1 -575
  105. package/vendor/cli/vendor/client/topup.js +1 -297
  106. package/vendor/cli/vendor/client/touch.js +1 -458
  107. package/vendor/cli/vendor/client/update.js +1 -763
  108. package/vendor/cli/vendor/client/user-models.js +1 -381
  109. package/vendor/cli/vendor/desktop/lib/local/agents.js +1 -105
  110. package/vendor/cli/vendor/desktop/lib/local/attachments.js +1 -276
  111. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1045
  112. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -1028
  113. package/vendor/cli/vendor/desktop/lib/local/context.js +1 -125
  114. package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -3666
  115. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -660
  116. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +1 -228
  117. package/vendor/cli/vendor/desktop/lib/local/integrity.js +1 -1
  118. package/vendor/cli/vendor/desktop/lib/local/local.js +1 -2145
  119. package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -280
  120. package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -560
  121. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -238
  122. package/vendor/cli/vendor/desktop/lib/local/spill.js +1 -75
  123. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -300
  124. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -235
  125. package/vendor/cli/vendor/desktop/lib/settings.js +1 -890
  126. package/vendor/cli/vendor/desktop/main.js +67 -1
  127. package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1239
  128. package/vendor/cli/vendor/hosts/install.js +1 -638
  129. package/vendor/cli/vendor/hosts/openai-shim.js +1 -515
  130. package/vendor/cli/vendor/hosts/spec.js +1 -164
  131. package/vendor/cli/vendor/hosts/targets.js +1 -346
  132. package/vendor/cli/vendor/mcp/server.js +1 -221
  133. package/vendor/cli/vendor/mcp/tools.js +1 -408
  134. package/vendor/cli/vendor/one/src/child.js +1 -285
  135. package/vendor/cli/vendor/one/src/permissions.js +1 -383
  136. package/vendor/cli/vendor/one/src/selfhost.js +3 -0
  137. package/vendor/desktop/bin/aegis.js +1 -32
  138. package/vendor/desktop/lib/account-key.js +1 -56
  139. package/vendor/desktop/lib/auto.js +1 -461
  140. package/vendor/desktop/lib/avatar/companion.js +1 -698
  141. package/vendor/desktop/lib/avatar/cosmetics.js +1 -532
  142. package/vendor/desktop/lib/avatar/events.js +1 -344
  143. package/vendor/desktop/lib/avatar/holder-turn.js +1 -350
  144. package/vendor/desktop/lib/avatar/holders.js +1 -612
  145. package/vendor/desktop/lib/avatar/identity.js +1 -641
  146. package/vendor/desktop/lib/avatar/level.js +1 -368
  147. package/vendor/desktop/lib/avatar/mirror.js +1 -524
  148. package/vendor/desktop/lib/avatar/persona.js +1 -388
  149. package/vendor/desktop/lib/avatar/profile.js +1 -977
  150. package/vendor/desktop/lib/avatar/register.js +1 -307
  151. package/vendor/desktop/lib/avatar/store.js +1 -472
  152. package/vendor/desktop/lib/avatar/tiers.js +1 -38
  153. package/vendor/desktop/lib/avatar/transfer.js +1 -415
  154. package/vendor/desktop/lib/avatar/turn.js +1 -216
  155. package/vendor/desktop/lib/avatar/voice.js +1 -328
  156. package/vendor/desktop/lib/avatar/xp.js +1 -404
  157. package/vendor/desktop/lib/deep-link.js +1 -120
  158. package/vendor/desktop/lib/fingerprint.js +2 -347
  159. package/vendor/desktop/lib/google-connect.js +1 -323
  160. package/vendor/desktop/lib/local/agents.js +1 -105
  161. package/vendor/desktop/lib/local/attachments.js +1 -276
  162. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  163. package/vendor/desktop/lib/local/claude-pro.js +1 -1028
  164. package/vendor/desktop/lib/local/context.js +1 -125
  165. package/vendor/desktop/lib/local/engine.js +1 -3666
  166. package/vendor/desktop/lib/local/entitlement.js +1 -660
  167. package/vendor/desktop/lib/local/git-scope.js +1 -228
  168. package/vendor/desktop/lib/local/integrity.js +1 -1
  169. package/vendor/desktop/lib/local/local.js +1 -2145
  170. package/vendor/desktop/lib/local/prompt.js +1 -280
  171. package/vendor/desktop/lib/local/queue.js +1 -560
  172. package/vendor/desktop/lib/local/session-rounds.js +1 -238
  173. package/vendor/desktop/lib/local/spill.js +1 -75
  174. package/vendor/desktop/lib/local/telemetry.js +1 -470
  175. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  176. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  177. package/vendor/desktop/lib/provider-key-mirror.js +1 -252
  178. package/vendor/desktop/lib/quick-launcher.js +1 -84
  179. package/vendor/desktop/lib/settings.js +1 -890
  180. package/vendor/desktop/lib/sync/memory-queue.js +1 -60
  181. package/vendor/desktop/lib/sync/persist-gate.js +1 -148
  182. package/vendor/desktop/lib/sync/sessions.js +1 -106
  183. package/vendor/desktop/lib/window-state.js +1 -66
  184. package/vendor/desktop/main.js +67 -1
  185. package/vendor/desktop/package.json +3 -5
  186. package/vendor/desktop/preload.js +1 -679
  187. package/vendor/desktop/renderer/app.js +1 -7250
  188. package/vendor/desktop/renderer/avatar/assemble.js +1 -335
  189. package/vendor/desktop/renderer/avatar/avatar.js +1 -380
  190. package/vendor/desktop/renderer/avatar/cards.js +1 -141
  191. package/vendor/desktop/renderer/avatar/hud.js +1 -206
  192. package/vendor/desktop/renderer/avatar/machine.js +1 -213
  193. package/vendor/desktop/renderer/avatar/pane.js +1 -439
  194. package/vendor/desktop/renderer/avatar/parts.js +1 -437
  195. package/vendor/desktop/renderer/budget.js +1 -172
  196. package/vendor/desktop/renderer/companion.js +1 -223
  197. package/vendor/desktop/renderer/diff.js +1 -359
  198. package/vendor/desktop/renderer/diffview.js +1 -336
  199. package/vendor/desktop/renderer/filepreview.js +1 -211
  200. package/vendor/desktop/renderer/fingerprint.js +3 -789
  201. package/vendor/desktop/renderer/markdown.js +1 -168
  202. package/vendor/desktop/renderer/provider-mark.js +1 -311
  203. package/vendor/desktop/renderer/provider-toolbar.js +1 -134
  204. package/vendor/desktop/renderer/providers.js +1 -259
  205. package/vendor/desktop/renderer/quick.js +1 -285
  206. package/vendor/desktop/renderer/stream-policy.js +1 -387
  207. package/vendor/desktop/renderer/transcript-view.js +1 -323
  208. package/vendor/desktop/renderer/usage.js +1 -1239
  209. package/vendor/desktop/vendor/aegis.js +1 -2441
  210. package/vendor/desktop/vendor/attest.js +1 -518
  211. package/vendor/desktop/vendor/authorship-key.js +1 -410
  212. package/vendor/desktop/vendor/auto-provision.js +1 -134
  213. package/vendor/desktop/vendor/brain-catalog.js +1 -268
  214. package/vendor/desktop/vendor/byok-catalog.js +1 -199
  215. package/vendor/desktop/vendor/catalog-client.js +1 -487
  216. package/vendor/desktop/vendor/conversation-export.js +1 -177
  217. package/vendor/desktop/vendor/credentials.js +1 -494
  218. package/vendor/desktop/vendor/device-fingerprint.js +1 -141
  219. package/vendor/desktop/vendor/drive-connect.js +1 -110
  220. package/vendor/desktop/vendor/drive-upload.js +1 -234
  221. package/vendor/desktop/vendor/env-file.js +1 -1273
  222. package/vendor/desktop/vendor/faces/cli/LICENSE +661 -0
  223. package/vendor/desktop/vendor/faces/cli/README.md +784 -0
  224. package/vendor/desktop/vendor/faces/cli/bin/aegiscode.js +20 -0
  225. package/vendor/desktop/vendor/faces/cli/package.json +44 -0
  226. package/vendor/desktop/vendor/faces/cli/scripts/check.mjs +4 -0
  227. package/vendor/desktop/vendor/faces/cli/scripts/demo.mjs +4 -0
  228. package/vendor/desktop/vendor/faces/cli/scripts/predist.mjs +4 -0
  229. package/vendor/desktop/vendor/faces/cli/scripts/runtests.mjs +4 -0
  230. package/vendor/desktop/vendor/faces/cli/scripts/seal-gate.mjs +3 -0
  231. package/vendor/desktop/vendor/faces/cli/src/agents.js +3 -0
  232. package/vendor/desktop/vendor/faces/cli/src/app.js +3 -0
  233. package/vendor/desktop/vendor/faces/cli/src/art.js +3 -0
  234. package/vendor/desktop/vendor/faces/cli/src/autonomous.js +3 -0
  235. package/vendor/desktop/vendor/faces/cli/src/caps.js +3 -0
  236. package/vendor/desktop/vendor/faces/cli/src/chatflow.js +3 -0
  237. package/vendor/desktop/vendor/faces/cli/src/checkpoint.js +3 -0
  238. package/vendor/desktop/vendor/faces/cli/src/clipboard.js +3 -0
  239. package/vendor/desktop/vendor/faces/cli/src/cloudsync.js +3 -0
  240. package/vendor/desktop/vendor/faces/cli/src/commands.js +3 -0
  241. package/vendor/desktop/vendor/faces/cli/src/config.js +3 -0
  242. package/vendor/desktop/vendor/faces/cli/src/connect.js +3 -0
  243. package/vendor/desktop/vendor/faces/cli/src/credentials.js +3 -0
  244. package/vendor/desktop/vendor/faces/cli/src/deps.js +3 -0
  245. package/vendor/desktop/vendor/faces/cli/src/devrun.js +3 -0
  246. package/vendor/desktop/vendor/faces/cli/src/diff.js +3 -0
  247. package/vendor/desktop/vendor/faces/cli/src/diffview.js +3 -0
  248. package/vendor/desktop/vendor/faces/cli/src/engine.js +3 -0
  249. package/vendor/desktop/vendor/faces/cli/src/entitlement.js +3 -0
  250. package/vendor/desktop/vendor/faces/cli/src/events.js +3 -0
  251. package/vendor/desktop/vendor/faces/cli/src/export.js +3 -0
  252. package/vendor/desktop/vendor/faces/cli/src/filepreview.js +3 -0
  253. package/vendor/desktop/vendor/faces/cli/src/fingerprint.js +3 -0
  254. package/vendor/desktop/vendor/faces/cli/src/format.js +3 -0
  255. package/vendor/desktop/vendor/faces/cli/src/fuzzy.js +3 -0
  256. package/vendor/desktop/vendor/faces/cli/src/gate.js +3 -0
  257. package/vendor/desktop/vendor/faces/cli/src/history.js +3 -0
  258. package/vendor/desktop/vendor/faces/cli/src/init.js +3 -0
  259. package/vendor/desktop/vendor/faces/cli/src/input.js +3 -0
  260. package/vendor/desktop/vendor/faces/cli/src/keys.js +3 -0
  261. package/vendor/desktop/vendor/faces/cli/src/limits.js +3 -0
  262. package/vendor/desktop/vendor/faces/cli/src/markdown.js +3 -0
  263. package/vendor/desktop/vendor/faces/cli/src/mcp.js +3 -0
  264. package/vendor/desktop/vendor/faces/cli/src/models.js +3 -0
  265. package/vendor/desktop/vendor/faces/cli/src/naming.js +3 -0
  266. package/vendor/desktop/vendor/faces/cli/src/overlays.js +3 -0
  267. package/vendor/desktop/vendor/faces/cli/src/panels.js +3 -0
  268. package/vendor/desktop/vendor/faces/cli/src/permissions.js +3 -0
  269. package/vendor/desktop/vendor/faces/cli/src/ping.js +3 -0
  270. package/vendor/desktop/vendor/faces/cli/src/presence.js +3 -0
  271. package/vendor/desktop/vendor/faces/cli/src/provenance.js +58 -0
  272. package/vendor/desktop/vendor/faces/cli/src/provenance.lock.json +36 -0
  273. package/vendor/desktop/vendor/faces/cli/src/render.js +3 -0
  274. package/vendor/desktop/vendor/faces/cli/src/screen.js +3 -0
  275. package/vendor/desktop/vendor/faces/cli/src/screens.js +3 -0
  276. package/vendor/desktop/vendor/faces/cli/src/secret.js +3 -0
  277. package/vendor/desktop/vendor/faces/cli/src/securefs.js +3 -0
  278. package/vendor/desktop/vendor/faces/cli/src/settings.js +3 -0
  279. package/vendor/desktop/vendor/faces/cli/src/shared.js +3 -0
  280. package/vendor/desktop/vendor/faces/cli/src/sharedpaths.js +3 -0
  281. package/vendor/desktop/vendor/faces/cli/src/signup.js +3 -0
  282. package/vendor/desktop/vendor/faces/cli/src/summarize.js +3 -0
  283. package/vendor/desktop/vendor/faces/cli/src/sysdiag.js +3 -0
  284. package/vendor/desktop/vendor/faces/cli/src/system.js +3 -0
  285. package/vendor/desktop/vendor/faces/cli/src/theme.js +3 -0
  286. package/vendor/desktop/vendor/faces/cli/src/title.js +3 -0
  287. package/vendor/desktop/vendor/faces/cli/src/todos.js +3 -0
  288. package/vendor/desktop/vendor/faces/cli/src/tokens.js +3 -0
  289. package/vendor/desktop/vendor/faces/cli/src/topup.js +3 -0
  290. package/vendor/desktop/vendor/faces/cli/src/update.js +3 -0
  291. package/vendor/desktop/vendor/faces/cli/vendor/client/aegis.js +4 -0
  292. package/vendor/desktop/vendor/faces/cli/vendor/client/attest.js +3 -0
  293. package/vendor/desktop/vendor/faces/cli/vendor/client/authorship-key.js +3 -0
  294. package/vendor/desktop/vendor/faces/cli/vendor/client/auto-provision.js +3 -0
  295. package/vendor/desktop/vendor/faces/cli/vendor/client/brain-catalog.js +3 -0
  296. package/vendor/desktop/vendor/faces/cli/vendor/client/byok-catalog.js +3 -0
  297. package/vendor/desktop/vendor/faces/cli/vendor/client/catalog-client.js +3 -0
  298. package/vendor/desktop/vendor/faces/cli/vendor/client/conversation-export.js +3 -0
  299. package/vendor/desktop/vendor/faces/cli/vendor/client/credentials.js +3 -0
  300. package/vendor/desktop/vendor/faces/cli/vendor/client/device-fingerprint.js +3 -0
  301. package/vendor/desktop/vendor/faces/cli/vendor/client/drive-connect.js +3 -0
  302. package/vendor/desktop/vendor/faces/cli/vendor/client/drive-upload.js +3 -0
  303. package/vendor/desktop/vendor/faces/cli/vendor/client/env-file.js +3 -0
  304. package/vendor/desktop/vendor/faces/cli/vendor/client/fingerprint.js +3 -0
  305. package/vendor/desktop/vendor/faces/cli/vendor/client/foreign-memory.js +3 -0
  306. package/vendor/desktop/vendor/faces/cli/vendor/client/google-signin.js +3 -0
  307. package/vendor/desktop/vendor/faces/cli/vendor/client/hooks.js +3 -0
  308. package/vendor/desktop/vendor/faces/cli/vendor/client/model-discovery.js +3 -0
  309. package/vendor/desktop/vendor/faces/cli/vendor/client/naming.js +3 -0
  310. package/vendor/desktop/vendor/faces/cli/vendor/client/platform.js +3 -0
  311. package/vendor/desktop/vendor/faces/cli/vendor/client/prefs.js +3 -0
  312. package/vendor/desktop/vendor/faces/cli/vendor/client/presence-constants.js +3 -0
  313. package/vendor/desktop/vendor/faces/cli/vendor/client/presence.js +3 -0
  314. package/vendor/desktop/vendor/faces/cli/vendor/client/record-vault.js +105 -0
  315. package/vendor/desktop/vendor/faces/cli/vendor/client/session-store.js +3 -0
  316. package/vendor/desktop/vendor/faces/cli/vendor/client/topup.js +3 -0
  317. package/vendor/desktop/vendor/faces/cli/vendor/client/touch.js +3 -0
  318. package/vendor/desktop/vendor/faces/cli/vendor/client/update.js +3 -0
  319. package/vendor/desktop/vendor/faces/cli/vendor/client/user-models.js +3 -0
  320. package/vendor/desktop/vendor/faces/cli/vendor/covenant/README.md +21 -0
  321. package/vendor/desktop/vendor/faces/cli/vendor/covenant/aegis.seal +177 -0
  322. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/aegis-seal.mjs +241 -0
  323. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/agents.js +3 -0
  324. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/attachments.js +3 -0
  325. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/autonomous.js +3 -0
  326. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/claude-pro.js +3 -0
  327. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/context.js +3 -0
  328. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/covenant.js +567 -0
  329. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/engine.js +3 -0
  330. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/entitlement.js +3 -0
  331. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/exec-plan.js +3 -0
  332. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/git-scope.js +3 -0
  333. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/integrity.js +3 -0
  334. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/local.js +3 -0
  335. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/prompt.js +3 -0
  336. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/queue.js +3 -0
  337. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/session-rounds.js +3 -0
  338. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/shell.js +3 -0
  339. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/spill.js +3 -0
  340. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/tools.js +3 -0
  341. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/turn-guard.js +3 -0
  342. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/worktree-lock.js +3 -0
  343. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/settings.js +3 -0
  344. package/vendor/desktop/vendor/faces/cli/vendor/desktop/main.js +4 -0
  345. package/vendor/desktop/vendor/faces/cli/vendor/desktop/renderer/usage.js +3 -0
  346. package/vendor/desktop/vendor/faces/cli/vendor/hosts/install.js +1 -0
  347. package/vendor/desktop/vendor/faces/cli/vendor/hosts/openai-shim.js +2 -0
  348. package/vendor/desktop/vendor/faces/cli/vendor/hosts/spec.js +1 -0
  349. package/vendor/desktop/vendor/faces/cli/vendor/hosts/targets.js +1 -0
  350. package/vendor/desktop/vendor/faces/cli/vendor/mcp/server.js +4 -0
  351. package/vendor/desktop/vendor/faces/cli/vendor/mcp/tools.js +3 -0
  352. package/vendor/desktop/vendor/faces/cli/vendor/one/src/child.js +3 -0
  353. package/vendor/desktop/vendor/faces/cli/vendor/one/src/permissions.js +3 -0
  354. package/vendor/desktop/vendor/faces/cli/vendor/one/src/selfhost.js +3 -0
  355. package/vendor/desktop/vendor/faces/cli/vendor/tools/agent-gate.mjs +1203 -0
  356. package/vendor/desktop/vendor/fingerprint.js +1 -1064
  357. package/vendor/desktop/vendor/foreign-memory.js +1 -669
  358. package/vendor/desktop/vendor/google-signin.js +1 -133
  359. package/vendor/desktop/vendor/hooks.js +1 -430
  360. package/vendor/desktop/vendor/model-discovery.js +1 -373
  361. package/vendor/desktop/vendor/naming.js +1 -283
  362. package/vendor/desktop/vendor/platform.js +1 -937
  363. package/vendor/desktop/vendor/prefs.js +1 -351
  364. package/vendor/desktop/vendor/presence-constants.js +1 -107
  365. package/vendor/desktop/vendor/presence.js +1 -438
  366. package/vendor/desktop/vendor/record-vault.js +3 -1055
  367. package/vendor/desktop/vendor/selfhost.js +3 -0
  368. package/vendor/desktop/vendor/session-store.js +1 -575
  369. package/vendor/desktop/vendor/topup.js +1 -297
  370. package/vendor/desktop/vendor/touch.js +1 -458
  371. package/vendor/desktop/vendor/update.js +1 -763
  372. package/vendor/desktop/vendor/user-models.js +1 -381
@@ -1,520 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * Terminal plumbing: cell-accurate width maths, the span/line render model,
10
- * wrapping, and the ephemeral "live" region the CLI redraws while a call is in
11
- * flight.
12
- *
13
- * The render model is the upstream engine's: a line is an array of spans
14
- * `{ t: text, s: style-prefix, w: cell-width }`, built with `span()`, measured
15
- * with `lineWidth()`, padded/truncated with `padLine()`, and painted with
16
- * `paint()`. Two width functions exist because they have different callers:
17
- * `w()` returns the display width of a *plain string* (the linear transcript
18
- * and the string renderers in render.js use it), while `padLine()` does the
19
- * per-codepoint maths for a span line (the overlays use it).
20
- *
21
- * Design note — this CLI is a LINEAR transcript, not a full-screen alt-buffer
22
- * TUI (which is what Claude Code and the upstream engine are). Finished turns are
23
- * written once to scrollback, so output stays selectable, pipeable and
24
- * scrollback-searchable; only the one live status/spinner line is redrawn. The
25
- * main session loop deliberately does NOT enter the alternate screen — `--print`
26
- * and piped runs must keep working. The alt-screen / mouse / bracketed-paste
27
- * helpers below exist only so the overlay renderers (overlays.js) and any future
28
- * modal can paint and restore cleanly; they are never called on the transcript
29
- * path. Keeping the two concerns in one module (rather than two) is the same
30
- * split the reference uses.
31
- */
32
-
33
- const ANSI_RE = /\x1b\[[0-9;]*[A-Za-z]/g;
34
-
35
- const { caps, cellWidth } = require('./caps.js');
36
-
37
- // Real terminal cell width (wcwidth-style) comes from `caps.js`, which is the
38
- // one place the table lives: a platform that draws a rune two cells wide that
39
- // wcwidth does not know about (`AEGIS_WIDE_RUNES=✦`) has to shift *every* width
40
- // decision at once, and a second copy of the table here is exactly how the
41
- // transcript pads to one width while the overlay pads to another.
42
- const cwidth = (ch) => cellWidth(ch);
43
-
44
- function stripAnsi(s) {
45
- return String(s).replace(ANSI_RE, '');
46
- }
47
-
48
- /** Display width of a string in terminal cells. ANSI escapes are transparent
49
- * (so a styled line measures the same as its visible text) — kept from the
50
- * previous revision so callers measuring render output stay correct. */
51
- function w(s) {
52
- let n = 0;
53
- for (const ch of stripAnsi(s)) n += cwidth(ch);
54
- return n;
55
- }
56
-
57
- /** Truncate a plain string to `width` cells without cutting a wide/combining
58
- * codepoint. */
59
- function clip(s, width) {
60
- if (w(s) <= width) return s;
61
- let out = '';
62
- let used = 0;
63
- for (const ch of String(s)) {
64
- const cw = cwidth(ch);
65
- if (used + cw > width) break;
66
- out += ch;
67
- used += cw;
68
- }
69
- return out;
70
- }
71
-
72
- /** Pad (or clip) a plain string to exactly `width` cells. */
73
- function pad(s, width) {
74
- const t = clip(s, width);
75
- return t + ' '.repeat(Math.max(0, width - w(t)));
76
- }
77
-
78
- /** Right-align a plain string inside `width`. */
79
- function padStart(s, width) {
80
- const t = clip(s, width);
81
- return ' '.repeat(Math.max(0, width - w(t))) + t;
82
- }
83
-
84
- // ── the span/line render model ──────────────────────────────────────────────
85
-
86
- /** A styled text run. Shape { t, s, w } is the contract with overlays.js and
87
- * markdown.js. */
88
- function span(style, t) {
89
- return { t, s: style, w: w(t) };
90
- }
91
-
92
- /** Total display width of a span line. */
93
- const lineWidth = (line) => line.reduce((a, sp) => a + sp.w, 0);
94
-
95
- /**
96
- * Pad / truncate a span line to an exact cell width. Truncation is visual only
97
- * (a trailing style reset may be dropped) — the terminal clips whole glyphs, and
98
- * a 2-cell glyph is never split mid-width.
99
- */
100
- function padLine(line, width) {
101
- let cur = 0;
102
- const out = [];
103
- for (const sp of line) {
104
- if (cur >= width) break;
105
- let t = sp.t;
106
- let tw = sp.w;
107
- if (cur + tw > width) {
108
- // Truncate by whole code points that fit in the remaining cells — a
109
- // codepoint slice (keep chars) would split a 2-cell glyph mid-width.
110
- const room = width - cur;
111
- let piece = '';
112
- let used = 0;
113
- for (const ch of [...t]) {
114
- const cw = w(ch);
115
- if (used + cw > room) break;
116
- piece += ch;
117
- used += cw;
118
- }
119
- t = piece;
120
- tw = used;
121
- }
122
- out.push({ t, s: sp.s, w: tw });
123
- cur += tw;
124
- }
125
- if (cur < width) out.push(span('', ' '.repeat(width - cur)));
126
- return out;
127
- }
128
-
129
- /** Term size, clamped so a zero-column report (CI, redirected stdout) still
130
- * yields a paintable frame. Resolved through `caps.js` so `AEGIS_WIDTH` and
131
- * `--width` reach every caller — the overlays used to read
132
- * `process.stdout.columns` directly, which is 0 on a redirected run and left
133
- * the frame 80 columns wide while the transcript had already been told
134
- * otherwise. */
135
- const getSize = () => {
136
- const c = caps();
137
- return { cols: c.cols, rows: c.rows };
138
- };
139
-
140
- // ── wrapping (plain strings; the string renderers use these) ─────────────────
141
-
142
- /**
143
- * Word-wrap one logical plain line to `width` cells, preserving words and never
144
- * breaking mid-word unless the word alone exceeds the width.
145
- */
146
- function wrapLine(line, width, indent = '') {
147
- const limit = Math.max(8, width);
148
- if (w(line) <= limit) return [line];
149
- const words = line.split(' ');
150
- const out = [];
151
- let cur = '';
152
- for (const word of words) {
153
- const piece = cur ? `${cur} ${word}` : word;
154
- if (w(piece) <= limit) {
155
- cur = piece;
156
- continue;
157
- }
158
- if (cur) out.push(cur);
159
- if (w(word) <= limit) {
160
- cur = word;
161
- continue;
162
- }
163
- // A single token longer than the line: hard-split on cells.
164
- let rest = word;
165
- while (w(rest) > limit) {
166
- const head = clip(rest, limit);
167
- out.push(head);
168
- rest = rest.slice(head.length);
169
- }
170
- cur = rest;
171
- }
172
- if (cur || !out.length) out.push(cur);
173
- return out;
174
- }
175
-
176
- /** Wrap a block of plain text (honours existing newlines), applying `indent`. */
177
- function wrapBlock(text, width, indent = '', hang = false) {
178
- const lines = [];
179
- for (const raw of String(text).split('\n')) {
180
- if (raw === '') {
181
- lines.push('');
182
- continue;
183
- }
184
- const parts = wrapLine(raw, width - w(indent));
185
- parts.forEach((p) => lines.push(indent + p));
186
- }
187
- return lines;
188
- }
189
-
190
- // ── cursor / screen control ─────────────────────────────────────────────────
191
-
192
- const ESC = {
193
- hideCursor: '\x1b[?25l',
194
- showCursor: '\x1b[?25h',
195
- clearToEnd: '\x1b[0K',
196
- clearLine: '\x1b[2K',
197
- clearScreen: '\x1b[2J\x1b[H',
198
- up: (n) => (n > 0 ? `\x1b[${n}A` : ''),
199
- down: (n) => (n > 0 ? `\x1b[${n}B` : ''),
200
- col: (n) => `\x1b[${n}G`,
201
- };
202
-
203
- const hideCursor = () => process.stdout.write('\x1b[?25l');
204
- const showCursor = () => process.stdout.write('\x1b[?25h');
205
- const moveTo = (row, col) => process.stdout.write(`\x1b[${row};${col}H`);
206
-
207
- function clearScreen() {
208
- process.stdout.write('\x1b[2J\x1b[H');
209
- }
210
-
211
- // Alternate screen buffer. Not used by the transcript (see the module note);
212
- // available to overlays that need to paint and then restore the pre-launch
213
- // terminal exactly. Guarded so paired enter/leave stay balanced.
214
- let inAlt = false;
215
- function enterAltScreen() {
216
- if (inAlt) return;
217
- inAlt = true;
218
- process.stdout.write('\x1b[?1049h');
219
- }
220
- function leaveAltScreen() {
221
- if (!inAlt) return;
222
- inAlt = false;
223
- process.stdout.write('\x1b[?1049l');
224
- flushExitNotice();
225
- }
226
-
227
- // ── exit notice: text that must land OUTSIDE the alternate screen ───────────
228
- // The resume hint is written on the way out, and its *position* is the whole
229
- // contract: written inside the screen, the restore that follows paints over it
230
- // and the user is told nothing. Ordering cannot deliver that guarantee here —
231
- // the teardown is reachable from three places (the session loop's `finally`,
232
- // the session's `process.once('exit')` handler, and the entrypoint's own exit
233
- // handler) and which one runs first varies with timing, which showed up as the
234
- // same 81 bytes in two positions across runs and platforms. So the notice is
235
- // not *scheduled* next to the restore; it is emitted *by* the restore, cleared
236
- // as it goes, which makes "outside the screen" true by construction and lets
237
- // only one of the paths ever produce it.
238
- let exitNotice = null;
239
- function queueExitNotice(text) {
240
- exitNotice = text;
241
- }
242
- function flushExitNotice() {
243
- if (exitNotice === null) return;
244
- const text = exitNotice;
245
- exitNotice = null;
246
- process.stdout.write(text);
247
- }
248
- const hasExitNotice = () => exitNotice !== null;
249
- const isAltScreen = () => inAlt;
250
-
251
- // Bracketed paste (DEC 2004): a paste arrives as one \x1b[200~ … \x1b[201~
252
- // chunk instead of a burst of keystrokes.
253
- const enableBracketedPaste = () => process.stdout.write('\x1b[?2004h');
254
- const disableBracketedPaste = () => process.stdout.write('\x1b[?2004l');
255
-
256
- // Mouse tracking + SGR coordinates. DECSET 1000 is the press/wheel report the
257
- // click-to-toggle path needs; 1002 adds DRAG reports, without which a
258
- // drag-to-mark gesture is invisible — the terminal reports the press and the
259
- // release and nothing in between, so a sweep over three lines arrives as a
260
- // single-cell marking. The terminal's own selection can't substitute for it:
261
- // the alt screen has no scrollback for the terminal to select from. Disabled on
262
- // exit so the shell we return to isn't left forwarding raw wheel bytes as input.
263
- const enableMouseTracking = () => process.stdout.write('\x1b[?1000h\x1b[?1002h\x1b[?1006h');
264
- const disableMouseTracking = () => process.stdout.write('\x1b[?1000l\x1b[?1002l\x1b[?1006l');
265
-
266
- // Reverse video, used to paint a mouse marking (text selection) over the
267
- // already-styled grid: the selected slice keeps its own colors and inverts its
268
- // background. SELECT_OFF (SGR 27) turns inversion back off for the spans that
269
- // follow the selection on the same row — paint() only resets attributes at the
270
- // start of a row, so a leftover inverse would wash out the row's tail.
271
- const SELECT_ON = '\x1b[7m';
272
- const SELECT_OFF = '\x1b[27m';
273
-
274
- // ── mouse marking (text selection) ─────────────────────────────────────────
275
- // The TUI owns the alternate screen, so the terminal's own drag-to-select is
276
- // unreachable — a marking has to be built from the SGR drag stream (events.js)
277
- // against the grid the last frame painted (chatflow.js keeps it as
278
- // `frameLines`). All of it is pure and cell-based: coordinates are grid row +
279
- // CELL column (0-based), never string indices, so wide glyphs and padded rows
280
- // can't shift the selection off the text the reader is pointing at.
281
- // Ported from the upstream engine reference so both hosts mark identically.
282
-
283
- /** Two drag endpoints → the same range in reading order (top-left first). */
284
- function selectionRange(a, b) {
285
- if (a.row < b.row || (a.row === b.row && a.col <= b.col)) {
286
- return { startRow: a.row, startCol: a.col, endRow: b.row, endCol: b.col };
287
- }
288
- return { startRow: b.row, startCol: b.col, endRow: a.row, endCol: a.col };
289
- }
290
-
291
- /**
292
- * Clip a span line to the cell range [from, to). Edges are cut on whole code
293
- * points via w() — slicing by character index would split a 2-cell glyph and
294
- * shift every later column by one. Spans keep their own style, so a marking
295
- * across a colored diff block stays colored.
296
- */
297
- function sliceLine(line, from, to) {
298
- const out = [];
299
- let col = 0;
300
- for (const sp of line) {
301
- const start = col;
302
- col += sp.w;
303
- if (col <= from || start >= to) continue;
304
- let text = sp.t;
305
- let seen = start; // cell column of text[0]
306
- if (seen < from) {
307
- const drop = from - seen;
308
- let acc = 0;
309
- let cut = 0;
310
- for (const ch of text) {
311
- if (acc >= drop) break;
312
- acc += w(ch);
313
- cut += ch.length;
314
- }
315
- text = text.slice(cut);
316
- seen += acc;
317
- }
318
- if (seen + w(text) > to) {
319
- let acc = 0;
320
- let keep = '';
321
- for (const ch of text) {
322
- const cw = w(ch);
323
- if (seen + acc + cw > to) break;
324
- keep += ch;
325
- acc += cw;
326
- }
327
- text = keep;
328
- }
329
- if (text) out.push({ t: text, s: sp.s, w: w(text) });
330
- }
331
- return out;
332
- }
333
-
334
- /**
335
- * The text a marking covers, read as a terminal would copy it: hard newlines
336
- * between rows, trailing padding trimmed (rows are padded to the full width,
337
- * and nobody wants 200 spaces per line on the clipboard), leading/trailing
338
- * blank rows dropped.
339
- */
340
- function selectionText(lines, sel) {
341
- const rows = [];
342
- for (let r = sel.startRow; r <= sel.endRow; r++) {
343
- const line = lines[r] || [];
344
- const from = r === sel.startRow ? sel.startCol : 0;
345
- const to = r === sel.endRow ? sel.endCol : Infinity;
346
- rows.push(sliceLine(line, from, to).map((sp) => sp.t).join('').replace(/[ \t]+$/, ''));
347
- }
348
- while (rows.length && rows[0] === '') rows.shift();
349
- while (rows.length && rows[rows.length - 1] === '') rows.pop();
350
- return rows.join('\n');
351
- }
352
-
353
- /**
354
- * A copy of `lines` with the marked cells wrapped in reverse video. Rows
355
- * outside the range are shared, not cloned — a marking repaints up to ~30x/sec
356
- * during a sweep and only the rows it touches should allocate. Each is padded
357
- * first so a short row's selection is still painted over the blank cells the
358
- * reader dragged across.
359
- */
360
- function applySelection(lines, sel, width) {
361
- const out = lines.slice();
362
- for (let r = sel.startRow; r <= sel.endRow; r++) {
363
- if (r < 0 || r >= out.length) continue;
364
- const line = padLine(out[r] || [], width);
365
- const from = r === sel.startRow ? sel.startCol : 0;
366
- const to = r === sel.endRow ? sel.endCol : width;
367
- const mid = sliceLine(line, from, to);
368
- if (!mid.length) continue;
369
- out[r] = [
370
- ...sliceLine(line, 0, from),
371
- { t: '', s: SELECT_ON, w: 0 },
372
- ...mid,
373
- { t: '', s: SELECT_OFF, w: 0 },
374
- ...sliceLine(line, to, width),
375
- ];
376
- }
377
- return out;
378
- }
379
-
380
- /**
381
- * Paint span lines top-aligned and clear the rest of the frame. Used by the
382
- * overlay renderers; the transcript path never calls it (it stays linear).
383
- */
384
- function paint(lines) {
385
- const { rows, cols } = getSize();
386
- let out = '\x1b[H';
387
- for (let i = 0; i < rows; i++) {
388
- // Reset at the top of every row: span styles are colour codes, and a colour
389
- // code does NOT clear bold/italic/dim. Without this a row that ends inside a
390
- // BOLD segment whose "off" span got dropped by padding would leak the
391
- // attribute into every later row of the frame.
392
- out += '\x1b[0m';
393
- const line = lines[i];
394
- if (line) {
395
- const pl = padLine(line, cols);
396
- for (const sp of pl) out += sp.s + sp.t;
397
- out += '\x1b[0K';
398
- } else {
399
- out += '\x1b[0K';
400
- }
401
- if (i < rows - 1) out += '\n';
402
- }
403
- out += '\x1b[0m';
404
- process.stdout.write(out);
405
- }
406
-
407
- /** Repaint from `startRow` down, leaving rows above it untouched. */
408
- function paintFrom(lines, startRow) {
409
- const { rows, cols } = getSize();
410
- let out = '';
411
- for (let i = 0; i < rows - startRow; i++) {
412
- const line = lines[startRow + i];
413
- if (i > 0) out += '\n';
414
- out += '\x1b[0K';
415
- out += '\x1b[0m';
416
- if (line) {
417
- const pl = padLine(line, cols);
418
- for (const sp of pl) out += sp.s + sp.t;
419
- }
420
- }
421
- out += '\x1b[0m';
422
- process.stdout.write(out);
423
- }
424
-
425
- function termWidth(fallback = 80) {
426
- const { cols } = getSize();
427
- return cols > 0 ? cols : Math.max(20, fallback);
428
- }
429
-
430
- /**
431
- * A block of lines at the bottom of the transcript that can be redrawn in
432
- * place. Every write goes through here, so the escape arithmetic lives in one
433
- * place: `update()` erases the previous block, prints the new one, and keeps
434
- * the cursor below it.
435
- */
436
- class LiveRegion {
437
- constructor(out = process.stdout) {
438
- this.out = out;
439
- this.rows = 0;
440
- this.active = false;
441
- }
442
-
443
- update(lines) {
444
- const body = lines.map((l) => l + ESC.clearToEnd).join('\n');
445
- if (!this.active) {
446
- this.out.write(body);
447
- this.active = true;
448
- } else {
449
- // Back to the first row of the old block, rewrite, clear the tail.
450
- this.out.write(ESC.col(1) + ESC.up(this.rows) + body + '\n' + ESC.col(1) + ESC.up(1));
451
- }
452
- // The PHYSICAL terminal rows the block just occupies, not the number of
453
- // logical lines passed in. A working line (render.js's `renderWorking`,
454
- // the only caller with a long verb + elapsed + token tail) can exceed the
455
- // terminal width and wrap to two rows on anything narrower than ~65
456
- // columns; recording `lines.length` (always 1) left the next tick's
457
- // `up(this.rows)` one row short, so the wrapped second row was never
458
- // erased. Since the line's content (elapsed time, token count) changes
459
- // every 90ms tick, that stray row renewed itself every tick — a
460
- // vertically growing stack of near-duplicate status lines while the
461
- // model streamed, instead of one line updating in place.
462
- const cols = Math.max(1, getSize().cols);
463
- this.rows = lines.reduce((n, l) => n + Math.max(1, Math.ceil(w(l) / cols)), 0);
464
- }
465
-
466
- /** Erase the block and return the cursor to its start, so the caller can
467
- * print the durable version of the same content. */
468
- clear() {
469
- if (!this.active) return;
470
- this.out.write(ESC.col(1) + ESC.clearLine);
471
- for (let i = 1; i < this.rows; i++) this.out.write(`\n${ESC.clearLine}`);
472
- this.out.write(ESC.up(this.rows - 1) + ESC.col(1));
473
- this.rows = 0;
474
- this.active = false;
475
- }
476
- }
477
-
478
- module.exports = {
479
- queueExitNotice,
480
- flushExitNotice,
481
- hasExitNotice,
482
- // plain-string width helpers (kept for the string renderers + app/bin)
483
- w,
484
- clip,
485
- pad,
486
- padStart,
487
- stripAnsi,
488
- wrapLine,
489
- wrapBlock,
490
- // span/line render model (from the upstream engine)
491
- span,
492
- lineWidth,
493
- padLine,
494
- paint,
495
- paintFrom,
496
- getSize,
497
- // cursor / screen / input helpers (overlay path)
498
- EC: ESC,
499
- hideCursor,
500
- showCursor,
501
- moveTo,
502
- clearScreen,
503
- enterAltScreen,
504
- leaveAltScreen,
505
- isAltScreen,
506
- enableBracketedPaste,
507
- disableBracketedPaste,
508
- enableMouseTracking,
509
- disableMouseTracking,
510
- // mouse marking (text selection)
511
- SELECT_ON,
512
- SELECT_OFF,
513
- selectionRange,
514
- sliceLine,
515
- selectionText,
516
- applySelection,
517
- // the live region + sizing (app/bin)
518
- LiveRegion,
519
- termWidth,
520
- };
3
+ "use strict";const ANSI_RE=/\x1b\[[0-9;]*[A-Za-z]/g,{caps:caps,cellWidth:cellWidth}=require("./caps.js"),cwidth=t=>cellWidth(t);function stripAnsi(t){return String(t).replace(ANSI_RE,"")}function w(t){let e=0;for(const o of stripAnsi(t))e+=cwidth(o);return e}function clip(t,e){if(w(t)<=e)return t;let o="",i=0;for(const n of String(t)){const t=cwidth(n);if(i+t>e)break;o+=n,i+=t}return o}function pad(t,e){const o=clip(t,e);return o+" ".repeat(Math.max(0,e-w(o)))}function padStart(t,e){const o=clip(t,e);return" ".repeat(Math.max(0,e-w(o)))+o}function span(t,e){return{t:e,s:t,w:w(e)}}const lineWidth=t=>t.reduce(((t,e)=>t+e.w),0);function padLine(t,e){let o=0;const i=[];for(const n of t){if(o>=e)break;let t=n.t,s=n.w;if(o+s>e){const i=e-o;let n="",r=0;for(const e of[...t]){const t=w(e);if(r+t>i)break;n+=e,r+=t}t=n,s=r}i.push({t:t,s:n.s,w:s}),o+=s}return o<e&&i.push(span(""," ".repeat(e-o))),i}const getSize=()=>{const t=caps();return{cols:t.cols,rows:t.rows}};function wrapLine(t,e,o=""){const i=Math.max(8,e);if(w(t)<=i)return[t];const n=t.split(" "),s=[];let r="";for(const t of n){const e=r?`${r} ${t}`:t;if(w(e)<=i){r=e;continue}if(r&&s.push(r),w(t)<=i){r=t;continue}let o=t;for(;w(o)>i;){const t=clip(o,i);s.push(t),o=o.slice(t.length)}r=o}return!r&&s.length||s.push(r),s}function wrapBlock(t,e,o="",i=!1){const n=[];for(const i of String(t).split("\n"))""!==i?wrapLine(i,e-w(o)).forEach((t=>n.push(o+t))):n.push("");return n}const ESC={hideCursor:"[?25l",showCursor:"[?25h",clearToEnd:"",clearLine:"",clearScreen:"",up:t=>t>0?`[${t}A`:"",down:t=>t>0?`[${t}B`:"",col:t=>`[${t}G`},hideCursor=()=>process.stdout.write("[?25l"),showCursor=()=>process.stdout.write("[?25h"),moveTo=(t,e)=>process.stdout.write(`[${t};${e}H`);function clearScreen(){process.stdout.write("")}let inAlt=!1;function enterAltScreen(){inAlt||(inAlt=!0,process.stdout.write("[?1049h"))}function leaveAltScreen(){inAlt&&(inAlt=!1,process.stdout.write("[?1049l"),flushExitNotice())}let exitNotice=null;function queueExitNotice(t){exitNotice=t}function flushExitNotice(){if(null===exitNotice)return;const t=exitNotice;exitNotice=null,process.stdout.write(t)}const hasExitNotice=()=>null!==exitNotice,isAltScreen=()=>inAlt,enableBracketedPaste=()=>process.stdout.write("[?2004h"),disableBracketedPaste=()=>process.stdout.write("[?2004l"),enableMouseTracking=()=>process.stdout.write("[?1000h[?1002h[?1006h"),disableMouseTracking=()=>process.stdout.write("[?1000l[?1002l[?1006l"),SELECT_ON="",SELECT_OFF="";function selectionRange(t,e){return t.row<e.row||t.row===e.row&&t.col<=e.col?{startRow:t.row,startCol:t.col,endRow:e.row,endCol:e.col}:{startRow:e.row,startCol:e.col,endRow:t.row,endCol:t.col}}function sliceLine(t,e,o){const i=[];let n=0;for(const s of t){const t=n;if(n+=s.w,n<=e||t>=o)continue;let r=s.t,c=t;if(c<e){const t=e-c;let o=0,i=0;for(const e of r){if(o>=t)break;o+=w(e),i+=e.length}r=r.slice(i),c+=o}if(c+w(r)>o){let t=0,e="";for(const i of r){const n=w(i);if(c+t+n>o)break;e+=i,t+=n}r=e}r&&i.push({t:r,s:s.s,w:w(r)})}return i}function selectionText(t,e){const o=[];for(let i=e.startRow;i<=e.endRow;i++){const n=t[i]||[],s=i===e.startRow?e.startCol:0,r=i===e.endRow?e.endCol:1/0;o.push(sliceLine(n,s,r).map((t=>t.t)).join("").replace(/[ \t]+$/,""))}for(;o.length&&""===o[0];)o.shift();for(;o.length&&""===o[o.length-1];)o.pop();return o.join("\n")}function applySelection(t,e,o){const i=t.slice();for(let t=e.startRow;t<=e.endRow;t++){if(t<0||t>=i.length)continue;const n=padLine(i[t]||[],o),s=t===e.startRow?e.startCol:0,r=t===e.endRow?e.endCol:o,c=sliceLine(n,s,r);c.length&&(i[t]=[...sliceLine(n,0,s),{t:"",s:"",w:0},...c,{t:"",s:"",w:0},...sliceLine(n,r,o)])}return i}function paint(t){const{rows:e,cols:o}=getSize();let i="";for(let n=0;n<e;n++){i+="";const s=t[n];if(s){const t=padLine(s,o);for(const e of t)i+=e.s+e.t;i+=""}else i+="";n<e-1&&(i+="\n")}i+="",process.stdout.write(i)}function paintFrom(t,e){const{rows:o,cols:i}=getSize();let n="";for(let s=0;s<o-e;s++){const o=t[e+s];if(s>0&&(n+="\n"),n+="",n+="",o){const t=padLine(o,i);for(const e of t)n+=e.s+e.t}}n+="",process.stdout.write(n)}function termWidth(t=80){const{cols:e}=getSize();return e>0?e:Math.max(20,t)}class LiveRegion{constructor(t=process.stdout){this.out=t,this.rows=0,this.active=!1}update(t){const e=t.map((t=>t+ESC.clearToEnd)).join("\n");this.active?this.out.write(ESC.col(1)+ESC.up(this.rows)+e+"\n"+ESC.col(1)+ESC.up(1)):(this.out.write(e),this.active=!0);const o=Math.max(1,getSize().cols);this.rows=t.reduce(((t,e)=>t+Math.max(1,Math.ceil(w(e)/o))),0)}clear(){if(this.active){this.out.write(ESC.col(1)+ESC.clearLine);for(let t=1;t<this.rows;t++)this.out.write(`\n${ESC.clearLine}`);this.out.write(ESC.up(this.rows-1)+ESC.col(1)),this.rows=0,this.active=!1}}}module.exports={queueExitNotice:queueExitNotice,flushExitNotice:flushExitNotice,hasExitNotice:hasExitNotice,w:w,clip:clip,pad:pad,padStart:padStart,stripAnsi:stripAnsi,wrapLine:wrapLine,wrapBlock:wrapBlock,span:span,lineWidth:lineWidth,padLine:padLine,paint:paint,paintFrom:paintFrom,getSize:getSize,EC:ESC,hideCursor:hideCursor,showCursor:showCursor,moveTo:moveTo,clearScreen:clearScreen,enterAltScreen:enterAltScreen,leaveAltScreen:leaveAltScreen,isAltScreen:isAltScreen,enableBracketedPaste:enableBracketedPaste,disableBracketedPaste:disableBracketedPaste,enableMouseTracking:enableMouseTracking,disableMouseTracking:disableMouseTracking,SELECT_ON:"",SELECT_OFF:"",selectionRange:selectionRange,sliceLine:sliceLine,selectionText:selectionText,applySelection:applySelection,LiveRegion:LiveRegion,termWidth:termWidth};