aegiscode 6.8.35 → 6.8.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/bin/aegiscode.js +15 -3
- package/package.json +1 -1
- package/src/app.js +113 -36
- package/src/chatflow.js +285 -39
- package/src/commands.js +79 -29
- package/src/config.js +41 -11
- package/src/engine.js +33 -4
- package/src/entitlement.js +30 -1
- package/src/format.js +175 -3
- package/src/overlays.js +13 -9
- package/src/panels.js +19 -6
- package/src/render.js +49 -14
- package/src/screen.js +12 -1
- package/src/screens.js +118 -25
- package/src/todos.js +7 -4
- package/src/tokens.js +31 -1
- package/vendor/desktop/lib/local/engine.js +113 -2
- package/vendor/desktop/renderer/usage.js +206 -20
- package/vendor/mcp/tools.js +1 -1
package/src/overlays.js
CHANGED
|
@@ -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/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/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/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
|
package/src/screens.js
CHANGED
|
@@ -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/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
|
}
|
package/src/tokens.js
CHANGED
|
@@ -32,7 +32,7 @@ const path = require('node:path');
|
|
|
32
32
|
const { resolveShared } = require('./sharedpaths.js');
|
|
33
33
|
const shared = require(resolveShared(path.join('desktop', 'renderer', 'usage.js')));
|
|
34
34
|
|
|
35
|
-
const { RATES, RATE_BASIS, UNPRICED_BY_DESIGN, isPeak, ratesFor, costBreakdown, cacheHitRate } = shared;
|
|
35
|
+
const { RATES, RATE_BASIS, UNPRICED_BY_DESIGN, isPeak, ratesFor, costBreakdown, cacheHitRate, usageBuckets } = shared;
|
|
36
36
|
|
|
37
37
|
// System prompt + tool definitions overhead, roughly, in tokens.
|
|
38
38
|
const SYSTEM_TOKENS = 18000;
|
|
@@ -94,6 +94,28 @@ function estimateTokens(text) {
|
|
|
94
94
|
return Math.max(1, Math.ceil([...String(text)].length / 4));
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* The same 4:1 rule, from a streamed LENGTH rather than from the text.
|
|
99
|
+
*
|
|
100
|
+
* The live tails count what has arrived as a display width, because they are
|
|
101
|
+
* painted from a counter on a timer rather than from a string — see app.js
|
|
102
|
+
* (`chars += w(chunk.delta)`) and chatflow.js (`streamedChars += w(delta)`).
|
|
103
|
+
* Both sites then label that number `tokens`, so the count form of the
|
|
104
|
+
* heuristic has to live beside the text form. Without it the two producers fed
|
|
105
|
+
* their raw cell count straight into `fmtTokens(...) tokens`, which printed the
|
|
106
|
+
* character count as a token count — the live spinner read ~4x high, and high
|
|
107
|
+
* against every settled figure for the same turn (the desktop meter included),
|
|
108
|
+
* which is exactly the "tokens spent" gap against the reference engine.
|
|
109
|
+
*
|
|
110
|
+
* Returns 0 for an empty stream so a caller can tell "nothing yet" from "some",
|
|
111
|
+
* rather than `estimateTokens`'s floor of 1.
|
|
112
|
+
*/
|
|
113
|
+
function estimateTokensFromCells(cells) {
|
|
114
|
+
const n = Number(cells);
|
|
115
|
+
if (!(n > 0)) return 0;
|
|
116
|
+
return Math.ceil(n / 4);
|
|
117
|
+
}
|
|
118
|
+
|
|
97
119
|
/**
|
|
98
120
|
* Bucket the transcript's token usage.
|
|
99
121
|
* input — user prompts + system + tools (per exchange)
|
|
@@ -220,7 +242,15 @@ module.exports = {
|
|
|
220
242
|
ratesFor,
|
|
221
243
|
costBreakdown,
|
|
222
244
|
cacheHitRate,
|
|
245
|
+
// Re-exported so a caller that only needs the bucket shape (the per-turn
|
|
246
|
+
// in/out readout in chatflow.js and app.js) does not have to reach past this
|
|
247
|
+
// module into the desktop bundle itself — and, more importantly, so it has
|
|
248
|
+
// exactly ONE way to read a usage object rather than a hand-rolled
|
|
249
|
+
// `input_tokens ?? prompt_tokens`, which is how the two hosts came to
|
|
250
|
+
// disagree about the same turn's prompt size in the first place.
|
|
251
|
+
usageBuckets,
|
|
223
252
|
estimateTokens,
|
|
253
|
+
estimateTokensFromCells,
|
|
224
254
|
transcriptUsage,
|
|
225
255
|
usageCost,
|
|
226
256
|
sessionAccounting,
|