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,406 +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
- * xp.js — the avatar's XP ledger: what earns XP, what provably cannot, and the
10
- * pure replay that turns a ledger into a level.
11
- *
12
- * The design constraint comes first, because it is the whole reason this file
13
- * exists rather than a counter incremented somewhere in main:
14
- *
15
- * XP IS PAID FOR MEMORY THAT WAS RETRIEVED AND USED, NEVER FOR VOLUME.
16
- *
17
- * A counter that grows with tokens, turns, messages or time-in-app rewards the
18
- * chattiest user, and a level that means "you typed a lot" means nothing. So
19
- * the paid events are the ones on the existing memory path (save / recall /
20
- * reinforce / correct / import) plus two that require work to have happened (a
21
- * green build, a logged idea). Everything else pays zero — by omission, which
22
- * is the only kind of rule that survives a new event kind being added.
23
- *
24
- * Three properties are load-bearing:
25
- *
26
- * 1. LEVEL IS DERIVED, NOT STORED. `evaluate()` replays the ledger from the
27
- * rules every time. The `xp` field written into each ledger line is
28
- * ADVISORY (a convenience for tools and for humans reading the file), and
29
- * replay deliberately ignores it. That makes a hand-edited ledger — or a
30
- * buggy writer — unable to inflate a level, and it makes the anti-farming
31
- * rules apply at replay time as well as append time.
32
- *
33
- * 2. DIMINISHING RETURNS ARE A HARD CEILING, NOT A VIBE. The Nth paid event of
34
- * a day pays `base * 0.5^(N/20)`. That geometric series converges, so one
35
- * day can never pay more than `MAX_BASE * 29.36 ≈ 587 XP` no matter how many
36
- * events are thrown at it. Since L5 costs 800, "farm a single day" is
37
- * mathematically impossible rather than merely discouraged. `SINGLE_DAY_XP_
38
- * CEILING` is exported so the fuzz test can assert the bound rather than
39
- * trusting this comment.
40
- *
41
- * 3. CAPS ARE PER-IDENTITY, NOT PER-CALL. Five recalls per turn, two hundred
42
- * imports per source. Without the second one, importing ten foreign tools
43
- * would jump ten levels in an afternoon.
44
- *
45
- * Pure: no fs, no Electron, no clock of its own. Every function takes the
46
- * ledger, entries and timestamps from the caller, so the whole module is
47
- * testable in plain `node --test`, exactly like `lib/sync/*`.
48
- */
49
-
50
- const { tierFor } = require('./tiers.js');
51
-
52
- /** Paid events and their base rate. Anything not listed here pays zero. */
53
- const XP_TABLE = Object.freeze({
54
- 'memory.saved': 10,
55
- 'memory.queued': 3,
56
- 'memory.recalled': 1,
57
- 'memory.reinforced': 5,
58
- 'memory.corrected': 15,
59
- 'memory.imported': 2,
60
- 'idea.logged': 10,
61
- 'build.green': 20,
62
- });
63
-
64
- /**
65
- * Kinds that look like activity and pay nothing. Not needed for correctness
66
- * (the table above already omits them) — they are named so the intent is
67
- * explicit and so a test can pin each one at zero. If someone later adds
68
- * `turn.completed: 1` to XP_TABLE, that test fails.
69
- */
70
- const VOLUME_KINDS = Object.freeze([
71
- 'token.spent',
72
- 'turn.started',
73
- 'turn.completed',
74
- 'message.sent',
75
- 'time.elapsed',
76
- 'app.opened',
77
- 'keystroke',
78
- 'scroll',
79
- ]);
80
-
81
- /** At most this many recall events pay per turn. */
82
- const RECALL_PER_TURN_CAP = 5;
83
- /** At most this many imports pay per foreign source. */
84
- const IMPORT_PER_SOURCE_CAP = 200;
85
- /** The Nth paid event of a day is scaled by 0.5^(N / this). */
86
- const DAILY_SOFT_CAP = 20;
87
-
88
- /** Ledger line schema version. */
89
- const LEDGER_VERSION = 1;
90
-
91
- /** Curve: xpForLevel(n) = 100*(n-1) + 25*(n-1)^2 → L2=125, L5=800, L10=2925. */
92
- const CURVE_LINEAR = 100;
93
- const CURVE_QUADRATIC = 25;
94
-
95
- const MAX_BASE = Math.max(...Object.values(XP_TABLE));
96
-
97
- /**
98
- * Geometric sum of the per-day decay factors: sum(0.5^(i/20)) for i=0..∞.
99
- * ~29.357. Multiplied by the largest base rate it bounds a single day's XP no
100
- * matter how many events are recorded.
101
- */
102
- const DAY_CEILING_MULTIPLE = 1 / (1 - 2 ** (-1 / DAILY_SOFT_CAP));
103
- const SINGLE_DAY_XP_CEILING = MAX_BASE * DAY_CEILING_MULTIPLE;
104
-
105
- // ---------------------------------------------------------------------------
106
- // small helpers
107
- // ---------------------------------------------------------------------------
108
-
109
- function num(v) {
110
- return typeof v === 'number' && Number.isFinite(v) ? v : 0;
111
- }
112
-
113
- function str(v) {
114
- return typeof v === 'string' && v ? v : null;
115
- }
116
-
117
- /** UTC calendar day key. Invalid timestamps share the 'unknown' bucket. */
118
- function dayKey(t) {
119
- const ms = num(t);
120
- if (!ms) return 'unknown';
121
- const d = new Date(ms);
122
- if (Number.isNaN(d.getTime())) return 'unknown';
123
- return d.toISOString().slice(0, 10);
124
- }
125
-
126
- /** Base rate for a kind, 0 for anything unpaid (including unknown kinds). */
127
- function xpFor(kind) {
128
- return XP_TABLE[String(kind)] ?? 0;
129
- }
130
-
131
- /**
132
- * Decay factor applied to the (n+1)-th paid event of a day, n 0-based.
133
- * Exported because the tests assert the bound analytically, not by sampling.
134
- */
135
- function dayScale(n) {
136
- const i = Math.max(0, Math.floor(num(n)));
137
- return 0.5 ** (i / DAILY_SOFT_CAP);
138
- }
139
-
140
- // ---------------------------------------------------------------------------
141
- // the curve
142
- // ---------------------------------------------------------------------------
143
-
144
- /** Total XP required to reach `level`. L1 = 0. */
145
- function xpForLevel(level) {
146
- const n = Math.max(1, Math.floor(num(level) || 1)) - 1;
147
- return CURVE_LINEAR * n + CURVE_QUADRATIC * n * n;
148
- }
149
-
150
- /**
151
- * Inverse of `xpForLevel`, closed-form then nudged. The closed form is exact
152
- * for integers but floating point can land a hair either side of a boundary
153
- * (xp == 125 must be L2, never L1), so the nudge loop corrects it. Bounded to
154
- * a couple of iterations in practice.
155
- */
156
- function levelForXp(xp) {
157
- const total = Math.max(0, num(xp));
158
- let n = Math.floor((-CURVE_LINEAR + Math.sqrt(CURVE_LINEAR ** 2 + 4 * CURVE_QUADRATIC * total)) / (2 * CURVE_QUADRATIC));
159
- if (!Number.isFinite(n) || n < 0) n = 0;
160
- while (xpForLevel(n + 2) <= total) n += 1;
161
- while (n > 0 && xpForLevel(n + 1) > total) n -= 1;
162
- return n + 1;
163
- }
164
-
165
- /** Progress into the current level, 0..1, with the numbers the HUD shows. */
166
- function progressAt(xp) {
167
- const total = Math.max(0, num(xp));
168
- const level = levelForXp(total);
169
- const floorAt = xpForLevel(level);
170
- const nextAt = xpForLevel(level + 1);
171
- const span = Math.max(1, nextAt - floorAt);
172
- return {
173
- level,
174
- xp: total,
175
- xpIntoLevel: total - floorAt,
176
- xpForNext: nextAt - floorAt,
177
- nextAt,
178
- progress: Math.min(1, Math.max(0, (total - floorAt) / span)),
179
- };
180
- }
181
-
182
- // ---------------------------------------------------------------------------
183
- // replay — the single source of truth
184
- // ---------------------------------------------------------------------------
185
-
186
- /**
187
- * Replay a ledger into { xp, level, ... }.
188
- *
189
- * @param {Array<object>} entries ledger lines, any order
190
- * @param {object} [opts]
191
- * @param {Set<string>|Array<string>} [opts.liveRefs] currently-live memory entry
192
- * ids. When supplied, `memory.recalled` credit for refs that no longer exist
193
- * is dropped (§1.4 decay) while *savings* survive — you did that work, and it
194
- * stays done. Omit to score every recall in the ledger.
195
- * @param {object} [opts.held] { level, session } from the current session
196
- * @param {string} [opts.session] the session being evaluated
197
- */
198
- function evaluate(entries, opts = {}) {
199
- const list = Array.isArray(entries) ? entries.slice() : [];
200
- // Deterministic replay: the same set of lines always scores the same, in the
201
- // same order, regardless of how they were read off disk.
202
- list.sort((a, b) => num(a && a.t) - num(b && b.t));
203
-
204
- const liveRefs = opts.liveRefs instanceof Set
205
- ? opts.liveRefs
206
- : Array.isArray(opts.liveRefs)
207
- ? new Set(opts.liveRefs.map(String))
208
- : null;
209
-
210
- const dayCount = new Map();
211
- const turnCount = new Map();
212
- const sourceCount = new Map();
213
- const lastRecall = new Map();
214
-
215
- const byKind = Object.create(null);
216
- const byDay = Object.create(null);
217
- const reasons = Object.create(null);
218
-
219
- let total = 0;
220
- let unpaid = 0;
221
- let suppressed = 0;
222
- let dropped = 0;
223
-
224
- for (const raw of list) {
225
- const e = raw && typeof raw === 'object' ? raw : {};
226
- const kind = String(e.kind ?? '');
227
- const base = xpFor(kind);
228
- const day = dayKey(e.t);
229
- let reason = 'ok';
230
- let gain = 0;
231
-
232
- if (base <= 0) {
233
- reason = 'unpaid-kind';
234
- } else if (kind === 'memory.recalled') {
235
- const ref = str(e.ref);
236
- if (liveRefs && ref && !liveRefs.has(ref)) {
237
- // §1.4 — the entry this recall was paid for is gone.
238
- reason = 'ref-gone';
239
- dropped += 1;
240
- } else {
241
- const turn = str(e.turn) ?? str(e.session) ?? '(unknown-turn)';
242
- if ((turnCount.get(turn) ?? 0) >= RECALL_PER_TURN_CAP) {
243
- reason = 'turn-cap';
244
- } else if (ref && lastRecall.get(ref) === str(e.session)) {
245
- // One fact must not be a slot machine: the same entry recalled twice
246
- // from the same session pays once.
247
- reason = 'duplicate-session';
248
- } else {
249
- turnCount.set(turn, (turnCount.get(turn) ?? 0) + 1);
250
- if (ref) lastRecall.set(ref, str(e.session));
251
- }
252
- }
253
- } else if (kind === 'memory.imported') {
254
- const src = str(e.source) ?? '(unknown-source)';
255
- if ((sourceCount.get(src) ?? 0) >= IMPORT_PER_SOURCE_CAP) {
256
- reason = 'source-cap';
257
- } else {
258
- sourceCount.set(src, (sourceCount.get(src) ?? 0) + 1);
259
- }
260
- }
261
-
262
- if (reason === 'ok') {
263
- const n = dayCount.get(day) ?? 0;
264
- dayCount.set(day, n + 1);
265
- gain = base * dayScale(n);
266
- total += gain;
267
- byKind[kind] = (byKind[kind] ?? 0) + gain;
268
- byDay[day] = (byDay[day] ?? 0) + gain;
269
- } else if (reason === 'unpaid-kind') {
270
- unpaid += 1;
271
- } else {
272
- suppressed += 1;
273
- }
274
-
275
- reasons[reason] = (reasons[reason] ?? 0) + 1;
276
- }
277
-
278
- const rounded = Math.floor(total);
279
- const projection = progressAt(rounded);
280
-
281
- // §1.4 held-level semantics: a level never silently regresses *while the user
282
- // is watching*. If this session already showed a higher level, report that
283
- // one and flag it; the next session settles to the derived value.
284
- const held = opts.held && typeof opts.held === 'object' ? opts.held : null;
285
- const sameSession = held && held.session != null && opts.session != null
286
- ? held.session === opts.session
287
- : false;
288
- const heldLevel = held ? Math.max(1, Math.floor(num(held.level) || 1)) : 1;
289
- const isHeld = Boolean(sameSession && heldLevel > projection.level);
290
-
291
- return Object.assign({}, projection, {
292
- xp: rounded,
293
- rawXp: total,
294
- rawLevel: projection.level,
295
- level: isHeld ? heldLevel : projection.level,
296
- held: isHeld,
297
- settledLevel: projection.level,
298
- tier: tierFor(isHeld ? heldLevel : projection.level).name,
299
- byKind,
300
- byDay,
301
- reasons,
302
- events: list.length,
303
- unpaidEvents: unpaid,
304
- suppressedEvents: suppressed,
305
- droppedEvents: dropped,
306
- days: Object.keys(byDay).length,
307
- });
308
- }
309
-
310
- /** Alias — the spec calls the replay "derive"; both names read well. */
311
- const derive = evaluate;
312
-
313
- /**
314
- * The held-level record to persist after rendering a projection, so the next
315
- * render in the same session keeps showing the same number.
316
- */
317
- function nextHeld(projection, session) {
318
- return {
319
- level: Math.max(1, Math.floor(num(projection && projection.level) || 1)),
320
- session: session ?? null,
321
- };
322
- }
323
-
324
- // ---------------------------------------------------------------------------
325
- // ledger lines
326
- // ---------------------------------------------------------------------------
327
-
328
- /**
329
- * Build a ledger line. `xp` is advisory — see the header — and is recorded on
330
- * the line so a human (or `jq`) can see what the event was worth at the time.
331
- */
332
- function makeEntry(kind, fields = {}, opts = {}) {
333
- const k = String(kind ?? '');
334
- const t = num(opts.t) || num(fields.t) || 0;
335
- const entry = {
336
- v: LEDGER_VERSION,
337
- t,
338
- kind: k,
339
- xp: xpFor(k),
340
- };
341
- for (const key of ['ref', 'session', 'turn', 'source', 'note', 'metrics']) {
342
- if (fields[key] !== undefined && fields[key] !== null) entry[key] = fields[key];
343
- }
344
- return entry;
345
- }
346
-
347
- /** Serialize ledger lines to jsonl. Unparseable lines are skipped, not written. */
348
- function formatLedger(entries) {
349
- if (!Array.isArray(entries)) return '';
350
- return entries
351
- .filter((e) => e && typeof e === 'object' && typeof e.kind === 'string')
352
- .map((e) => JSON.stringify(e))
353
- .join('\n')
354
- .concat(entries.length ? '\n' : '');
355
- }
356
-
357
- /**
358
- * Parse jsonl into ledger lines. Tolerant on purpose: a truncated final line is
359
- * the normal result of a process killed mid-append, and losing the whole level
360
- * to it would be absurd.
361
- */
362
- function parseLedger(text) {
363
- if (typeof text !== 'string' || !text) return { entries: [], corrupt: 0 };
364
- const entries = [];
365
- let corrupt = 0;
366
- for (const line of text.split('\n')) {
367
- const trimmed = line.trim();
368
- if (!trimmed) continue;
369
- try {
370
- const parsed = JSON.parse(trimmed);
371
- if (parsed && typeof parsed === 'object' && typeof parsed.kind === 'string') {
372
- entries.push(parsed);
373
- } else {
374
- corrupt += 1;
375
- }
376
- } catch {
377
- corrupt += 1;
378
- }
379
- }
380
- return { entries, corrupt };
381
- }
382
-
383
- module.exports = {
384
- XP_TABLE,
385
- VOLUME_KINDS,
386
- RECALL_PER_TURN_CAP,
387
- IMPORT_PER_SOURCE_CAP,
388
- DAILY_SOFT_CAP,
389
- LEDGER_VERSION,
390
- MAX_BASE,
391
- DAY_CEILING_MULTIPLE,
392
- SINGLE_DAY_XP_CEILING,
393
- xpFor,
394
- dayScale,
395
- dayKey,
396
- xpForLevel,
397
- levelForXp,
398
- progressAt,
399
- tierFor,
400
- evaluate,
401
- derive,
402
- nextHeld,
403
- makeEntry,
404
- formatLedger,
405
- parseLedger,
406
- };
3
+ "use strict";const{tierFor:tierFor}=require("./tiers.js"),XP_TABLE=Object.freeze({"memory.saved":10,"memory.queued":3,"memory.recalled":1,"memory.reinforced":5,"memory.corrected":15,"memory.imported":2,"idea.logged":10,"build.green":20}),VOLUME_KINDS=Object.freeze(["token.spent","turn.started","turn.completed","message.sent","time.elapsed","app.opened","keystroke","scroll"]),RECALL_PER_TURN_CAP=5,IMPORT_PER_SOURCE_CAP=200,DAILY_SOFT_CAP=20,LEDGER_VERSION=1,CURVE_LINEAR=100,CURVE_QUADRATIC=25,MAX_BASE=Math.max(...Object.values(XP_TABLE)),DAY_CEILING_MULTIPLE=1/(1-2**(-1/DAILY_SOFT_CAP)),SINGLE_DAY_XP_CEILING=MAX_BASE*DAY_CEILING_MULTIPLE;function num(e){return"number"==typeof e&&Number.isFinite(e)?e:0}function str(e){return"string"==typeof e&&e?e:null}function dayKey(e){const t=num(e);if(!t)return"unknown";const r=new Date(t);return Number.isNaN(r.getTime())?"unknown":r.toISOString().slice(0,10)}function xpFor(e){return XP_TABLE[String(e)]??0}function dayScale(e){return.5**(Math.max(0,Math.floor(num(e)))/DAILY_SOFT_CAP)}function xpForLevel(e){const t=Math.max(1,Math.floor(num(e)||1))-1;return CURVE_LINEAR*t+CURVE_QUADRATIC*t*t}function levelForXp(e){const t=Math.max(0,num(e));let r=Math.floor((-CURVE_LINEAR+Math.sqrt(CURVE_LINEAR**2+4*CURVE_QUADRATIC*t))/(2*CURVE_QUADRATIC));for((!Number.isFinite(r)||r<0)&&(r=0);xpForLevel(r+2)<=t;)r+=1;for(;r>0&&xpForLevel(r+1)>t;)r-=1;return r+1}function progressAt(e){const t=Math.max(0,num(e)),r=levelForXp(t),n=xpForLevel(r),o=xpForLevel(r+1),s=Math.max(1,o-n);return{level:r,xp:t,xpIntoLevel:t-n,xpForNext:o-n,nextAt:o,progress:Math.min(1,Math.max(0,(t-n)/s))}}function evaluate(e,t={}){const r=Array.isArray(e)?e.slice():[];r.sort(((e,t)=>num(e&&e.t)-num(t&&t.t)));const n=t.liveRefs instanceof Set?t.liveRefs:Array.isArray(t.liveRefs)?new Set(t.liveRefs.map(String)):null,o=new Map,s=new Map,l=new Map,a=new Map,i=Object.create(null),u=Object.create(null),c=Object.create(null);let p=0,_=0,f=0,m=0;for(const e of r){const t=e&&"object"==typeof e?e:{},r=String(t.kind??""),A=xpFor(r),E=dayKey(t.t);let d="ok",L=0;if(A<=0)d="unpaid-kind";else if("memory.recalled"===r){const e=str(t.ref);if(n&&e&&!n.has(e))d="ref-gone",m+=1;else{const r=str(t.turn)??str(t.session)??"(unknown-turn)";(s.get(r)??0)>=5?d="turn-cap":e&&a.get(e)===str(t.session)?d="duplicate-session":(s.set(r,(s.get(r)??0)+1),e&&a.set(e,str(t.session)))}}else if("memory.imported"===r){const e=str(t.source)??"(unknown-source)";(l.get(e)??0)>=200?d="source-cap":l.set(e,(l.get(e)??0)+1)}if("ok"===d){const e=o.get(E)??0;o.set(E,e+1),L=A*dayScale(e),p+=L,i[r]=(i[r]??0)+L,u[E]=(u[E]??0)+L}else"unpaid-kind"===d?_+=1:f+=1;c[d]=(c[d]??0)+1}const A=Math.floor(p),E=progressAt(A),d=t.held&&"object"==typeof t.held?t.held:null,L=!(!d||null==d.session||null==t.session)&&d.session===t.session,y=d?Math.max(1,Math.floor(num(d.level)||1)):1,v=Boolean(L&&y>E.level);return Object.assign({},E,{xp:A,rawXp:p,rawLevel:E.level,level:v?y:E.level,held:v,settledLevel:E.level,tier:tierFor(v?y:E.level).name,byKind:i,byDay:u,reasons:c,events:r.length,unpaidEvents:_,suppressedEvents:f,droppedEvents:m,days:Object.keys(u).length})}const derive=evaluate;function nextHeld(e,t){return{level:Math.max(1,Math.floor(num(e&&e.level)||1)),session:t??null}}function makeEntry(e,t={},r={}){const n=String(e??""),o={v:1,t:num(r.t)||num(t.t)||0,kind:n,xp:xpFor(n)};for(const e of["ref","session","turn","source","note","metrics"])void 0!==t[e]&&null!==t[e]&&(o[e]=t[e]);return o}function formatLedger(e){return Array.isArray(e)?e.filter((e=>e&&"object"==typeof e&&"string"==typeof e.kind)).map((e=>JSON.stringify(e))).join("\n").concat(e.length?"\n":""):""}function parseLedger(e){if("string"!=typeof e||!e)return{entries:[],corrupt:0};const t=[];let r=0;for(const n of e.split("\n")){const e=n.trim();if(e)try{const n=JSON.parse(e);n&&"object"==typeof n&&"string"==typeof n.kind?t.push(n):r+=1}catch{r+=1}}return{entries:t,corrupt:r}}module.exports={XP_TABLE:XP_TABLE,VOLUME_KINDS:VOLUME_KINDS,RECALL_PER_TURN_CAP:5,IMPORT_PER_SOURCE_CAP:200,DAILY_SOFT_CAP:DAILY_SOFT_CAP,LEDGER_VERSION:1,MAX_BASE:MAX_BASE,DAY_CEILING_MULTIPLE:DAY_CEILING_MULTIPLE,SINGLE_DAY_XP_CEILING:SINGLE_DAY_XP_CEILING,xpFor:xpFor,dayScale:dayScale,dayKey:dayKey,xpForLevel:xpForLevel,levelForXp:levelForXp,progressAt:progressAt,tierFor:tierFor,evaluate:evaluate,derive:derive,nextHeld:nextHeld,makeEntry:makeEntry,formatLedger:formatLedger,parseLedger:parseLedger};
@@ -1,122 +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
- * deep-link.js — aegis:// URL parsing (native desktop plumbing).
10
- * Pure functions, no Electron import, so this unit-tests without the
11
- * Electron binary. main.js wires the result into IPC; this module only
12
- * turns a raw URL/argv list into `{ action, ... }` or null.
13
- *
14
- * Supported shapes:
15
- * aegis://open?session=<id> -> { action: 'open', sessionId }
16
- * aegis://new?prompt=<text> -> { action: 'new', prompt }
17
- */
18
-
19
- const PROTOCOL = 'aegis';
20
- const SCHEME_PREFIX = `${PROTOCOL}://`;
21
-
22
- /**
23
- * Ceilings on the two values a *remote* caller controls.
24
- *
25
- * Any web page or any other app on the machine can hand the OS an `aegis://`
26
- * URL, so both fields are attacker-chosen input on a channel nobody authenticates
27
- * (there is no "is this link from the user?" check, and there cannot be one for
28
- * a custom scheme). Bounding them keeps a hostile link from parking megabytes of
29
- * text in the composer, from filling the window with a wall of pre-filled prompt,
30
- * or from using the deep link as a bulk data channel into a session that can run
31
- * tools. The renderer pre-fills rather than auto-sends (renderer/app.js
32
- * handleDeepLink), so the cost is bounded, but a pre-filled prompt is still the
33
- * most direct route from "a page I visited" to "text the user is invited to send
34
- * to a model with tools on".
35
- *
36
- * These are generous on purpose: a real hand-written link is a sentence or two.
37
- */
38
- const MAX_PROMPT_LENGTH = 2000;
39
- /** Session ids are uuids (36 chars); the slack is for a future format, not a payload. */
40
- const MAX_SESSION_ID_LENGTH = 128;
41
- /**
42
- * …and the charset is pinned too, because this id does not stay a string: the
43
- * renderer's `open` handler hands it to openSession(), which loads the session
44
- * by name. A hostile link could otherwise offer `../../…` or an absolute path
45
- * and have the *renderer* ask main to open whatever that resolves to. Ids this
46
- * app mints are `[0-9a-f-]`; anything outside a conservative id alphabet is not
47
- * one of ours, so it is rejected rather than escaped or repaired.
48
- */
49
- const SESSION_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
50
-
51
-
52
- /** True for any string that looks like our protocol, cheap enough to filter
53
- * argv with before the full URL parse (which throws on most argv entries —
54
- * flags, file paths — so callers should not run it against every arg). */
55
- function isDeepLinkUrl(value) {
56
- return typeof value === 'string' && value.toLowerCase().startsWith(SCHEME_PREFIX);
57
- }
58
-
59
- /**
60
- * Parse a raw `aegis://...` URL into a routable action, or null for anything
61
- * unparseable or from a scheme/action this app doesn't recognise. Never
62
- * throws — a malformed or malicious URL (e.g. handed to the OS by another
63
- * app) just yields null.
64
- */
65
- function parseDeepLinkUrl(url) {
66
- if (!isDeepLinkUrl(url)) return null;
67
- let parsed;
68
- try {
69
- parsed = new URL(url);
70
- } catch {
71
- return null;
72
- }
73
- if (parsed.protocol !== `${PROTOCOL}:`) return null;
74
-
75
- // For a non-special scheme like "aegis:", "//host" still parses into
76
- // `.hostname` — aegis://open?session=x -> hostname "open".
77
- const action = (parsed.hostname || '').toLowerCase();
78
-
79
- if (action === 'open') {
80
- const sessionId = parsed.searchParams.get('session');
81
- if (!sessionId) return null;
82
- if (sessionId.length > MAX_SESSION_ID_LENGTH) return null;
83
- if (!SESSION_ID_PATTERN.test(sessionId)) return null;
84
- return { action: 'open', sessionId };
85
- }
86
-
87
- if (action === 'new') {
88
- const prompt = parsed.searchParams.get('prompt') || '';
89
- if (prompt.length > MAX_PROMPT_LENGTH) return null;
90
- return { action: 'new', prompt };
91
- }
92
-
93
- return null;
94
- }
95
-
96
- /**
97
- * Find the deep-link URL among a process's argv, handling the Linux quirk
98
- * where the OS hands the URL to the app as a bare positional argument (no
99
- * `--url=` flag, no special marker) — it can land anywhere after the
100
- * executable/script path, so every entry is checked rather than assuming a
101
- * fixed index.
102
- */
103
- function extractDeepLinkUrl(argv) {
104
- if (!Array.isArray(argv)) return null;
105
- for (const arg of argv) {
106
- if (isDeepLinkUrl(arg)) return arg;
107
- }
108
- return null;
109
- }
110
-
111
- /** Convenience: argv -> parsed action in one call, or null at either step. */
112
- function parseDeepLinkArgv(argv) {
113
- return parseDeepLinkUrl(extractDeepLinkUrl(argv));
114
- }
115
-
116
- module.exports = {
117
- PROTOCOL,
118
- isDeepLinkUrl,
119
- parseDeepLinkUrl,
120
- extractDeepLinkUrl,
121
- parseDeepLinkArgv,
122
- };
3
+ "use strict";const PROTOCOL="aegis",SCHEME_PREFIX=`${PROTOCOL}://`,MAX_PROMPT_LENGTH=2e3,MAX_SESSION_ID_LENGTH=128,SESSION_ID_PATTERN=/^[A-Za-z0-9_-]{1,128}$/;function isDeepLinkUrl(e){return"string"==typeof e&&e.toLowerCase().startsWith(SCHEME_PREFIX)}function parseDeepLinkUrl(e){if(!isDeepLinkUrl(e))return null;let r;try{r=new URL(e)}catch{return null}if(r.protocol!==`${PROTOCOL}:`)return null;const n=(r.hostname||"").toLowerCase();if("open"===n){const e=r.searchParams.get("session");return e?e.length>MAX_SESSION_ID_LENGTH?null:SESSION_ID_PATTERN.test(e)?{action:"open",sessionId:e}:null:null}if("new"===n){const e=r.searchParams.get("prompt")||"";return e.length>MAX_PROMPT_LENGTH?null:{action:"new",prompt:e}}return null}function extractDeepLinkUrl(e){if(!Array.isArray(e))return null;for(const r of e)if(isDeepLinkUrl(r))return r;return null}function parseDeepLinkArgv(e){return parseDeepLinkUrl(extractDeepLinkUrl(e))}module.exports={PROTOCOL:PROTOCOL,isDeepLinkUrl:isDeepLinkUrl,parseDeepLinkUrl:parseDeepLinkUrl,extractDeepLinkUrl:extractDeepLinkUrl,parseDeepLinkArgv:parseDeepLinkArgv};