aegisone 0.0.0-stage → 1.0.4

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 (266) hide show
  1. package/README.md +98 -2
  2. package/bin/aegis.js +295 -0
  3. package/install.ps1 +151 -0
  4. package/install.sh +178 -0
  5. package/package.json +44 -4
  6. package/scripts/bump.mjs +184 -0
  7. package/scripts/bundle.js +126 -0
  8. package/scripts/predist.mjs +673 -0
  9. package/src/child.js +163 -0
  10. package/src/dispatch.js +265 -0
  11. package/src/doctor.js +636 -0
  12. package/src/host.js +108 -0
  13. package/src/permissions.js +239 -0
  14. package/src/probes.js +156 -0
  15. package/src/release.js +397 -0
  16. package/vendor/cli/LICENSE +661 -0
  17. package/vendor/cli/README.md +745 -0
  18. package/vendor/cli/bin/aegiscode.js +742 -0
  19. package/vendor/cli/package.json +42 -0
  20. package/vendor/cli/scripts/check.mjs +50 -0
  21. package/vendor/cli/scripts/demo.mjs +92 -0
  22. package/vendor/cli/scripts/predist.mjs +48 -0
  23. package/vendor/cli/scripts/runtests.mjs +54 -0
  24. package/vendor/cli/src/agents.js +136 -0
  25. package/vendor/cli/src/app.js +2166 -0
  26. package/vendor/cli/src/art.js +286 -0
  27. package/vendor/cli/src/autonomous.js +468 -0
  28. package/vendor/cli/src/caps.js +876 -0
  29. package/vendor/cli/src/chatflow.js +2389 -0
  30. package/vendor/cli/src/checkpoint.js +87 -0
  31. package/vendor/cli/src/clipboard.js +421 -0
  32. package/vendor/cli/src/cloudsync.js +525 -0
  33. package/vendor/cli/src/commands.js +3014 -0
  34. package/vendor/cli/src/config.js +527 -0
  35. package/vendor/cli/src/credentials.js +30 -0
  36. package/vendor/cli/src/deps.js +106 -0
  37. package/vendor/cli/src/devrun.js +184 -0
  38. package/vendor/cli/src/diff.js +330 -0
  39. package/vendor/cli/src/diffview.js +293 -0
  40. package/vendor/cli/src/engine.js +142 -0
  41. package/vendor/cli/src/entitlement.js +323 -0
  42. package/vendor/cli/src/events.js +694 -0
  43. package/vendor/cli/src/export.js +64 -0
  44. package/vendor/cli/src/fingerprint.js +559 -0
  45. package/vendor/cli/src/format.js +84 -0
  46. package/vendor/cli/src/fuzzy.js +116 -0
  47. package/vendor/cli/src/gate.js +45 -0
  48. package/vendor/cli/src/history.js +398 -0
  49. package/vendor/cli/src/init.js +172 -0
  50. package/vendor/cli/src/input.js +136 -0
  51. package/vendor/cli/src/keys.js +153 -0
  52. package/vendor/cli/src/markdown.js +303 -0
  53. package/vendor/cli/src/mcp.js +683 -0
  54. package/vendor/cli/src/models.js +409 -0
  55. package/vendor/cli/src/naming.js +226 -0
  56. package/vendor/cli/src/overlays.js +338 -0
  57. package/vendor/cli/src/panels.js +1402 -0
  58. package/vendor/cli/src/permissions.js +237 -0
  59. package/vendor/cli/src/ping.js +223 -0
  60. package/vendor/cli/src/presence.js +235 -0
  61. package/vendor/cli/src/render.js +469 -0
  62. package/vendor/cli/src/screen.js +504 -0
  63. package/vendor/cli/src/screens.js +776 -0
  64. package/vendor/cli/src/secret.js +56 -0
  65. package/vendor/cli/src/securefs.js +356 -0
  66. package/vendor/cli/src/settings.js +152 -0
  67. package/vendor/cli/src/shared.js +49 -0
  68. package/vendor/cli/src/sharedpaths.js +50 -0
  69. package/vendor/cli/src/signup.js +153 -0
  70. package/vendor/cli/src/summarize.js +92 -0
  71. package/vendor/cli/src/system.js +37 -0
  72. package/vendor/cli/src/theme.js +567 -0
  73. package/vendor/cli/src/title.js +217 -0
  74. package/vendor/cli/src/todos.js +109 -0
  75. package/vendor/cli/src/tokens.js +230 -0
  76. package/vendor/cli/src/topup.js +207 -0
  77. package/vendor/cli/src/update.js +87 -0
  78. package/vendor/cli/vendor/client/aegis.js +1744 -0
  79. package/vendor/cli/vendor/client/attest.js +439 -0
  80. package/vendor/cli/vendor/client/authorship-key.js +407 -0
  81. package/vendor/cli/vendor/client/auto-provision.js +59 -0
  82. package/vendor/cli/vendor/client/brain-catalog.js +265 -0
  83. package/vendor/cli/vendor/client/byok-catalog.js +192 -0
  84. package/vendor/cli/vendor/client/credentials.js +478 -0
  85. package/vendor/cli/vendor/client/device-fingerprint.js +145 -0
  86. package/vendor/cli/vendor/client/env-file.js +1016 -0
  87. package/vendor/cli/vendor/client/fingerprint.js +1061 -0
  88. package/vendor/cli/vendor/client/foreign-memory.js +666 -0
  89. package/vendor/cli/vendor/client/hooks.js +427 -0
  90. package/vendor/cli/vendor/client/platform.js +934 -0
  91. package/vendor/cli/vendor/client/prefs.js +348 -0
  92. package/vendor/cli/vendor/client/presence-constants.js +104 -0
  93. package/vendor/cli/vendor/client/presence.js +435 -0
  94. package/vendor/cli/vendor/client/record-vault.js +834 -0
  95. package/vendor/cli/vendor/client/session-store.js +545 -0
  96. package/vendor/cli/vendor/client/topup.js +294 -0
  97. package/vendor/cli/vendor/client/touch.js +455 -0
  98. package/vendor/cli/vendor/client/update.js +343 -0
  99. package/vendor/cli/vendor/covenant/README.md +21 -0
  100. package/vendor/cli/vendor/covenant/aegis.seal +177 -0
  101. package/vendor/cli/vendor/desktop/lib/local/aegis-seal.mjs +236 -0
  102. package/vendor/cli/vendor/desktop/lib/local/agents.js +102 -0
  103. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +921 -0
  104. package/vendor/cli/vendor/desktop/lib/local/context.js +92 -0
  105. package/vendor/cli/vendor/desktop/lib/local/covenant.js +562 -0
  106. package/vendor/cli/vendor/desktop/lib/local/engine.js +2155 -0
  107. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +651 -0
  108. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +225 -0
  109. package/vendor/cli/vendor/desktop/lib/local/local.js +2132 -0
  110. package/vendor/cli/vendor/desktop/lib/local/prompt.js +242 -0
  111. package/vendor/cli/vendor/desktop/lib/local/queue.js +557 -0
  112. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +205 -0
  113. package/vendor/cli/vendor/desktop/lib/local/shell.js +603 -0
  114. package/vendor/cli/vendor/desktop/lib/local/tools.js +1197 -0
  115. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +297 -0
  116. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +232 -0
  117. package/vendor/cli/vendor/desktop/lib/settings.js +846 -0
  118. package/vendor/cli/vendor/desktop/renderer/usage.js +964 -0
  119. package/vendor/cli/vendor/hosts/install.js +638 -0
  120. package/vendor/cli/vendor/hosts/openai-shim.js +516 -0
  121. package/vendor/cli/vendor/hosts/spec.js +164 -0
  122. package/vendor/cli/vendor/hosts/targets.js +346 -0
  123. package/vendor/cli/vendor/mcp/server.js +219 -0
  124. package/vendor/cli/vendor/mcp/tools.js +405 -0
  125. package/vendor/cli/vendor/tools/agent-gate.mjs +1180 -0
  126. package/vendor/desktop/README.md +365 -0
  127. package/vendor/desktop/bin/aegis.js +30 -0
  128. package/vendor/desktop/lib/auto.js +423 -0
  129. package/vendor/desktop/lib/avatar/companion.js +695 -0
  130. package/vendor/desktop/lib/avatar/cosmetics.js +529 -0
  131. package/vendor/desktop/lib/avatar/events.js +341 -0
  132. package/vendor/desktop/lib/avatar/holder-turn.js +347 -0
  133. package/vendor/desktop/lib/avatar/holders.js +609 -0
  134. package/vendor/desktop/lib/avatar/identity.js +638 -0
  135. package/vendor/desktop/lib/avatar/level.js +365 -0
  136. package/vendor/desktop/lib/avatar/mirror.js +521 -0
  137. package/vendor/desktop/lib/avatar/packs/README.md +47 -0
  138. package/vendor/desktop/lib/avatar/packs/core-wardrobe.pack.json +15 -0
  139. package/vendor/desktop/lib/avatar/packs/local-voice-core.pack.json +16 -0
  140. package/vendor/desktop/lib/avatar/packs/seasonal-winter.pack.json +14 -0
  141. package/vendor/desktop/lib/avatar/persona.js +385 -0
  142. package/vendor/desktop/lib/avatar/profile.js +974 -0
  143. package/vendor/desktop/lib/avatar/register.js +304 -0
  144. package/vendor/desktop/lib/avatar/store.js +469 -0
  145. package/vendor/desktop/lib/avatar/tiers.js +35 -0
  146. package/vendor/desktop/lib/avatar/transfer.js +412 -0
  147. package/vendor/desktop/lib/avatar/turn.js +213 -0
  148. package/vendor/desktop/lib/avatar/voice.js +325 -0
  149. package/vendor/desktop/lib/avatar/xp.js +401 -0
  150. package/vendor/desktop/lib/deep-link.js +83 -0
  151. package/vendor/desktop/lib/fingerprint.js +327 -0
  152. package/vendor/desktop/lib/local/aegis-seal.mjs +236 -0
  153. package/vendor/desktop/lib/local/agents.js +102 -0
  154. package/vendor/desktop/lib/local/autonomous.js +921 -0
  155. package/vendor/desktop/lib/local/context.js +92 -0
  156. package/vendor/desktop/lib/local/covenant.js +562 -0
  157. package/vendor/desktop/lib/local/engine.js +2155 -0
  158. package/vendor/desktop/lib/local/entitlement.js +651 -0
  159. package/vendor/desktop/lib/local/git-scope.js +225 -0
  160. package/vendor/desktop/lib/local/local.js +2132 -0
  161. package/vendor/desktop/lib/local/prompt.js +242 -0
  162. package/vendor/desktop/lib/local/queue.js +557 -0
  163. package/vendor/desktop/lib/local/session-rounds.js +205 -0
  164. package/vendor/desktop/lib/local/shell.js +603 -0
  165. package/vendor/desktop/lib/local/telemetry.js +467 -0
  166. package/vendor/desktop/lib/local/tools.js +1197 -0
  167. package/vendor/desktop/lib/local/turn-guard.js +297 -0
  168. package/vendor/desktop/lib/local/worktree-lock.js +232 -0
  169. package/vendor/desktop/lib/provider-key-mirror.js +136 -0
  170. package/vendor/desktop/lib/quick-launcher.js +81 -0
  171. package/vendor/desktop/lib/settings.js +846 -0
  172. package/vendor/desktop/lib/sync/memory-queue.js +57 -0
  173. package/vendor/desktop/lib/sync/persist-gate.js +145 -0
  174. package/vendor/desktop/lib/sync/sessions.js +103 -0
  175. package/vendor/desktop/lib/window-state.js +63 -0
  176. package/vendor/desktop/main.js +3727 -0
  177. package/vendor/desktop/package.json +70 -0
  178. package/vendor/desktop/preload.js +557 -0
  179. package/vendor/desktop/renderer/app.js +5085 -0
  180. package/vendor/desktop/renderer/avatar/assemble.js +332 -0
  181. package/vendor/desktop/renderer/avatar/avatar.css +260 -0
  182. package/vendor/desktop/renderer/avatar/avatar.js +377 -0
  183. package/vendor/desktop/renderer/avatar/cards.js +138 -0
  184. package/vendor/desktop/renderer/avatar/hud.js +203 -0
  185. package/vendor/desktop/renderer/avatar/machine.js +210 -0
  186. package/vendor/desktop/renderer/avatar/pane.js +436 -0
  187. package/vendor/desktop/renderer/avatar/parts.js +434 -0
  188. package/vendor/desktop/renderer/budget.js +156 -0
  189. package/vendor/desktop/renderer/diff.js +356 -0
  190. package/vendor/desktop/renderer/diffview.js +333 -0
  191. package/vendor/desktop/renderer/fingerprint.css +143 -0
  192. package/vendor/desktop/renderer/fingerprint.js +583 -0
  193. package/vendor/desktop/renderer/fonts/4iCs6KVjbNBYlgoKcQ72j00.woff2 +0 -0
  194. package/vendor/desktop/renderer/fonts/4iCs6KVjbNBYlgoKcg72j00.woff2 +0 -0
  195. package/vendor/desktop/renderer/fonts/4iCs6KVjbNBYlgoKcw72j00.woff2 +0 -0
  196. package/vendor/desktop/renderer/fonts/4iCs6KVjbNBYlgoKew72j00.woff2 +0 -0
  197. package/vendor/desktop/renderer/fonts/4iCs6KVjbNBYlgoKfA72j00.woff2 +0 -0
  198. package/vendor/desktop/renderer/fonts/4iCs6KVjbNBYlgoKfw72.woff2 +0 -0
  199. package/vendor/desktop/renderer/fonts/4iCu6KVjbNBYlgoKej70l0k.woff2 +0 -0
  200. package/vendor/desktop/renderer/fonts/4iCu6KVjbNBYlgoKej73l0mwFg.woff2 +0 -0
  201. package/vendor/desktop/renderer/fonts/4iCu6KVjbNBYlgoKej74l0mwFg.woff2 +0 -0
  202. package/vendor/desktop/renderer/fonts/4iCu6KVjbNBYlgoKej75l0mwFg.woff2 +0 -0
  203. package/vendor/desktop/renderer/fonts/4iCu6KVjbNBYlgoKej76l0mwFg.woff2 +0 -0
  204. package/vendor/desktop/renderer/fonts/4iCu6KVjbNBYlgoKej7wl0mwFg.woff2 +0 -0
  205. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCjC3js2yNL4U.woff2 +0 -0
  206. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCjC3jsGyN.woff2 +0 -0
  207. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCjC3jtGyNL4U.woff2 +0 -0
  208. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCjC3jvGyNL4U.woff2 +0 -0
  209. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCjC3jvWyNL4U.woff2 +0 -0
  210. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCjC3jvmyNL4U.woff2 +0 -0
  211. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCxCvjs2yNL4U.woff2 +0 -0
  212. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCxCvjsGyN.woff2 +0 -0
  213. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCxCvjtGyNL4U.woff2 +0 -0
  214. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCxCvjvGyNL4U.woff2 +0 -0
  215. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCxCvjvWyNL4U.woff2 +0 -0
  216. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCxCvjvmyNL4U.woff2 +0 -0
  217. package/vendor/desktop/renderer/fonts/8vIH7w4qzmVxm25L9Hz_.woff2 +0 -0
  218. package/vendor/desktop/renderer/fonts/8vIH7w4qzmVxm2BL9A.woff2 +0 -0
  219. package/vendor/desktop/renderer/fonts/8vIH7w4qzmVxm2NL9Hz_.woff2 +0 -0
  220. package/vendor/desktop/renderer/fonts/NOTICE.md +57 -0
  221. package/vendor/desktop/renderer/fonts/aFTR7PB1QTsUX8KYvrGyEY2tbZX9.woff2 +0 -0
  222. package/vendor/desktop/renderer/fonts/aFTR7PB1QTsUX8KYvrGyEYOtbQ.woff2 +0 -0
  223. package/vendor/desktop/renderer/fonts/aFTR7PB1QTsUX8KYvumzEY2tbZX9.woff2 +0 -0
  224. package/vendor/desktop/renderer/fonts/aFTR7PB1QTsUX8KYvumzEYOtbQ.woff2 +0 -0
  225. package/vendor/desktop/renderer/fonts/aFTU7PB1QTsUX8KYthSQBLyM.woff2 +0 -0
  226. package/vendor/desktop/renderer/fonts/aFTU7PB1QTsUX8KYthqQBA.woff2 +0 -0
  227. package/vendor/desktop/renderer/fonts/aFTW7PB1QTsUX8KYth-gBqSI.woff2 +0 -0
  228. package/vendor/desktop/renderer/fonts/aFTW7PB1QTsUX8KYth-gCKSIUKw.woff2 +0 -0
  229. package/vendor/desktop/renderer/fonts/fonts.css +368 -0
  230. package/vendor/desktop/renderer/index.html +864 -0
  231. package/vendor/desktop/renderer/markdown.js +165 -0
  232. package/vendor/desktop/renderer/quick.css +151 -0
  233. package/vendor/desktop/renderer/quick.html +42 -0
  234. package/vendor/desktop/renderer/quick.js +188 -0
  235. package/vendor/desktop/renderer/stream-policy.js +281 -0
  236. package/vendor/desktop/renderer/style.css +2519 -0
  237. package/vendor/desktop/renderer/transcript-view.js +320 -0
  238. package/vendor/desktop/renderer/usage.js +964 -0
  239. package/vendor/desktop/renderer/vendor/NOTICE.md +20 -0
  240. package/vendor/desktop/renderer/vendor/aegis-highlight.js +135 -0
  241. package/vendor/desktop/renderer/vendor/marked.umd.js +80 -0
  242. package/vendor/desktop/renderer/vendor/purify.min.js +3 -0
  243. package/vendor/desktop/vendor/aegis.js +1744 -0
  244. package/vendor/desktop/vendor/agent-gate.mjs +1180 -0
  245. package/vendor/desktop/vendor/attest.js +439 -0
  246. package/vendor/desktop/vendor/authorship-key.js +407 -0
  247. package/vendor/desktop/vendor/auto-provision.js +59 -0
  248. package/vendor/desktop/vendor/brain-catalog.js +265 -0
  249. package/vendor/desktop/vendor/byok-catalog.js +192 -0
  250. package/vendor/desktop/vendor/covenant/README.md +21 -0
  251. package/vendor/desktop/vendor/covenant/aegis.seal +177 -0
  252. package/vendor/desktop/vendor/credentials.js +478 -0
  253. package/vendor/desktop/vendor/device-fingerprint.js +145 -0
  254. package/vendor/desktop/vendor/env-file.js +1016 -0
  255. package/vendor/desktop/vendor/fingerprint.js +1061 -0
  256. package/vendor/desktop/vendor/foreign-memory.js +666 -0
  257. package/vendor/desktop/vendor/hooks.js +427 -0
  258. package/vendor/desktop/vendor/platform.js +934 -0
  259. package/vendor/desktop/vendor/prefs.js +348 -0
  260. package/vendor/desktop/vendor/presence-constants.js +104 -0
  261. package/vendor/desktop/vendor/presence.js +435 -0
  262. package/vendor/desktop/vendor/record-vault.js +834 -0
  263. package/vendor/desktop/vendor/session-store.js +545 -0
  264. package/vendor/desktop/vendor/topup.js +294 -0
  265. package/vendor/desktop/vendor/touch.js +455 -0
  266. package/vendor/desktop/vendor/update.js +343 -0
