aegisone 1.0.22 → 1.0.23

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 (226) 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 -2
  6. package/scripts/bump.mjs +1 -211
  7. package/scripts/bundle.js +1 -129
  8. package/scripts/predist.mjs +1 -939
  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/permissions.js +1 -369
  14. package/src/probes.js +1 -159
  15. package/src/release.js +1 -409
  16. package/vendor/cli/bin/aegiscode.js +2 -914
  17. package/vendor/cli/package.json +3 -2
  18. package/vendor/cli/scripts/check.mjs +1 -52
  19. package/vendor/cli/scripts/demo.mjs +1 -94
  20. package/vendor/cli/scripts/predist.mjs +1 -75
  21. package/vendor/cli/scripts/runtests.mjs +1 -56
  22. package/vendor/cli/scripts/seal-gate.mjs +1 -74
  23. package/vendor/cli/src/agents.js +1 -139
  24. package/vendor/cli/src/app.js +1 -2932
  25. package/vendor/cli/src/art.js +1 -289
  26. package/vendor/cli/src/autonomous.js +1 -515
  27. package/vendor/cli/src/caps.js +1 -879
  28. package/vendor/cli/src/chatflow.js +1 -3020
  29. package/vendor/cli/src/checkpoint.js +1 -90
  30. package/vendor/cli/src/clipboard.js +1 -424
  31. package/vendor/cli/src/cloudsync.js +1 -528
  32. package/vendor/cli/src/commands.js +1 -4003
  33. package/vendor/cli/src/config.js +1 -581
  34. package/vendor/cli/src/connect.js +1 -349
  35. package/vendor/cli/src/credentials.js +1 -33
  36. package/vendor/cli/src/deps.js +1 -232
  37. package/vendor/cli/src/devrun.js +1 -187
  38. package/vendor/cli/src/diff.js +1 -333
  39. package/vendor/cli/src/diffview.js +1 -296
  40. package/vendor/cli/src/engine.js +1 -297
  41. package/vendor/cli/src/entitlement.js +1 -355
  42. package/vendor/cli/src/events.js +1 -707
  43. package/vendor/cli/src/export.js +1 -67
  44. package/vendor/cli/src/fingerprint.js +1 -592
  45. package/vendor/cli/src/format.js +1 -259
  46. package/vendor/cli/src/fuzzy.js +1 -119
  47. package/vendor/cli/src/gate.js +1 -55
  48. package/vendor/cli/src/history.js +1 -401
  49. package/vendor/cli/src/init.js +1 -175
  50. package/vendor/cli/src/input.js +1 -139
  51. package/vendor/cli/src/keys.js +1 -183
  52. package/vendor/cli/src/limits.js +1 -190
  53. package/vendor/cli/src/markdown.js +1 -306
  54. package/vendor/cli/src/mcp.js +1 -694
  55. package/vendor/cli/src/models.js +1 -487
  56. package/vendor/cli/src/naming.js +1 -229
  57. package/vendor/cli/src/overlays.js +1 -461
  58. package/vendor/cli/src/panels.js +1 -1418
  59. package/vendor/cli/src/permissions.js +1 -290
  60. package/vendor/cli/src/ping.js +1 -226
  61. package/vendor/cli/src/presence.js +1 -238
  62. package/vendor/cli/src/provenance.js +2 -182
  63. package/vendor/cli/src/render.js +1 -515
  64. package/vendor/cli/src/screen.js +1 -518
  65. package/vendor/cli/src/screens.js +1 -896
  66. package/vendor/cli/src/secret.js +1 -59
  67. package/vendor/cli/src/securefs.js +1 -359
  68. package/vendor/cli/src/settings.js +1 -155
  69. package/vendor/cli/src/shared.js +1 -52
  70. package/vendor/cli/src/sharedpaths.js +1 -53
  71. package/vendor/cli/src/signup.js +1 -156
  72. package/vendor/cli/src/summarize.js +1 -95
  73. package/vendor/cli/src/sysdiag.js +1 -585
  74. package/vendor/cli/src/system.js +1 -40
  75. package/vendor/cli/src/theme.js +1 -570
  76. package/vendor/cli/src/title.js +1 -220
  77. package/vendor/cli/src/todos.js +1 -115
  78. package/vendor/cli/src/tokens.js +1 -263
  79. package/vendor/cli/src/topup.js +1 -210
  80. package/vendor/cli/src/update.js +1 -181
  81. package/vendor/cli/vendor/client/aegis.js +1 -2179
  82. package/vendor/cli/vendor/client/attest.js +1 -442
  83. package/vendor/cli/vendor/client/authorship-key.js +1 -410
  84. package/vendor/cli/vendor/client/auto-provision.js +1 -134
  85. package/vendor/cli/vendor/client/brain-catalog.js +1 -268
  86. package/vendor/cli/vendor/client/byok-catalog.js +1 -230
  87. package/vendor/cli/vendor/client/credentials.js +1 -494
  88. package/vendor/cli/vendor/client/device-fingerprint.js +1 -141
  89. package/vendor/cli/vendor/client/drive-connect.js +1 -110
  90. package/vendor/cli/vendor/client/drive-upload.js +1 -174
  91. package/vendor/cli/vendor/client/env-file.js +1 -1273
  92. package/vendor/cli/vendor/client/fingerprint.js +1 -1064
  93. package/vendor/cli/vendor/client/foreign-memory.js +1 -669
  94. package/vendor/cli/vendor/client/google-signin.js +1 -133
  95. package/vendor/cli/vendor/client/hooks.js +1 -430
  96. package/vendor/cli/vendor/client/model-discovery.js +1 -373
  97. package/vendor/cli/vendor/client/platform.js +1 -937
  98. package/vendor/cli/vendor/client/prefs.js +1 -351
  99. package/vendor/cli/vendor/client/presence-constants.js +1 -107
  100. package/vendor/cli/vendor/client/presence.js +1 -438
  101. package/vendor/cli/vendor/client/record-vault.js +3 -1055
  102. package/vendor/cli/vendor/client/session-store.js +1 -548
  103. package/vendor/cli/vendor/client/topup.js +1 -297
  104. package/vendor/cli/vendor/client/touch.js +1 -458
  105. package/vendor/cli/vendor/client/update.js +1 -704
  106. package/vendor/cli/vendor/client/user-models.js +1 -381
  107. package/vendor/cli/vendor/desktop/lib/local/agents.js +1 -105
  108. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1045
  109. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -993
  110. package/vendor/cli/vendor/desktop/lib/local/context.js +1 -95
  111. package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -3301
  112. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -660
  113. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +1 -228
  114. package/vendor/cli/vendor/desktop/lib/local/local.js +1 -2135
  115. package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -275
  116. package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -560
  117. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -208
  118. package/vendor/cli/vendor/desktop/lib/local/shell.js +1 -680
  119. package/vendor/cli/vendor/desktop/lib/local/tools.js +1 -1238
  120. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -300
  121. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -235
  122. package/vendor/cli/vendor/desktop/lib/settings.js +1 -890
  123. package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1239
  124. package/vendor/cli/vendor/hosts/install.js +1 -638
  125. package/vendor/cli/vendor/hosts/openai-shim.js +1 -515
  126. package/vendor/cli/vendor/hosts/spec.js +1 -164
  127. package/vendor/cli/vendor/hosts/targets.js +1 -346
  128. package/vendor/cli/vendor/mcp/server.js +1 -221
  129. package/vendor/cli/vendor/mcp/tools.js +1 -408
  130. package/vendor/cli/vendor/one/src/child.js +1 -285
  131. package/vendor/cli/vendor/one/src/permissions.js +1 -369
  132. package/vendor/desktop/bin/aegis.js +1 -32
  133. package/vendor/desktop/lib/account-key.js +1 -56
  134. package/vendor/desktop/lib/auto.js +1 -430
  135. package/vendor/desktop/lib/avatar/companion.js +1 -698
  136. package/vendor/desktop/lib/avatar/cosmetics.js +1 -532
  137. package/vendor/desktop/lib/avatar/events.js +1 -344
  138. package/vendor/desktop/lib/avatar/holder-turn.js +1 -350
  139. package/vendor/desktop/lib/avatar/holders.js +1 -612
  140. package/vendor/desktop/lib/avatar/identity.js +1 -641
  141. package/vendor/desktop/lib/avatar/level.js +1 -368
  142. package/vendor/desktop/lib/avatar/mirror.js +1 -524
  143. package/vendor/desktop/lib/avatar/persona.js +1 -388
  144. package/vendor/desktop/lib/avatar/profile.js +1 -977
  145. package/vendor/desktop/lib/avatar/register.js +1 -307
  146. package/vendor/desktop/lib/avatar/store.js +1 -472
  147. package/vendor/desktop/lib/avatar/tiers.js +1 -38
  148. package/vendor/desktop/lib/avatar/transfer.js +1 -415
  149. package/vendor/desktop/lib/avatar/turn.js +1 -216
  150. package/vendor/desktop/lib/avatar/voice.js +1 -328
  151. package/vendor/desktop/lib/avatar/xp.js +1 -404
  152. package/vendor/desktop/lib/deep-link.js +1 -120
  153. package/vendor/desktop/lib/fingerprint.js +2 -347
  154. package/vendor/desktop/lib/google-connect.js +1 -227
  155. package/vendor/desktop/lib/local/agents.js +1 -105
  156. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  157. package/vendor/desktop/lib/local/claude-pro.js +1 -993
  158. package/vendor/desktop/lib/local/context.js +1 -95
  159. package/vendor/desktop/lib/local/engine.js +1 -3301
  160. package/vendor/desktop/lib/local/entitlement.js +1 -660
  161. package/vendor/desktop/lib/local/git-scope.js +1 -228
  162. package/vendor/desktop/lib/local/local.js +1 -2135
  163. package/vendor/desktop/lib/local/prompt.js +1 -275
  164. package/vendor/desktop/lib/local/queue.js +1 -560
  165. package/vendor/desktop/lib/local/session-rounds.js +1 -208
  166. package/vendor/desktop/lib/local/shell.js +1 -680
  167. package/vendor/desktop/lib/local/telemetry.js +1 -470
  168. package/vendor/desktop/lib/local/tools.js +1 -1238
  169. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  170. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  171. package/vendor/desktop/lib/provider-key-mirror.js +1 -252
  172. package/vendor/desktop/lib/quick-launcher.js +1 -84
  173. package/vendor/desktop/lib/settings.js +1 -890
  174. package/vendor/desktop/lib/sync/memory-queue.js +1 -60
  175. package/vendor/desktop/lib/sync/persist-gate.js +1 -148
  176. package/vendor/desktop/lib/sync/sessions.js +1 -106
  177. package/vendor/desktop/lib/window-state.js +1 -66
  178. package/vendor/desktop/main.js +1 -4529
  179. package/vendor/desktop/package.json +3 -2
  180. package/vendor/desktop/preload.js +1 -636
  181. package/vendor/desktop/renderer/app.js +1 -6660
  182. package/vendor/desktop/renderer/avatar/assemble.js +1 -335
  183. package/vendor/desktop/renderer/avatar/avatar.js +1 -380
  184. package/vendor/desktop/renderer/avatar/cards.js +1 -141
  185. package/vendor/desktop/renderer/avatar/hud.js +1 -206
  186. package/vendor/desktop/renderer/avatar/machine.js +1 -213
  187. package/vendor/desktop/renderer/avatar/pane.js +1 -439
  188. package/vendor/desktop/renderer/avatar/parts.js +1 -437
  189. package/vendor/desktop/renderer/budget.js +1 -168
  190. package/vendor/desktop/renderer/companion.js +1 -223
  191. package/vendor/desktop/renderer/diff.js +1 -359
  192. package/vendor/desktop/renderer/diffview.js +1 -336
  193. package/vendor/desktop/renderer/fingerprint.js +3 -736
  194. package/vendor/desktop/renderer/markdown.js +1 -168
  195. package/vendor/desktop/renderer/provider-toolbar.js +1 -134
  196. package/vendor/desktop/renderer/providers.js +1 -259
  197. package/vendor/desktop/renderer/quick.js +1 -191
  198. package/vendor/desktop/renderer/stream-policy.js +1 -306
  199. package/vendor/desktop/renderer/transcript-view.js +1 -323
  200. package/vendor/desktop/renderer/usage.js +1 -1239
  201. package/vendor/desktop/vendor/aegis.js +1 -2179
  202. package/vendor/desktop/vendor/attest.js +1 -442
  203. package/vendor/desktop/vendor/authorship-key.js +1 -410
  204. package/vendor/desktop/vendor/auto-provision.js +1 -134
  205. package/vendor/desktop/vendor/brain-catalog.js +1 -268
  206. package/vendor/desktop/vendor/byok-catalog.js +1 -230
  207. package/vendor/desktop/vendor/credentials.js +1 -494
  208. package/vendor/desktop/vendor/device-fingerprint.js +1 -141
  209. package/vendor/desktop/vendor/drive-connect.js +1 -110
  210. package/vendor/desktop/vendor/drive-upload.js +1 -174
  211. package/vendor/desktop/vendor/env-file.js +1 -1273
  212. package/vendor/desktop/vendor/fingerprint.js +1 -1064
  213. package/vendor/desktop/vendor/foreign-memory.js +1 -669
  214. package/vendor/desktop/vendor/google-signin.js +1 -133
  215. package/vendor/desktop/vendor/hooks.js +1 -430
  216. package/vendor/desktop/vendor/model-discovery.js +1 -373
  217. package/vendor/desktop/vendor/platform.js +1 -937
  218. package/vendor/desktop/vendor/prefs.js +1 -351
  219. package/vendor/desktop/vendor/presence-constants.js +1 -107
  220. package/vendor/desktop/vendor/presence.js +1 -438
  221. package/vendor/desktop/vendor/record-vault.js +3 -1055
  222. package/vendor/desktop/vendor/session-store.js +1 -548
  223. package/vendor/desktop/vendor/topup.js +1 -297
  224. package/vendor/desktop/vendor/touch.js +1 -458
  225. package/vendor/desktop/vendor/update.js +1 -704
  226. package/vendor/desktop/vendor/user-models.js +1 -381
