aegiscode 6.8.1 → 6.8.3
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.
- package/package.json +1 -1
- package/src/commands.js +18 -5
- package/src/panels.js +19 -2
- package/src/screens.js +72 -10
- package/src/signup.js +153 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "6.8.
|
|
4
|
+
"version": "6.8.3",
|
|
5
5
|
"description": "aegiscode — the command-line version of AEGIS Desktop. The shared tool surface in your shell, over the same thin transport and tool registry as the MCP plugin and the desktop app. Ships transport + UI only; no brain.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "AEGIS Code",
|
package/src/commands.js
CHANGED
|
@@ -57,6 +57,7 @@ const {
|
|
|
57
57
|
} = require('./config.js');
|
|
58
58
|
const { copyToClipboard } = require('./clipboard.js');
|
|
59
59
|
const { snapshotCheckpoint, listCheckpoints, loadCheckpoint } = require('./checkpoint.js');
|
|
60
|
+
const { signupUrl, goUrl } = require('./signup.js');
|
|
60
61
|
const screens = require('./screens.js');
|
|
61
62
|
const { summarizeTranscript, recapLine } = require('./summarize.js');
|
|
62
63
|
const { sessionAccounting, accountingFromUsage, estimateTokens } = require('./tokens.js');
|
|
@@ -258,7 +259,7 @@ function keyPanelLines(c, title = 'AEGIS account key') {
|
|
|
258
259
|
if (!st.configured) {
|
|
259
260
|
lines.push([span(C.gray, '')]);
|
|
260
261
|
lines.push([span(C.white, ' Set one with /key <api_key>, or press Enter on /key to paste it.')]);
|
|
261
|
-
lines.push([span(C.gray,
|
|
262
|
+
lines.push([span(C.gray, ` Free key: ${signupUrl('key_status')}`)]);
|
|
262
263
|
}
|
|
263
264
|
if (st.legacyPlaintext) {
|
|
264
265
|
lines.push([span(C.gray, '')]);
|
|
@@ -406,7 +407,15 @@ function memoryStatusLines(c) {
|
|
|
406
407
|
if (st.overQuota) {
|
|
407
408
|
rows.push([span(C.coral, ' writes: paused — the plan’s ceiling is reached, so new memory is not being stored')]);
|
|
408
409
|
rows.push([span(C.green, ' reads: still work — everything already stored stays readable (/aegis-recall <topic>)')]);
|
|
409
|
-
rows
|
|
410
|
+
// Two rows, not one. This was a single 92-cell line ending in
|
|
411
|
+
// "or /cloud memory off to stop trying", and panel rows go through
|
|
412
|
+
// `padLine()`, which TRUNCATES at `cols` instead of wrapping — so at 80
|
|
413
|
+
// columns the escape hatch was cut off the end and never rendered. The URL
|
|
414
|
+
// gets its own row for the same reason: it is the actionable half, and
|
|
415
|
+
// truncation is survivable in prose and fatal in a URL. The rows are 76 and
|
|
416
|
+
// 45 cells of 80, both asserted by test/cli-commands.test.mjs.
|
|
417
|
+
rows.push([span(C.gray, ` free room at ${goUrl('upgrade', 'cloud_quota')}`)]);
|
|
418
|
+
rows.push([span(C.gray, ' or /cloud memory off to stop trying')]);
|
|
410
419
|
}
|
|
411
420
|
if (gate.enabled && st.pending > 0) {
|
|
412
421
|
rows.push([span(C.gray, ` pending: ${st.pending} session(s) waiting to sync`)]);
|
|
@@ -843,7 +852,7 @@ const COMMANDS = [
|
|
|
843
852
|
: // The key travels in the environment only (client/aegis.js reads
|
|
844
853
|
// AEGIS_API_KEY); /login is an unavailable command here, so
|
|
845
854
|
// pointing at it would send the user to a refusal.
|
|
846
|
-
|
|
855
|
+
`No API key set, so the model catalog cannot be read — export AEGIS_API_KEY (free key: ${signupUrl('model_blocked')}), then retry /model.`);
|
|
847
856
|
c.render();
|
|
848
857
|
return true;
|
|
849
858
|
}
|
|
@@ -1151,7 +1160,7 @@ const COMMANDS = [
|
|
|
1151
1160
|
ks.configured,
|
|
1152
1161
|
ks.configured
|
|
1153
1162
|
? `${maskKey(ks.key)} via ${credentials.sourceLabel(ks.source)}`
|
|
1154
|
-
: `not set — ${credentials.HOW_TO_SET} (free
|
|
1163
|
+
: `not set — ${credentials.HOW_TO_SET} (free key: ${signupUrl('doctor')})`
|
|
1155
1164
|
);
|
|
1156
1165
|
ok('credentials', true, `${ks.path}${ks.fileMode ? ` (${ks.fileMode})` : ''}`);
|
|
1157
1166
|
ok('cloud memory', ks.memoryToken, ks.memoryToken ? 'token held' : 'no memory token — /cloud activate');
|
|
@@ -1710,7 +1719,11 @@ const COMMANDS = [
|
|
|
1710
1719
|
credentials.clearMemoryToken();
|
|
1711
1720
|
c.client.setApiKey(c.client.apiKey);
|
|
1712
1721
|
note(c, 'cloud memory token cleared locally — sync stops until /cloud activate re-issues one');
|
|
1713
|
-
|
|
1722
|
+
// The URL rides its own note: `note` rows are a single unwrapped span
|
|
1723
|
+
// (chatflow.js), so appending it to that sentence would push the tail
|
|
1724
|
+
// past `cols` where `padLine()` cuts it — and the tail is the URL.
|
|
1725
|
+
note(c, 'the account itself is still subscribed; manage the subscription here:');
|
|
1726
|
+
note(c, goUrl('upgrade', 'cloud_deactivate'));
|
|
1714
1727
|
c.render();
|
|
1715
1728
|
return true;
|
|
1716
1729
|
}
|
package/src/panels.js
CHANGED
|
@@ -41,6 +41,9 @@
|
|
|
41
41
|
|
|
42
42
|
const { span, getSize, lineWidth } = require('./screen.js');
|
|
43
43
|
const { themeOf, BOLD, BOLD_OFF, GLYPH } = require('./theme.js');
|
|
44
|
+
// Pure, like this module (signup.js requires nothing and does no I/O), so the
|
|
45
|
+
// "everything here is assertable from a plain Node test" contract still holds.
|
|
46
|
+
const { goUrl } = require('./signup.js');
|
|
44
47
|
|
|
45
48
|
const VERSION = require('../package.json').version;
|
|
46
49
|
|
|
@@ -178,8 +181,14 @@ function buildHelp(commands, ctx = {}) {
|
|
|
178
181
|
out.push([span(t.gray, 'No commands registered.')]);
|
|
179
182
|
}
|
|
180
183
|
out.push([span('', '')]);
|
|
184
|
+
// 71 cells, and it has to stay under 80. This row was 81: the label already
|
|
185
|
+
// reads "Shortcuts:", so `? shortcuts` repeated the word — which cost the 10
|
|
186
|
+
// cells that pushed it one over, and `padLine()` truncates to `cols` rather
|
|
187
|
+
// than wrapping, so on every 80-column terminal the row rendered as
|
|
188
|
+
// "Ctrl-D exi". Measured by test/cli-panels.test.mjs, which asserts every
|
|
189
|
+
// buildHelp row fits the terminal.
|
|
181
190
|
out.push([
|
|
182
|
-
span(t.gray, 'Shortcuts: '), span(t.white, '?'), span(t.gray, '
|
|
191
|
+
span(t.gray, 'Shortcuts: '), span(t.white, '?'), span(t.gray, ' · '),
|
|
183
192
|
span(t.white, '/help'), span(t.gray, ' commands · '), span(t.white, '↑↓'), span(t.gray, ' history · '),
|
|
184
193
|
span(t.white, 'Ctrl-L'), span(t.gray, ' clear · '), span(t.white, 'Ctrl-D'), span(t.gray, ' exit'),
|
|
185
194
|
]);
|
|
@@ -866,7 +875,15 @@ function buildBilling(state, ctx = {}) {
|
|
|
866
875
|
lines.push([span('', '')]);
|
|
867
876
|
lines.push([span(t.white, 'AEGIS pooled inference'), span(t.gray, ' metered against your token bank')]);
|
|
868
877
|
lines.push([span(t.gray, ' AEGIS has no subscription of its own — /cost shows this session\'s spend.')]);
|
|
869
|
-
|
|
878
|
+
// Was a literal `https://aegiscloud.org/billing`, which has never been a
|
|
879
|
+
// route on aegis1 — only `/billing/success` is real; the page is `/topup`.
|
|
880
|
+
// So the one row on the one screen that exists to convert a free user sent
|
|
881
|
+
// every user who reached it to a 404, and correcting a wrong path needed an
|
|
882
|
+
// npm release because it was compiled into the client. Now it points at
|
|
883
|
+
// `/go/topup`, a server-side indirection: the destination can change without
|
|
884
|
+
// a client release, and the click arrives tagged with the channel. 75 cells
|
|
885
|
+
// of 80 — measured, because `padLine()` truncates rather than wraps.
|
|
886
|
+
lines.push([span(t.gray, ` Top-ups and invoices: ${goUrl('topup', 'cost_screen')}`)]);
|
|
870
887
|
return lines;
|
|
871
888
|
}
|
|
872
889
|
|
package/src/screens.js
CHANGED
|
@@ -38,6 +38,8 @@ const render = require('./render.js');
|
|
|
38
38
|
const { updateConfig, configExists, loadConfig } = require('./config.js');
|
|
39
39
|
const { updateNotice, updateLine } = require('./update.js');
|
|
40
40
|
const credentials = require('./credentials.js');
|
|
41
|
+
const { signupUrl, signupDisplayUrl } = require('./signup.js');
|
|
42
|
+
const { createSettingsStore, isReservedNamespace } = require('./deps.js');
|
|
41
43
|
|
|
42
44
|
const VERSION = require('../package.json').version;
|
|
43
45
|
|
|
@@ -92,13 +94,24 @@ const WHATS_NEW = [
|
|
|
92
94
|
* exactly, one route each, and the desktop line shares the second.
|
|
93
95
|
*
|
|
94
96
|
* Both commands named here are real registry entries — `/byok-key` saves a
|
|
95
|
-
* provider key, `/key` saves the AEGIS account key — and the URL is the
|
|
96
|
-
*
|
|
97
|
-
*
|
|
97
|
+
* provider key, `/key` saves the AEGIS account key — and the URL is the shared
|
|
98
|
+
* signup deep link from signup.js, not a hand-written one: it lands on the
|
|
99
|
+
* register panel with the key page queued behind it and the channel attached,
|
|
100
|
+
* which the bare `aegiscloud.org` this row used to print did not. Nothing here
|
|
101
|
+
* is a URL or a command that only exists in this comment.
|
|
98
102
|
*/
|
|
99
103
|
const CONNECT = [
|
|
100
104
|
'Your key, your bill: /byok-key <provider> — or AEGIS Cloud, /key',
|
|
101
|
-
|
|
105
|
+
// The scheme-less form, and this is the only link in the CLI that uses it.
|
|
106
|
+
// The row's copy spends 45 of the 75 cells `wrapped()` allows at 80 columns
|
|
107
|
+
// (cols - 4 - indent), so `https://aegiscloud.org/key?s=cli` makes the row 77
|
|
108
|
+
// and wraps — a line the 80x24 screen does not have, because the connect
|
|
109
|
+
// block sits on row 21 of 23 and the row it pushes out is the footer hint.
|
|
110
|
+
// `s=cli` is the parameter that files the signup, so it is the scheme that
|
|
111
|
+
// goes, not the channel: see signup.js `signupDisplayUrl()`. Editing this copy
|
|
112
|
+
// means re-measuring; test/cli-onboarding.test.mjs fails on the row count if
|
|
113
|
+
// the row grows past the budget, and names the row that caused it.
|
|
114
|
+
`AEGIS Desktop: same engine on your machine — ${signupDisplayUrl()}`,
|
|
102
115
|
];
|
|
103
116
|
|
|
104
117
|
/** Centre a plain string, returning one span line. Clip first, or a string
|
|
@@ -442,12 +455,42 @@ function make(style, text) {
|
|
|
442
455
|
return sp;
|
|
443
456
|
}
|
|
444
457
|
|
|
458
|
+
/**
|
|
459
|
+
* Whether this machine holds a BYOK provider route of the user's own — the
|
|
460
|
+
* desktop host's `providerRouteConfigured()`, ported here because the CLI's
|
|
461
|
+
* `/byok-key <provider>` writes the exact same `byok:<provider>` row (see
|
|
462
|
+
* `engine.js`'s `byokNamespace`) into the exact same settings.json, and
|
|
463
|
+
* `connectNeeded()` below used to only ever check the AEGIS account key —
|
|
464
|
+
* so a CLI user who did BYOK and never touched the account key got the
|
|
465
|
+
* connect block re-pitched at them on every single launch.
|
|
466
|
+
*
|
|
467
|
+
* `settings.list()` goes through `get()`, which never puts a plaintext key on
|
|
468
|
+
* a row (only the `configured` boolean already derived from it) — that field
|
|
469
|
+
* is what a row counts on, not a `key` string that doesn't exist on it.
|
|
470
|
+
*
|
|
471
|
+
* Failure reads as "no configured route found", which keeps the block
|
|
472
|
+
* visible — same fail-toward-showing-it bias as the account-key read below.
|
|
473
|
+
*/
|
|
474
|
+
function providerRouteConfigured() {
|
|
475
|
+
try {
|
|
476
|
+
const store = createSettingsStore({ dir: credentials.aegisHome() });
|
|
477
|
+
return store.list().some((row) => {
|
|
478
|
+
if (!row || !row.provider || isReservedNamespace(row.provider)) return false;
|
|
479
|
+
const baseURL = typeof row.baseURL === 'string' ? row.baseURL.trim() : '';
|
|
480
|
+
return Boolean(row.configured || baseURL);
|
|
481
|
+
});
|
|
482
|
+
} catch {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
445
487
|
/**
|
|
446
488
|
* Whether the welcome screen should still pitch the two connect routes.
|
|
447
489
|
*
|
|
448
|
-
* Once an AEGIS account key is on this machine
|
|
449
|
-
* of them, and two rows repeating
|
|
450
|
-
* onboarding — the same rule the desktop
|
|
490
|
+
* Once an AEGIS account key is on this machine, or a BYOK provider route is
|
|
491
|
+
* configured, the user has already taken one of them, and two rows repeating
|
|
492
|
+
* what they just did is nagging, not onboarding — the same rule the desktop
|
|
493
|
+
* host applies to its welcome panel.
|
|
451
494
|
*
|
|
452
495
|
* A read that fails (no credentials file, an unreadable one) resolves to
|
|
453
496
|
* "show it": the block is exactly what a user with no key needs, and a
|
|
@@ -456,6 +499,7 @@ function make(style, text) {
|
|
|
456
499
|
*/
|
|
457
500
|
function connectNeeded() {
|
|
458
501
|
try {
|
|
502
|
+
if (providerRouteConfigured()) return false;
|
|
459
503
|
return !credentials.keyStatus().configured;
|
|
460
504
|
} catch {
|
|
461
505
|
return true;
|
|
@@ -482,7 +526,12 @@ async function showWelcome(ctx, firstRun = true) {
|
|
|
482
526
|
|
|
483
527
|
// ── the account key ──────────────────────────────────────────────────────────
|
|
484
528
|
|
|
485
|
-
|
|
529
|
+
// The key screen is the highest-intent moment in the CLI: the user pressed
|
|
530
|
+
// Enter on a bare /key, so they have already decided they want an account.
|
|
531
|
+
// The link is the short aegis1 deep link (see signup.js) — it lands on the
|
|
532
|
+
// register panel with the key page queued behind it, which is the round trip
|
|
533
|
+
// that used to be left to the user to figure out from the homepage.
|
|
534
|
+
const KEY_URL = signupUrl('key_screen');
|
|
486
535
|
|
|
487
536
|
/**
|
|
488
537
|
* The key screen's lines. Pure, so what the user is told is asserted directly.
|
|
@@ -498,13 +547,25 @@ function keyLines(ctx, cols, { value = '', error = null, verify = false } = {})
|
|
|
498
547
|
lines.push([span(t.white + BOLD, 'Connect your AEGIS account')]);
|
|
499
548
|
lines.push([span('', '')]);
|
|
500
549
|
for (const l of wrapped(
|
|
501
|
-
|
|
502
|
-
'
|
|
550
|
+
'Paste an API key to use AEGIS Cloud. It is stored in your user config ' +
|
|
551
|
+
'directory with owner-only permissions, so later launches and scripts ' +
|
|
552
|
+
'pick it up without an export.',
|
|
503
553
|
cols,
|
|
504
554
|
t.white
|
|
505
555
|
)) {
|
|
506
556
|
lines.push(l);
|
|
507
557
|
}
|
|
558
|
+
// The link gets its own row whenever it would otherwise run past the edge:
|
|
559
|
+
// a URL sheared across two lines is not typeable, and this is the one screen
|
|
560
|
+
// where the user has nothing to copy it out of.
|
|
561
|
+
lines.push([span('', '')]);
|
|
562
|
+
const invite = ' No key yet? Free one at ';
|
|
563
|
+
if (w(invite) + w(KEY_URL) + 2 <= cols) {
|
|
564
|
+
lines.push([span(t.white, invite), span(t.cyan, KEY_URL)]);
|
|
565
|
+
} else {
|
|
566
|
+
lines.push([span(t.white, ' No key yet? Free one:')]);
|
|
567
|
+
lines.push([span(t.cyan, ` ${KEY_URL}`)]);
|
|
568
|
+
}
|
|
508
569
|
lines.push([span('', '')]);
|
|
509
570
|
lines.push([
|
|
510
571
|
span(t.lavender, GLYPH.cursor),
|
|
@@ -688,6 +749,7 @@ module.exports = {
|
|
|
688
749
|
WHATS_NEW,
|
|
689
750
|
CONNECT,
|
|
690
751
|
connectNeeded,
|
|
752
|
+
providerRouteConfigured,
|
|
691
753
|
trustLines,
|
|
692
754
|
themePickerLines,
|
|
693
755
|
keyLines,
|
package/src/signup.js
ADDED
|
@@ -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
|
+
};
|