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,390 +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
- * persona.js — the avatar is DATA, not art.
10
- *
11
- * The user asked to "customize her or him as you want". The cheap way to build
12
- * that is a settings pane with hand-written branches for every option, which
13
- * makes a new outfit a code change and a commissioned art pack a fork. The way
14
- * this module does it: a persona is one JSON record, validated and coerced
15
- * here, and the renderer assembles layered SVG from a part manifest. A
16
- * theme is then a file. Zero code changes.
17
- *
18
- * Validation is REPAIR-ORIENTED, not reject-oriented, with exactly two hard
19
- * errors:
20
- *
21
- * - the input is not an object at all, or
22
- * - its `schema` is newer than this build understands.
23
- *
24
- * Everything else is coerced to a legal value and reported in `warnings`. That
25
- * ordering matters for a file the user can hand-edit: an unknown `hair` id from
26
- * a newer release should render the default hair and tell the user, not blank
27
- * the avatar or refuse to start the app. A persona is not a security boundary;
28
- * it is the user's own file.
29
- *
30
- * The one place that IS adversarial is the `register` block and the identity
31
- * strings, because they end up in the system prompt. Those are
32
- * sanitized here at the storage boundary — control characters and newlines are
33
- * stripped so a name cannot break out of its line — and the *prompt* fragment
34
- * is additionally bounded and neutralized in `register.js`. Two layers, because
35
- * a name is user-authored text going into a prompt.
36
- *
37
- * Pure: no fs, no Electron. The main process reads/writes the file.
38
- */
39
-
40
- /** Bump when the record shape changes; `migrate` walks old records forward. */
41
- const SCHEMA_VERSION = 1;
42
-
43
- /**
44
- * The part manifest. Ids only — geometry lives in `renderer/avatar/`,
45
- * which reads these same ids. Validation is against THIS list so a typo in a
46
- * hand-edited persona is caught at load rather than rendering an empty head.
47
- */
48
- const PARTS = Object.freeze({
49
- frame: Object.freeze(['A', 'B', 'C']),
50
- skin: Object.freeze([0, 1, 2, 3, 4, 5]),
51
- hair: Object.freeze([
52
- 'short-1', 'bob-2', 'long-3', 'curly-4', 'buzz-5',
53
- 'ponytail-6', 'braids-7', 'wavy-8',
54
- ]),
55
- eyes: Object.freeze(['soft', 'sharp', 'sleepy', 'bright']),
56
- outfit: Object.freeze([
57
- 'hoodie', 'tshirt', 'flannel', 'jacket', 'headphones',
58
- 'glasses', 'scarf', 'apron', 'seasonal-winter', 'archive-coat',
59
- ]),
60
- palette: Object.freeze(['amber', 'slate', 'moss', 'plum', 'mono', 'sunset']),
61
- motion: Object.freeze(['full', 'reduced', 'minimal']),
62
- size: Object.freeze(['small', 'medium', 'large']),
63
- expressionPack: Object.freeze(['core', 'trusted', 'companion', 'confidant', 'archivist']),
64
- proactivity: Object.freeze(['off', 'hints', 'brief']),
65
- voiceEngine: Object.freeze(['none', 'local', 'system']),
66
- });
67
-
68
- /** How many outfit layers may be worn at once (spec §2: 3 layers at L5). */
69
- const MAX_OUTFIT_LAYERS = 3;
70
-
71
- const LIMITS = Object.freeze({
72
- name: 40,
73
- pronouns: 24,
74
- selfDesc: 120,
75
- address: 32,
76
- voiceId: 64,
77
- customExpressions: 24,
78
- });
79
-
80
- const HEX_COLOR = /^#[0-9a-f]{6}$/i;
81
- /** Anything a prompt could use to start a new directive line or smuggle a role. */
82
- const UNSAFE_TEXT = /[\u0000-\u001f\u007f\u2028\u2029]+/g;
83
-
84
- function has(list, value) {
85
- return list.some((v) => v === value);
86
- }
87
-
88
- /**
89
- * Collapse whitespace and strip control characters. A name is a single line of
90
- * text in a UI, and a single line in a prompt — so newlines, tabs and
91
- * the unicode line separators are removed rather than escaped.
92
- */
93
- function cleanText(value, max) {
94
- if (typeof value !== 'string') return '';
95
- const flat = value.replace(UNSAFE_TEXT, ' ').replace(/\s+/g, ' ').trim();
96
- return flat.slice(0, max);
97
- }
98
-
99
- function clamp01(value, fallback) {
100
- const n = typeof value === 'number' && Number.isFinite(value) ? value : fallback;
101
- return Math.min(1, Math.max(0, n));
102
- }
103
-
104
- function pick(list, value, fallback) {
105
- return has(list, value) ? value : fallback;
106
- }
107
-
108
- function nonEmptyId(value, fallback, fallbackOn) {
109
- if (typeof value !== 'string') return fallback;
110
- const id = value.trim();
111
- if (has(fallbackOn, id)) return id;
112
- return fallback;
113
- }
114
-
115
- /** The persona a fresh install gets. Everything here is replaceable by the user. */
116
- const DEFAULT_PERSONA = Object.freeze({
117
- schema: SCHEMA_VERSION,
118
- identity: Object.freeze({
119
- name: 'Aegis',
120
- pronouns: 'they/them',
121
- selfDesc: 'your build partner',
122
- }),
123
- presentation: Object.freeze({
124
- frame: 'A',
125
- skin: 2,
126
- hair: 'bob-2',
127
- hairColor: '#3b2a20',
128
- eyes: 'soft',
129
- outfit: Object.freeze(['hoodie']),
130
- palette: 'amber',
131
- }),
132
- expressions: Object.freeze({ pack: 'core', custom: Object.freeze({}) }),
133
- voice: Object.freeze({ enabled: false, engine: 'none', id: null, rate: 1 }),
134
- register: Object.freeze({
135
- formality: 0.3,
136
- humor: 0.4,
137
- verbosity: 0.5,
138
- proactivity: 'hints',
139
- address: 'you',
140
- emojis: false,
141
- }),
142
- appearance: Object.freeze({ motion: 'full', size: 'medium', docked: true }),
143
- });
144
-
145
- /** A deep, mutable copy of the defaults — safe for the settings pane to edit. */
146
- function defaultPersona() {
147
- return JSON.parse(JSON.stringify(DEFAULT_PERSONA));
148
- }
149
-
150
- /**
151
- * Walk an old record forward. With one schema version this is trivial, but the
152
- * mechanism exists now so that adding v2 is a table entry rather than a
153
- * discovery that shipped personas cannot be read.
154
- */
155
- const MIGRATIONS = Object.freeze({
156
- // 0 → 1: pre-schema personas are just partial records; normalisation fills them.
157
- 0: (raw) => Object.assign({}, raw),
158
- });
159
-
160
- function migrate(raw) {
161
- if (!raw || typeof raw !== 'object') return { persona: defaultPersona(), migrated: false };
162
- let current = raw;
163
- let version = Number.isInteger(current.schema) ? current.schema : 0;
164
- // A record from the future is not migrated — the validator reports it.
165
- let migrated = false;
166
- while (version < SCHEMA_VERSION) {
167
- const step = MIGRATIONS[version];
168
- current = step ? step(current) : current;
169
- version += 1;
170
- migrated = true;
171
- }
172
- return { persona: current, migrated, fromSchema: Number.isInteger(raw.schema) ? raw.schema : 0 };
173
- }
174
-
175
- /**
176
- * Validate and repair a persona record.
177
- *
178
- * @returns {{ ok: boolean, persona: object, errors: string[], warnings: string[], migrated: boolean }}
179
- * `ok` is false only for a non-object input or a schema from the future. In
180
- * that case `persona` is the default, so the caller always has something
181
- * renderable.
182
- */
183
- function validate(raw) {
184
- const errors = [];
185
- const warnings = [];
186
-
187
- if (raw === undefined || raw === null) {
188
- return { ok: true, persona: defaultPersona(), errors, warnings: ['no persona stored yet — using defaults'], migrated: false };
189
- }
190
- if (typeof raw !== 'object' || Array.isArray(raw)) {
191
- return {
192
- ok: false,
193
- persona: defaultPersona(),
194
- errors: ['persona must be a JSON object'],
195
- warnings,
196
- migrated: false,
197
- };
198
- }
199
- if (Number.isInteger(raw.schema) && raw.schema > SCHEMA_VERSION) {
200
- return {
201
- ok: false,
202
- persona: defaultPersona(),
203
- errors: [`persona schema ${raw.schema} is newer than this build supports (${SCHEMA_VERSION})`],
204
- warnings,
205
- migrated: false,
206
- };
207
- }
208
-
209
- const { persona: migratedPersona, migrated } = migrate(raw);
210
- const src = migratedPersona;
211
- const d = DEFAULT_PERSONA;
212
-
213
- // --- identity -----------------------------------------------------------
214
- const rawIdentity = src.identity && typeof src.identity === 'object' ? src.identity : {};
215
- const name = cleanText(rawIdentity.name, LIMITS.name) || d.identity.name;
216
- if (rawIdentity.name !== undefined && name !== rawIdentity.name) {
217
- warnings.push('identity.name was trimmed to a single line and length-capped');
218
- }
219
- const identity = {
220
- name,
221
- pronouns: cleanText(rawIdentity.pronouns, LIMITS.pronouns) || d.identity.pronouns,
222
- selfDesc: cleanText(rawIdentity.selfDesc, LIMITS.selfDesc),
223
- };
224
-
225
- // --- presentation -------------------------------------------------------
226
- const rawPresentation = src.presentation && typeof src.presentation === 'object' ? src.presentation : {};
227
- const skin = has(PARTS.skin, rawPresentation.skin)
228
- ? rawPresentation.skin
229
- : (Number.isInteger(rawPresentation.skin) ? d.presentation.skin : d.presentation.skin);
230
- if (rawPresentation.skin !== undefined && !has(PARTS.skin, rawPresentation.skin)) {
231
- warnings.push(`unknown skin index ${JSON.stringify(rawPresentation.skin)} — using ${skin}`);
232
- }
233
- for (const key of ['frame', 'hair', 'eyes', 'palette']) {
234
- const got = rawPresentation[key];
235
- if (got !== undefined && !has(PARTS[key], got)) {
236
- warnings.push(`unknown ${key} ${JSON.stringify(got)} — using ${d.presentation[key]}`);
237
- }
238
- }
239
- const hairColor = HEX_COLOR.test(String(rawPresentation.hairColor || ''))
240
- ? String(rawPresentation.hairColor).toLowerCase()
241
- : d.presentation.hairColor;
242
- if (rawPresentation.hairColor !== undefined && hairColor !== rawPresentation.hairColor) {
243
- warnings.push(`hairColor must be a #rrggbb hex — using ${hairColor}`);
244
- }
245
-
246
- let outfit = Array.isArray(rawPresentation.outfit) ? rawPresentation.outfit : d.presentation.outfit;
247
- const knownOutfit = [];
248
- for (const item of outfit) {
249
- if (!has(PARTS.outfit, item)) {
250
- warnings.push(`unknown outfit item ${JSON.stringify(item)} — dropped`);
251
- continue;
252
- }
253
- if (!knownOutfit.includes(item)) knownOutfit.push(item);
254
- }
255
- if (knownOutfit.length > MAX_OUTFIT_LAYERS) {
256
- warnings.push(`at most ${MAX_OUTFIT_LAYERS} outfit layers — extra layers dropped`);
257
- knownOutfit.length = MAX_OUTFIT_LAYERS;
258
- }
259
- outfit = knownOutfit;
260
-
261
- const presentation = {
262
- frame: pick(PARTS.frame, rawPresentation.frame, d.presentation.frame),
263
- skin,
264
- hair: pick(PARTS.hair, rawPresentation.hair, d.presentation.hair),
265
- hairColor,
266
- eyes: pick(PARTS.eyes, rawPresentation.eyes, d.presentation.eyes),
267
- outfit,
268
- palette: pick(PARTS.palette, rawPresentation.palette, d.presentation.palette),
269
- };
270
-
271
- // --- expressions --------------------------------------------------------
272
- const rawExpressions = src.expressions && typeof src.expressions === 'object' ? src.expressions : {};
273
- const custom = {};
274
- if (rawExpressions.custom && typeof rawExpressions.custom === 'object' && !Array.isArray(rawExpressions.custom)) {
275
- let count = 0;
276
- for (const [key, value] of Object.entries(rawExpressions.custom)) {
277
- if (count >= LIMITS.customExpressions) {
278
- warnings.push(`at most ${LIMITS.customExpressions} custom expressions — extras dropped`);
279
- break;
280
- }
281
- const id = cleanText(key, 40);
282
- if (!id || typeof value !== 'object' || value === null) continue;
283
- custom[id] = JSON.parse(JSON.stringify(value));
284
- count += 1;
285
- }
286
- }
287
- const expressions = {
288
- pack: pick(PARTS.expressionPack, rawExpressions.pack, d.expressions.pack),
289
- custom,
290
- };
291
-
292
- // --- voice --------------------------------------------------------------
293
- const rawVoice = src.voice && typeof src.voice === 'object' ? src.voice : {};
294
- const engine = pick(PARTS.voiceEngine, rawVoice.engine, d.voice.engine);
295
- const rateNum = typeof rawVoice.rate === 'number' && Number.isFinite(rawVoice.rate)
296
- ? Math.min(2, Math.max(0.5, rawVoice.rate))
297
- : d.voice.rate;
298
- const voice = {
299
- enabled: rawVoice.enabled === true,
300
- engine,
301
- id: engine === 'none' ? null : cleanText(rawVoice.id, LIMITS.voiceId) || null,
302
- rate: rateNum,
303
- };
304
- if (voice.id && /clone|voiceprint|imitat/i.test(voice.id)) {
305
- // Non-goal from the spec: no cloning of real people. Refuse, don't warn.
306
- warnings.push('voice.id looks like a cloned voice — refused (no cloning of real people)');
307
- voice.id = null;
308
- voice.enabled = false;
309
- }
310
-
311
- // --- register (feeds the prompt, so it is the sanitized one) ------------
312
- const rawRegister = src.register && typeof src.register === 'object' ? src.register : {};
313
- const register = {
314
- formality: clamp01(rawRegister.formality, d.register.formality),
315
- humor: clamp01(rawRegister.humor, d.register.humor),
316
- verbosity: clamp01(rawRegister.verbosity, d.register.verbosity),
317
- proactivity: pick(PARTS.proactivity, rawRegister.proactivity, d.register.proactivity),
318
- address: cleanText(rawRegister.address, LIMITS.address) || d.register.address,
319
- emojis: rawRegister.emojis === true,
320
- };
321
-
322
- // --- appearance ---------------------------------------------------------
323
- const rawAppearance = src.appearance && typeof src.appearance === 'object' ? src.appearance : {};
324
- const appearance = {
325
- motion: pick(PARTS.motion, rawAppearance.motion, d.appearance.motion),
326
- size: pick(PARTS.size, rawAppearance.size, d.appearance.size),
327
- docked: rawAppearance.docked !== false,
328
- };
329
-
330
- // Unknown top-level keys are dropped, not carried: a persona that silently
331
- // accumulates junk is a persona that grows forever in the user's profile.
332
- const known = ['schema', 'identity', 'presentation', 'expressions', 'voice', 'register', 'appearance'];
333
- for (const key of Object.keys(src)) {
334
- if (!known.includes(key)) warnings.push(`unknown persona key ${JSON.stringify(key)} — ignored`);
335
- }
336
-
337
- return {
338
- ok: true,
339
- errors,
340
- warnings,
341
- migrated,
342
- persona: { schema: SCHEMA_VERSION, identity, presentation, expressions, voice, register, appearance },
343
- };
344
- }
345
-
346
- /** Convenience: validate and hand back just the record. */
347
- function load(raw) {
348
- return validate(raw).persona;
349
- }
350
-
351
- /** Deep-merge a partial update onto a valid persona, then re-validate. */
352
- function update(current, patch) {
353
- const base = validate(current).persona;
354
- if (!patch || typeof patch !== 'object') return validate(base);
355
- const merged = {
356
- schema: SCHEMA_VERSION,
357
- identity: { ...base.identity, ...(patch.identity || {}) },
358
- presentation: { ...base.presentation, ...(patch.presentation || {}) },
359
- expressions: { ...base.expressions, ...(patch.expressions || {}) },
360
- voice: { ...base.voice, ...(patch.voice || {}) },
361
- register: { ...base.register, ...(patch.register || {}) },
362
- appearance: { ...base.appearance, ...(patch.appearance || {}) },
363
- };
364
- return validate(merged);
365
- }
366
-
367
- /**
368
- * Apply an accessibility preference. `prefers-reduced-motion` is not advisory:
369
- * it forces the least motion the renderer has, regardless of what the persona
370
- * stored.
371
- */
372
- function appliesMotion(persona, prefersReducedMotion) {
373
- const motion = prefersReducedMotion ? 'minimal' : persona.appearance.motion;
374
- return motion === 'minimal' ? 'minimal' : motion;
375
- }
376
-
377
- module.exports = {
378
- SCHEMA_VERSION,
379
- PARTS,
380
- LIMITS,
381
- MAX_OUTFIT_LAYERS,
382
- DEFAULT_PERSONA,
383
- defaultPersona,
384
- migrate,
385
- validate,
386
- load,
387
- update,
388
- appliesMotion,
389
- cleanText,
390
- };
3
+ "use strict";const SCHEMA_VERSION=1,PARTS=Object.freeze({frame:Object.freeze(["A","B","C"]),skin:Object.freeze([0,1,2,3,4,5]),hair:Object.freeze(["short-1","bob-2","long-3","curly-4","buzz-5","ponytail-6","braids-7","wavy-8"]),eyes:Object.freeze(["soft","sharp","sleepy","bright"]),outfit:Object.freeze(["hoodie","tshirt","flannel","jacket","headphones","glasses","scarf","apron","seasonal-winter","archive-coat"]),palette:Object.freeze(["amber","slate","moss","plum","mono","sunset"]),motion:Object.freeze(["full","reduced","minimal"]),size:Object.freeze(["small","medium","large"]),expressionPack:Object.freeze(["core","trusted","companion","confidant","archivist"]),proactivity:Object.freeze(["off","hints","brief"]),voiceEngine:Object.freeze(["none","local","system"])}),MAX_OUTFIT_LAYERS=3,LIMITS=Object.freeze({name:40,pronouns:24,selfDesc:120,address:32,voiceId:64,customExpressions:24}),HEX_COLOR=/^#[0-9a-f]{6}$/i,UNSAFE_TEXT=/[\u0000-\u001f\u007f\u2028\u2029]+/g;function has(e,t){return e.some((e=>e===t))}function cleanText(e,t){return"string"!=typeof e?"":e.replace(UNSAFE_TEXT," ").replace(/\s+/g," ").trim().slice(0,t)}function clamp01(e,t){const r="number"==typeof e&&Number.isFinite(e)?e:t;return Math.min(1,Math.max(0,r))}function pick(e,t,r){return has(e,t)?t:r}function nonEmptyId(e,t,r){if("string"!=typeof e)return t;const n=e.trim();return has(r,n)?n:t}const DEFAULT_PERSONA=Object.freeze({schema:SCHEMA_VERSION,identity:Object.freeze({name:"Aegis",pronouns:"they/them",selfDesc:"your build partner"}),presentation:Object.freeze({frame:"A",skin:2,hair:"bob-2",hairColor:"#3b2a20",eyes:"soft",outfit:Object.freeze(["hoodie"]),palette:"amber"}),expressions:Object.freeze({pack:"core",custom:Object.freeze({})}),voice:Object.freeze({enabled:!1,engine:"none",id:null,rate:1}),register:Object.freeze({formality:.3,humor:.4,verbosity:.5,proactivity:"hints",address:"you",emojis:!1}),appearance:Object.freeze({motion:"full",size:"medium",docked:!0})});function defaultPersona(){return JSON.parse(JSON.stringify(DEFAULT_PERSONA))}const MIGRATIONS=Object.freeze({0:e=>Object.assign({},e)});function migrate(e){if(!e||"object"!=typeof e)return{persona:defaultPersona(),migrated:!1};let t=e,r=Number.isInteger(t.schema)?t.schema:0,n=!1;for(;r<SCHEMA_VERSION;){const e=MIGRATIONS[r];t=e?e(t):t,r+=1,n=!0}return{persona:t,migrated:n,fromSchema:Number.isInteger(e.schema)?e.schema:0}}function validate(e){const t=[],r=[];if(null==e)return{ok:!0,persona:defaultPersona(),errors:t,warnings:["no persona stored yet — using defaults"],migrated:!1};if("object"!=typeof e||Array.isArray(e))return{ok:!1,persona:defaultPersona(),errors:["persona must be a JSON object"],warnings:r,migrated:!1};if(Number.isInteger(e.schema)&&e.schema>SCHEMA_VERSION)return{ok:!1,persona:defaultPersona(),errors:[`persona schema ${e.schema} is newer than this build supports (${SCHEMA_VERSION})`],warnings:r,migrated:!1};const{persona:n,migrated:i}=migrate(e),s=n,o=DEFAULT_PERSONA,a=s.identity&&"object"==typeof s.identity?s.identity:{},c=cleanText(a.name,LIMITS.name)||o.identity.name;void 0!==a.name&&c!==a.name&&r.push("identity.name was trimmed to a single line and length-capped");const p={name:c,pronouns:cleanText(a.pronouns,LIMITS.pronouns)||o.identity.pronouns,selfDesc:cleanText(a.selfDesc,LIMITS.selfDesc)},u=s.presentation&&"object"==typeof s.presentation?s.presentation:{},l=has(PARTS.skin,u.skin)?u.skin:(Number.isInteger(u.skin),o.presentation.skin);void 0===u.skin||has(PARTS.skin,u.skin)||r.push(`unknown skin index ${JSON.stringify(u.skin)} — using ${l}`);for(const e of["frame","hair","eyes","palette"]){const t=u[e];void 0===t||has(PARTS[e],t)||r.push(`unknown ${e} ${JSON.stringify(t)} — using ${o.presentation[e]}`)}const f=HEX_COLOR.test(String(u.hairColor||""))?String(u.hairColor).toLowerCase():o.presentation.hairColor;void 0!==u.hairColor&&f!==u.hairColor&&r.push(`hairColor must be a #rrggbb hex — using ${f}`);let m=Array.isArray(u.outfit)?u.outfit:o.presentation.outfit;const d=[];for(const e of m)has(PARTS.outfit,e)?d.includes(e)||d.push(e):r.push(`unknown outfit item ${JSON.stringify(e)} — dropped`);d.length>MAX_OUTFIT_LAYERS&&(r.push(`at most ${MAX_OUTFIT_LAYERS} outfit layers — extra layers dropped`),d.length=MAX_OUTFIT_LAYERS),m=d;const y={frame:pick(PARTS.frame,u.frame,o.presentation.frame),skin:l,hair:pick(PARTS.hair,u.hair,o.presentation.hair),hairColor:f,eyes:pick(PARTS.eyes,u.eyes,o.presentation.eyes),outfit:m,palette:pick(PARTS.palette,u.palette,o.presentation.palette)},h=s.expressions&&"object"==typeof s.expressions?s.expressions:{},b={};if(h.custom&&"object"==typeof h.custom&&!Array.isArray(h.custom)){let e=0;for(const[t,n]of Object.entries(h.custom)){if(e>=LIMITS.customExpressions){r.push(`at most ${LIMITS.customExpressions} custom expressions — extras dropped`);break}const i=cleanText(t,40);i&&"object"==typeof n&&null!==n&&(b[i]=JSON.parse(JSON.stringify(n)),e+=1)}}const S={pack:pick(PARTS.expressionPack,h.pack,o.expressions.pack),custom:b},g=s.voice&&"object"==typeof s.voice?s.voice:{},O=pick(PARTS.voiceEngine,g.engine,o.voice.engine),A="number"==typeof g.rate&&Number.isFinite(g.rate)?Math.min(2,Math.max(.5,g.rate)):o.voice.rate,T={enabled:!0===g.enabled,engine:O,id:"none"===O?null:cleanText(g.id,LIMITS.voiceId)||null,rate:A};T.id&&/clone|voiceprint|imitat/i.test(T.id)&&(r.push("voice.id looks like a cloned voice — refused (no cloning of real people)"),T.id=null,T.enabled=!1);const k=s.register&&"object"==typeof s.register?s.register:{},E={formality:clamp01(k.formality,o.register.formality),humor:clamp01(k.humor,o.register.humor),verbosity:clamp01(k.verbosity,o.register.verbosity),proactivity:pick(PARTS.proactivity,k.proactivity,o.register.proactivity),address:cleanText(k.address,LIMITS.address)||o.register.address,emojis:!0===k.emojis},I=s.appearance&&"object"==typeof s.appearance?s.appearance:{},j={motion:pick(PARTS.motion,I.motion,o.appearance.motion),size:pick(PARTS.size,I.size,o.appearance.size),docked:!1!==I.docked},v=["schema","identity","presentation","expressions","voice","register","appearance"];for(const e of Object.keys(s))v.includes(e)||r.push(`unknown persona key ${JSON.stringify(e)} — ignored`);return{ok:!0,errors:t,warnings:r,migrated:i,persona:{schema:SCHEMA_VERSION,identity:p,presentation:y,expressions:S,voice:T,register:E,appearance:j}}}function load(e){return validate(e).persona}function update(e,t){const r=validate(e).persona;return validate(t&&"object"==typeof t?{schema:SCHEMA_VERSION,identity:{...r.identity,...t.identity||{}},presentation:{...r.presentation,...t.presentation||{}},expressions:{...r.expressions,...t.expressions||{}},voice:{...r.voice,...t.voice||{}},register:{...r.register,...t.register||{}},appearance:{...r.appearance,...t.appearance||{}}}:r)}function appliesMotion(e,t){const r=t?"minimal":e.appearance.motion;return"minimal"===r?"minimal":r}module.exports={SCHEMA_VERSION:SCHEMA_VERSION,PARTS:PARTS,LIMITS:LIMITS,MAX_OUTFIT_LAYERS:MAX_OUTFIT_LAYERS,DEFAULT_PERSONA:DEFAULT_PERSONA,defaultPersona:defaultPersona,migrate:migrate,validate:validate,load:load,update:update,appliesMotion:appliesMotion,cleanText:cleanText};