@@ -1,55 +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
- * WHERE the CLI's shared modules are, with no side effects.
10
- *
11
- * This is `deps.js`'s path resolution split into its own module, and the split
12
- * is load-bearing rather than cosmetic. `deps.js` eagerly requires everything
13
- * it resolves — the engine, the tool registry, the client — so a module that
14
- * only needs to *locate* one shared file cannot require deps.js: doing so
15
- * from inside something deps.js itself requires would be a require cycle,
16
- * handing one side a half-built exports object at load time.
17
- *
18
- * So: paths here, code in deps.js.
19
- *
20
- * Two layouts must work, exactly as deps.js documents:
21
- *
22
- * in-repo <repo>/cli/src/sharedpaths.js -> <repo>/desktop/lib/local/...
23
- * npm <pkg>/src/sharedpaths.js -> <pkg>/vendor/desktop/lib/...
24
- *
25
- * Resolution is by existence, and a missing module is a loud error rather than
26
- * a silent fallback to a second copy: duplicate implementations are how the
27
- * desktop and the terminal would drift apart.
28
- */
29
-
30
- const fs = require('node:fs');
31
- const path = require('node:path');
32
-
33
- function roots() {
34
- const srcDir = __dirname; // <root>/cli/src
35
- const cliDir = path.join(srcDir, '..');
36
- return [
37
- path.join(srcDir, '..', '..'), // repo root (in-repo layout)
38
- path.join(cliDir, 'vendor'), // staged tree (published layout)
39
- ];
40
- }
41
-
42
- /** Resolve a repo-relative module path against whichever root has it. */
43
- function resolveShared(relPath) {
44
- for (const root of roots()) {
45
- const candidate = path.join(root, relPath);
46
- if (fs.existsSync(candidate)) return candidate;
47
- }
48
- throw new Error(
49
- `aegiscode: cannot find ${relPath}. Expected it beside cli/ (in the repo) or ` +
50
- 'under cli/vendor/ (installed package). Reinstall the package, or run ' +
51
- '`node scripts/predist.mjs` from cli/ if this is a source checkout.'
52
- );
53
- }
54
-
55
- module.exports = { roots, resolveShared };
3
+ "use strict";const fs=require("node:fs"),path=require("node:path");function roots(){const e=__dirname,o=path.join(e,"..");return[path.join(e,"..",".."),path.join(o,"vendor")]}function resolveShared(e){for(const o of roots()){const r=path.join(o,e);if(fs.existsSync(r))return r}throw new Error(`aegiscode: cannot find ${e}. Expected it beside cli/ (in the repo) or under cli/vendor/ (installed package). Reinstall the package, or run \`node scripts/predist.mjs\` from cli/ if this is a source checkout.`)}module.exports={roots:roots,resolveShared:resolveShared};
@@ -1,158 +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
- /**
7
- * The one place the CLI tells a user where to get an account key.
8
- *
9
- * Every prompt used to say "free at https://aegiscloud.org" — the marketing
10
- * homepage. No registration panel, no route to the page that shows the key,
11
- * and (because the landing URL carried no UTM) no way for aegis1 to tell the
12
- * signup came from the CLI at all. That is a round trip the user has to
13
- * complete unaided, at the exact moment they have already decided to keep the
14
- * tool: the prompts were the top of the funnel and they dead-ended.
15
- *
16
- * So the prompt now prints a short, typeable deep link instead:
17
- *
18
- * https://aegiscloud.org/key?s=cli&c=key_screen
19
- *
20
- * `/key` is a real aegis1 route (app.py `key_short_link`) that expands —
21
- * server-side — into the register panel plus the key page, with the channel
22
- * UTMs attached. Two consequences worth knowing before editing anything here:
23
- *
24
- * - `s=cli` must stay in aegis1's SIGNUP_SOURCES or the signup is filed as
25
- * 'direct' and this channel looks dead in the funnel. `s` is deliberately
26
- * not caller-supplied: one wrong value silently zeroes the channel.
27
- * - the URL is displayed, not just linked, so it has to stay short enough
28
- * not to wrap in an 80-column terminal. That is the whole reason the
29
- * expansion is a server-side redirect rather than a long query string: the
30
- * full form is 108 chars and shears across lines.
31
- *
32
- * `campaign` is the prompt that printed the link, so prompts can be compared
33
- * against each other instead of reported as one number. Unknown or absent
34
- * campaigns are simply not sent — unattributed is a missing datapoint, never a
35
- * wrong one.
36
- */
37
-
38
- const SIGNUP_ORIGIN = 'https://aegiscloud.org';
39
-
40
- /** The short aegis1 route that expands to "register, then show me my key". */
41
- const SIGNUP_PATH = '/key';
42
-
43
- /** The channel every CLI signup is filed under in aegis1 (SIGNUP_SOURCES). */
44
- const SIGNUP_SOURCE = 'cli';
45
-
46
- /** Bare `https://aegiscloud.org` for copy about the project rather than the
47
- * key — the docs/troubleshooting links in system.js want the homepage. */
48
- const HOME_URL = SIGNUP_ORIGIN;
49
-
50
- /** Longest campaign slug aegis1 will record (`_sanitize_signup_slug`). */
51
- const CAMPAIGN_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/;
52
-
53
- /**
54
- * The deep link to show a user who has no key.
55
- *
56
- * A campaign that would not survive aegis1's slug sanitiser is dropped rather
57
- * than sent: a link that records nothing is honest, a link that records the
58
- * wrong prompt is not.
59
- */
60
- function signupUrl(campaign) {
61
- const url = new URL(SIGNUP_ORIGIN + SIGNUP_PATH);
62
- url.searchParams.set('s', SIGNUP_SOURCE);
63
- const slug = campaign === undefined || campaign === null ? '' : String(campaign).trim().toLowerCase();
64
- if (CAMPAIGN_RE.test(slug)) url.searchParams.set('c', slug);
65
- return url.toString();
66
- }
67
-
68
- /**
69
- * Any other aegiscloud.org page the CLI links to, tagged with the same
70
- * channel so the visit is attributable if it ends in a signup.
71
- *
72
- * aegis1's first-touch hook stores the UTMs on whichever page the visitor
73
- * lands on, so a tagged link to the desktop page or the subscribe page is
74
- * enough for the signup it eventually produces to be credited to the CLI —
75
- * no separate route needed, unlike the key link above.
76
- */
77
- function link(path, campaign) {
78
- const url = new URL(SIGNUP_ORIGIN + (String(path).startsWith('/') ? path : `/${path}`));
79
- url.searchParams.set('utm_source', SIGNUP_SOURCE);
80
- url.searchParams.set('utm_medium', 'app');
81
- const slug = campaign === undefined || campaign === null ? '' : String(campaign).trim().toLowerCase();
82
- if (CAMPAIGN_RE.test(slug)) url.searchParams.set('utm_campaign', slug);
83
- return url.toString();
84
- }
85
-
86
- /**
87
- * The printed form of the same link: scheme-less.
88
- *
89
- * Not cosmetic, and not a second URL — it is `signupUrl()` with the `https://`
90
- * stripped, so the host, the route and the channel still come from one place.
91
- * It exists because the welcome screen's connect row wraps its text at
92
- * `cols - 4 - indent` (screens.js `wrapped()`), which is 75 cells at 80
93
- * columns, and the row's copy already spends 45 of them:
94
- *
95
- * AEGIS Desktop: same engine on your machine — <url>
96
- *
97
- * https://aegiscloud.org/key?s=cli -> 77 cells, wraps
98
- * aegiscloud.org/key?s=cli -> 69 cells, fits
99
- *
100
- * A wrapped row is not just ugly there: the welcome screen fills 23 of an
101
- * 80x24 terminal's 24 rows, so the extra line pushes the footer hint off the
102
- * bottom (test/cli-onboarding.test.mjs measures it). Given that, the scheme is
103
- * the cheapest thing to lose — a browser prepends it when the user pastes, and
104
- * `aegiscloud.org/teleport` is already printed this way in commands.js — while
105
- * `s=cli` is not, because dropping that files the signup as 'direct'.
106
- *
107
- * Screens with room for the real thing (the key screen puts the link on its
108
- * own row) must use `signupUrl()`.
109
- */
110
- function signupDisplayUrl(campaign) {
111
- return signupUrl(campaign).replace(/^https?:\/\//, '');
112
- }
113
-
114
- /** aegis1's paid-prompt indirection: `/go/<page>` (app.py `GO_TARGETS`). */
115
- const GO_PATH = '/go/';
116
-
117
- /**
118
- * A paid prompt's destination, in the short form `/go/<page>` documents.
119
- *
120
- * Deliberately NOT `link()`, and this is the whole reason the function exists.
121
- * `link()` appends the wire names (`utm_source`/`utm_campaign`) because
122
- * aegis1's first-touch hook reads those off whichever page the visitor lands
123
- * on. `/go/<page>` is not that kind of link: it is a redirect, and it reads the
124
- * short names (`s`/`c`) and re-emits the wire names itself.
125
- *
126
- * Sending wire names to `/go/` does not fail loudly. It fails silently, in the
127
- * worst available way — the route finds no `s`, files the click as 'direct',
128
- * drops the campaign, and the client that sent it reads as zero conversions
129
- * while the link still visibly works. Measured against a real app instance:
130
- *
131
- * /go/upgrade?s=cli&c=memory_quota -> ?utm_source=cli&utm_campaign=memory_quota
132
- * /go/upgrade?utm_source=cli&... -> ?utm_source=direct&utm_medium=app
133
- *
134
- * The route now also accepts the wire names as a fallback, so that mistake can
135
- * no longer zero a channel — but the short form is still what to send, and not
136
- * only for correctness: it is ~40 cells shorter, on rows that `padLine()`
137
- * truncates rather than wraps (see `signupDisplayUrl()` above).
138
- */
139
- function goUrl(page, campaign) {
140
- const slug = String(page == null ? '' : page).trim().toLowerCase().replace(/^\/+|\/+$/g, '');
141
- const url = new URL(SIGNUP_ORIGIN + GO_PATH + slug);
142
- url.searchParams.set('s', SIGNUP_SOURCE);
143
- const c = campaign === undefined || campaign === null ? '' : String(campaign).trim().toLowerCase();
144
- if (CAMPAIGN_RE.test(c)) url.searchParams.set('c', c);
145
- return url.toString();
146
- }
147
-
148
- module.exports = {
149
- signupUrl,
150
- signupDisplayUrl,
151
- goUrl,
152
- link,
153
- HOME_URL,
154
- SIGNUP_SOURCE,
155
- SIGNUP_PATH,
156
- SIGNUP_ORIGIN,
157
- CAMPAIGN_RE,
158
- };
3
+ const SIGNUP_ORIGIN="https://aegiscloud.org",SIGNUP_PATH="/key",SIGNUP_SOURCE="cli",HOME_URL=SIGNUP_ORIGIN,CAMPAIGN_RE=/^[a-z0-9][a-z0-9_-]{0,63}$/;function signupUrl(t){const s=new URL(SIGNUP_ORIGIN+SIGNUP_PATH);s.searchParams.set("s",SIGNUP_SOURCE);const r=null==t?"":String(t).trim().toLowerCase();return CAMPAIGN_RE.test(r)&&s.searchParams.set("c",r),s.toString()}function link(t,s){const r=new URL(SIGNUP_ORIGIN+(String(t).startsWith("/")?t:`/${t}`));r.searchParams.set("utm_source",SIGNUP_SOURCE),r.searchParams.set("utm_medium","app");const n=null==s?"":String(s).trim().toLowerCase();return CAMPAIGN_RE.test(n)&&r.searchParams.set("utm_campaign",n),r.toString()}function signupDisplayUrl(t){return signupUrl(t).replace(/^https?:\/\//,"")}const GO_PATH="/go/";function goUrl(t,s){const r=String(null==t?"":t).trim().toLowerCase().replace(/^\/+|\/+$/g,""),n=new URL(SIGNUP_ORIGIN+"/go/"+r);n.searchParams.set("s",SIGNUP_SOURCE);const e=null==s?"":String(s).trim().toLowerCase();return CAMPAIGN_RE.test(e)&&n.searchParams.set("c",e),n.toString()}module.exports={signupUrl:signupUrl,signupDisplayUrl:signupDisplayUrl,goUrl:goUrl,link:link,HOME_URL:HOME_URL,SIGNUP_SOURCE:SIGNUP_SOURCE,SIGNUP_PATH:SIGNUP_PATH,SIGNUP_ORIGIN:SIGNUP_ORIGIN,CAMPAIGN_RE:CAMPAIGN_RE};
@@ -1,97 +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
- * Transcript summarization for /compact and /recap.
10
- *
11
- * Dependency-free port of the upstream engine reference. The reference
12
- * spawns `claude -p "Summarize…"` (via `resolveExecutable()` in
13
- * client/platform.js — the shared module this repo actually ships, staged into
14
- * cli/vendor/client/platform.js); here the
15
- * backend is *injected* instead, so this module pulls in nothing but tokens.js:
16
- *
17
- * async summarizeTranscript(transcript, { callModel, model, signal } = {})
18
- * async recapLine(transcript, { callModel, model, signal } = {})
19
- *
20
- * `callModel(prompt) -> string` (async) is the caller's own model seam. When
21
- * `callModel` is not a function the module falls back to a purely local
22
- * extraction — the first user text, the last assistant text and the turn count
23
- * — and never throws. On abort (signal.aborted) it resolves null so handlers
24
- * can report "cancelled"; on any other backend failure it resolves the local
25
- * extraction.
26
- */
27
-
28
- const { estimateTokens } = require('./tokens.js');
29
-
30
- // Guard: don't push more than this many chars into a prompt.
31
- const MAX_INPUT_CHARS = 120_000;
32
- const MAX_REPLY_CHARS = 2_000;
33
-
34
- function extractiveSummary(transcript) {
35
- const users = transcript.filter((m) => m.role === 'user').map((m) => m.text || '');
36
- const lastAsst = [...transcript].reverse().find((m) => m.role === 'assistant');
37
- const topics = users.slice(0, 3).map((t) => `“${t.length > 48 ? t.slice(0, 45) + '…' : t}”`);
38
- const parts = [];
39
- if (users.length) parts.push(`Covered ${users.length} prompt${users.length > 1 ? 's' : ''}: ${topics.join('; ')}.`);
40
- if (lastAsst) {
41
- const tail = (lastAsst.text || '').split(/\s+/).slice(0, 30).join(' ');
42
- parts.push(`Last reply began: ${tail.length > 100 ? tail.slice(0, 97) + '…' : tail}`);
43
- }
44
- if (!parts.length) return 'Session with no exchanges yet.';
45
- return parts.join(' ');
46
- }
47
-
48
- function demoSummary(transcript) {
49
- return `[demo summary] ${extractiveSummary(transcript)}`;
50
- }
51
-
52
- /** Summarize the whole transcript in a few sentences. Resolves null on abort. */
53
- async function summarizeTranscript(transcript, { callModel, model, signal } = {}) {
54
- if (!transcript || !transcript.length) return 'Session with no exchanges yet.';
55
- if (typeof callModel !== 'function') return demoSummary(transcript);
56
- return callBackend('summarize', transcript, model, signal, callModel, () => demoSummary(transcript));
57
- }
58
-
59
- /** A single-line recap. Resolves null on abort. */
60
- async function recapLine(transcript, { callModel, model, signal } = {}) {
61
- if (!transcript || !transcript.length) return 'No exchanges yet.';
62
- if (typeof callModel !== 'function') return `[demo recap] ${extractiveSummary(transcript)}`;
63
- return callBackend('recap', transcript, model, signal, callModel, () => `[demo recap] ${extractiveSummary(transcript)}`);
64
- }
65
-
66
- async function callBackend(kind, transcript, model, signal, callModel, fallback) {
67
- const text = transcriptToText(transcript).slice(0, MAX_INPUT_CHARS);
68
- // NB: the ternary binds exactly as in the reference — the recap branch does
69
- // not append the transcript text. Ported verbatim.
70
- const prompt = kind === 'recap'
71
- ? 'Recap the following conversation in one sentence. Be factual and specific.'
72
- : 'Summarize the following conversation. Preserve every requirement, decision, and open question, in 2-4 sentences.'
73
- + '\n\n' + text;
74
-
75
- try {
76
- if (signal && signal.aborted) return null;
77
- const out = await callModel(prompt, { model, signal });
78
- if (signal && signal.aborted) return null;
79
- if (typeof out === 'string' && out.trim()) return out.trim().slice(0, MAX_REPLY_CHARS);
80
- return fallback();
81
- } catch {
82
- return fallback();
83
- }
84
- }
85
-
86
- function transcriptToText(transcript) {
87
- return transcript
88
- .filter((m) => m.role === 'user' || m.role === 'assistant' || m.role === 'note')
89
- .map((m) => `${m.role}: ${m.text || ''}`)
90
- .join('\n\n');
91
- }
92
-
93
- module.exports = {
94
- summarizeTranscript,
95
- recapLine,
96
- estimateTokens,
97
- };
3
+ "use strict";const{estimateTokens:estimateTokens}=require("./tokens.js"),MAX_INPUT_CHARS=12e4,MAX_REPLY_CHARS=2e3;function extractiveSummary(e){const n=e.filter((e=>"user"===e.role)).map((e=>e.text||"")),t=[...e].reverse().find((e=>"assistant"===e.role)),r=n.slice(0,3).map((e=>`“${e.length>48?e.slice(0,45)+"…":e}”`)),i=[];if(n.length&&i.push(`Covered ${n.length} prompt${n.length>1?"s":""}: ${r.join("; ")}.`),t){const e=(t.text||"").split(/\s+/).slice(0,30).join(" ");i.push(`Last reply began: ${e.length>100?e.slice(0,97)+"…":e}`)}return i.length?i.join(" "):"Session with no exchanges yet."}function demoSummary(e){return`[demo summary] ${extractiveSummary(e)}`}async function summarizeTranscript(e,{callModel:n,model:t,signal:r}={}){return e&&e.length?"function"!=typeof n?demoSummary(e):callBackend("summarize",e,t,r,n,(()=>demoSummary(e))):"Session with no exchanges yet."}async function recapLine(e,{callModel:n,model:t,signal:r}={}){return e&&e.length?"function"!=typeof n?`[demo recap] ${extractiveSummary(e)}`:callBackend("recap",e,t,r,n,(()=>`[demo recap] ${extractiveSummary(e)}`)):"No exchanges yet."}async function callBackend(e,n,t,r,i,s){const a=transcriptToText(n).slice(0,MAX_INPUT_CHARS),o="recap"===e?"Recap the following conversation in one sentence. Be factual and specific.":"Summarize the following conversation. Preserve every requirement, decision, and open question, in 2-4 sentences.\n\n"+a;try{if(r&&r.aborted)return null;const e=await i(o,{model:t,signal:r});return r&&r.aborted?null:"string"==typeof e&&e.trim()?e.trim().slice(0,MAX_REPLY_CHARS):s()}catch{return s()}}function transcriptToText(e){return e.filter((e=>"user"===e.role||"assistant"===e.role||"note"===e.role)).map((e=>`${e.role}: ${e.text||""}`)).join("\n\n")}module.exports={summarizeTranscript:summarizeTranscript,recapLine:recapLine,estimateTokens:estimateTokens};