aegiscode 6.6.1 → 6.7.1
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 +46 -0
- package/bin/aegiscode.js +87 -0
- package/package.json +1 -1
- package/src/app.js +156 -11
- package/src/art.js +114 -60
- package/src/autonomous.js +8 -2
- package/src/caps.js +597 -0
- package/src/chatflow.js +59 -6
- package/src/cloudsync.js +86 -6
- package/src/commands.js +243 -23
- package/src/config.js +87 -0
- package/src/diff.js +330 -0
- package/src/diffview.js +286 -0
- package/src/events.js +21 -10
- package/src/panels.js +59 -1
- package/src/render.js +39 -17
- package/src/screen.js +20 -20
- package/src/theme.js +334 -125
- package/vendor/desktop/lib/local/autonomous.js +45 -4
- package/vendor/desktop/lib/local/engine.js +38 -0
- package/vendor/desktop/lib/local/queue.js +4 -0
- package/vendor/desktop/lib/local/session-rounds.js +19 -2
package/README.md
CHANGED
|
@@ -67,8 +67,53 @@ aegiscode "why is the sky blue" # one-shot, prints the answer and the tokens
|
|
|
67
67
|
aegiscode -p "..." --json # machine-readable
|
|
68
68
|
echo "q" | aegiscode -p - # prompt on stdin
|
|
69
69
|
aegiscode -m deepseek/deepseek-v4-flash -p "..." # pin a model
|
|
70
|
+
aegiscode --terminal # print the resolved terminal capabilities
|
|
71
|
+
aegiscode --ascii # force the ASCII mark (legacy consoles)
|
|
72
|
+
aegiscode --width 100 # pin the frame width
|
|
70
73
|
```
|
|
71
74
|
|
|
75
|
+
## One look on every terminal
|
|
76
|
+
|
|
77
|
+
The welcome screen, the palette and the glyph set are resolved from what the
|
|
78
|
+
terminal *can actually draw*, not from `process.platform`. PowerShell inside
|
|
79
|
+
Windows Terminal sets `WT_SESSION`/`TERM_PROGRAM`, so it renders the **same
|
|
80
|
+
byte-identical frame** as zsh: `unicode` mark, `native` star, 24-bit colour. The
|
|
81
|
+
host OS is only a fallback hint; the environment wins.
|
|
82
|
+
|
|
83
|
+
`cli/src/caps.js` resolves one capability object — mark (`unicode`/`ascii`), face
|
|
84
|
+
(`native`/`edges`), star (`native`/`narrow`), colour depth (24/8/4/0), control
|
|
85
|
+
(`ansi`/`plain`), size and EOL — and everything that draws goes through it.
|
|
86
|
+
`theme.js` builds its palettes and glyph table via `caps.rgb()`/`caps.bg()`, so a
|
|
87
|
+
16-colour console is painted in colours it has instead of literal escape text,
|
|
88
|
+
and `art.js` applies composable stencils (`ascii`, `edges`, `star`) rather than a
|
|
89
|
+
per-platform art table.
|
|
90
|
+
|
|
91
|
+
Only a **legacy** Windows console degrades — and it says why:
|
|
92
|
+
|
|
93
|
+
| host | mark | star | colour | reason |
|
|
94
|
+
| --- | --- | --- | --- | --- |
|
|
95
|
+
| win32 legacy conhost | `ascii` | `narrow` | 16 | Consolas has no block glyphs |
|
|
96
|
+
| win32 Windows Terminal | `unicode` | `native` | truecolor | Windows VT host (`WT_SESSION`) |
|
|
97
|
+
| Linux/macOS, zsh | `unicode` | `native` | truecolor | — |
|
|
98
|
+
| `TERM=dumb` | `ascii` | `narrow` | none | no control sequences |
|
|
99
|
+
|
|
100
|
+
The **star defaults to native on Windows VT.** `✦` appears eleven times in the
|
|
101
|
+
welcome art, so forcing it narrow there would *create* the divergence this is
|
|
102
|
+
meant to remove; ConPTY does font fallback single-width. `AEGIS_STAR=narrow`
|
|
103
|
+
is the escape hatch if a host proves otherwise.
|
|
104
|
+
|
|
105
|
+
Overrides, at launch — `--ascii`, `--unicode`, `--no-color`, `--color`,
|
|
106
|
+
`--width <cols>`, `--terminal` (print the report) — and in-session via
|
|
107
|
+
`/terminal ascii|unicode|color|no-color|star <native|narrow>|width <cols>|auto|status`.
|
|
108
|
+
`/terminal auto` re-probes rather than restoring launch flags. `/terminal width`
|
|
109
|
+
pins the frame, so resizes are ignored until `/terminal auto`; every other
|
|
110
|
+
`/terminal` switch leaves resize handling intact.
|
|
111
|
+
|
|
112
|
+
The same axes are settable by environment for scripts and CI: `AEGIS_ART`,
|
|
113
|
+
`AEGIS_ASCII`, `AEGIS_UNICODE`, `AEGIS_STAR`, `AEGIS_COLOR`, `AEGIS_VT`,
|
|
114
|
+
`AEGIS_WIDTH`, `AEGIS_WIDE_RUNES`. `NO_COLOR` is honoured to the letter —
|
|
115
|
+
"present and not an empty string, regardless of its value".
|
|
116
|
+
|
|
72
117
|
## First run
|
|
73
118
|
|
|
74
119
|
A genuine first run walks the reference's onboarding before the session starts —
|
|
@@ -307,6 +352,7 @@ node ../test/cli-commands.test.mjs # the full command table, aliases, dispatc
|
|
|
307
352
|
node ../test/cli-panels.test.mjs # every panel builder, defensive against missing data
|
|
308
353
|
node ../test/cli-support.test.mjs # config/history/tokens/agents/export/checkpoints
|
|
309
354
|
node ../test/cli-conformance.test.mjs # the design guard: palette, glyphs, art, verbs
|
|
355
|
+
node ../test/cli-terminal-caps.test.mjs # capability resolution: PowerShell and zsh agree
|
|
310
356
|
node ../test/cli-render.test.mjs # width safety, accounting, live region
|
|
311
357
|
node ../test/cli-overlays.test.mjs # the / palette, model + effort pickers, resume list
|
|
312
358
|
node ../test/cli-fuzzy.test.mjs # palette ranking and match positions
|
package/bin/aegiscode.js
CHANGED
|
@@ -16,6 +16,18 @@
|
|
|
16
16
|
|
|
17
17
|
const path = require('node:path');
|
|
18
18
|
|
|
19
|
+
// A closed pipe is not a failure. `aegiscode --terminal | head`, PowerShell's
|
|
20
|
+
// `| Select-Object -First 5`, and a pager the user quits all close the read end
|
|
21
|
+
// while we still have lines to write, and the default unhandled `error` event
|
|
22
|
+
// on stdout turns that into a stack trace over the answer. Every line of output
|
|
23
|
+
// this host produces is disposable, so the first EPIPE ends the process cleanly.
|
|
24
|
+
for (const stream of [process.stdout, process.stderr]) {
|
|
25
|
+
stream.on('error', (e) => {
|
|
26
|
+
if (e && (e.code === 'EPIPE' || e.code === 'ERR_STREAM_DESTROYED')) process.exit(0);
|
|
27
|
+
throw e;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
const HELP = `aegiscode — AEGIS in your shell.
|
|
20
32
|
|
|
21
33
|
Usage:
|
|
@@ -47,6 +59,14 @@ Options:
|
|
|
47
59
|
--width <cols> force a render width (useful for piping/logs)
|
|
48
60
|
--yolo skip tool-approval prompts (exec/writeFile/editFile
|
|
49
61
|
run without asking) — same as the in-session /yolo
|
|
62
|
+
--ascii draw with the ASCII mark and glyph set (no Unicode).
|
|
63
|
+
Same as AEGIS_ART=ascii; /terminal ascii toggles it
|
|
64
|
+
mid-session.
|
|
65
|
+
--no-color no colour at all (same as NO_COLOR=1)
|
|
66
|
+
--terminal print the resolved terminal capabilities and exit —
|
|
67
|
+
one report shape on every platform, so pasting it
|
|
68
|
+
from PowerShell (or into a bug report) reads the same
|
|
69
|
+
as pasting it from zsh
|
|
50
70
|
-c, --continue skip onboarding and resume the most recent session
|
|
51
71
|
-h, --help this text
|
|
52
72
|
-v, --version print the version
|
|
@@ -67,6 +87,15 @@ function parseArgs(argv) {
|
|
|
67
87
|
light: false,
|
|
68
88
|
width: null,
|
|
69
89
|
yolo: false,
|
|
90
|
+
// Three-state, like `color`: `null` means "no art flag was given, let the
|
|
91
|
+
// capability probe decide". It must NOT default to `false`, because `false`
|
|
92
|
+
// is how `--unicode` is spelled — a default of `false` sets
|
|
93
|
+
// `AEGIS_ART=unicode` on every run and silently out-ranks the legacy-console
|
|
94
|
+
// ASCII downgrade, so a plain `aegiscode` on an old Windows console would
|
|
95
|
+
// draw Unicode blocks it cannot render.
|
|
96
|
+
ascii: null,
|
|
97
|
+
color: null,
|
|
98
|
+
terminal: false,
|
|
70
99
|
continue: false,
|
|
71
100
|
prompt: null,
|
|
72
101
|
help: false,
|
|
@@ -157,6 +186,28 @@ function parseArgs(argv) {
|
|
|
157
186
|
case '--width':
|
|
158
187
|
opts.width = Number(next());
|
|
159
188
|
break;
|
|
189
|
+
case '--ascii':
|
|
190
|
+
// The same switch as AEGIS_ART=ascii, spelled as a flag because it is
|
|
191
|
+
// the one thing a user has to do to fix a mangled welcome mark, and
|
|
192
|
+
// asking them to export a variable and restart the shell first is how
|
|
193
|
+
// the mark stayed broken.
|
|
194
|
+
opts.ascii = true;
|
|
195
|
+
break;
|
|
196
|
+
case '--unicode':
|
|
197
|
+
opts.ascii = false;
|
|
198
|
+
break;
|
|
199
|
+
case '--no-color':
|
|
200
|
+
case '--no-colour':
|
|
201
|
+
opts.color = false;
|
|
202
|
+
break;
|
|
203
|
+
case '--color':
|
|
204
|
+
case '--colour':
|
|
205
|
+
opts.color = true;
|
|
206
|
+
break;
|
|
207
|
+
case '--terminal':
|
|
208
|
+
case '--caps':
|
|
209
|
+
opts.terminal = true;
|
|
210
|
+
break;
|
|
160
211
|
default:
|
|
161
212
|
if (a.startsWith('-') && a !== '-') throw new Error(`unknown option: ${a}`);
|
|
162
213
|
rest.push(a);
|
|
@@ -325,6 +376,42 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
325
376
|
return 0;
|
|
326
377
|
}
|
|
327
378
|
|
|
379
|
+
// ── terminal capabilities, resolved before anything else is loaded ────────
|
|
380
|
+
//
|
|
381
|
+
// Ordering is the whole point. `theme.js` materialises its palettes and its
|
|
382
|
+
// glyph table at load time and `art.js` picks its stencil at load time, and
|
|
383
|
+
// `app.js` pulls in both. Resolving caps first means the welcome screen is
|
|
384
|
+
// drawn for the terminal actually in use — PowerShell with VT enabled gets
|
|
385
|
+
// the same mark as zsh, a legacy console gets the ASCII pass — instead of
|
|
386
|
+
// whatever the first probe guessed being frozen into a module that is never
|
|
387
|
+
// re-evaluated.
|
|
388
|
+
const { setCaps, describe } = require('../src/caps.js');
|
|
389
|
+
const capEnv = { ...process.env };
|
|
390
|
+
if (opts.ascii === true) capEnv.AEGIS_ART = 'ascii';
|
|
391
|
+
if (opts.ascii === false) capEnv.AEGIS_ART = 'unicode';
|
|
392
|
+
if (opts.color === false) capEnv.NO_COLOR = '1';
|
|
393
|
+
if (opts.color === true) {
|
|
394
|
+
// An explicit --color has to beat an inherited NO_COLOR, and NO_COLOR is
|
|
395
|
+
// checked first, so it is removed rather than out-ranked.
|
|
396
|
+
delete capEnv.NO_COLOR;
|
|
397
|
+
capEnv.FORCE_COLOR = '3';
|
|
398
|
+
}
|
|
399
|
+
if (opts.width) capEnv.AEGIS_WIDTH = String(opts.width);
|
|
400
|
+
setCaps(null, capEnv);
|
|
401
|
+
|
|
402
|
+
// `--terminal` answers "why does it look like that here?" in one shape on
|
|
403
|
+
// every platform, so a paste from PowerShell reads like one from zsh. It
|
|
404
|
+
// prints the resolved values and exits before a session, a config read or a
|
|
405
|
+
// network call can colour the answer.
|
|
406
|
+
if (opts.terminal) {
|
|
407
|
+
const rows = describe();
|
|
408
|
+
const key = rows.reduce((m, [k]) => Math.max(m, k.length), 0);
|
|
409
|
+
process.stdout.write(`aegiscode ${pkg.version} — terminal capabilities\n\n`);
|
|
410
|
+
for (const [k, v] of rows) process.stdout.write(` ${k.padEnd(key)} ${v}\n`);
|
|
411
|
+
process.stdout.write('\nOverride with --ascii / --color / --width, or AEGIS_ART,\nAEGIS_STAR, AEGIS_COLOR, AEGIS_VT, AEGIS_WIDTH (see README).\n');
|
|
412
|
+
return 0;
|
|
413
|
+
}
|
|
414
|
+
|
|
328
415
|
// Apply the flags that the shared client reads from the environment, before
|
|
329
416
|
// anything constructs it.
|
|
330
417
|
if (opts.base) process.env.AEGIS_API_BASE = opts.base;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.7.1",
|
|
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/app.js
CHANGED
|
@@ -25,8 +25,18 @@ const { createTools, createClient, usageTokens, buildSystemPrompt } = require('.
|
|
|
25
25
|
const { createEngine } = require('./engine.js');
|
|
26
26
|
const { GLYPH, VERBS, themeOf, RESET, THEME_TABLE } = require('./theme.js');
|
|
27
27
|
const { LiveRegion, termWidth, w } = require('./screen.js');
|
|
28
|
+
const { editPreview } = require('./diff.js');
|
|
29
|
+
const { defaultOpen } = require('./diffview.js');
|
|
28
30
|
const { parseLine, COMMANDS, visibleCommands } = require('./commands.js');
|
|
29
|
-
const {
|
|
31
|
+
const {
|
|
32
|
+
updateConfig,
|
|
33
|
+
loadPermissions,
|
|
34
|
+
loadConfig,
|
|
35
|
+
configExists,
|
|
36
|
+
memoryPersistState,
|
|
37
|
+
memoryPersistEnabled,
|
|
38
|
+
setMemoryPersist,
|
|
39
|
+
} = require('./config.js');
|
|
30
40
|
const credentials = require('./credentials.js');
|
|
31
41
|
const cloudsync = require('./cloudsync.js');
|
|
32
42
|
const { readSecret } = require('./secret.js');
|
|
@@ -377,16 +387,32 @@ function createApp(options = {}) {
|
|
|
377
387
|
return res;
|
|
378
388
|
}
|
|
379
389
|
|
|
390
|
+
/**
|
|
391
|
+
* The persisting-memory gate — the WRITE half of aegis_memory, and now ON by
|
|
392
|
+
* default for every account (see config.js `memoryPersistState` for the
|
|
393
|
+
* migration and the reasoning). The name is historical: `/sync`, `/cloud sync`
|
|
394
|
+
* and `cloudSyncEnabled()` predate the flip, and they all mean this one gate,
|
|
395
|
+
* so there is exactly one boolean behind every switch and status line.
|
|
396
|
+
*/
|
|
380
397
|
function cloudSyncEnabled() {
|
|
381
398
|
try {
|
|
382
|
-
return
|
|
399
|
+
return memoryPersistEnabled();
|
|
383
400
|
} catch {
|
|
384
|
-
return
|
|
401
|
+
return true; // default on: a corrupt config must not silently stop storage
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** Where that answer came from — 'config' | 'legacy' | 'default'. */
|
|
406
|
+
function cloudSyncState() {
|
|
407
|
+
try {
|
|
408
|
+
return memoryPersistState();
|
|
409
|
+
} catch {
|
|
410
|
+
return { enabled: true, source: 'default', explicit: false };
|
|
385
411
|
}
|
|
386
412
|
}
|
|
387
413
|
|
|
388
414
|
function setCloudSync(on) {
|
|
389
|
-
return
|
|
415
|
+
return setMemoryPersist(on);
|
|
390
416
|
}
|
|
391
417
|
|
|
392
418
|
/**
|
|
@@ -534,6 +560,22 @@ function createApp(options = {}) {
|
|
|
534
560
|
// Presentation hooks. With no presenter these reproduce the linear
|
|
535
561
|
// behaviour exactly (live-region spinner, tool rows written to scrollback).
|
|
536
562
|
const p = presenter || {};
|
|
563
|
+
// The engine opens a tool with a `phase: 'run'` frame BEFORE the executor
|
|
564
|
+
// runs, so a writeFile preview built here still reads the pre-edit file.
|
|
565
|
+
// Cached per tool id so the later `done` frame reuses the same preview
|
|
566
|
+
// instead of re-reading a file the tool has already overwritten (which
|
|
567
|
+
// would diff clean and show nothing).
|
|
568
|
+
const diffCache = new Map();
|
|
569
|
+
const previewFor = (tool) => {
|
|
570
|
+
const key =
|
|
571
|
+
tool && tool.id !== undefined
|
|
572
|
+
? `id:${tool.id}`
|
|
573
|
+
: `${tool && tool.name}:${JSON.stringify(tool && tool.args)}`;
|
|
574
|
+
if (!diffCache.has(key)) {
|
|
575
|
+
diffCache.set(key, editPreview(tool && tool.name, tool && tool.args, { cwd: process.cwd() }));
|
|
576
|
+
}
|
|
577
|
+
return diffCache.get(key);
|
|
578
|
+
};
|
|
537
579
|
const present = {
|
|
538
580
|
text: (d) => {
|
|
539
581
|
if (p.text) return p.text(d);
|
|
@@ -547,10 +589,11 @@ function createApp(options = {}) {
|
|
|
547
589
|
tool: (tool) => {
|
|
548
590
|
if (p.tool) return p.tool(tool);
|
|
549
591
|
if (live) live.clear();
|
|
592
|
+
const diff = previewFor(tool);
|
|
550
593
|
emit(
|
|
551
594
|
render.renderTurn(
|
|
552
595
|
ctx(),
|
|
553
|
-
{ role: 'tool', label: tool.name, args: tool.args, ok: tool.ok },
|
|
596
|
+
{ role: 'tool', label: tool.name, args: tool.args, ok: tool.ok, diff, diffOpen: defaultOpen(diff) },
|
|
554
597
|
width()
|
|
555
598
|
)
|
|
556
599
|
);
|
|
@@ -911,9 +954,17 @@ function createApp(options = {}) {
|
|
|
911
954
|
case 'error': emit(render.renderNotice(ctx(), 'error', row.text)); return;
|
|
912
955
|
case 'user': emit(render.renderTurn(ctx(), { role: 'user', text: row.text, label: row.label }, W)); return;
|
|
913
956
|
case 'assistant': emit(render.renderTurn(ctx(), { role: 'assistant', text: row.text }, W)); return;
|
|
914
|
-
case 'tool':
|
|
915
|
-
|
|
957
|
+
case 'tool': {
|
|
958
|
+
// A chatflow row carries the preview it built from the run frame
|
|
959
|
+
// (chatflow.js); a row pushed straight from a command handler has none,
|
|
960
|
+
// so build one here rather than re-showing the gray `$ {args}` row.
|
|
961
|
+
if (row.diff === undefined) {
|
|
962
|
+
row.diff = editPreview(row.name || row.label, row.args, { cwd: process.cwd() });
|
|
963
|
+
row.diffOpen = defaultOpen(row.diff);
|
|
964
|
+
}
|
|
965
|
+
emit(render.renderTurn(ctx(), { role: 'tool', label: row.label || row.name, args: row.args, ok: row.ok, diff: row.diff, diffOpen: !!row.diffOpen }, W));
|
|
916
966
|
return;
|
|
967
|
+
}
|
|
917
968
|
default: emit(render.renderNotice(ctx(), 'info', row.text == null ? '' : String(row.text))); return;
|
|
918
969
|
}
|
|
919
970
|
}
|
|
@@ -1012,6 +1063,7 @@ function createApp(options = {}) {
|
|
|
1012
1063
|
readSecret: (text) => readSecret(text, { stdin: process.stdin, stdout: out }),
|
|
1013
1064
|
cloudsync,
|
|
1014
1065
|
cloudSyncEnabled: () => cloudSyncEnabled(),
|
|
1066
|
+
cloudSyncState: () => cloudSyncState(),
|
|
1015
1067
|
setCloudSync: (on) => setCloudSync(on),
|
|
1016
1068
|
adoptLegacyKey: () => adoptLegacyKeyOnce(),
|
|
1017
1069
|
};
|
|
@@ -1111,12 +1163,47 @@ function createApp(options = {}) {
|
|
|
1111
1163
|
}
|
|
1112
1164
|
if (cmd.tool === 'aegis_ask') return await runPrompt(args.prompt);
|
|
1113
1165
|
await runTool(cmd.tool, args);
|
|
1166
|
+
// `/memory` is where a user actually looks at what is stored, so the
|
|
1167
|
+
// quota state belongs here as well as in /cloud: the ceiling is the one
|
|
1168
|
+
// fact about this feature that changes what the account can do, and it is
|
|
1169
|
+
// invisible from the entries themselves.
|
|
1170
|
+
if (cmd.tool === 'aegis_memory_list' || cmd.tool === 'aegis_memory_search') memoryQuotaNote();
|
|
1114
1171
|
} catch (e) {
|
|
1115
1172
|
emit(render.renderNotice(ctx(), 'error', e.message));
|
|
1116
1173
|
}
|
|
1117
1174
|
return true;
|
|
1118
1175
|
}
|
|
1119
1176
|
|
|
1177
|
+
/**
|
|
1178
|
+
* One line of quota state for the memory read commands. Quiet when the server
|
|
1179
|
+
* has not reported a ceiling yet (nothing useful to say), a statement when it
|
|
1180
|
+
* has, and — when the account is at it — the two halves spelled out: reads
|
|
1181
|
+
* keep working, new writes do not.
|
|
1182
|
+
*/
|
|
1183
|
+
function memoryQuotaNote() {
|
|
1184
|
+
let st;
|
|
1185
|
+
try {
|
|
1186
|
+
st = cloudsync.status();
|
|
1187
|
+
} catch {
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
const q = st.quota;
|
|
1191
|
+
if (!q) return;
|
|
1192
|
+
const used = fmtTokens(q.used || 0);
|
|
1193
|
+
const limit = fmtTokens(q.limit || 0);
|
|
1194
|
+
if (st.overQuota) {
|
|
1195
|
+
emit(
|
|
1196
|
+
render.renderNotice(
|
|
1197
|
+
ctx(),
|
|
1198
|
+
'warn',
|
|
1199
|
+
`cloud memory: ${used} of ${limit} synced tokens — at the plan's ceiling. Everything stored stays readable; new writes are paused until there is room. /cloud memory for the full state.`
|
|
1200
|
+
)
|
|
1201
|
+
);
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
emit(render.renderNotice(ctx(), 'info', `cloud memory: ${used} of ${limit} synced tokens — /cloud memory for the full state`));
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1120
1207
|
/**
|
|
1121
1208
|
* Ask for a secret on this session's streams.
|
|
1122
1209
|
*
|
|
@@ -1236,9 +1323,12 @@ function createApp(options = {}) {
|
|
|
1236
1323
|
/* persistence is best-effort */
|
|
1237
1324
|
}
|
|
1238
1325
|
// Auto-sync hook: one place, reached by both the linear REPL and the
|
|
1239
|
-
// chatflow's session loop
|
|
1240
|
-
//
|
|
1241
|
-
//
|
|
1326
|
+
// chatflow's session loop. On by default — a push is billed against the
|
|
1327
|
+
// plan's synced-token ceiling (aegis1 charges the *growth* of a session),
|
|
1328
|
+
// so it is a real gate rather than an unconditional write, but the default
|
|
1329
|
+
// is on because a session that dies at its tool-round horizon is only
|
|
1330
|
+
// recoverable if the transcript exists somewhere the next session can read
|
|
1331
|
+
// it. `/cloud memory off` is the opt-out.
|
|
1242
1332
|
if (cloudSyncEnabled()) autoSync();
|
|
1243
1333
|
}
|
|
1244
1334
|
|
|
@@ -1250,6 +1340,13 @@ function createApp(options = {}) {
|
|
|
1250
1340
|
* per session per session-cycle — a quota refusal that repeats forever is a
|
|
1251
1341
|
* wall of text, not information — and never thrown, because the user's turn
|
|
1252
1342
|
* already succeeded by the time this runs.
|
|
1343
|
+
*
|
|
1344
|
+
* The quota refusal gets its own sentence, and it is the whole point of the
|
|
1345
|
+
* default flip being safe: past the plan's ceiling the account does NOT lose
|
|
1346
|
+
* anything it already stored (reads keep working — aegis1 meters writes
|
|
1347
|
+
* only), and the failure is not "sync failed", it is "there is no room left
|
|
1348
|
+
* for new writes". Saying which half stopped is what keeps a silent stop from
|
|
1349
|
+
* looking like a broken feature.
|
|
1253
1350
|
*/
|
|
1254
1351
|
let autoSyncNotes = new Set();
|
|
1255
1352
|
function autoSync() {
|
|
@@ -1261,8 +1358,18 @@ function createApp(options = {}) {
|
|
|
1261
1358
|
const f = res.failed[0];
|
|
1262
1359
|
if (autoSyncNotes.has(f.kind)) return;
|
|
1263
1360
|
autoSyncNotes.add(f.kind);
|
|
1361
|
+
if (f.kind === 'quota') {
|
|
1362
|
+
emit(
|
|
1363
|
+
render.renderNotice(
|
|
1364
|
+
ctx(),
|
|
1365
|
+
'warn',
|
|
1366
|
+
`cloud memory: the plan's synced-token ceiling is reached — earlier sessions stay readable, only NEW writes pause. /cloud memory shows the quota; /cloud memory off stops trying.`
|
|
1367
|
+
)
|
|
1368
|
+
);
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1264
1371
|
const hint = f.hint ? ` — ${f.hint}` : '';
|
|
1265
|
-
emit(render.renderNotice(ctx(),
|
|
1372
|
+
emit(render.renderNotice(ctx(), 'error', `cloud sync: ${f.message}${hint}`));
|
|
1266
1373
|
}
|
|
1267
1374
|
})
|
|
1268
1375
|
.catch(() => {
|
|
@@ -1270,6 +1377,38 @@ function createApp(options = {}) {
|
|
|
1270
1377
|
});
|
|
1271
1378
|
}
|
|
1272
1379
|
|
|
1380
|
+
/**
|
|
1381
|
+
* First-run notice for the write half, printed once, right after onboarding.
|
|
1382
|
+
*
|
|
1383
|
+
* The default flip is invisible otherwise: the read half was already on for
|
|
1384
|
+
* everyone, so nothing about the first session looks different — the thing
|
|
1385
|
+
* that changed is that the transcript is now being *stored*, and that costs
|
|
1386
|
+
* quota on a free plan. One line at the moment the account is set up is the
|
|
1387
|
+
* difference between a default and a surprise.
|
|
1388
|
+
*/
|
|
1389
|
+
function memoryFirstRunNotice() {
|
|
1390
|
+
const st = cloudSyncState();
|
|
1391
|
+
if (!st.enabled) {
|
|
1392
|
+
emit(
|
|
1393
|
+
render.renderNotice(
|
|
1394
|
+
ctx(),
|
|
1395
|
+
'info',
|
|
1396
|
+
'cross-session memory: off (you turned it off) — /cloud memory on stores sessions so an interrupted turn can be picked up later'
|
|
1397
|
+
)
|
|
1398
|
+
);
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
const quota = cloudsync.status().quota;
|
|
1402
|
+
const usage = quota && quota.limit ? ` (used ${fmtTokens(quota.used || 0)} of ${fmtTokens(quota.limit)} tokens)` : '';
|
|
1403
|
+
emit(
|
|
1404
|
+
render.renderNotice(
|
|
1405
|
+
ctx(),
|
|
1406
|
+
'info',
|
|
1407
|
+
`cross-session memory: on${usage} — sessions are stored to your account so a turn that is interrupted can be resumed. /cloud memory shows the quota; /cloud memory off stops it. Past the ceiling, saved memory stays readable and only new writes pause.`
|
|
1408
|
+
)
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1273
1412
|
/** One line of session accounting, for ctrl+t and the meta row. */ function tokenSummary() {
|
|
1274
1413
|
return (
|
|
1275
1414
|
`${fmtTokens(session.tokens)} tok ` +
|
|
@@ -1466,6 +1605,11 @@ function createApp(options = {}) {
|
|
|
1466
1605
|
)
|
|
1467
1606
|
);
|
|
1468
1607
|
}
|
|
1608
|
+
// The write half of cross-session memory is on by default (see
|
|
1609
|
+
// config.js). Say so once, on the run that sets the account up, together
|
|
1610
|
+
// with the ceiling and the opt-out — a default nobody is told about is a
|
|
1611
|
+
// setting they cannot make a decision about.
|
|
1612
|
+
if (onboard.firstRun) memoryFirstRunNotice();
|
|
1469
1613
|
// A stored pin the platform does not advertise routes elsewhere in
|
|
1470
1614
|
// silence (see validatePinnedModel) — checked once, here, where the user
|
|
1471
1615
|
// can act on it. Not on `-p`: a network round-trip ahead of the first
|
|
@@ -1519,6 +1663,7 @@ function createApp(options = {}) {
|
|
|
1519
1663
|
forgetApiKey,
|
|
1520
1664
|
adoptLegacyKeyOnce,
|
|
1521
1665
|
cloudSyncEnabled,
|
|
1666
|
+
cloudSyncState,
|
|
1522
1667
|
setCloudSync,
|
|
1523
1668
|
cloudsync,
|
|
1524
1669
|
keyStatus: () => credentials.keyStatus(),
|