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,189 +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
- * /run support: sniff the project's dev command and run it in a captured
10
- * sub-shell. Output streams to the transcript as it happens; the session loop
11
- * can stop the process (Esc) via the returned job handle.
12
- *
13
- * Ported from the upstream engine reference (ESM → CommonJS).
14
- */
15
-
16
- const { spawn } = require('node:child_process');
17
- const fs = require('node:fs');
18
- const path = require('node:path');
19
-
20
- // The one shared module that knows which OS this is (plan Phase 30.1), staged
21
- // into `cli/vendor/client/` for the published layout — same resolver every
22
- // other shared client module goes through, so this file never re-derives
23
- // `process.platform` on its own (that duplication is F4's complaint).
24
- const { resolveClientModule } = require('./shared.js');
25
- const sharedPlatform = require(resolveClientModule('platform.js'));
26
-
27
- const MAX_STREAM_LINES = 40;
28
-
29
- /** Detect the most likely dev command for a project, or null. */
30
- function detectDevCommand(cwd = process.cwd()) {
31
- const pkg = path.join(cwd, 'package.json');
32
- if (fs.existsSync(pkg)) {
33
- try {
34
- const scripts = JSON.parse(fs.readFileSync(pkg, 'utf8')).scripts || {};
35
- for (const name of ['dev', 'start', 'watch', 'serve']) {
36
- if (typeof scripts[name] === 'string' && scripts[name].trim()) return `npm run ${name}`;
37
- }
38
- } catch {}
39
- return 'npm start';
40
- }
41
- if (fs.existsSync(path.join(cwd, 'go.mod'))) return 'go run .';
42
- if (fs.existsSync(path.join(cwd, 'Cargo.toml'))) return 'cargo run';
43
- if (fs.existsSync(path.join(cwd, 'Makefile'))) return 'make';
44
- if (fs.existsSync(path.join(cwd, 'pyproject.toml'))) return 'python -m <module>'; // honest: user picks
45
- return null;
46
- }
47
-
48
- /**
49
- * Run a shell command, streaming stdout/stderr lines to onLine. Returns a job:
50
- * { stop(), done: Promise<{ code, stopped }> }
51
- * The child — and, via platform.killTree(), its descendants — is killed when
52
- * stop() is called or `signal` aborts.
53
- *
54
- * Options:
55
- * onLine (line) => void stream sink
56
- * signal AbortSignal abort => stop
57
- * cwd string
58
- * onError (err, result) => void where a FAILED kill is reported
59
- * platform implementation or name the test seam: pass an object with
60
- * `killTree` to stub the kill, or an
61
- * OS name ('win32' | 'linux' | …) to
62
- * drive the real module's win32 path
63
- * from a non-Windows host
64
- * killOptions seams forwarded to killTree ({ platform, kill, run, signal,
65
- * detached, timeout })
66
- */
67
- function runDevServer(command, { onLine, signal, cwd, onError, platform: platformImpl, killOptions } = {}) {
68
- // detached: the child leads its own process group on posix, which is what
69
- // lets killTree() take the whole tree out with kill(-pid) instead of leaking
70
- // grandchildren. On win32 there is no group to signal — killTree() uses
71
- // `taskkill /T` to walk the parent/child tree instead.
72
- const child = spawn(command, { shell: true, cwd: cwd || process.cwd(), env: process.env, detached: true });
73
- let buffer = '';
74
- let stopped = false;
75
- let code = null;
76
- let nLines = 0;
77
- // Settle-once guard shared by every completion path. The job's `done` MUST
78
- // resolve: the session loop's streamJob guard — which swallows every key
79
- // while a /run job is live — is only cleared by job.done settling. If
80
- // 'close' never fires (a detached grandchild escaped the group kill and
81
- // still holds the stdout pipe), 'exit' + the stop fallback cover it.
82
- let doneResolved = false;
83
- let resolveDone = null;
84
-
85
- const deliver = (chunk) => {
86
- buffer += chunk;
87
- let idx;
88
- while ((idx = buffer.indexOf('\n')) >= 0) {
89
- const line = buffer.slice(0, idx).replace(/\r$/, '').trimEnd();
90
- buffer = buffer.slice(idx + 1);
91
- if (line && nLines++ < MAX_STREAM_LINES && onLine) onLine(line);
92
- }
93
- };
94
- child.stdout && child.stdout.on('data', deliver);
95
- child.stderr && child.stderr.on('data', deliver);
96
- if (buffer.trim() && onLine) onLine(buffer.trim()); // trailing partial line
97
-
98
- // ---------------------------------------------------------------------
99
- // Stopping the server (plan Phase 30.2, defect F3).
100
- //
101
- // This used to be a bare negative-pid signal to the process group, wrapped in
102
- // an empty `try {} catch {}`.
103
- //
104
- // A negative pid is a POSIX *process-group* kill. On win32 that call throws,
105
- // and the empty catch ate the throw, so the dev server and every child it
106
- // had spawned were silently orphaned with no error anywhere: not in the
107
- // transcript, not on stderr. The swallow was as much the bug as the signal
108
- // (the same defect class the engine fixed in its Phase 21c, src/proc.js).
109
- //
110
- // The stop now goes through platform.killTree() (the shared module, plan
111
- // 30.1): posix keeps the detached-group kill, win32 runs
112
- // `taskkill /PID <pid> /T /F`, and the result is `{ ok, error }` rather than
113
- // a throw — so a failure can be *reported*. It is: onError if the caller
114
- // gave one, otherwise the transcript the user is already reading, otherwise
115
- // stderr. Never dropped.
116
- // ---------------------------------------------------------------------
117
- const killApi =
118
- platformImpl && typeof platformImpl === 'object' && typeof platformImpl.killTree === 'function'
119
- ? platformImpl
120
- : sharedPlatform;
121
- const killSeams = { ...(killOptions || {}) };
122
- if (typeof platformImpl === 'string' && !killSeams.platform) killSeams.platform = platformImpl;
123
-
124
- const reportKillFailure = (err) => {
125
- if (typeof onError === 'function') {
126
- onError(err);
127
- return;
128
- }
129
- const text = `[run] could not stop the dev server (pid ${child.pid}): ${err && err.message} — it may still be running`;
130
- if (typeof onLine === 'function') onLine(text);
131
- else console.error(text);
132
- };
133
-
134
- let killError = null;
135
- const killGroup = () => {
136
- const res = killApi.killTree(child, killSeams);
137
- if (res && res.ok) return res;
138
- killError = (res && res.error) || new Error('killTree failed without an error result');
139
- reportKillFailure(killError);
140
- return res;
141
- };
142
- const onAbort = () => { stopped = true; killGroup(); };
143
- if (signal) signal.addEventListener('abort', onAbort, { once: true });
144
-
145
- const settle = (patch) => {
146
- if (doneResolved) return;
147
- doneResolved = true;
148
- if (signal) signal.removeEventListener('abort', onAbort);
149
- resolveDone(patch);
150
- };
151
-
152
- const done = new Promise((resolve) => { resolveDone = resolve; });
153
- child.on('error', () => settle({ code: code ?? 1, stopped }));
154
- child.on('close', (c) => {
155
- code = c;
156
- settle({ code, stopped });
157
- });
158
- // 'close' waits for the stdio pipes; a grandchild that escaped the group
159
- // keeps the write end open and 'close' never fires. Settle shortly after
160
- // the shell itself exits, whatever the pipes do.
161
- child.on('exit', () => setTimeout(() => settle({ code: code ?? 0, stopped }), 1000));
162
-
163
- return {
164
- // The spawned pid — the one stop() actually kills, and the value a caller
165
- // (or a test, on a host that is not the OS under test) needs to reason
166
- // about the kill after the fact.
167
- pid: child.pid,
168
- stop: () => {
169
- stopped = true;
170
- const res = killGroup();
171
- // Pipe-holding survivors can still delay 'close' — force the job to
172
- // settle so the session loop's streamJob guard can't swallow keys.
173
- setTimeout(() => settle({ code: code ?? null, stopped: true }), 5000);
174
- return res;
175
- },
176
- // The last kill failure, if any — the caller can report it after the fact
177
- // instead of only through the onError callback.
178
- get killError() {
179
- return killError;
180
- },
181
- done,
182
- };
183
- }
184
-
185
- module.exports = {
186
- MAX_STREAM_LINES,
187
- detectDevCommand,
188
- runDevServer,
189
- };
3
+ "use strict";const{spawn:spawn}=require("node:child_process"),fs=require("node:fs"),path=require("node:path"),{resolveClientModule:resolveClientModule}=require("./shared.js"),sharedPlatform=require(resolveClientModule("platform.js")),MAX_STREAM_LINES=40;function detectDevCommand(e=process.cwd()){const t=path.join(e,"package.json");if(fs.existsSync(t)){try{const e=JSON.parse(fs.readFileSync(t,"utf8")).scripts||{};for(const t of["dev","start","watch","serve"])if("string"==typeof e[t]&&e[t].trim())return`npm run ${t}`}catch{}return"npm start"}return fs.existsSync(path.join(e,"go.mod"))?"go run .":fs.existsSync(path.join(e,"Cargo.toml"))?"cargo run":fs.existsSync(path.join(e,"Makefile"))?"make":fs.existsSync(path.join(e,"pyproject.toml"))?"python -m <module>":null}function runDevServer(e,{onLine:t,signal:r,cwd:o,onError:n,platform:s,killOptions:i}={}){const l=spawn(e,{shell:!0,cwd:o||process.cwd(),env:process.env,detached:!0});let c="",d=!1,p=null,a=0,u=!1,f=null;const m=e=>{let r;for(c+=e;(r=c.indexOf("\n"))>=0;){const e=c.slice(0,r).replace(/\r$/,"").trimEnd();c=c.slice(r+1),e&&a++<40&&t&&t(e)}};l.stdout&&l.stdout.on("data",m),l.stderr&&l.stderr.on("data",m),c.trim()&&t&&t(c.trim());const v=s&&"object"==typeof s&&"function"==typeof s.killTree?s:sharedPlatform,h={...i||{}};"string"!=typeof s||h.platform||(h.platform=s);let y=null;const S=()=>{const e=v.killTree(l,h);return e&&e.ok||(y=e&&e.error||new Error("killTree failed without an error result"),(e=>{if("function"==typeof n)return void n(e);const r=`[run] could not stop the dev server (pid ${l.pid}): ${e&&e.message} — it may still be running`;"function"==typeof t?t(r):console.error(r)})(y)),e},g=()=>{d=!0,S()};r&&r.addEventListener("abort",g,{once:!0});const w=e=>{u||(u=!0,r&&r.removeEventListener("abort",g),f(e))},j=new Promise((e=>{f=e}));return l.on("error",(()=>w({code:p??1,stopped:d}))),l.on("close",(e=>{p=e,w({code:p,stopped:d})})),l.on("exit",(()=>setTimeout((()=>w({code:p??0,stopped:d})),1e3))),{pid:l.pid,stop:()=>{d=!0;const e=S();return setTimeout((()=>w({code:p??null,stopped:!0})),5e3),e},get killError(){return y},done:j}}module.exports={MAX_STREAM_LINES:40,detectDevCommand:detectDevCommand,runDevServer:runDevServer};
@@ -1,335 +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
- * Line-level diff for the transcript's edit blocks.
10
- *
11
- * An `editFile`/`writeFile` call used to render as a single gray row
12
- * (" ⎿ $ {\"file_path\":\"src/hello.js\",...}"): you could see that a file
13
- * changed and never *what* changed — the one thing a coding session is
14
- * actually about. This module turns the tool call's arguments into a real
15
- * unified-style diff, which diffview.js paints as a colored block.
16
- *
17
- * Where the two sides come from:
18
- * editFile — args.old_string → args.new_string. No I/O at all.
19
- * writeFile — the file as it was on disk *before* the call ran, against
20
- * args.content. app.js builds the preview when the tool's
21
- * `phase: 'run'` event arrives, which is strictly before the
22
- * executor writes, so the read is the pre-edit state.
23
- *
24
- * Pure: strings in, plain row objects out — no spans, no colors, no globals,
25
- * no `process.stdout` — so the whole thing is unit-testable with no TTY. The
26
- * ANSI painting lives in diffview.js, exactly the split render.js already
27
- * keeps between structure and paint.
28
- *
29
- * Ported from the upstream engine reference; the engine's tool names are
30
- * `Edit`/`Write`/`MultiEdit`, this host's are `editFile`/`writeFile`, so
31
- * `editPreview` accepts both spellings. `MultiEdit` has no counterpart here
32
- * and is kept only so a newer engine frame cannot silently render nothing.
33
- */
34
-
35
- const fs = require('node:fs');
36
- const path = require('node:path');
37
-
38
- // Budgets. The preview is built synchronously inside the tool event, on the
39
- // render path, so a 200 MB writeFile must not stall the CLI — the read is
40
- // capped and the LCS table is bounded so a pathological pair of long files
41
- // cannot allocate hundreds of megabytes. Past a budget the middle collapses to
42
- // "remove everything, add everything", which is honest about being incomplete
43
- // (`truncated: true` on the preview, `… N unchanged lines` in the block).
44
- const DIFF_LIMITS = {
45
- fileBytes: 256 * 1024, // bytes read from disk for writeFile
46
- lcsCells: 250000, // n*m cap for the LCS table (~1 MB of Int32)
47
- rows: 400, // diff rows kept per preview
48
- context: 3, // unchanged lines kept around each change
49
- };
50
-
51
- /**
52
- * Split text into display lines. A trailing newline is a terminator, not an
53
- * empty last line — otherwise every normal file diff ends in a phantom
54
- * "- " / "+ " pair. CRLF is normalized so a Windows checkout doesn't render as
55
- * "every line changed".
56
- */
57
- function splitLines(text) {
58
- const s = String(text == null ? '' : text).replace(/\r\n?/g, '\n');
59
- if (s === '') return [];
60
- const lines = s.split('\n');
61
- if (lines.length && lines[lines.length - 1] === '') lines.pop();
62
- return lines;
63
- }
64
-
65
- /**
66
- * Unified-style diff of two strings.
67
- *
68
- * @returns {{rows: Array<{sign: string, text: string, no: number|null,
69
- * marker?: boolean, note?: string}>, adds: number, dels: number,
70
- * truncated: boolean}} `rows` carries context rows around each change run
71
- * (DIFF_LIMITS.context lines), collapsed runs of unchanged lines as `marker`
72
- * rows, and every changed line with a `no` for the gutter (old number on
73
- * '-', new number otherwise).
74
- */
75
- function lineDiff(oldText, newText) {
76
- const a = splitLines(oldText);
77
- const b = splitLines(newText);
78
- let pre = 0;
79
- while (pre < a.length && pre < b.length && a[pre] === b[pre]) pre++;
80
- let post = 0;
81
- while (post < a.length - pre && post < b.length - pre && a[a.length - 1 - post] === b[b.length - 1 - post]) post++;
82
-
83
- const midA = a.slice(pre, a.length - post);
84
- const midB = b.slice(pre, b.length - post);
85
- const ops = lcsOps(midA, midB);
86
- const truncated = ops === null;
87
- const body = ops || [
88
- ...midA.map((text) => ({ sign: '-', text })),
89
- ...midB.map((text) => ({ sign: '+', text })),
90
- ];
91
-
92
- // Nothing changed: say so with no rows at all. The prefix/suffix trim ate the
93
- // whole file (pre === a.length, post === 0), so the context arithmetic below
94
- // would otherwise paint "… 46 unchanged lines" plus three orphans over an
95
- // identical pair — a marker claiming an omission that never happened.
96
- if (!body.some((op) => op.sign !== ' ')) return { rows: [], adds: 0, dels: 0, truncated };
97
-
98
- const ctx = DIFF_LIMITS.context;
99
-
100
- const rows = [];
101
- let oldNo = 1;
102
- let newNo = 1;
103
- // Leading context: keep *all* of it when it fits, otherwise the last `ctx`
104
- // lines plus a marker for the ones actually dropped. The engine's original
105
- // condition (`ctxBeforeStart < pre`) fires whenever the change is preceded by
106
- // any line at all, so an ordinary three-line edit grew a bogus
107
- // "… 1 unchanged line" marker and a change deep in a file reported `ctx` as
108
- // the number hidden rather than the real count. A marker means "something was
109
- // omitted", so it may only appear when something was.
110
- const leadStart = pre > ctx ? pre - ctx : 0;
111
- const hiddenLead = leadStart;
112
- if (hiddenLead > 0) {
113
- rows.push({ sign: ' ', text: '', marker: true, note: `… ${hiddenLead} unchanged line${hiddenLead === 1 ? '' : 's'}` });
114
- }
115
- for (let i = leadStart; i < pre; i++) {
116
- rows.push({ sign: ' ', text: a[i], no: newNo });
117
- newNo++;
118
- oldNo++;
119
- }
120
- for (const op of body) {
121
- if (op.sign === ' ') {
122
- rows.push({ sign: ' ', text: op.text, no: newNo });
123
- newNo++;
124
- oldNo++;
125
- } else if (op.sign === '-') {
126
- rows.push({ sign: '-', text: op.text, no: oldNo });
127
- oldNo++;
128
- } else {
129
- rows.push({ sign: '+', text: op.text, no: newNo });
130
- newNo++;
131
- }
132
- }
133
- // Suffix context: the first `ctx` lines of the untouched tail, then a marker
134
- // for whatever unchanged tail is left over. Both the index into `b` and the
135
- // gutter number come from `b`'s tail, not `a`'s: the engine read
136
- // `b[a.length - post + i]`, which is the wrong line — and the wrong numbering
137
- // — for every edit that changes the line count.
138
- const tailStart = b.length - post;
139
- const tailCount = Math.min(post, ctx);
140
- newNo = tailStart + 1;
141
- for (let i = 0; i < tailCount; i++) {
142
- rows.push({ sign: ' ', text: b[tailStart + i], no: newNo });
143
- newNo++;
144
- oldNo++;
145
- }
146
- if (post > ctx) {
147
- const n = post - ctx;
148
- rows.push({ sign: ' ', text: '', marker: true, note: `… ${n} unchanged line${n === 1 ? '' : 's'}` });
149
- }
150
-
151
- const adds = rows.filter((r) => r.sign === '+').length;
152
- const dels = rows.filter((r) => r.sign === '-').length;
153
- let out = rows;
154
- let cut = false;
155
- if (out.length > DIFF_LIMITS.rows) {
156
- out = out.slice(0, DIFF_LIMITS.rows);
157
- out.push({ sign: ' ', text: '', marker: true, note: `… ${rows.length - DIFF_LIMITS.rows} more diff lines` });
158
- cut = true;
159
- }
160
- return { rows: out, adds, dels, truncated: truncated || cut };
161
- }
162
-
163
- /**
164
- * Longest-common-subsequence walk over two line arrays.
165
- * @returns {Array<{sign: string, text: string}>|null} ops, or null when the
166
- * table would exceed DIFF_LIMITS.lcsCells (the caller then treats the middle
167
- * as a full replacement).
168
- */
169
- function lcsOps(a, b) {
170
- const n = a.length;
171
- const m = b.length;
172
- if (!n || !m) {
173
- return [
174
- ...a.map((text) => ({ sign: '-', text })),
175
- ...b.map((text) => ({ sign: '+', text })),
176
- ];
177
- }
178
- if (n * m > DIFF_LIMITS.lcsCells) return null;
179
- const w = m + 1;
180
- const dp = new Int32Array((n + 1) * w); // dp[i*w+j] = |LCS(a[i:], b[j:])|
181
- for (let i = n - 1; i >= 0; i--) {
182
- for (let j = m - 1; j >= 0; j--) {
183
- dp[i * w + j] = a[i] === b[j]
184
- ? dp[(i + 1) * w + (j + 1)] + 1
185
- : Math.max(dp[(i + 1) * w + j], dp[i * w + (j + 1)]);
186
- }
187
- }
188
- const ops = [];
189
- let i = 0;
190
- let j = 0;
191
- while (i < n && j < m) {
192
- if (a[i] === b[j]) { ops.push({ sign: ' ', text: a[i] }); i++; j++; }
193
- else if (dp[(i + 1) * w + j] >= dp[i * w + (j + 1)]) { ops.push({ sign: '-', text: a[i] }); i++; }
194
- else { ops.push({ sign: '+', text: b[j] }); j++; }
195
- }
196
- while (i < n) ops.push({ sign: '-', text: a[i++] });
197
- while (j < m) ops.push({ sign: '+', text: b[j++] });
198
- return ops;
199
- }
200
-
201
- /** Capped read for the pre-edit state. Never throws; missing/unreadable → null. */
202
- function readCapped(file, opts = {}) {
203
- const bytes = opts.bytes == null ? DIFF_LIMITS.fileBytes : opts.bytes;
204
- try {
205
- const st = fs.statSync(file);
206
- if (!st.isFile()) return { text: null, missing: true };
207
- const text = fs.readFileSync(file, 'utf8');
208
- if (st.size > bytes) return { text: text.slice(0, bytes), missing: false, truncated: true };
209
- return { text, missing: false };
210
- } catch {
211
- return { text: null, missing: true };
212
- }
213
- }
214
-
215
- /** Path as the user thinks of it: relative to the session cwd when it is inside it. */
216
- function shortPath(file, cwd) {
217
- const f = String(file || '');
218
- if (!cwd) return f;
219
- const rel = path.relative(cwd, f);
220
- if (rel && !rel.startsWith('..') && !path.isAbsolute(rel)) return rel;
221
- const parts = f.split(path.sep).filter(Boolean);
222
- const base = f.startsWith(path.sep) ? path.sep : '';
223
- return parts.length > 2 ? base + '…' + path.sep + parts.slice(-2).join(path.sep) : f;
224
- }
225
-
226
- /**
227
- * Build the diff preview for a tool call, or null when the call isn't an edit
228
- * or its arguments don't carry enough to diff (a partial stream, a malformed
229
- * call). Never throws — a preview is decoration, not the tool result, so a bad
230
- * argument object must not be able to break a turn.
231
- *
232
- * @param {string} name Tool name — this host's `editFile`/`writeFile`, or the
233
- * engine's `Edit`/`Write`/`MultiEdit` (a vendored frame can carry either).
234
- * @param {object|string} args Tool arguments as parsed from the stream.
235
- * @param {{cwd?: string, readFile?: Function}} [opts] `readFile` is injectable
236
- * so tests never touch disk.
237
- */
238
- function editPreview(name, args, opts = {}) {
239
- try {
240
- const cwd = opts.cwd == null ? process.cwd() : opts.cwd;
241
- const readFile = opts.readFile || readCapped;
242
- if (!args || typeof args !== 'object') return null;
243
- const file = typeof args.file_path === 'string' ? args.file_path
244
- : typeof args.path === 'string' ? args.path : null;
245
- if (!file) return null;
246
- const base = { file, short: shortPath(file, cwd) };
247
-
248
- if (name === 'Edit' || name === 'editFile') {
249
- if (typeof args.old_string !== 'string' || typeof args.new_string !== 'string') return null;
250
- return Object.assign(
251
- { kind: 'Update' },
252
- base,
253
- lineDiff(args.old_string, args.new_string),
254
- { replaceAll: !!args.replace_all },
255
- );
256
- }
257
-
258
- if (name === 'Write' || name === 'writeFile') {
259
- if (typeof args.content !== 'string') return null;
260
- const prev = readFile(file) || { text: null, missing: true };
261
- const d = lineDiff(prev.text == null ? '' : prev.text, args.content);
262
- return Object.assign(
263
- { kind: prev.missing ? 'Create' : 'Write' },
264
- base,
265
- d,
266
- { truncated: d.truncated || !!prev.truncated },
267
- );
268
- }
269
-
270
- if (name === 'MultiEdit') {
271
- const edits = (Array.isArray(args.edits) ? args.edits : []).filter(
272
- (e) => e && typeof e.old_string === 'string' && typeof e.new_string === 'string',
273
- );
274
- if (!edits.length) return null;
275
- const prev = readFile(file) || { text: null, missing: true };
276
- if (typeof prev.text === 'string') {
277
- let cur = prev.text;
278
- let misses = 0;
279
- for (const e of edits) {
280
- if (cur.indexOf(e.old_string) === -1) { misses++; continue; }
281
- cur = e.replace_all
282
- ? cur.split(e.old_string).join(e.new_string)
283
- : cur.replace(e.old_string, e.new_string);
284
- }
285
- const d = lineDiff(prev.text, cur);
286
- return Object.assign(
287
- { kind: 'Update' },
288
- base,
289
- d,
290
- { misses, replaceAll: edits.some((e) => e.replace_all) },
291
- );
292
- }
293
- // No base on disk: stack each edit's own diff rather than inventing one.
294
- let rows = [];
295
- let adds = 0;
296
- let dels = 0;
297
- let truncated = false;
298
- edits.forEach((e, i) => {
299
- const d = lineDiff(e.old_string, e.new_string);
300
- if (i) rows.push({ sign: ' ', text: '', marker: true, note: `… edit ${i + 1} of ${edits.length}` });
301
- rows = rows.concat(d.rows);
302
- adds += d.adds;
303
- dels += d.dels;
304
- truncated = truncated || d.truncated;
305
- });
306
- return Object.assign(
307
- { kind: 'Update' },
308
- base,
309
- { rows, adds, dels, truncated, stacked: edits.length },
310
- );
311
- }
312
-
313
- return null;
314
- } catch {
315
- return null; // decoration must never break a turn
316
- }
317
- }
318
-
319
- /** Human count line in the reference's wording: "Added 3 lines, removed 1 line". */
320
- function changeSummary(preview) {
321
- const parts = [];
322
- if (preview.adds) parts.push(`Added ${preview.adds} line${preview.adds === 1 ? '' : 's'}`);
323
- if (preview.dels) parts.push(`removed ${preview.dels} line${preview.dels === 1 ? '' : 's'}`);
324
- return parts.length ? parts.join(', ') : 'no line changes';
325
- }
326
-
327
- module.exports = {
328
- DIFF_LIMITS,
329
- splitLines,
330
- lineDiff,
331
- readCapped,
332
- shortPath,
333
- changeSummary,
334
- editPreview,
335
- };
3
+ "use strict";const fs=require("node:fs"),path=require("node:path"),DIFF_LIMITS={fileBytes:262144,lcsCells:25e4,rows:400,context:3};function splitLines(t){const e=String(null==t?"":t).replace(/\r\n?/g,"\n");if(""===e)return[];const n=e.split("\n");return n.length&&""===n[n.length-1]&&n.pop(),n}function lineDiff(t,e){const n=splitLines(t),s=splitLines(e);let i=0;for(;i<n.length&&i<s.length&&n[i]===s[i];)i++;let r=0;for(;r<n.length-i&&r<s.length-i&&n[n.length-1-r]===s[s.length-1-r];)r++;const l=n.slice(i,n.length-r),o=s.slice(i,s.length-r),a=lcsOps(l,o),c=null===a,g=a||[...l.map((t=>({sign:"-",text:t}))),...o.map((t=>({sign:"+",text:t})))];if(!g.some((t=>" "!==t.sign)))return{rows:[],adds:0,dels:0,truncated:c};const u=DIFF_LIMITS.context,p=[];let f=1,d=1;const h=i>u?i-u:0,x=h;x>0&&p.push({sign:" ",text:"",marker:!0,note:`… ${x} unchanged line${1===x?"":"s"}`});for(let t=h;t<i;t++)p.push({sign:" ",text:n[t],no:d}),d++,f++;for(const t of g)" "===t.sign?(p.push({sign:" ",text:t.text,no:d}),d++,f++):"-"===t.sign?(p.push({sign:"-",text:t.text,no:f}),f++):(p.push({sign:"+",text:t.text,no:d}),d++);const m=s.length-r,I=Math.min(r,u);d=m+1;for(let t=0;t<I;t++)p.push({sign:" ",text:s[m+t],no:d}),d++,f++;if(r>u){const t=r-u;p.push({sign:" ",text:"",marker:!0,note:`… ${t} unchanged line${1===t?"":"s"}`})}const _=p.filter((t=>"+"===t.sign)).length,y=p.filter((t=>"-"===t.sign)).length;let F=p,w=!1;return F.length>DIFF_LIMITS.rows&&(F=F.slice(0,DIFF_LIMITS.rows),F.push({sign:" ",text:"",marker:!0,note:`… ${p.length-DIFF_LIMITS.rows} more diff lines`}),w=!0),{rows:F,adds:_,dels:y,truncated:c||w}}function lcsOps(t,e){const n=t.length,s=e.length;if(!n||!s)return[...t.map((t=>({sign:"-",text:t}))),...e.map((t=>({sign:"+",text:t})))];if(n*s>DIFF_LIMITS.lcsCells)return null;const i=s+1,r=new Int32Array((n+1)*i);for(let l=n-1;l>=0;l--)for(let n=s-1;n>=0;n--)r[l*i+n]=t[l]===e[n]?r[(l+1)*i+(n+1)]+1:Math.max(r[(l+1)*i+n],r[l*i+(n+1)]);const l=[];let o=0,a=0;for(;o<n&&a<s;)t[o]===e[a]?(l.push({sign:" ",text:t[o]}),o++,a++):r[(o+1)*i+a]>=r[o*i+(a+1)]?(l.push({sign:"-",text:t[o]}),o++):(l.push({sign:"+",text:e[a]}),a++);for(;o<n;)l.push({sign:"-",text:t[o++]});for(;a<s;)l.push({sign:"+",text:e[a++]});return l}function readCapped(t,e={}){const n=null==e.bytes?DIFF_LIMITS.fileBytes:e.bytes;try{const e=fs.statSync(t);if(!e.isFile())return{text:null,missing:!0};const s=fs.readFileSync(t,"utf8");return e.size>n?{text:s.slice(0,n),missing:!1,truncated:!0}:{text:s,missing:!1}}catch{return{text:null,missing:!0}}}function shortPath(t,e){const n=String(t||"");if(!e)return n;const s=path.relative(e,n);if(s&&!s.startsWith("..")&&!path.isAbsolute(s))return s;const i=n.split(path.sep).filter(Boolean),r=n.startsWith(path.sep)?path.sep:"";return i.length>2?r+"…"+path.sep+i.slice(-2).join(path.sep):n}function editPreview(t,e,n={}){try{const s=null==n.cwd?process.cwd():n.cwd,i=n.readFile||readCapped;if(!e||"object"!=typeof e)return null;const r="string"==typeof e.file_path?e.file_path:"string"==typeof e.path?e.path:null;if(!r)return null;const l={file:r,short:shortPath(r,s)};if("Edit"===t||"editFile"===t)return"string"!=typeof e.old_string||"string"!=typeof e.new_string?null:Object.assign({kind:"Update"},l,lineDiff(e.old_string,e.new_string),{replaceAll:!!e.replace_all});if("Write"===t||"writeFile"===t){if("string"!=typeof e.content)return null;const t=i(r)||{text:null,missing:!0},n=lineDiff(null==t.text?"":t.text,e.content);return Object.assign({kind:t.missing?"Create":"Write"},l,n,{truncated:n.truncated||!!t.truncated})}if("MultiEdit"===t){const t=(Array.isArray(e.edits)?e.edits:[]).filter((t=>t&&"string"==typeof t.old_string&&"string"==typeof t.new_string));if(!t.length)return null;const n=i(r)||{text:null,missing:!0};if("string"==typeof n.text){let e=n.text,s=0;for(const n of t)-1!==e.indexOf(n.old_string)?e=n.replace_all?e.split(n.old_string).join(n.new_string):e.replace(n.old_string,n.new_string):s++;const i=lineDiff(n.text,e);return Object.assign({kind:"Update"},l,i,{misses:s,replaceAll:t.some((t=>t.replace_all))})}let s=[],o=0,a=0,c=!1;return t.forEach(((e,n)=>{const i=lineDiff(e.old_string,e.new_string);n&&s.push({sign:" ",text:"",marker:!0,note:`… edit ${n+1} of ${t.length}`}),s=s.concat(i.rows),o+=i.adds,a+=i.dels,c=c||i.truncated})),Object.assign({kind:"Update"},l,{rows:s,adds:o,dels:a,truncated:c,stacked:t.length})}return null}catch{return null}}function changeSummary(t){const e=[];return t.adds&&e.push(`Added ${t.adds} line${1===t.adds?"":"s"}`),t.dels&&e.push(`removed ${t.dels} line${1===t.dels?"":"s"}`),e.length?e.join(", "):"no line changes"}module.exports={DIFF_LIMITS:DIFF_LIMITS,splitLines:splitLines,lineDiff:lineDiff,readCapped:readCapped,shortPath:shortPath,changeSummary:changeSummary,editPreview:editPreview};