aegisone 1.0.5 → 1.0.8
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/README.md +2 -2
- package/bin/aegis.js +28 -3
- package/package.json +1 -1
- package/scripts/predist.mjs +230 -0
- package/src/permissions.js +134 -7
- package/src/release.js +14 -5
- package/vendor/cli/README.md +42 -3
- package/vendor/cli/bin/aegiscode.js +15 -3
- package/vendor/cli/package.json +1 -1
- package/vendor/cli/src/app.js +167 -37
- package/vendor/cli/src/chatflow.js +285 -39
- package/vendor/cli/src/commands.js +251 -30
- package/vendor/cli/src/config.js +41 -11
- package/vendor/cli/src/engine.js +33 -4
- package/vendor/cli/src/entitlement.js +30 -1
- package/vendor/cli/src/format.js +175 -3
- package/vendor/cli/src/overlays.js +13 -9
- package/vendor/cli/src/panels.js +19 -6
- package/vendor/cli/src/render.js +49 -14
- package/vendor/cli/src/screen.js +12 -1
- package/vendor/cli/src/screens.js +118 -25
- package/vendor/cli/src/todos.js +7 -4
- package/vendor/cli/src/tokens.js +31 -1
- package/vendor/cli/vendor/client/aegis.js +22 -0
- package/vendor/cli/vendor/client/byok-catalog.js +43 -8
- package/vendor/cli/vendor/client/user-models.js +378 -0
- package/vendor/cli/vendor/desktop/lib/local/autonomous.js +81 -0
- package/vendor/cli/vendor/desktop/lib/local/engine.js +447 -14
- package/vendor/cli/vendor/desktop/renderer/usage.js +274 -21
- package/vendor/cli/vendor/mcp/tools.js +1 -1
- package/vendor/desktop/README.md +11 -0
- package/vendor/desktop/lib/deep-link.js +35 -1
- package/vendor/desktop/lib/local/autonomous.js +81 -0
- package/vendor/desktop/lib/local/engine.js +447 -14
- package/vendor/desktop/main.js +271 -6
- package/vendor/desktop/package.json +1 -1
- package/vendor/desktop/preload.js +18 -0
- package/vendor/desktop/renderer/app.js +631 -43
- package/vendor/desktop/renderer/index.html +4 -5
- package/vendor/desktop/renderer/stream-policy.js +24 -2
- package/vendor/desktop/renderer/style.css +81 -7
- package/vendor/desktop/renderer/usage.js +274 -21
- package/vendor/desktop/vendor/aegis.js +22 -0
- package/vendor/desktop/vendor/byok-catalog.js +43 -8
- package/vendor/desktop/vendor/user-models.js +378 -0
package/vendor/cli/src/format.js
CHANGED
|
@@ -33,8 +33,180 @@ function fmtEurSigned(n) {
|
|
|
33
33
|
return `${v < 0 ? '-' : '+'}${fmtEur(Math.abs(v))}`;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* The per-turn token figure the accounting rows report: `312 tokens` — the
|
|
38
|
+
* OUTPUT half only.
|
|
39
|
+
*
|
|
40
|
+
* The input half is gone deliberately, not by omission. It is the prompt
|
|
41
|
+
* restated, on a cached turn it is the larger number by an order of magnitude,
|
|
42
|
+
* and it is the one figure in the row nobody can act on: you change what a turn
|
|
43
|
+
* costs by changing what it PRODUCES, while the input count grows on its own as
|
|
44
|
+
* the session does. Both meta rows printed it, so the same turn showed
|
|
45
|
+
* `156,189 tok · 151,175 in · 5,014 tokens` and read as a runaway — the eye landed
|
|
46
|
+
* on 151,175, which is the prompt, not the spend. The rows now report what the
|
|
47
|
+
* turn produced. `/cost` still carries the full miss/hit breakdown for anyone
|
|
48
|
+
* who wants it: that is a panel you open, not a line painted under every
|
|
49
|
+
* answer.
|
|
50
|
+
*
|
|
51
|
+
* The labels remain part of the job — both rows once printed the bare pair
|
|
52
|
+
* `1,250/312` in one colour, and an unlabelled figure only states what it
|
|
53
|
+
* measures to a reader who already knows the convention.
|
|
54
|
+
*
|
|
55
|
+
* The wording lives here, not in the two renderers that call it, because those
|
|
56
|
+
* two are documented as never drifting apart and this is the only part of the
|
|
57
|
+
* row they both spell out identically.
|
|
58
|
+
*
|
|
59
|
+
* Returns `null` when the output is not a number, so a caller falls back to the
|
|
60
|
+
* total it does have rather than print a figure it never measured — an absent
|
|
61
|
+
* half is omitted rather than rendered as `0`, because `0 tokens` states a figure
|
|
62
|
+
* the provider never reported and this codebase refuses that shape elsewhere:
|
|
63
|
+
* `fmtRoll` will not put `0 tokens` on a meter that never took a reading, for the
|
|
64
|
+
* same reason.
|
|
65
|
+
*
|
|
66
|
+
* The name is left over from when this returned both halves: it is re-exported
|
|
67
|
+
* to the desktop's renderer, and a rename for a wording change would be a
|
|
68
|
+
* compatibility break for nothing.
|
|
69
|
+
*
|
|
70
|
+
* @param {object} [usage] flat `{ input, output }`, or an object carrying them
|
|
71
|
+
* @returns {{output: string}|null}
|
|
72
|
+
*/
|
|
73
|
+
function fmtUsageSplit(usage) {
|
|
74
|
+
const src = usage && typeof usage === 'object' ? usage : {};
|
|
75
|
+
if (!Number.isFinite(src.output)) return null;
|
|
76
|
+
return { output: `${fmtTokens(src.output || 0)} tokens` };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The OUTPUT half of a usage record, or `null` — never the wire's total.
|
|
81
|
+
*
|
|
82
|
+
* The twin of `desktop/renderer/usage.js`'s `displayTokens`, and here for the
|
|
83
|
+
* reason that file states at length: the row under a turn reports what the turn
|
|
84
|
+
* PRODUCED. `tokens` is input + output, and on a cached or long-context turn the
|
|
85
|
+
* prompt restated is the larger half — falling back to it printed `3,145 tokens`
|
|
86
|
+
* for a turn that wrote 145, which is the input half back on the screen with no
|
|
87
|
+
* label. Both CLI renderers (`renderMeta` in render.js, `metaBits` in
|
|
88
|
+
* chatflow.js) used to do exactly that once `output` was missing, and it was the
|
|
89
|
+
* last surviving place the input half reached a row: the split had been dropped,
|
|
90
|
+
* and the total they fell back to still carried it.
|
|
91
|
+
*
|
|
92
|
+
* `null` rather than `0` when no output figure arrived — `0 tokens` states a
|
|
93
|
+
* figure no provider sent, the rule `fmtUsageSplit` and `fmtRoll` already hold.
|
|
94
|
+
* A turn the wire priced but did not itemise has no output figure, and inventing
|
|
95
|
+
* one from the total would be a number that provider never sent.
|
|
96
|
+
*
|
|
97
|
+
* @param {object} [source] flat `{output}`, or a record carrying `tokens:{output}`
|
|
98
|
+
* @returns {number|null}
|
|
99
|
+
*/
|
|
100
|
+
function displayTokens(source) {
|
|
101
|
+
const src = source && typeof source === 'object' ? source : {};
|
|
102
|
+
const nested = src.tokens && typeof src.tokens === 'object' ? src.tokens : null;
|
|
103
|
+
const candidates = [src.output];
|
|
104
|
+
if (nested) candidates.push(nested.output, nested.output_tokens, nested.completion_tokens);
|
|
105
|
+
else candidates.push(src.output_tokens, src.completion_tokens);
|
|
106
|
+
for (const c of candidates) {
|
|
107
|
+
if (typeof c === 'number' && isFinite(c) && c > 0) return c;
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The account's tier, as the host last read it off the server. Held here
|
|
114
|
+
* because the RENDERERS need it and they run synchronously, on a path that
|
|
115
|
+
* cannot await a probe: `cli/src/entitlement.js` publishes every reading it
|
|
116
|
+
* takes (`noteTier`), and the money rule below spends it.
|
|
117
|
+
*/
|
|
118
|
+
let tierSnapshot = null;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Publish the entitlement snapshot for the renderers. Called by the host's
|
|
122
|
+
* entitlement gate on every `current()`/`refresh()`, so the waiver rule and the
|
|
123
|
+
* gate the host enforces can never read two different tiers.
|
|
124
|
+
*/
|
|
125
|
+
function noteTier(entitlement) {
|
|
126
|
+
tierSnapshot = entitlement && typeof entitlement === 'object' ? entitlement : null;
|
|
127
|
+
return tierSnapshot;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* True when this account's tier means AEGIS bills no per-turn fee, so no money
|
|
132
|
+
* figure belongs on a turn row or a session total.
|
|
133
|
+
*
|
|
134
|
+
* The CLI's half of the desktop's rule (`desktop/renderer/usage.js`), and it is
|
|
135
|
+
* the same rule deliberately: the two hosts render the same turn from the same
|
|
136
|
+
* engine, so a row that shows a fee on one and waives it on the other is a
|
|
137
|
+
* disagreement about what the user owes. The desktop had this gate and the CLI
|
|
138
|
+
* did not, which is why a trial account saw `€0.0031` under every answer here
|
|
139
|
+
* and no money there.
|
|
140
|
+
*
|
|
141
|
+
* The fee is the BYOK handling fee, waived by aegis1 on Unlimited — and the tier
|
|
142
|
+
* a 30-day welcome trial grants IS Unlimited (`subscriptions` row), so a trial
|
|
143
|
+
* account resolves here exactly like a paying one. Matching is on the resolved
|
|
144
|
+
* tier rather than `pro`, and a funded bank on a free plan is NOT waived: that
|
|
145
|
+
* account pays from its bank, and hiding the number would leave it with no meter
|
|
146
|
+
* for the only money it spends.
|
|
147
|
+
*
|
|
148
|
+
* @param {{tier?: string|null, plan?: string|null, planRaw?: string|null,
|
|
149
|
+
* subscription?: string|null, item?: string|null, sku?: string|null,
|
|
150
|
+
* unlimited?: boolean}} [entitlement] the snapshot to read; omitted, the last
|
|
151
|
+
* one the host published (see `noteTier`).
|
|
152
|
+
* @returns {boolean}
|
|
153
|
+
*/
|
|
154
|
+
function feeWaived(entitlement) {
|
|
155
|
+
const ent = entitlement === undefined ? tierSnapshot : entitlement;
|
|
156
|
+
if (!ent || typeof ent !== 'object') return false;
|
|
157
|
+
if (ent.unlimited === true) return true;
|
|
158
|
+
const named = [
|
|
159
|
+
ent.tier,
|
|
160
|
+
ent.plan,
|
|
161
|
+
ent.planRaw,
|
|
162
|
+
ent.subscription,
|
|
163
|
+
ent.subscriptionTier,
|
|
164
|
+
ent.product,
|
|
165
|
+
ent.item,
|
|
166
|
+
ent.sku,
|
|
167
|
+
]
|
|
168
|
+
.filter((v) => typeof v === 'string')
|
|
169
|
+
.map((v) => v.trim().toLowerCase());
|
|
170
|
+
if (named.some((v) => v === 'unlimited' || v === 'trial')) return true;
|
|
171
|
+
// A tier string that merely CONTAINS the word — `unlimited_trial`,
|
|
172
|
+
// `plan.unlimited` — so a server that decorates the name cannot put the fee
|
|
173
|
+
// back on an account whose tier is Unlimited.
|
|
174
|
+
return named.some((v) => /(^|[^a-z])unlimited([^a-z]|$)/.test(v));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Whether a money figure belongs on this account's turn row or session total.
|
|
179
|
+
*
|
|
180
|
+
* A price is printed UNLESS AEGIS either waives it or has not proven it owed:
|
|
181
|
+
*
|
|
182
|
+
* - a tier AEGIS waives (`feeWaived`) → no price. Unlimited, paid or on the
|
|
183
|
+
* 30-day welcome trial, has no per-turn charge and no bank draw;
|
|
184
|
+
* - a snapshot that asserts a plan it cannot prove (`degraded`, i.e. the
|
|
185
|
+
* entitlement module's unresolved placeholder, whose `plan` reads `free`
|
|
186
|
+
* before any probe has answered) → no price. That placeholder says "no
|
|
187
|
+
* verdict yet", not "this account is free", and reading it as a verdict is
|
|
188
|
+
* what put `€0.0031` under a trial account's answers before its probe had
|
|
189
|
+
* replied — a fee charged in writing to the one account that does not pay it;
|
|
190
|
+
* - everything else → the price stands, including when NOTHING was claimed at
|
|
191
|
+
* all. A cost figure is a measurement of the turn, and silently dropping a
|
|
192
|
+
* real number because no tier was published would leave a BYO-key or offline
|
|
193
|
+
* run with no meter for money it actually spent.
|
|
194
|
+
*
|
|
195
|
+
* The token figure is never gated by this, on any branch: what a turn produced
|
|
196
|
+
* is not a price, and hiding it would leave an Unlimited account with no meter.
|
|
197
|
+
*
|
|
198
|
+
* @param {{tier?: string|null, plan?: string|null, planRaw?: string|null,
|
|
199
|
+
* degraded?: boolean, source?: string|null, unlimited?: boolean}} [entitlement]
|
|
200
|
+
* @returns {boolean}
|
|
201
|
+
*/
|
|
202
|
+
function feeBillable(entitlement) {
|
|
203
|
+
const ent = entitlement === undefined ? tierSnapshot : entitlement;
|
|
204
|
+
if (!ent || typeof ent !== 'object') return true;
|
|
205
|
+
if (feeWaived(ent)) return false;
|
|
206
|
+
return ent.degraded !== true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** Compact duration: 850 -> "0.9s", 65000 -> "1m05s". */function fmtElapsed(ms) {
|
|
38
210
|
const s = Math.max(0, Number(ms) || 0) / 1000;
|
|
39
211
|
if (s < 10) return `${s.toFixed(1)}s`;
|
|
40
212
|
if (s < 60) return `${Math.round(s)}s`;
|
|
@@ -81,4 +253,4 @@ function shortCwd() {
|
|
|
81
253
|
return cwdName(process.cwd());
|
|
82
254
|
}
|
|
83
255
|
|
|
84
|
-
module.exports = { fmtTokens, fmtEur, fmtEurSigned, fmtElapsed, maskKey, pathName, cwdName, shortCwd };
|
|
256
|
+
module.exports = { fmtTokens, fmtEur, fmtEurSigned, fmtElapsed, fmtUsageSplit, displayTokens, feeWaived, feeBillable, noteTier, maskKey, pathName, cwdName, shortCwd };
|
|
@@ -215,23 +215,29 @@ function renderModelPicker(models, sel = 0, width = 80, height = 24, current = n
|
|
|
215
215
|
|
|
216
216
|
// ── Effort picker overlay (/effort) ──────────────────────────────────────────
|
|
217
217
|
|
|
218
|
+
// The three rungs, in the order the picker draws them. `High` is the default
|
|
219
|
+
// (config.js seeds `effort: 'high'`, and engine.js/desktop/renderer both resolve
|
|
220
|
+
// an unknown rung to high), so the list is exactly the levels that can be in
|
|
221
|
+
// force — there is no fourth "auto" row any more. "auto" was not a level: it
|
|
222
|
+
// meant "send no rung", and because it was the default, a fresh install sent no
|
|
223
|
+
// effort at all and the knob did nothing until it was set by hand.
|
|
218
224
|
const EFFORT_LEVELS = [
|
|
219
|
-
{ label: 'Auto', value: null, note: 'Sized per turn from the ask (default)' },
|
|
220
225
|
{ label: 'Low', note: 'Fastest, cheapest budget' },
|
|
221
226
|
{ label: 'Medium', note: 'Balanced' },
|
|
222
|
-
{ label: 'High', note: 'Highest budget, slowest' },
|
|
227
|
+
{ label: 'High', note: 'Highest budget, slowest (default)' },
|
|
223
228
|
];
|
|
224
229
|
|
|
225
230
|
// The picker's order reduced to the values a selection means, so the row a user
|
|
226
231
|
// picks and the value the session stores can never come from two different
|
|
227
232
|
// lists (commands.js validates against this, chatflow.js resolves the overlay
|
|
228
|
-
// through it).
|
|
233
|
+
// through it).
|
|
229
234
|
const EFFORT_VALUES = EFFORT_LEVELS.map((lv) => (lv.value === undefined ? lv.label.toLowerCase() : lv.value));
|
|
230
235
|
|
|
231
236
|
/**
|
|
232
237
|
* @param {number} sel selected index
|
|
233
238
|
* @param {number} width
|
|
234
|
-
* @param {string|null} current the currently-selected effort level (null =
|
|
239
|
+
* @param {string|null} current the currently-selected effort level (null = the
|
|
240
|
+
* high default, which is what the engine applies)
|
|
235
241
|
* @param {Array} [levels] override the level table
|
|
236
242
|
*/
|
|
237
243
|
function renderEffortPicker(sel = 0, width = 80, current = null, levels = EFFORT_LEVELS) {
|
|
@@ -243,11 +249,9 @@ function renderEffortPicker(sel = 0, width = 80, current = null, levels = EFFORT
|
|
|
243
249
|
for (let i = 0; i < levels.length; i++) {
|
|
244
250
|
const lv = levels[i];
|
|
245
251
|
const active = i === sel;
|
|
246
|
-
// `current == null` is
|
|
247
|
-
//
|
|
248
|
-
const cur = current
|
|
249
|
-
? lv.value === null
|
|
250
|
-
: String(current).toLowerCase() === String(lv.label).toLowerCase();
|
|
252
|
+
// `current == null` means no rung is stored, which is the high default the
|
|
253
|
+
// engine resolves — so the check mark lands on High rather than on nothing.
|
|
254
|
+
const cur = String(current || 'high').toLowerCase() === String(lv.label).toLowerCase();
|
|
251
255
|
const left = active ? span(C.lavender, GLYPH.cursor) : span('', ' ');
|
|
252
256
|
const nameSpan = active ? span(C.lavender, lv.label) : span(C.white, lv.label);
|
|
253
257
|
const mark = cur ? span(C.green, ' ' + GLYPH.check) : span('', '');
|
package/vendor/cli/src/panels.js
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* renderSessionsOverlay buildPermissions buildModelList buildRewindList
|
|
27
27
|
* buildOnboarding buildShellCompletion buildTerminalSetup buildPRs
|
|
28
28
|
* buildBenchmark buildWaifu buildAegisStatus buildAegisRecall buildAegisMulti
|
|
29
|
-
* buildBilling buildMemory buildMemoryTiers buildRouter
|
|
29
|
+
* buildBilling buildMemory buildMemoryTiers buildRouter buildAutomode buildSkills
|
|
30
30
|
* buildMcp buildHooksStatus buildHooksList buildTroubleshooting
|
|
31
31
|
* buildReleaseNotes
|
|
32
32
|
* (plus the pure reference helpers with no missing capability)
|
|
@@ -279,7 +279,7 @@ function buildStatus(state, ctx = {}) {
|
|
|
279
279
|
add('Model', s.model);
|
|
280
280
|
// `null` = auto: the pool sizes each turn from the ask, so the row says so
|
|
281
281
|
// rather than vanishing (add() skips empty values).
|
|
282
|
-
add('Effort', s.effort || '
|
|
282
|
+
add('Effort', s.effort || 'high');
|
|
283
283
|
if (s.thinking != null) add('Thinking', s.thinking ? 'on' : 'off');
|
|
284
284
|
if (s.stream != null) add('Streaming', s.stream === false ? 'off' : 'on');
|
|
285
285
|
if (s.vim != null) add('Vim keymap', s.vim ? 'on' : 'off');
|
|
@@ -1263,20 +1263,32 @@ function buildMemoryEmbeddings(status, stats, ctx = {}) {
|
|
|
1263
1263
|
return lines;
|
|
1264
1264
|
}
|
|
1265
1265
|
|
|
1266
|
-
// ── /
|
|
1266
|
+
// ── /automode ────────────────────────────────────────────────────────────────
|
|
1267
|
+
//
|
|
1268
|
+
// This mode is called "automode" here, the same word the engine repo
|
|
1269
|
+
// (aegiscodex-dev) uses for its ← -on-an-empty-input mode: one name for one
|
|
1270
|
+
// idea across the two faces. `/yolo` remains a working ALIAS — it is what the
|
|
1271
|
+
// desktop switch, the persisted posture and every existing install's muscle
|
|
1272
|
+
// memory say, so dropping it would break the command for people who typed it
|
|
1273
|
+
// yesterday — but nothing user-facing is *labelled* YOLO any more.
|
|
1267
1274
|
|
|
1268
|
-
function
|
|
1275
|
+
function buildAutomode(state, ctx = {}) {
|
|
1269
1276
|
const t = themeOf(ctx);
|
|
1270
1277
|
const lines = [];
|
|
1271
|
-
lines.push([span(t.gold + BOLD, '⚠
|
|
1278
|
+
lines.push([span(t.gold + BOLD, '⚠ automode enabled'), span(BOLD_OFF, '')]);
|
|
1272
1279
|
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
1273
1280
|
lines.push([span(t.white, 'All tool executions are auto-approved: file writes,')]);
|
|
1274
1281
|
lines.push([span(t.white, 'bash commands, and network requests run without asking.')]);
|
|
1275
1282
|
lines.push([span('', '')]);
|
|
1276
|
-
lines.push([span(t.gray, 'Run /
|
|
1283
|
+
lines.push([span(t.gray, 'Run /automode off to restore confirmations.')]);
|
|
1284
|
+
lines.push([span(t.gray, '(/yolo is accepted as an alias.)')]);
|
|
1277
1285
|
return lines;
|
|
1278
1286
|
}
|
|
1279
1287
|
|
|
1288
|
+
// The pre-rename name, kept as an export so vendored copies and the panels
|
|
1289
|
+
// test's export list cannot break on the rename. Same function object.
|
|
1290
|
+
const buildYolo = buildAutomode;
|
|
1291
|
+
|
|
1280
1292
|
// ── /release-notes ───────────────────────────────────────────────────────────
|
|
1281
1293
|
|
|
1282
1294
|
/**
|
|
@@ -1381,6 +1393,7 @@ module.exports = {
|
|
|
1381
1393
|
buildMemory,
|
|
1382
1394
|
buildMemoryTiers,
|
|
1383
1395
|
buildRouter,
|
|
1396
|
+
buildAutomode,
|
|
1384
1397
|
buildYolo,
|
|
1385
1398
|
buildSkills,
|
|
1386
1399
|
buildMcp,
|
package/vendor/cli/src/render.js
CHANGED
|
@@ -33,7 +33,7 @@ const {
|
|
|
33
33
|
} = require('./theme.js');
|
|
34
34
|
const { WELCOME_TITLE, WELCOME_BACK, TAGLINE, STAR, stencilGlyph, welcomeArtParts } = require('./art.js');
|
|
35
35
|
const { w, pad, padStart, wrapBlock, clip, span } = require('./screen.js');
|
|
36
|
-
const { fmtTokens, fmtEur, fmtElapsed } = require('./format.js');
|
|
36
|
+
const { fmtTokens, fmtEur, fmtElapsed, fmtUsageSplit, displayTokens, feeBillable } = require('./format.js');
|
|
37
37
|
const { renderDiffBlock } = require('./diffview.js');
|
|
38
38
|
|
|
39
39
|
// Guarded: a concurrent workstream owns ./markdown.js.
|
|
@@ -262,16 +262,23 @@ function renderTurn(ctx, turn, width = 80) {
|
|
|
262
262
|
const body = assistantLines(ctx, text, Math.max(8, width - 2));
|
|
263
263
|
if (!body.length) body.push('');
|
|
264
264
|
body[0] = `${t.white}${GLYPH.block}${RESET} ` + body[0];
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
|
|
265
|
+
// No trailing cursor, deliberately — the twin of the rule in chatflow.js's
|
|
266
|
+
// `rowLines`. Appending one to the last line only when the message ran past
|
|
267
|
+
// one row made the glyph count depend on the text's WRAP (`● Working` at one
|
|
268
|
+
// line, `● Working●` at two), so the extra dot appeared on exactly the long
|
|
269
|
+
// answers a reader is likeliest to look at. The head marker is the answer's
|
|
270
|
+
// gutter, not half of a bracket, and it is the same glyph the finished row
|
|
271
|
+
// keeps — the live turn is the working line's job to advertise.
|
|
268
272
|
lines.push(...body);
|
|
269
273
|
} else if (role === 'tool') {
|
|
270
274
|
// turn.ok is only known once the call has actually run (the agent loop's
|
|
271
275
|
// tool-activity event fires after execution); undefined means "no result
|
|
272
276
|
// yet to report" (the plain registry-tool path, which never set it).
|
|
273
277
|
const status = turn.ok === undefined ? '' : turn.ok ? ` ${t.green}${GLYPH.check}${RESET}` : ` ${t.red}${errMark()}${RESET}`;
|
|
274
|
-
|
|
278
|
+
// A tool row is a running command, not a bullet in a list — it carries no
|
|
279
|
+
// leading `●` mark. Only the assistant's answer keeps that marker (see the
|
|
280
|
+
// role branch above), so the two row kinds no longer look interchangeable.
|
|
281
|
+
lines.push(`${t.gray}${turn.label || 'tool'}${RESET}${status}`);
|
|
275
282
|
const args =
|
|
276
283
|
turn.args == null
|
|
277
284
|
? ''
|
|
@@ -303,24 +310,52 @@ function renderTurn(ctx, turn, width = 80) {
|
|
|
303
310
|
}
|
|
304
311
|
|
|
305
312
|
/**
|
|
306
|
-
* The per-turn accounting line —
|
|
307
|
-
* row style, e.g. `⎿
|
|
313
|
+
* The per-turn accounting line — what the turn produced beside what it cost, in
|
|
314
|
+
* the `⎿` hook row style, e.g. `⎿ 312 out · €0.0007 · 4.2s`. The figure is
|
|
315
|
+
* labelled and is the OUTPUT half alone (see `fmtUsageSplit`).
|
|
308
316
|
*/
|
|
309
317
|
function renderMeta(ctx, meta = {}, width = 80) {
|
|
310
318
|
const t = themeOf(ctx);
|
|
311
319
|
const bits = [];
|
|
312
320
|
if (meta.model) bits.push(`${t.blue}${meta.model}${RESET}`);
|
|
313
|
-
|
|
314
|
-
// The producer (chatflow.js's accounting row) pushes the split flat, as
|
|
321
|
+
// The producer (chatflow.js's accounting row) pushes the pair flat, as
|
|
315
322
|
// `input`/`output` — reading it as `meta.usage.input` here meant the pair was
|
|
316
323
|
// never printed on this path even though the docstring above promises it.
|
|
317
324
|
// Both shapes are accepted: `usage` is what the desktop's renderer hands over.
|
|
318
325
|
const split = meta.usage && typeof meta.usage === 'object' ? meta.usage : meta;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
326
|
+
// The row's token figure is what the turn PRODUCED, and it is the only one it
|
|
327
|
+
// prints: labelled `tokens`, in this theme's strongest token — the figure the row
|
|
328
|
+
// exists to report. The input half is gone deliberately, not by omission. It
|
|
329
|
+
// is the prompt restated, on a cached turn it is the larger number by an order
|
|
330
|
+
// of magnitude, and it is the one figure in the row nobody can act on: you
|
|
331
|
+
// change what a turn costs by changing what it PRODUCES. Leading with it made
|
|
332
|
+
// the row read as a runaway (`156,189 tok · 151,175 in · 5,014 tokens`) while
|
|
333
|
+
// saying nothing about the answer. Its one remaining reader is `/cost`, which
|
|
334
|
+
// carries the full miss/hit breakdown — a panel you open, not a line painted
|
|
335
|
+
// under every answer.
|
|
336
|
+
//
|
|
337
|
+
// This is the twin of chatflow.js's accounting row (see `metaBits`): the two
|
|
338
|
+
// render the same row through different plumbing, so they state the same
|
|
339
|
+
// figure. The total does NOT stand in when no output figure arrived: `tokens`
|
|
340
|
+
// is input + output, so the fallback that used to sit here printed a turn's
|
|
341
|
+
// prompt back at it under an unlabelled figure — the exact reading this row
|
|
342
|
+
// exists to remove, and the one the desktop already refuses in
|
|
343
|
+
// `displayTokens` (desktop/renderer/usage.js). An unmeasurable output leaves
|
|
344
|
+
// the figure off rather than stating a total, and `0 tokens` is refused for the
|
|
345
|
+
// reason `fmtRoll` refuses `0 tokens`: it states a figure the provider never
|
|
346
|
+
// reported.
|
|
347
|
+
const parts = fmtUsageSplit(split);
|
|
348
|
+
if (parts) bits.push(`${t.white}${parts.output}${RESET}`);
|
|
349
|
+
else {
|
|
350
|
+
const produced = displayTokens(split);
|
|
351
|
+
if (produced != null) bits.push(`${t.white}${fmtTokens(produced)} tokens${RESET}`);
|
|
322
352
|
}
|
|
323
|
-
|
|
353
|
+
// No money on a tier AEGIS bills no fee to, and none from a snapshot that has
|
|
354
|
+
// not proven a fee is owed — the desktop's rule, and now this host's too
|
|
355
|
+
// (`feeBillable`). The token figure above stays either way: what the turn
|
|
356
|
+
// produced is not a price, and hiding it would leave an Unlimited account with
|
|
357
|
+
// no meter at all.
|
|
358
|
+
if (meta.eur != null && feeBillable()) bits.push(`${meta.eur > 0 ? t.coral : t.green}${fmtEur(meta.eur)}${RESET}`);
|
|
324
359
|
if (meta.ms != null) bits.push(`${t.gray}${fmtElapsed(meta.ms)}${RESET}`);
|
|
325
360
|
if (meta.calls > 1) bits.push(`${t.gray}${meta.calls} calls${RESET}`);
|
|
326
361
|
if (!bits.length) return '';
|
|
@@ -337,7 +372,7 @@ function renderStatus(ctx, state = {}, width = 80) {
|
|
|
337
372
|
const t = themeOf(ctx);
|
|
338
373
|
const left = ['aegis'];
|
|
339
374
|
if (state.model) left.push(state.model);
|
|
340
|
-
if (state.tokens != null) left.push(`${fmtTokens(state.tokens)}
|
|
375
|
+
if (state.tokens != null) left.push(`${fmtTokens(state.tokens)} tokens`);
|
|
341
376
|
if (state.spend != null) left.push(fmtEur(state.spend));
|
|
342
377
|
if (state.mode) left.push(state.mode);
|
|
343
378
|
|
package/vendor/cli/src/screen.js
CHANGED
|
@@ -444,7 +444,18 @@ class LiveRegion {
|
|
|
444
444
|
// Back to the first row of the old block, rewrite, clear the tail.
|
|
445
445
|
this.out.write(ESC.col(1) + ESC.up(this.rows) + body + '\n' + ESC.col(1) + ESC.up(1));
|
|
446
446
|
}
|
|
447
|
-
|
|
447
|
+
// The PHYSICAL terminal rows the block just occupies, not the number of
|
|
448
|
+
// logical lines passed in. A working line (render.js's `renderWorking`,
|
|
449
|
+
// the only caller with a long verb + elapsed + token tail) can exceed the
|
|
450
|
+
// terminal width and wrap to two rows on anything narrower than ~65
|
|
451
|
+
// columns; recording `lines.length` (always 1) left the next tick's
|
|
452
|
+
// `up(this.rows)` one row short, so the wrapped second row was never
|
|
453
|
+
// erased. Since the line's content (elapsed time, token count) changes
|
|
454
|
+
// every 90ms tick, that stray row renewed itself every tick — a
|
|
455
|
+
// vertically growing stack of near-duplicate status lines while the
|
|
456
|
+
// model streamed, instead of one line updating in place.
|
|
457
|
+
const cols = Math.max(1, getSize().cols);
|
|
458
|
+
this.rows = lines.reduce((n, l) => n + Math.max(1, Math.ceil(w(l) / cols)), 0);
|
|
448
459
|
}
|
|
449
460
|
|
|
450
461
|
/** Erase the block and return the cursor to its start, so the caller can
|
|
@@ -91,7 +91,15 @@ const WHATS_NEW = [
|
|
|
91
91
|
* the Tips/What's-new pair already come to 21 of the 23 usable rows, so a
|
|
92
92
|
* boxed third panel (three rows minimum, two of them rules) would push the
|
|
93
93
|
* footer hint off the bottom of the commonest terminal there is. Two rows fit
|
|
94
|
-
* exactly
|
|
94
|
+
* exactly: one route row, and the desktop line under it.
|
|
95
|
+
*
|
|
96
|
+
* WHICH route row is the part that matters, and it is composed by
|
|
97
|
+
* `connectRows()` below rather than being a constant, because the two routes
|
|
98
|
+
* have separate gates. They used to share a single one that short-circuited on
|
|
99
|
+
* the account key, so the `/byok-key` row disappeared the moment a user
|
|
100
|
+
* redeemed an AEGIS key — see `byokRouteNeeded()`. Holding the block to two
|
|
101
|
+
* rows is why the both-owed case merges the routes into one row again: at
|
|
102
|
+
* 80×24 a third row is the footer hint.
|
|
95
103
|
*
|
|
96
104
|
* Both commands named here are real registry entries — `/byok-key` saves a
|
|
97
105
|
* provider key, `/key` saves the AEGIS account key — and the URL is the shared
|
|
@@ -100,20 +108,65 @@ const WHATS_NEW = [
|
|
|
100
108
|
* which the bare `aegiscloud.org` this row used to print did not. Nothing here
|
|
101
109
|
* is a URL or a command that only exists in this comment.
|
|
102
110
|
*/
|
|
103
|
-
const
|
|
111
|
+
const CONNECT_BYOK = [
|
|
112
|
+
'Your own provider key: /byok-key <provider> — works with your AEGIS key',
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
// The AEGIS Cloud route. The URL in the desktop row below is the shared signup
|
|
116
|
+
// deep link from signup.js, not a hand-written one: it lands on the register
|
|
117
|
+
// panel with the key page queued behind it and the channel attached, which the
|
|
118
|
+
// bare `aegiscloud.org` that row used to print did not.
|
|
119
|
+
//
|
|
120
|
+
// The scheme-less form, and this is the only link in the CLI that uses it. The
|
|
121
|
+
// row's copy spends 45 of the 75 cells `wrapped()` allows at 80 columns
|
|
122
|
+
// (cols - 4 - indent), so `https://aegiscloud.org/key?s=cli` makes the row 77
|
|
123
|
+
// and wraps — a line the 80x24 screen does not have, because the connect
|
|
124
|
+
// block sits on row 21 of 23 and the row it pushes out is the footer hint.
|
|
125
|
+
// `s=cli` is the parameter that files the signup, so it is the scheme that
|
|
126
|
+
// goes, not the channel: see signup.js `signupDisplayUrl()`. Editing this copy
|
|
127
|
+
// means re-measuring; test/cli-onboarding.test.mjs fails on the row count if
|
|
128
|
+
// the row grows past the budget, and names the row that caused it.
|
|
129
|
+
const CONNECT_CLOUD = [
|
|
130
|
+
'AEGIS Cloud, one account key: /key — no provider signup',
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
// Both routes still owed (a fresh install): one row naming both, the original
|
|
134
|
+
// copy. Two rows is the whole budget, so this is not a third line — see the
|
|
135
|
+
// block comment above.
|
|
136
|
+
const CONNECT_BOTH = [
|
|
104
137
|
'Your key, your bill: /byok-key <provider> — or AEGIS Cloud, /key',
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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.
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
const CONNECT_DESKTOP = [
|
|
114
141
|
`AEGIS Desktop: same engine on your machine — ${signupDisplayUrl()}`,
|
|
115
142
|
];
|
|
116
143
|
|
|
144
|
+
/**
|
|
145
|
+
* The connect rows to draw, in order, for the machine as it stands now.
|
|
146
|
+
*
|
|
147
|
+
* `[]` means nothing to say — both routes are configured — and the caller then
|
|
148
|
+
* draws no block at all. Otherwise: one route row (both-owed merges into a
|
|
149
|
+
* single row, the 80×24 budget above, and the desktop pointer always shares
|
|
150
|
+
* the block with it).
|
|
151
|
+
*
|
|
152
|
+
* The gates are independent on purpose. An AEGIS key does not cancel the
|
|
153
|
+
* `/byok-key` row and a provider route does not cancel the `/key` row: the two
|
|
154
|
+
* are not alternatives, they are two ways in, and the row a user has already
|
|
155
|
+
* taken is the only one that may be dropped.
|
|
156
|
+
*/
|
|
157
|
+
function connectRows() {
|
|
158
|
+
const rows = [];
|
|
159
|
+
const byok = byokRouteNeeded();
|
|
160
|
+
const cloud = cloudRouteNeeded();
|
|
161
|
+
if (byok && cloud) rows.push(...CONNECT_BOTH);
|
|
162
|
+
else if (byok) rows.push(...CONNECT_BYOK);
|
|
163
|
+
else if (cloud) rows.push(...CONNECT_CLOUD);
|
|
164
|
+
// The desktop pointer is not a route, so it is not gated on one: whenever the
|
|
165
|
+
// block is drawn at all, the "why would I want the app" answer is in it.
|
|
166
|
+
if (rows.length) rows.push(...CONNECT_DESKTOP);
|
|
167
|
+
return rows;
|
|
168
|
+
}
|
|
169
|
+
|
|
117
170
|
/** Centre a plain string, returning one span line. Clip first, or a string
|
|
118
171
|
* wider than the terminal produces a row that wraps and shears the frame. */
|
|
119
172
|
function centered(text, cols, style) {
|
|
@@ -354,13 +407,14 @@ function welcomeLines(ctx, cols, rows, firstRun = true) {
|
|
|
354
407
|
|
|
355
408
|
lines.push(...boxes(t, cols, rows - lines.length - 4));
|
|
356
409
|
lines.push([span('', '')]);
|
|
357
|
-
// The connect block, before the footer hint
|
|
358
|
-
//
|
|
359
|
-
//
|
|
360
|
-
//
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
410
|
+
// The connect block, before the footer hint. The rows are composed by
|
|
411
|
+
// `connectRows()` — the two routes gate SEPARATELY, so an AEGIS-key holder
|
|
412
|
+
// with no provider route of their own is still told `/byok-key` exists,
|
|
413
|
+
// which is the whole point: holding an account key is not a reason to hide
|
|
414
|
+
// the bring-your-own-key route. `wrapped` splits rather than clips, so a
|
|
415
|
+
// narrow terminal gets short rows instead of sheared ones; the height budget
|
|
416
|
+
// is unaffected at 80×24, where each row still fits on one line.
|
|
417
|
+
for (const text of connectRows()) lines.push(...wrapped(text, cols, t.white, 1));
|
|
364
418
|
lines.push([span(t.gray, GLYPH.hint), span(t.white, ' Try "write a test for <filepath>"')]);
|
|
365
419
|
while (lines.length < rows - 1) lines.push([span('', '')]);
|
|
366
420
|
return lines;
|
|
@@ -492,12 +546,14 @@ function providerRouteConfigured() {
|
|
|
492
546
|
}
|
|
493
547
|
|
|
494
548
|
/**
|
|
495
|
-
* Whether the
|
|
549
|
+
* Whether ANY part of the connect block is still owed to this machine.
|
|
496
550
|
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
551
|
+
* It is the OR of the two route gates, and it is deliberately not the thing
|
|
552
|
+
* `welcomeLines` branches on any more: the rows are composed one at a time by
|
|
553
|
+
* `connectRows()`, so a machine that holds an AEGIS account key and no
|
|
554
|
+
* provider route still gets the `/byok-key` row. This helper is the coarse
|
|
555
|
+
* question ("is there anything left to say") — a caller that wants the rows
|
|
556
|
+
* should ask `connectRows()` instead.
|
|
501
557
|
*
|
|
502
558
|
* A read that fails (no credentials file, an unreadable one) resolves to
|
|
503
559
|
* "show it": the block is exactly what a user with no key needs, and a
|
|
@@ -506,7 +562,38 @@ function providerRouteConfigured() {
|
|
|
506
562
|
*/
|
|
507
563
|
function connectNeeded() {
|
|
508
564
|
try {
|
|
509
|
-
|
|
565
|
+
return byokRouteNeeded() || cloudRouteNeeded();
|
|
566
|
+
} catch {
|
|
567
|
+
return true;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* The two halves of the connect block, gated SEPARATELY — this is the fix.
|
|
573
|
+
*
|
|
574
|
+
* They used to share one gate that short-circuited on the account key, so a
|
|
575
|
+
* user who redeemed an AEGIS key was never told BYOK exists at all: the row
|
|
576
|
+
* naming `/byok-key` was retired at the exact moment they had an account and
|
|
577
|
+
* were most likely to want a provider route of their own (unlimited/no relay
|
|
578
|
+
* billing, a model the pool does not carry). An account key and a provider
|
|
579
|
+
* route are not alternatives — `/byok-key` works alongside one — so the BYOK
|
|
580
|
+
* row is now gated on the BYOK route alone and an AEGIS-key holder still
|
|
581
|
+
* reads it. The Cloud row keeps the old account-key gate, because that is the
|
|
582
|
+
* thing it pitches.
|
|
583
|
+
*
|
|
584
|
+
* Both reads fail toward SHOWING the row: a failed status read must never be
|
|
585
|
+
* the reason a new install is told nothing about how to start.
|
|
586
|
+
*/
|
|
587
|
+
function byokRouteNeeded() {
|
|
588
|
+
try {
|
|
589
|
+
return !providerRouteConfigured();
|
|
590
|
+
} catch {
|
|
591
|
+
return true;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function cloudRouteNeeded() {
|
|
596
|
+
try {
|
|
510
597
|
return !credentials.keyStatus().configured;
|
|
511
598
|
} catch {
|
|
512
599
|
return true;
|
|
@@ -754,8 +841,14 @@ module.exports = {
|
|
|
754
841
|
PRODUCT,
|
|
755
842
|
TIPS,
|
|
756
843
|
WHATS_NEW,
|
|
757
|
-
|
|
844
|
+
CONNECT_BYOK,
|
|
845
|
+
CONNECT_CLOUD,
|
|
846
|
+
CONNECT_BOTH,
|
|
847
|
+
CONNECT_DESKTOP,
|
|
848
|
+
connectRows,
|
|
758
849
|
connectNeeded,
|
|
850
|
+
byokRouteNeeded,
|
|
851
|
+
cloudRouteNeeded,
|
|
759
852
|
providerRouteConfigured,
|
|
760
853
|
trustLines,
|
|
761
854
|
themePickerLines,
|
package/vendor/cli/src/todos.js
CHANGED
|
@@ -29,6 +29,7 @@ const fs = require('node:fs');
|
|
|
29
29
|
const path = require('node:path');
|
|
30
30
|
|
|
31
31
|
const { aegisDir } = require('./config.js');
|
|
32
|
+
const { writePrivateFile } = require('./securefs.js');
|
|
32
33
|
|
|
33
34
|
function todosFile() {
|
|
34
35
|
return path.join(aegisDir(), 'todos.json');
|
|
@@ -53,10 +54,12 @@ function writeTodos(list) {
|
|
|
53
54
|
.filter((t) => t && typeof t.text === 'string' && t.text.trim())
|
|
54
55
|
.map((t) => ({ text: t.text.trim(), done: t.done === true, at: t.at || new Date().toISOString() }));
|
|
55
56
|
try {
|
|
56
|
-
fs.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
// Through securefs, not `fs.writeFileSync`: todos.json lives in the data
|
|
58
|
+
// dir, so the raw write gave it umask mode (0664 — world-readable in a
|
|
59
|
+
// 0775 dir) and followed a symlink planted there. The temp-file + rename
|
|
60
|
+
// shape the old code spelled out by hand is what `writePrivateFile` does,
|
|
61
|
+
// plus 0600/0700 and O_NOFOLLOW.
|
|
62
|
+
writePrivateFile(todosFile(), `${JSON.stringify(clean, null, 2)}\n`);
|
|
60
63
|
} catch {
|
|
61
64
|
/* best-effort, like every other store in this host */
|
|
62
65
|
}
|