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,460 +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
- * VENDORED — do not edit. Generated by tools/vendor-fingerprint.mjs.
10
- *
11
- * source: aegiscodex 079f445 — src/touch.js
12
- * rewrite: ESM -> CJS, module syntax only. No constant, purpose string,
13
- * attested field list or digest differs from the engine's.
14
- * verify: node --test test/fingerprint-interop.test.mjs
15
- * refresh: node tools/vendor-fingerprint.mjs
16
- */
17
- /**
18
- * touch.js — the thumb axis of φ(α): gesture dynamics from the trackpad.
19
- *
20
- * ## What this is, and what it is not
21
- *
22
- * It is NOT a fingerprint. This machine has no fingerprint sensor: `fprintd-list`
23
- * reports "No devices available", `lsusb` shows no imaging device, and the
24
- * trackpad (Apple `05ac:0253`, bcm5974) has no imager. A trackpad cannot image a
25
- * ridge pattern, so nothing here should ever be labelled `fingerprint`.
26
- *
27
- * It is also not the trackpad's *touch* data. The kernel does expose contact size
28
- * and force for this device (`ABS_MT_TOUCH_MAJOR`, pressure), but only through
29
- * `/dev/input/eventN`, which is `root:input` and this user is not in `input`.
30
- * Reachable without privilege through X, the trackpad exposes exactly four
31
- * valuators — `Rel X`, `Rel Y`, `Rel Horiz Scroll`, `Rel Vert Scroll`. There is
32
- * no absolute contact geometry in that list, and there is no `Touch` class, so
33
- * the pad cannot say where a finger is, how big it is, or how hard it presses.
34
- *
35
- * What is left — and it is real — is *how the thumb moves*: the timing, shape and
36
- * smoothness of a stroke. That is a behavioural biometric, the same family as
37
- * keystroke dynamics. It is stable enough to distinguish habitual users on one
38
- * device, and it is a much weaker claim than a fingerprint: it varies with
39
- * fatigue, moisture, posture and what else is on the pad, and it is *learned*,
40
- * not measured. `compareTouch` therefore returns a graded score, never a
41
- * boolean identity, and `THRESHOLD` is documented as a default rather than a
42
- * truth.
43
- *
44
- * ## Why the deltas are raw
45
- *
46
- * `Rel X`/`Rel Y` in a `Motion` event have already been through the X pointer
47
- * acceleration curve, which multiplies fast movement more than slow movement.
48
- * Speed is one of the features below, so acceleration would make the feature
49
- * partly a function of the acceleration profile rather than of the thumb.
50
- * `RawMotion` valuators are the device's own deltas, before acceleration, and
51
- * that is what `parseXi2` prefers when both are present.
52
- *
53
- * ## Why nothing here is a timestamp from X
54
- *
55
- * `xinput test-xi2` prints no event time, so the sampler stamps arrival time at
56
- * read. That makes every duration a *lower bound* with reader jitter on top.
57
- * Features are therefore built to survive tens of milliseconds of noise: they
58
- * are binned with explicit tolerances, and the median across strokes is what
59
- * gets hashed, so one mistimed stroke cannot swing the result.
60
- *
61
- * Pure: node:crypto only, no I/O, no spawn. The capture tool
62
- * (`tools/aegis-touchpad.mjs`) owns the process side and is the only file in
63
- * this axis allowed to touch it.
64
- */
65
-
66
- const crypto = require('node:crypto');
67
-
68
- /** Enough strokes for a median to mean something, few enough to ask of a thumb. */
69
- const MIN_STROKES = 3;
70
- const MAX_STROKES = 64;
71
- const MAX_SAMPLES = 20000;
72
-
73
- /** A gap this long with no motion ends a stroke. Motion bursts are all X gives us. */
74
- const DEFAULT_IDLE_GAP_MS = 140;
75
-
76
- /** Bump when the axis set or a tolerance changes: signatures are not portable across it. */
77
- const TOUCH_VERSION = 1;
78
-
79
- const SIG_LENGTH = 16;
80
-
81
- /**
82
- * One axis per habitual trait. `mode` decides how a value is binned:
83
- * 'linear' — absolute tolerance in the axis's own units
84
- * 'log' — multiplicative tolerance, for axes whose *scale* is device-specific
85
- * `tol` is the half-bin width; a value is quantised to `round(v / tol)`.
86
- */
87
- const AXES = Object.freeze([
88
- { name: 'samples', mode: 'linear', tol: 3 }, // how many events the stroke took
89
- { name: 'durationMs', mode: 'linear', tol: 150 }, // how long the thumb was moving
90
- { name: 'straightness', mode: 'linear', tol: 0.15 }, // net / path; 1 = dead straight
91
- { name: 'verticalBias', mode: 'linear', tol: 0.15 }, // |dy| / path
92
- { name: 'pauseRatio', mode: 'linear', tol: 0.15 }, // fraction of zero-delta samples
93
- { name: 'dtCv', mode: 'linear', tol: 0.15 }, // jitter of the sampling interval
94
- { name: 'turnMean', mode: 'linear', tol: 0.12 }, // mean turn per sample, radians
95
- { name: 'speedSkew', mode: 'linear', tol: 0.5 }, // peak / mean - 1
96
- { name: 'reversalRate', mode: 'linear', tol: 0.1 }, // direction changes per sample
97
- { name: 'pathPerSample', mode: 'log', tol: 1.25 }, // device-scale, so multiplicative
98
- ]);
99
-
100
- /**
101
- * Mean bin distance at or below which two profiles are called a match. One whole
102
- * bin of slop on every axis on average is a deliberately loose default: this is a
103
- * behavioural axis, and a tight threshold would report "different thumb" for the
104
- * same thumb on a cold hand. Tune per device; do not read it as an identity test.
105
- */
106
- const THRESHOLD = 1.0;
107
-
108
- const AXIS_NAMES = Object.freeze(AXES.map((a) => a.name));
109
-
110
- // ---------------------------------------------------------------------------
111
- // parsing
112
- // ---------------------------------------------------------------------------
113
-
114
- /**
115
- * Parse `xinput test-xi2 --root` output into motion samples.
116
- *
117
- * Two shapes are accepted. The block form is what XI2 prints:
118
- *
119
- * EVENT type 17 (RawMotion)
120
- * device: 9 (9)
121
- * valuators:
122
- * 0: -1.00 (0.00)
123
- * 1: 6.00 (0.00)
124
- *
125
- * and the flat form is what the older `xinput test <id>` prints:
126
- *
127
- * motion id 9 [9, 3] 0: -1 1: 0
128
- *
129
- * The leading device table that `test-xi2` prints at startup is skipped. Events
130
- * are stamped with arrival time: `now` is injectable so tests are deterministic.
131
- */
132
- function parseXi2(text, { now = () => Date.now(), device = null } = {}) {
133
- const samples = [];
134
- let current = null;
135
-
136
- const flush = () => {
137
- if (!current) return;
138
- const dv = current.valuators;
139
- if (dv[0] !== undefined || dv[1] !== undefined) {
140
- samples.push({
141
- type: current.type,
142
- device: current.device,
143
- dx: Number(dv[0] || 0),
144
- dy: Number(dv[1] || 0),
145
- t: current.t,
146
- });
147
- }
148
- current = null;
149
- };
150
-
151
- for (const rawLine of String(text).split('\n')) {
152
- const line = rawLine.replace(/\u001b\[[0-9;]*m/g, '');
153
-
154
- const ev = /^\s*EVENT\s+type\s+(\d+)\s*(?:\(([^)]*)\))?/.exec(line);
155
- if (ev) {
156
- flush();
157
- current = { type: Number(ev[1]), name: ev[2] || '', device: null, valuators: {}, t: now() };
158
- continue;
159
- }
160
-
161
- const dev = /^\s*device:\s*(\d+)/.exec(line);
162
- if (dev && current) {
163
- current.device = Number(dev[1]);
164
- continue;
165
- }
166
-
167
- if (current) {
168
- // " 0: -1.00 (0.00)" — index: value (raw value)
169
- const v = /^\s*(\d+):\s*(-?[\d.]+)\s*(?:\((-?[\d.]+)\))?\s*$/.exec(line);
170
- if (v) {
171
- current.valuators[Number(v[1])] = Number(v[2]);
172
- continue;
173
- }
174
- continue;
175
- }
176
-
177
- // flat form
178
- const flat = /^\s*(?:motion|raw motion)\s+id\s+(\d+)\s+\[[^\]]*\]\s*(.*)$/.exec(line);
179
- if (flat) {
180
- const dv = {};
181
- for (const pair of flat[2].matchAll(/(\d+):\s*(-?\d+)/g)) dv[Number(pair[1])] = Number(pair[2]);
182
- if (dv[0] !== undefined || dv[1] !== undefined) {
183
- samples.push({ type: 0, device: Number(flat[1]), dx: Number(dv[0] || 0), dy: Number(dv[1] || 0), t: now() });
184
- }
185
- }
186
- }
187
- flush();
188
-
189
- const filtered = device === null ? samples : samples.filter((s) => s.device === device);
190
- return filtered.slice(0, MAX_SAMPLES);
191
- }
192
-
193
- // ---------------------------------------------------------------------------
194
- // segmentation
195
- // ---------------------------------------------------------------------------
196
-
197
- /**
198
- * Split samples into strokes: a stroke is a run of samples with no gap longer
199
- * than `idleGapMs`. X gives us no finger-down/finger-up through the relative
200
- * pointer path, so a silence gap is the only boundary available — which is why
201
- * `aegis-touchpad.mjs` asks for *separate, deliberate* strokes with the thumb
202
- * lifted in between rather than one continuous scribble.
203
- */
204
- function segmentStrokes(samples, { idleGapMs = DEFAULT_IDLE_GAP_MS } = {}) {
205
- const strokes = [];
206
- let current = [];
207
- for (const s of samples) {
208
- if (current.length) {
209
- const gap = s.t - current[current.length - 1].t;
210
- if (gap > idleGapMs) {
211
- strokes.push(current);
212
- current = [];
213
- }
214
- }
215
- current.push(s);
216
- }
217
- if (current.length) strokes.push(current);
218
- return strokes.filter((s) => s.length > 1).slice(0, MAX_STROKES);
219
- }
220
-
221
- // ---------------------------------------------------------------------------
222
- // features
223
- // ---------------------------------------------------------------------------
224
-
225
- const mean = (xs) => (xs.length ? xs.reduce((a, b) => a + b, 0) / xs.length : 0);
226
-
227
- /**
228
- * Ten traits from one stroke. Every ratio is guarded against a zero denominator
229
- * and returns 0 rather than NaN: a NaN would poison canonicalisation downstream,
230
- * and a stroke that moved nowhere is better described as "no trait" than as a
231
- * crash.
232
- */
233
- function strokeFeatures(stroke) {
234
- const n = stroke.length;
235
- let path = 0;
236
- let dx = 0;
237
- let dy = 0;
238
- let pauses = 0;
239
- let turns = 0;
240
- let reversals = 0;
241
-
242
- const speeds = [];
243
- const dts = [];
244
-
245
- let prevSignX = 0;
246
- let prevSignY = 0;
247
- let prevAngle = null;
248
-
249
- for (let i = 0; i < n; i++) {
250
- const s = stroke[i];
251
- const mag = Math.hypot(s.dx, s.dy);
252
- path += mag;
253
- dx += s.dx;
254
- dy += s.dy;
255
- if (mag === 0) pauses++;
256
-
257
- if (i > 0) {
258
- const dt = Math.max(1, stroke[i].t - stroke[i - 1].t);
259
- dts.push(dt);
260
- speeds.push(mag / dt);
261
- const angle = Math.atan2(s.dy, s.dx);
262
- if (prevAngle !== null) {
263
- let d = angle - prevAngle;
264
- while (d > Math.PI) d -= 2 * Math.PI;
265
- while (d < -Math.PI) d += 2 * Math.PI;
266
- turns += Math.abs(d);
267
- }
268
- prevAngle = angle;
269
- }
270
-
271
- const sx = Math.sign(s.dx);
272
- const sy = Math.sign(s.dy);
273
- if (sx && prevSignX && sx !== prevSignX) reversals++;
274
- if (sy && prevSignY && sy !== prevSignY) reversals++;
275
- if (sx) prevSignX = sx;
276
- if (sy) prevSignY = sy;
277
- }
278
-
279
- const net = Math.hypot(dx, dy);
280
- const duration = Math.max(1, stroke[n - 1].t - stroke[0].t);
281
- const meanSpeed = mean(speeds);
282
- const dtMean = mean(dts);
283
- const dtVar = mean(dts.map((d) => (d - dtMean) ** 2));
284
-
285
- return {
286
- samples: n,
287
- durationMs: duration,
288
- straightness: path ? net / path : 0,
289
- verticalBias: path ? Math.abs(dy) / path : 0,
290
- pauseRatio: pauses / n,
291
- dtCv: dtMean ? Math.sqrt(dtVar) / dtMean : 0,
292
- turnMean: n > 1 ? turns / (n - 1) : 0,
293
- speedSkew: meanSpeed ? Math.max(...speeds) / meanSpeed - 1 : 0,
294
- reversalRate: reversals / n,
295
- pathPerSample: path / n,
296
- };
297
- }
298
-
299
- // ---------------------------------------------------------------------------
300
- // quantisation
301
- // ---------------------------------------------------------------------------
302
-
303
- /** Bin one value. `log` mode is symmetric in ratio, so 2x and 0.5x are equidistant. */
304
- function binValue(axis, value) {
305
- const v = Number.isFinite(value) ? value : 0;
306
- if (axis.mode === 'log') {
307
- if (v <= 0) return 0;
308
- return Math.round(Math.log(v) / Math.log(axis.tol));
309
- }
310
- return Math.round(v / axis.tol);
311
- }
312
-
313
- /** Distance between two bins, in bin units, on one axis. */
314
- function binDistance(axis, a, b) {
315
- if (axis.mode === 'log') {
316
- const ratio = Math.log(axis.tol);
317
- const ra = a * ratio;
318
- const rb = b * ratio;
319
- return Math.abs(ra - rb);
320
- }
321
- return Math.abs(a - b);
322
- }
323
-
324
- /** Quantise a feature object to integers, axis by axis. Unknown axes are ignored. */
325
- function quantise(features) {
326
- const out = {};
327
- for (const axis of AXES) out[axis.name] = binValue(axis, features[axis.name]);
328
- return out;
329
- }
330
-
331
- /** Median across strokes per axis: order-independent, and robust to one bad stroke. */
332
- function medians(featureList) {
333
- const out = {};
334
- for (const axis of AXES) {
335
- const xs = featureList.map((f) => Number(f[axis.name]) || 0).sort((a, b) => a - b);
336
- const mid = Math.floor(xs.length / 2);
337
- const med = xs.length % 2 ? xs[mid] : (xs[mid - 1] + xs[mid]) / 2;
338
- out[axis.name] = Number.isFinite(med) ? med : 0;
339
- }
340
- return out;
341
- }
342
-
343
- /**
344
- * The signature body: versioned, one `axis=bin` line per trait, fixed order.
345
- * Exported shape is a hash, but this is the thing hashed, and it is what a
346
- * verifier recomputes.
347
- */
348
- function signatureBody(med) {
349
- const bins = quantise(med);
350
- return TOUCH_VERSION + '\n' + AXIS_NAMES.map((k) => `${k}=${bins[k]}`).join('\n');
351
- }
352
-
353
- /**
354
- * 16 hex over the median-binned trait vector, recomputed from the medians.
355
- *
356
- * This is the function `src/fingerprint.js` calls, and it takes medians rather
357
- * than a stored hash on purpose: a profile file's own `signature` field is then
358
- * never trusted, only recomputed. Editing `medians` in that file changes the
359
- * signature and the record's attestation breaks, which is the same property the
360
- * rest of φ(α) has.
361
- *
362
- * `strokeCount` is what makes absence honest — see rule 3.
363
- *
364
- * @returns {string|null} null below `MIN_STROKES`: the median of one stroke is
365
- * just that stroke, and one gesture is not evidence of a habit.
366
- */
367
- function signatureFromMedians(med, strokeCount) {
368
- if (!med || Number(strokeCount) < MIN_STROKES) return null;
369
- return crypto.createHash('sha256').update(signatureBody(med), 'utf8').digest('hex').slice(0, SIG_LENGTH);
370
- }
371
-
372
- /**
373
- * The thumb signature over a list of stroke features.
374
- *
375
- * Median across strokes makes this order-independent — the same thumb producing
376
- * the same habits in a different order fingerprints identically, matching the
377
- * rule the behavioural axis already follows.
378
- */
379
- function touchSignature(featureList) {
380
- const usable = (Array.isArray(featureList) ? featureList : [])
381
- .filter((f) => f && Number.isFinite(Number(f.samples)) && Number(f.samples) > 1)
382
- .slice(0, MAX_STROKES);
383
- if (usable.length < MIN_STROKES) return null;
384
- return signatureFromMedians(medians(usable), usable.length);
385
- }
386
-
387
- // ---------------------------------------------------------------------------
388
- // profile + comparison
389
- // ---------------------------------------------------------------------------
390
-
391
- /**
392
- * A full touch profile: the signature, the medians it came from, and the axis
393
- * table with tolerances — so a verifier can recompute rather than trust, and a
394
- * reader can see which axes were even in play.
395
- */
396
- function profile(samples, opts = {}) {
397
- const strokes = segmentStrokes(samples, opts);
398
- const featureList = strokes.map(strokeFeatures);
399
- const signature = touchSignature(featureList);
400
- const med = featureList.length ? medians(featureList) : null;
401
-
402
- return Object.freeze({
403
- version: TOUCH_VERSION,
404
- kind: 'gesture-dynamics',
405
- notice:
406
- 'not a fingerprint: this machine has no fingerprint sensor, and the trackpad ' +
407
- 'exposes no contact geometry through X. These are habits of motion, learned not measured.',
408
- signature,
409
- samples: featureList.length,
410
- strokes: strokes.length,
411
- medians: med ? Object.freeze({ ...med }) : null,
412
- bins: med ? Object.freeze(quantise(med)) : null,
413
- axes: AXES,
414
- });
415
- }
416
-
417
- /**
418
- * Graded comparison, never a bare boolean.
419
- *
420
- * @returns {{score:number, withinTolerance:boolean, distance:number, worst:Array, comparable:boolean}}
421
- * `comparable` is false when either side has no signature — two absences are
422
- * not a match, and saying so is the point.
423
- */
424
- function compareTouch(a, b, { threshold = THRESHOLD } = {}) {
425
- const empty = { score: 0, withinTolerance: false, distance: Infinity, worst: [], comparable: false };
426
- if (!a || !b) return empty;
427
- const ba = a.bins || (a.medians ? quantise(a.medians) : null);
428
- const bb = b.bins || (b.medians ? quantise(b.medians) : null);
429
- if (!ba || !bb) return empty;
430
-
431
- const worst = [];
432
- let total = 0;
433
- let count = 0;
434
- for (const axis of AXES) {
435
- if (ba[axis.name] === undefined || bb[axis.name] === undefined) continue;
436
- const d = binDistance(axis, ba[axis.name], bb[axis.name]);
437
- total += d;
438
- count++;
439
- worst.push({ axis: axis.name, bins: d, a: ba[axis.name], b: bb[axis.name] });
440
- }
441
- if (!count) return empty;
442
- const distance = total / count;
443
- worst.sort((x, y) => y.bins - x.bins);
444
- return {
445
- score: Number((1 / (1 + distance)).toFixed(4)),
446
- withinTolerance: distance <= threshold,
447
- distance: Number(distance.toFixed(4)),
448
- worst: worst.slice(0, 3),
449
- comparable: true,
450
- };
451
- }
452
-
453
-
454
-
455
- module.exports = {
456
- parseXi2, segmentStrokes, strokeFeatures, quantise, medians, touchSignature,
457
- signatureBody, signatureFromMedians, profile, compareTouch, binValue, binDistance,
458
- AXES, AXIS_NAMES, TOUCH_VERSION, SIG_LENGTH, MIN_STROKES, MAX_STROKES,
459
- DEFAULT_IDLE_GAP_MS, THRESHOLD,
460
- };
3
+ "use strict";const crypto=require("node:crypto"),MIN_STROKES=3,MAX_STROKES=64,MAX_SAMPLES=2e4,DEFAULT_IDLE_GAP_MS=140,TOUCH_VERSION=1,SIG_LENGTH=16,AXES=Object.freeze([{name:"samples",mode:"linear",tol:3},{name:"durationMs",mode:"linear",tol:150},{name:"straightness",mode:"linear",tol:.15},{name:"verticalBias",mode:"linear",tol:.15},{name:"pauseRatio",mode:"linear",tol:.15},{name:"dtCv",mode:"linear",tol:.15},{name:"turnMean",mode:"linear",tol:.12},{name:"speedSkew",mode:"linear",tol:.5},{name:"reversalRate",mode:"linear",tol:.1},{name:"pathPerSample",mode:"log",tol:1.25}]),THRESHOLD=1,AXIS_NAMES=Object.freeze(AXES.map((e=>e.name)));function parseXi2(e,{now:t=(()=>Date.now()),device:n=null}={}){const s=[];let a=null;const o=()=>{if(!a)return;const e=a.valuators;void 0===e[0]&&void 0===e[1]||s.push({type:a.type,device:a.device,dx:Number(e[0]||0),dy:Number(e[1]||0),t:a.t}),a=null};for(const n of String(e).split("\n")){const e=n.replace(/\u001b\[[0-9;]*m/g,""),r=/^\s*EVENT\s+type\s+(\d+)\s*(?:\(([^)]*)\))?/.exec(e);if(r){o(),a={type:Number(r[1]),name:r[2]||"",device:null,valuators:{},t:t()};continue}const i=/^\s*device:\s*(\d+)/.exec(e);if(i&&a){a.device=Number(i[1]);continue}if(a){const t=/^\s*(\d+):\s*(-?[\d.]+)\s*(?:\((-?[\d.]+)\))?\s*$/.exec(e);if(t){a.valuators[Number(t[1])]=Number(t[2]);continue}continue}const u=/^\s*(?:motion|raw motion)\s+id\s+(\d+)\s+\[[^\]]*\]\s*(.*)$/.exec(e);if(u){const e={};for(const t of u[2].matchAll(/(\d+):\s*(-?\d+)/g))e[Number(t[1])]=Number(t[2]);void 0===e[0]&&void 0===e[1]||s.push({type:0,device:Number(u[1]),dx:Number(e[0]||0),dy:Number(e[1]||0),t:t()})}}return o(),(null===n?s:s.filter((e=>e.device===n))).slice(0,2e4)}function segmentStrokes(e,{idleGapMs:t=DEFAULT_IDLE_GAP_MS}={}){const n=[];let s=[];for(const a of e)s.length&&a.t-s[s.length-1].t>t&&(n.push(s),s=[]),s.push(a);return s.length&&n.push(s),n.filter((e=>e.length>1)).slice(0,MAX_STROKES)}const mean=e=>e.length?e.reduce(((e,t)=>e+t),0)/e.length:0;function strokeFeatures(e){const t=e.length;let n=0,s=0,a=0,o=0,r=0,i=0;const u=[],l=[];let c=0,m=0,d=null;for(let h=0;h<t;h++){const t=e[h],S=Math.hypot(t.dx,t.dy);if(n+=S,s+=t.dx,a+=t.dy,0===S&&o++,h>0){const n=Math.max(1,e[h].t-e[h-1].t);l.push(n),u.push(S/n);const s=Math.atan2(t.dy,t.dx);if(null!==d){let e=s-d;for(;e>Math.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;r+=Math.abs(e)}d=s}const f=Math.sign(t.dx),p=Math.sign(t.dy);f&&c&&f!==c&&i++,p&&m&&p!==m&&i++,f&&(c=f),p&&(m=p)}const h=Math.hypot(s,a),S=Math.max(1,e[t-1].t-e[0].t),f=mean(u),p=mean(l),M=mean(l.map((e=>(e-p)**2)));return{samples:t,durationMs:S,straightness:n?h/n:0,verticalBias:n?Math.abs(a)/n:0,pauseRatio:o/t,dtCv:p?Math.sqrt(M)/p:0,turnMean:t>1?r/(t-1):0,speedSkew:f?Math.max(...u)/f-1:0,reversalRate:i/t,pathPerSample:n/t}}function binValue(e,t){const n=Number.isFinite(t)?t:0;return"log"===e.mode?n<=0?0:Math.round(Math.log(n)/Math.log(e.tol)):Math.round(n/e.tol)}function binDistance(e,t,n){if("log"===e.mode){const s=Math.log(e.tol),a=t*s,o=n*s;return Math.abs(a-o)}return Math.abs(t-n)}function quantise(e){const t={};for(const n of AXES)t[n.name]=binValue(n,e[n.name]);return t}function medians(e){const t={};for(const n of AXES){const s=e.map((e=>Number(e[n.name])||0)).sort(((e,t)=>e-t)),a=Math.floor(s.length/2),o=s.length%2?s[a]:(s[a-1]+s[a])/2;t[n.name]=Number.isFinite(o)?o:0}return t}function signatureBody(e){const t=quantise(e);return TOUCH_VERSION+"\n"+AXIS_NAMES.map((e=>`${e}=${t[e]}`)).join("\n")}function signatureFromMedians(e,t){return!e||Number(t)<MIN_STROKES?null:crypto.createHash("sha256").update(signatureBody(e),"utf8").digest("hex").slice(0,SIG_LENGTH)}function touchSignature(e){const t=(Array.isArray(e)?e:[]).filter((e=>e&&Number.isFinite(Number(e.samples))&&Number(e.samples)>1)).slice(0,MAX_STROKES);return t.length<MIN_STROKES?null:signatureFromMedians(medians(t),t.length)}function profile(e,t={}){const n=segmentStrokes(e,t),s=n.map(strokeFeatures),a=touchSignature(s),o=s.length?medians(s):null;return Object.freeze({version:TOUCH_VERSION,kind:"gesture-dynamics",notice:"not a fingerprint: this machine has no fingerprint sensor, and the trackpad exposes no contact geometry through X. These are habits of motion, learned not measured.",signature:a,samples:s.length,strokes:n.length,medians:o?Object.freeze({...o}):null,bins:o?Object.freeze(quantise(o)):null,axes:AXES})}function compareTouch(e,t,{threshold:n=1}={}){const s={score:0,withinTolerance:!1,distance:1/0,worst:[],comparable:!1};if(!e||!t)return s;const a=e.bins||(e.medians?quantise(e.medians):null),o=t.bins||(t.medians?quantise(t.medians):null);if(!a||!o)return s;const r=[];let i=0,u=0;for(const e of AXES){if(void 0===a[e.name]||void 0===o[e.name])continue;const t=binDistance(e,a[e.name],o[e.name]);i+=t,u++,r.push({axis:e.name,bins:t,a:a[e.name],b:o[e.name]})}if(!u)return s;const l=i/u;return r.sort(((e,t)=>t.bins-e.bins)),{score:Number((1/(1+l)).toFixed(4)),withinTolerance:l<=n,distance:Number(l.toFixed(4)),worst:r.slice(0,3),comparable:!0}}module.exports={parseXi2:parseXi2,segmentStrokes:segmentStrokes,strokeFeatures:strokeFeatures,quantise:quantise,medians:medians,touchSignature:touchSignature,signatureBody:signatureBody,signatureFromMedians:signatureFromMedians,profile:profile,compareTouch:compareTouch,binValue:binValue,binDistance:binDistance,AXES:AXES,AXIS_NAMES:AXIS_NAMES,TOUCH_VERSION:TOUCH_VERSION,SIG_LENGTH:SIG_LENGTH,MIN_STROKES:MIN_STROKES,MAX_STROKES:MAX_STROKES,DEFAULT_IDLE_GAP_MS:DEFAULT_IDLE_GAP_MS,THRESHOLD:1};