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,261 +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
- * Number/text formatting for the CLI — one place, so the transcript, the status
10
- * bar and the headless `--print` output always agree.
11
- *
12
- * The sub-cent rule mirrors the server-side ledger: AEGIS pooled calls settle
13
- * around €0.0007, so a 2dp rendering shows a real charge as "€0.00" next to its
14
- * token count and reads as free usage.
15
- */
16
-
17
- /** Group digits: 1562 -> "1,562". */
18
- function fmtTokens(n) {
19
- const v = Number(n);
20
- if (!Number.isFinite(v) || v <= 0) return '0';
21
- return Math.round(v)
22
- .toString()
23
- .replace(/\B(?=(\d{3})+(?!\d))/g, ',');
24
- }
25
-
26
- /** € amount, 4dp below a cent (per-call spend) and 2dp above it (top-ups). */
27
- function fmtEur(n) {
28
- const v = Number(n);
29
- if (!Number.isFinite(v)) return '€?';
30
- const abs = Math.abs(v);
31
- return `€${abs < 0.01 ? abs.toFixed(4) : abs.toFixed(2)}`;
32
- }
33
-
34
- /** Signed € amount, from the user's side: -€0.0007 spent, +€5.00 added. */
35
- function fmtEurSigned(n) {
36
- const v = Number(n);
37
- if (!Number.isFinite(v)) return '€?';
38
- return `${v < 0 ? '-' : '+'}${fmtEur(Math.abs(v))}`;
39
- }
40
-
41
- /**
42
- * The per-turn token figure the accounting rows report: `312 tokens` — the
43
- * OUTPUT half only.
44
- *
45
- * The input half is gone deliberately, not by omission. It is the prompt
46
- * restated, on a cached turn it is the larger number by an order of magnitude,
47
- * and it is the one figure in the row nobody can act on: you change what a turn
48
- * costs by changing what it PRODUCES, while the input count grows on its own as
49
- * the session does. Both meta rows printed it, so the same turn showed
50
- * `156,189 tok · 151,175 in · 5,014 tokens` and read as a runaway — the eye landed
51
- * on 151,175, which is the prompt, not the spend. The rows now report what the
52
- * turn produced. `/cost` still carries the full miss/hit breakdown for anyone
53
- * who wants it: that is a panel you open, not a line painted under every
54
- * answer.
55
- *
56
- * The labels remain part of the job — both rows once printed the bare pair
57
- * `1,250/312` in one colour, and an unlabelled figure only states what it
58
- * measures to a reader who already knows the convention.
59
- *
60
- * The wording lives here, not in the two renderers that call it, because those
61
- * two are documented as never drifting apart and this is the only part of the
62
- * row they both spell out identically.
63
- *
64
- * Returns `null` when the output is not a number, so a caller falls back to the
65
- * total it does have rather than print a figure it never measured — an absent
66
- * half is omitted rather than rendered as `0`, because `0 tokens` states a figure
67
- * the provider never reported and this codebase refuses that shape elsewhere:
68
- * `fmtRoll` will not put `0 tokens` on a meter that never took a reading, for the
69
- * same reason.
70
- *
71
- * The name is left over from when this returned both halves: it is re-exported
72
- * to the desktop's renderer, and a rename for a wording change would be a
73
- * compatibility break for nothing.
74
- *
75
- * @param {object} [usage] flat `{ input, output }`, or an object carrying them
76
- * @returns {{output: string}|null}
77
- */
78
- function fmtUsageSplit(usage) {
79
- const src = usage && typeof usage === 'object' ? usage : {};
80
- if (!Number.isFinite(src.output)) return null;
81
- return { output: `${fmtTokens(src.output || 0)} tokens` };
82
- }
83
-
84
- /**
85
- * The OUTPUT half of a usage record, or `null` — never the wire's total.
86
- *
87
- * The twin of `desktop/renderer/usage.js`'s `displayTokens`, and here for the
88
- * reason that file states at length: the row under a turn reports what the turn
89
- * PRODUCED. `tokens` is input + output, and on a cached or long-context turn the
90
- * prompt restated is the larger half — falling back to it printed `3,145 tokens`
91
- * for a turn that wrote 145, which is the input half back on the screen with no
92
- * label. Both CLI renderers (`renderMeta` in render.js, `metaBits` in
93
- * chatflow.js) used to do exactly that once `output` was missing, and it was the
94
- * last surviving place the input half reached a row: the split had been dropped,
95
- * and the total they fell back to still carried it.
96
- *
97
- * `null` rather than `0` when no output figure arrived — `0 tokens` states a
98
- * figure no provider sent, the rule `fmtUsageSplit` and `fmtRoll` already hold.
99
- * A turn the wire priced but did not itemise has no output figure, and inventing
100
- * one from the total would be a number that provider never sent.
101
- *
102
- * @param {object} [source] flat `{output}`, or a record carrying `tokens:{output}`
103
- * @returns {number|null}
104
- */
105
- function displayTokens(source) {
106
- const src = source && typeof source === 'object' ? source : {};
107
- const nested = src.tokens && typeof src.tokens === 'object' ? src.tokens : null;
108
- const candidates = [src.output];
109
- if (nested) candidates.push(nested.output, nested.output_tokens, nested.completion_tokens);
110
- else candidates.push(src.output_tokens, src.completion_tokens);
111
- for (const c of candidates) {
112
- if (typeof c === 'number' && isFinite(c) && c > 0) return c;
113
- }
114
- return null;
115
- }
116
-
117
- /**
118
- * The account's tier, as the host last read it off the server. Held here
119
- * because the RENDERERS need it and they run synchronously, on a path that
120
- * cannot await a probe: `cli/src/entitlement.js` publishes every reading it
121
- * takes (`noteTier`), and the money rule below spends it.
122
- */
123
- let tierSnapshot = null;
124
-
125
- /**
126
- * Publish the entitlement snapshot for the renderers. Called by the host's
127
- * entitlement gate on every `current()`/`refresh()`, so the waiver rule and the
128
- * gate the host enforces can never read two different tiers.
129
- */
130
- function noteTier(entitlement) {
131
- tierSnapshot = entitlement && typeof entitlement === 'object' ? entitlement : null;
132
- return tierSnapshot;
133
- }
134
-
135
- /**
136
- * True when this account's tier means AEGIS bills no per-turn fee, so no money
137
- * figure belongs on a turn row or a session total.
138
- *
139
- * The CLI's half of the desktop's rule (`desktop/renderer/usage.js`), and it is
140
- * the same rule deliberately: the two hosts render the same turn from the same
141
- * engine, so a row that shows a fee on one and waives it on the other is a
142
- * disagreement about what the user owes. The desktop had this gate and the CLI
143
- * did not, which is why a trial account saw `€0.0031` under every answer here
144
- * and no money there.
145
- *
146
- * The fee is the BYOK handling fee, waived by aegis1 on Unlimited — and the tier
147
- * a 30-day welcome trial grants IS Unlimited (`subscriptions` row), so a trial
148
- * account resolves here exactly like a paying one. Matching is on the resolved
149
- * tier rather than `pro`, and a funded bank on a free plan is NOT waived: that
150
- * account pays from its bank, and hiding the number would leave it with no meter
151
- * for the only money it spends.
152
- *
153
- * @param {{tier?: string|null, plan?: string|null, planRaw?: string|null,
154
- * subscription?: string|null, item?: string|null, sku?: string|null,
155
- * unlimited?: boolean}} [entitlement] the snapshot to read; omitted, the last
156
- * one the host published (see `noteTier`).
157
- * @returns {boolean}
158
- */
159
- function feeWaived(entitlement) {
160
- const ent = entitlement === undefined ? tierSnapshot : entitlement;
161
- if (!ent || typeof ent !== 'object') return false;
162
- if (ent.unlimited === true) return true;
163
- const named = [
164
- ent.tier,
165
- ent.plan,
166
- ent.planRaw,
167
- ent.subscription,
168
- ent.subscriptionTier,
169
- ent.product,
170
- ent.item,
171
- ent.sku,
172
- ]
173
- .filter((v) => typeof v === 'string')
174
- .map((v) => v.trim().toLowerCase());
175
- if (named.some((v) => v === 'unlimited' || v === 'trial')) return true;
176
- // A tier string that merely CONTAINS the word — `unlimited_trial`,
177
- // `plan.unlimited` — so a server that decorates the name cannot put the fee
178
- // back on an account whose tier is Unlimited.
179
- return named.some((v) => /(^|[^a-z])unlimited([^a-z]|$)/.test(v));
180
- }
181
-
182
- /**
183
- * Whether a money figure belongs on this account's turn row or session total.
184
- *
185
- * A price is printed UNLESS AEGIS either waives it or has not proven it owed:
186
- *
187
- * - a tier AEGIS waives (`feeWaived`) → no price. Unlimited, paid or on the
188
- * 30-day welcome trial, has no per-turn charge and no bank draw;
189
- * - a snapshot that asserts a plan it cannot prove (`degraded`, i.e. the
190
- * entitlement module's unresolved placeholder, whose `plan` reads `free`
191
- * before any probe has answered) → no price. That placeholder says "no
192
- * verdict yet", not "this account is free", and reading it as a verdict is
193
- * what put `€0.0031` under a trial account's answers before its probe had
194
- * replied — a fee charged in writing to the one account that does not pay it;
195
- * - everything else → the price stands, including when NOTHING was claimed at
196
- * all. A cost figure is a measurement of the turn, and silently dropping a
197
- * real number because no tier was published would leave a BYO-key or offline
198
- * run with no meter for money it actually spent.
199
- *
200
- * The token figure is never gated by this, on any branch: what a turn produced
201
- * is not a price, and hiding it would leave an Unlimited account with no meter.
202
- *
203
- * @param {{tier?: string|null, plan?: string|null, planRaw?: string|null,
204
- * degraded?: boolean, source?: string|null, unlimited?: boolean}} [entitlement]
205
- * @returns {boolean}
206
- */
207
- function feeBillable(entitlement) {
208
- const ent = entitlement === undefined ? tierSnapshot : entitlement;
209
- if (!ent || typeof ent !== 'object') return true;
210
- if (feeWaived(ent)) return false;
211
- return ent.degraded !== true;
212
- }
213
-
214
- /** Compact duration: 850 -> "0.9s", 65000 -> "1m05s". */function fmtElapsed(ms) {
215
- const s = Math.max(0, Number(ms) || 0) / 1000;
216
- if (s < 10) return `${s.toFixed(1)}s`;
217
- if (s < 60) return `${Math.round(s)}s`;
218
- const m = Math.floor(s / 60);
219
- const rest = Math.round(s - m * 60);
220
- return `${m}m${String(rest).padStart(2, '0')}s`;
221
- }
222
-
223
- /** Mask an API key for display: never echo enough to be useful if leaked. */
224
- function maskKey(key) {
225
- const s = String(key || '');
226
- if (!s) return 'not set';
227
- if (s.length <= 8) return '•'.repeat(s.length);
228
- return `${s.slice(0, 6)}${'•'.repeat(4)}${s.slice(-4)}`;
229
- }
230
-
231
- // ── Paths, as the CLI labels them ───────────────────────────────────────────
232
- //
233
- // One home for "what do we call this directory", because the answer was
234
- // `p.split('/').filter(Boolean).pop() || '~'` in five files — commands.js,
235
- // history.js (twice), panels.js and init.js — and that is wrong on win32, where
236
- // the separator is `\`: the status line, the session list and the resume picker
237
- // each showed the WHOLE path where linux and darwin showed the leaf. Same class
238
- // of bug as the tool layer's, so it is fixed the same way: the shared platform
239
- // module owns the rule and the CLI calls it rather than spelling it again.
240
-
241
- const sharedPlatform = require(require('./shared.js').resolveClientModule('platform.js'));
242
-
243
- /**
244
- * The name of a path — the leaf segment, whatever separator it arrived with.
245
- * `''` when there is no leaf to name (empty, `/`, `C:\`).
246
- */
247
- function pathName(p) {
248
- return sharedPlatform.baseName(p);
249
- }
250
-
251
- /** The leaf of a recorded cwd, or `~` when nothing was recorded. */
252
- function cwdName(p) {
253
- return pathName(p) || '~';
254
- }
255
-
256
- /** The leaf of THIS process's cwd — the status line's own label. */
257
- function shortCwd() {
258
- return cwdName(process.cwd());
259
- }
260
-
261
- module.exports = { fmtTokens, fmtEur, fmtEurSigned, fmtElapsed, fmtUsageSplit, displayTokens, feeWaived, feeBillable, noteTier, maskKey, pathName, cwdName, shortCwd };
3
+ "use strict";function fmtTokens(t){const e=Number(t);return!Number.isFinite(e)||e<=0?"0":Math.round(e).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function fmtEur(t){const e=Number(t);if(!Number.isFinite(e))return"€?";const n=Math.abs(e);return`€${n<.01?n.toFixed(4):n.toFixed(2)}`}function fmtEurSigned(t){const e=Number(t);return Number.isFinite(e)?`${e<0?"-":"+"}${fmtEur(Math.abs(e))}`:"€?"}function fmtUsageSplit(t){const e=t&&"object"==typeof t?t:{};return Number.isFinite(e.output)?{output:`${fmtTokens(e.output||0)} tokens`}:null}function displayTokens(t){const e=t&&"object"==typeof t?t:{},n=e.tokens&&"object"==typeof e.tokens?e.tokens:null,o=[e.output];n?o.push(n.output,n.output_tokens,n.completion_tokens):o.push(e.output_tokens,e.completion_tokens);for(const t of o)if("number"==typeof t&&isFinite(t)&&t>0)return t;return null}let tierSnapshot=null;function noteTier(t){return tierSnapshot=t&&"object"==typeof t?t:null,tierSnapshot}function feeWaived(t){const e=void 0===t?tierSnapshot:t;if(!e||"object"!=typeof e)return!1;if(!0===e.unlimited)return!0;const n=[e.tier,e.plan,e.planRaw,e.subscription,e.subscriptionTier,e.product,e.item,e.sku].filter((t=>"string"==typeof t)).map((t=>t.trim().toLowerCase()));return!!n.some((t=>"unlimited"===t||"trial"===t))||n.some((t=>/(^|[^a-z])unlimited([^a-z]|$)/.test(t)))}function feeBillable(t){const e=void 0===t?tierSnapshot:t;return!e||"object"!=typeof e||!feeWaived(e)&&!0!==e.degraded}function fmtElapsed(t){const e=Math.max(0,Number(t)||0)/1e3;if(e<10)return`${e.toFixed(1)}s`;if(e<60)return`${Math.round(e)}s`;const n=Math.floor(e/60),o=Math.round(e-60*n);return`${n}m${String(o).padStart(2,"0")}s`}function maskKey(t){const e=String(t||"");return e?e.length<=8?"•".repeat(e.length):`${e.slice(0,6)}${"•".repeat(4)}${e.slice(-4)}`:"not set"}const sharedPlatform=require(require("./shared.js").resolveClientModule("platform.js"));function pathName(t){return sharedPlatform.baseName(t)}function cwdName(t){return pathName(t)||"~"}function shortCwd(){return cwdName(process.cwd())}module.exports={fmtTokens:fmtTokens,fmtEur:fmtEur,fmtEurSigned:fmtEurSigned,fmtElapsed:fmtElapsed,fmtUsageSplit:fmtUsageSplit,displayTokens:displayTokens,feeWaived:feeWaived,feeBillable:feeBillable,noteTier:noteTier,maskKey:maskKey,pathName:pathName,cwdName:cwdName,shortCwd:shortCwd};
@@ -1,121 +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
- // Fuzzy command matching for the "/" palette (and anything else that needs it).
9
- //
10
- // The real Claude Code palette ranks matches by relevance rather than plain
11
- // prefix: an exact match beats a prefix, a prefix beats a substring, and a
12
- // substring beats characters scattered through the name. Ties fall back to
13
- // the source (registry) order so the palette stays stable for empty queries.
14
- //
15
- // Scoring tiers (deliberately spaced so no position/length detail in a lower
16
- // tier can overtake a higher tier):
17
- // exact match 1000
18
- // prefix match 900
19
- // substring 700 − position (earlier substring wins)
20
- // scattered 50 + bonuses (consecutive runs, name-start hits)
21
- //
22
- // Ported verbatim from the upstream engine reference (ESM → CommonJS). The tier
23
- // numbers are a contract: cli-fuzzy.test.mjs asserts the ordering they encode.
24
-
25
- function fuzzyScore(query, name) {
26
- const q = String(query).toLowerCase();
27
- const n = String(name).toLowerCase();
28
- if (!q) return { matched: true, score: 0 };
29
- if (n === q) return { matched: true, score: 1000 };
30
- if (n.startsWith(q)) return { matched: true, score: 900 };
31
- const at = n.indexOf(q);
32
- if (at !== -1) return { matched: true, score: 700 - at };
33
-
34
- // Scattered subsequence: every query char must appear in order.
35
- let score = 50;
36
- let prev = -2;
37
- let last = -1;
38
- for (const ch of q) {
39
- const k = n.indexOf(ch, last + 1);
40
- if (k === -1) return { matched: false, score: 0 };
41
- if (k === prev + 1) score += 15; // consecutive run — strong signal
42
- else score += 5;
43
- if (k === 0) score += 10; // starts at the name — weak signal
44
- prev = k;
45
- last = k;
46
- }
47
- return { matched: true, score };
48
- }
49
-
50
- /**
51
- * The indices (in the original `name`) of the characters that matched
52
- * `query`, mirroring fuzzyScore's tiers — exact = every index, prefix =
53
- * leading run, substring = that run, scattered = the scattered picks.
54
- * Returns [] for an empty query and null when nothing matches.
55
- * Drives the palette's bold-matched-chars rendering.
56
- */
57
- function fuzzyMatchPositions(query, name) {
58
- const q = String(query).toLowerCase();
59
- const n = String(name).toLowerCase();
60
- if (!q) return [];
61
- if (n === q) return Array.from({ length: q.length }, (_, i) => i);
62
- if (n.startsWith(q)) return Array.from({ length: q.length }, (_, i) => i);
63
- const at = n.indexOf(q);
64
- if (at !== -1) return Array.from({ length: q.length }, (_, i) => at + i);
65
- const pos = [];
66
- let last = -1;
67
- for (const ch of q) {
68
- const k = n.indexOf(ch, last + 1);
69
- if (k === -1) return null;
70
- pos.push(k);
71
- last = k;
72
- }
73
- return pos;
74
- }
75
-
76
- /**
77
- * Rank `items` by how well `nameOf(item)` matches `query`.
78
- * Empty query returns the items unchanged (preserves registry/palette order).
79
- * Non-matches are dropped; matches sort by score desc, then source order.
80
- */
81
- function fuzzyRank(query, items, nameOf) {
82
- const q = String(query || '');
83
- if (!q) return items;
84
- return items
85
- .map((item, idx) => ({ item, idx, m: fuzzyScore(q, nameOf(item)) }))
86
- .filter((x) => x.m.matched)
87
- .sort((a, b) => b.m.score - a.m.score || a.idx - b.idx)
88
- .map((x) => x.item);
89
- }
90
-
91
- /**
92
- * Alias-aware ranking. The reference palette searches the command name and its
93
- * aliases (name weight 3, aliases weight 2.5 — Fuse.js in the reference; here
94
- * the best fuzzy score across both wins). An item matches when the query scores
95
- * against at least one of its names; ties keep source order so the palette
96
- * stays stable.
97
- */
98
- function fuzzyRankWithAliases(query, items, nameOf, aliasesOf) {
99
- const q = String(query || '');
100
- if (!q) return items;
101
- return items
102
- .map((item, idx) => {
103
- const names = [nameOf(item), ...((aliasesOf && aliasesOf(item)) || [])];
104
- let best = null;
105
- for (const n of names) {
106
- const m = fuzzyScore(q, n);
107
- if (m.matched && (!best || m.score > best.score)) best = m;
108
- }
109
- return { item, idx, m: best };
110
- })
111
- .filter((x) => x.m)
112
- .sort((a, b) => b.m.score - a.m.score || a.idx - b.idx)
113
- .map((x) => x.item);
114
- }
115
-
116
- module.exports = {
117
- fuzzyScore,
118
- fuzzyMatchPositions,
119
- fuzzyRank,
120
- fuzzyRankWithAliases,
121
- };
3
+ "use strict";function fuzzyScore(t,r){const e=String(t).toLowerCase(),n=String(r).toLowerCase();if(!e)return{matched:!0,score:0};if(n===e)return{matched:!0,score:1e3};if(n.startsWith(e))return{matched:!0,score:900};const o=n.indexOf(e);if(-1!==o)return{matched:!0,score:700-o};let s=50,i=-2,c=-1;for(const t of e){const r=n.indexOf(t,c+1);if(-1===r)return{matched:!1,score:0};s+=r===i+1?15:5,0===r&&(s+=10),i=r,c=r}return{matched:!0,score:s}}function fuzzyMatchPositions(t,r){const e=String(t).toLowerCase(),n=String(r).toLowerCase();if(!e)return[];if(n===e)return Array.from({length:e.length},((t,r)=>r));if(n.startsWith(e))return Array.from({length:e.length},((t,r)=>r));const o=n.indexOf(e);if(-1!==o)return Array.from({length:e.length},((t,r)=>o+r));const s=[];let i=-1;for(const t of e){const r=n.indexOf(t,i+1);if(-1===r)return null;s.push(r),i=r}return s}function fuzzyRank(t,r,e){const n=String(t||"");return n?r.map(((t,r)=>({item:t,idx:r,m:fuzzyScore(n,e(t))}))).filter((t=>t.m.matched)).sort(((t,r)=>r.m.score-t.m.score||t.idx-r.idx)).map((t=>t.item)):r}function fuzzyRankWithAliases(t,r,e,n){const o=String(t||"");return o?r.map(((t,r)=>{const s=[e(t),...n&&n(t)||[]];let i=null;for(const t of s){const r=fuzzyScore(o,t);r.matched&&(!i||r.score>i.score)&&(i=r)}return{item:t,idx:r,m:i}})).filter((t=>t.m)).sort(((t,r)=>r.m.score-t.m.score||t.idx-r.idx)).map((t=>t.item)):r}module.exports={fuzzyScore:fuzzyScore,fuzzyMatchPositions:fuzzyMatchPositions,fuzzyRank:fuzzyRank,fuzzyRankWithAliases:fuzzyRankWithAliases};