@@ -0,0 +1,153 @@
1
+ /**
2
+ * The one place the CLI tells a user where to get an account key.
3
+ *
4
+ * Every prompt used to say "free at https://aegiscloud.org" — the marketing
5
+ * homepage. No registration panel, no route to the page that shows the key,
6
+ * and (because the landing URL carried no UTM) no way for aegis1 to tell the
7
+ * signup came from the CLI at all. That is a round trip the user has to
8
+ * complete unaided, at the exact moment they have already decided to keep the
9
+ * tool: the prompts were the top of the funnel and they dead-ended.
10
+ *
11
+ * So the prompt now prints a short, typeable deep link instead:
12
+ *
13
+ * https://aegiscloud.org/key?s=cli&c=key_screen
14
+ *
15
+ * `/key` is a real aegis1 route (app.py `key_short_link`) that expands —
16
+ * server-side — into the register panel plus the key page, with the channel
17
+ * UTMs attached. Two consequences worth knowing before editing anything here:
18
+ *
19
+ * - `s=cli` must stay in aegis1's SIGNUP_SOURCES or the signup is filed as
20
+ * 'direct' and this channel looks dead in the funnel. `s` is deliberately
21
+ * not caller-supplied: one wrong value silently zeroes the channel.
22
+ * - the URL is displayed, not just linked, so it has to stay short enough
23
+ * not to wrap in an 80-column terminal. That is the whole reason the
24
+ * expansion is a server-side redirect rather than a long query string: the
25
+ * full form is 108 chars and shears across lines.
26
+ *
27
+ * `campaign` is the prompt that printed the link, so prompts can be compared
28
+ * against each other instead of reported as one number. Unknown or absent
29
+ * campaigns are simply not sent — unattributed is a missing datapoint, never a
30
+ * wrong one.
31
+ */
32
+
33
+ const SIGNUP_ORIGIN = 'https://aegiscloud.org';
34
+
35
+ /** The short aegis1 route that expands to "register, then show me my key". */
36
+ const SIGNUP_PATH = '/key';
37
+
38
+ /** The channel every CLI signup is filed under in aegis1 (SIGNUP_SOURCES). */
39
+ const SIGNUP_SOURCE = 'cli';
40
+
41
+ /** Bare `https://aegiscloud.org` for copy about the project rather than the
42
+ * key — the docs/troubleshooting links in system.js want the homepage. */
43
+ const HOME_URL = SIGNUP_ORIGIN;
44
+
45
+ /** Longest campaign slug aegis1 will record (`_sanitize_signup_slug`). */
46
+ const CAMPAIGN_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/;
47
+
48
+ /**
49
+ * The deep link to show a user who has no key.
50
+ *
51
+ * A campaign that would not survive aegis1's slug sanitiser is dropped rather
52
+ * than sent: a link that records nothing is honest, a link that records the
53
+ * wrong prompt is not.
54
+ */
55
+ function signupUrl(campaign) {
56
+ const url = new URL(SIGNUP_ORIGIN + SIGNUP_PATH);
57
+ url.searchParams.set('s', SIGNUP_SOURCE);
58
+ const slug = campaign === undefined || campaign === null ? '' : String(campaign).trim().toLowerCase();
59
+ if (CAMPAIGN_RE.test(slug)) url.searchParams.set('c', slug);
60
+ return url.toString();
61
+ }
62
+
63
+ /**
64
+ * Any other aegiscloud.org page the CLI links to, tagged with the same
65
+ * channel so the visit is attributable if it ends in a signup.
66
+ *
67
+ * aegis1's first-touch hook stores the UTMs on whichever page the visitor
68
+ * lands on, so a tagged link to the desktop page or the subscribe page is
69
+ * enough for the signup it eventually produces to be credited to the CLI —
70
+ * no separate route needed, unlike the key link above.
71
+ */
72
+ function link(path, campaign) {
73
+ const url = new URL(SIGNUP_ORIGIN + (String(path).startsWith('/') ? path : `/${path}`));
74
+ url.searchParams.set('utm_source', SIGNUP_SOURCE);
75
+ url.searchParams.set('utm_medium', 'app');
76
+ const slug = campaign === undefined || campaign === null ? '' : String(campaign).trim().toLowerCase();
77
+ if (CAMPAIGN_RE.test(slug)) url.searchParams.set('utm_campaign', slug);
78
+ return url.toString();
79
+ }
80
+
81
+ /**
82
+ * The printed form of the same link: scheme-less.
83
+ *
84
+ * Not cosmetic, and not a second URL — it is `signupUrl()` with the `https://`
85
+ * stripped, so the host, the route and the channel still come from one place.
86
+ * It exists because the welcome screen's connect row wraps its text at
87
+ * `cols - 4 - indent` (screens.js `wrapped()`), which is 75 cells at 80
88
+ * columns, and the row's copy already spends 45 of them:
89
+ *
90
+ * AEGIS Desktop: same engine on your machine — <url>
91
+ *
92
+ * https://aegiscloud.org/key?s=cli -> 77 cells, wraps
93
+ * aegiscloud.org/key?s=cli -> 69 cells, fits
94
+ *
95
+ * A wrapped row is not just ugly there: the welcome screen fills 23 of an
96
+ * 80x24 terminal's 24 rows, so the extra line pushes the footer hint off the
97
+ * bottom (test/cli-onboarding.test.mjs measures it). Given that, the scheme is
98
+ * the cheapest thing to lose — a browser prepends it when the user pastes, and
99
+ * `aegiscloud.org/teleport` is already printed this way in commands.js — while
100
+ * `s=cli` is not, because dropping that files the signup as 'direct'.
101
+ *
102
+ * Screens with room for the real thing (the key screen puts the link on its
103
+ * own row) must use `signupUrl()`.
104
+ */
105
+ function signupDisplayUrl(campaign) {
106
+ return signupUrl(campaign).replace(/^https?:\/\//, '');
107
+ }
108
+
109
+ /** aegis1's paid-prompt indirection: `/go/<page>` (app.py `GO_TARGETS`). */
110
+ const GO_PATH = '/go/';
111
+
112
+ /**
113
+ * A paid prompt's destination, in the short form `/go/<page>` documents.
114
+ *
115
+ * Deliberately NOT `link()`, and this is the whole reason the function exists.
116
+ * `link()` appends the wire names (`utm_source`/`utm_campaign`) because
117
+ * aegis1's first-touch hook reads those off whichever page the visitor lands
118
+ * on. `/go/<page>` is not that kind of link: it is a redirect, and it reads the
119
+ * short names (`s`/`c`) and re-emits the wire names itself.
120
+ *
121
+ * Sending wire names to `/go/` does not fail loudly. It fails silently, in the
122
+ * worst available way — the route finds no `s`, files the click as 'direct',
123
+ * drops the campaign, and the client that sent it reads as zero conversions
124
+ * while the link still visibly works. Measured against a real app instance:
125
+ *
126
+ * /go/upgrade?s=cli&c=memory_quota -> ?utm_source=cli&utm_campaign=memory_quota
127
+ * /go/upgrade?utm_source=cli&... -> ?utm_source=direct&utm_medium=app
128
+ *
129
+ * The route now also accepts the wire names as a fallback, so that mistake can
130
+ * no longer zero a channel — but the short form is still what to send, and not
131
+ * only for correctness: it is ~40 cells shorter, on rows that `padLine()`
132
+ * truncates rather than wraps (see `signupDisplayUrl()` above).
133
+ */
134
+ function goUrl(page, campaign) {
135
+ const slug = String(page == null ? '' : page).trim().toLowerCase().replace(/^\/+|\/+$/g, '');
136
+ const url = new URL(SIGNUP_ORIGIN + GO_PATH + slug);
137
+ url.searchParams.set('s', SIGNUP_SOURCE);
138
+ const c = campaign === undefined || campaign === null ? '' : String(campaign).trim().toLowerCase();
139
+ if (CAMPAIGN_RE.test(c)) url.searchParams.set('c', c);
140
+ return url.toString();
141
+ }
142
+
143
+ module.exports = {
144
+ signupUrl,
145
+ signupDisplayUrl,
146
+ goUrl,
147
+ link,
148
+ HOME_URL,
149
+ SIGNUP_SOURCE,
150
+ SIGNUP_PATH,
151
+ SIGNUP_ORIGIN,
152
+ CAMPAIGN_RE,
153
+ };
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Transcript summarization for /compact and /recap.
5
+ *
6
+ * Dependency-free port of the upstream engine reference. The reference
7
+ * spawns `claude -p "Summarize…"` (via `resolveExecutable()` in
8
+ * client/platform.js — the shared module this repo actually ships, staged into
9
+ * cli/vendor/client/platform.js); here the
10
+ * backend is *injected* instead, so this module pulls in nothing but tokens.js:
11
+ *
12
+ * async summarizeTranscript(transcript, { callModel, model, signal } = {})
13
+ * async recapLine(transcript, { callModel, model, signal } = {})
14
+ *
15
+ * `callModel(prompt) -> string` (async) is the caller's own model seam. When
16
+ * `callModel` is not a function the module falls back to a purely local
17
+ * extraction — the first user text, the last assistant text and the turn count
18
+ * — and never throws. On abort (signal.aborted) it resolves null so handlers
19
+ * can report "cancelled"; on any other backend failure it resolves the local
20
+ * extraction.
21
+ */
22
+
23
+ const { estimateTokens } = require('./tokens.js');
24
+
25
+ // Guard: don't push more than this many chars into a prompt.
26
+ const MAX_INPUT_CHARS = 120_000;
27
+ const MAX_REPLY_CHARS = 2_000;
28
+
29
+ function extractiveSummary(transcript) {
30
+ const users = transcript.filter((m) => m.role === 'user').map((m) => m.text || '');
31
+ const lastAsst = [...transcript].reverse().find((m) => m.role === 'assistant');
32
+ const topics = users.slice(0, 3).map((t) => `“${t.length > 48 ? t.slice(0, 45) + '…' : t}”`);
33
+ const parts = [];
34
+ if (users.length) parts.push(`Covered ${users.length} prompt${users.length > 1 ? 's' : ''}: ${topics.join('; ')}.`);
35
+ if (lastAsst) {
36
+ const tail = (lastAsst.text || '').split(/\s+/).slice(0, 30).join(' ');
37
+ parts.push(`Last reply began: ${tail.length > 100 ? tail.slice(0, 97) + '…' : tail}`);
38
+ }
39
+ if (!parts.length) return 'Session with no exchanges yet.';
40
+ return parts.join(' ');
41
+ }
42
+
43
+ function demoSummary(transcript) {
44
+ return `[demo summary] ${extractiveSummary(transcript)}`;
45
+ }
46
+
47
+ /** Summarize the whole transcript in a few sentences. Resolves null on abort. */
48
+ async function summarizeTranscript(transcript, { callModel, model, signal } = {}) {
49
+ if (!transcript || !transcript.length) return 'Session with no exchanges yet.';
50
+ if (typeof callModel !== 'function') return demoSummary(transcript);
51
+ return callBackend('summarize', transcript, model, signal, callModel, () => demoSummary(transcript));
52
+ }
53
+
54
+ /** A single-line recap. Resolves null on abort. */
55
+ async function recapLine(transcript, { callModel, model, signal } = {}) {
56
+ if (!transcript || !transcript.length) return 'No exchanges yet.';
57
+ if (typeof callModel !== 'function') return `[demo recap] ${extractiveSummary(transcript)}`;
58
+ return callBackend('recap', transcript, model, signal, callModel, () => `[demo recap] ${extractiveSummary(transcript)}`);
59
+ }
60
+
61
+ async function callBackend(kind, transcript, model, signal, callModel, fallback) {
62
+ const text = transcriptToText(transcript).slice(0, MAX_INPUT_CHARS);
63
+ // NB: the ternary binds exactly as in the reference — the recap branch does
64
+ // not append the transcript text. Ported verbatim.
65
+ const prompt = kind === 'recap'
66
+ ? 'Recap the following conversation in one sentence. Be factual and specific.'
67
+ : 'Summarize the following conversation. Preserve every requirement, decision, and open question, in 2-4 sentences.'
68
+ + '\n\n' + text;
69
+
70
+ try {
71
+ if (signal && signal.aborted) return null;
72
+ const out = await callModel(prompt, { model, signal });
73
+ if (signal && signal.aborted) return null;
74
+ if (typeof out === 'string' && out.trim()) return out.trim().slice(0, MAX_REPLY_CHARS);
75
+ return fallback();
76
+ } catch {
77
+ return fallback();
78
+ }
79
+ }
80
+
81
+ function transcriptToText(transcript) {
82
+ return transcript
83
+ .filter((m) => m.role === 'user' || m.role === 'assistant' || m.role === 'note')
84
+ .map((m) => `${m.role}: ${m.text || ''}`)
85
+ .join('\n\n');
86
+ }
87
+
88
+ module.exports = {
89
+ summarizeTranscript,
90
+ recapLine,
91
+ estimateTokens,
92
+ };
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Small system helpers: best-effort URL opening (never blocks or errors) and
5
+ * a few constants shared by the support/easter-egg commands.
6
+ *
7
+ * Ported from the upstream engine reference (ESM → CommonJS). The URLS table
8
+ * pointed at Anthropic/Claude support endpoints; those are re-homed to the
9
+ * AEGIS base (https://aegiscloud.org) and the project repo. Deep paths that
10
+ * had no AEGIS equivalent collapse to the base rather than inventing a route.
11
+ */
12
+
13
+ const { spawn } = require('node:child_process');
14
+
15
+ /** Best-effort open of a URL in the system browser. Returns true if launched. */
16
+ function openUrl(url) {
17
+ try {
18
+ const platform = process.platform;
19
+ const cmd = platform === 'darwin' ? ['open'] : platform === 'win32' ? ['cmd', '/c', 'start', ''] : ['xdg-open'];
20
+ const child = spawn(cmd[0], [...cmd.slice(1), url], { stdio: 'ignore', detached: true });
21
+ child.unref();
22
+ return true;
23
+ } catch {
24
+ return false;
25
+ }
26
+ }
27
+
28
+ // AEGIS support URLs (used by /troubleshooting, /feedback…).
29
+ const URLS = {
30
+ troubleshooting: 'https://aegiscloud.org',
31
+ feedback: 'https://aegiscloud.org',
32
+ issues: 'https://aegiscloud.org',
33
+ docs: 'https://aegiscloud.org',
34
+ radio: 'https://www.youtube.com/watch?v=cP8jB6YQWbQ',
35
+ };
36
+
37
+ module.exports = { openUrl, URLS };