aegisone 1.0.47 → 1.0.49

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.
@@ -4264,6 +4264,10 @@ function createNpmUpdateManager({
4264
4264
  plan: null,
4265
4265
  method: null,
4266
4266
  canDownload: false,
4267
+ // A release the server has declared retired (`decomposed: true` from
4268
+ // /api/v1/version) is not a suggestion — the banner must say it even
4269
+ // when no newer version resolves and no download can be offered.
4270
+ decomposed: false,
4267
4271
  };
4268
4272
  const set = (patch) => {
4269
4273
  state = { ...state, ...patch };
@@ -4376,6 +4380,22 @@ function createNpmUpdateManager({
4376
4380
  return reason === 'unknown'; // unclassified: assume retryable, stay quiet
4377
4381
  };
4378
4382
 
4383
+ // The server is asked at most once per process for this: a retired release
4384
+ // does not un-retire, and re-asking on every 4h check is the nagging the
4385
+ // checker's once-a-day rule exists to avoid.
4386
+ let decomposedCache = null; // null = no answer yet (failures are not cached)
4387
+ async function decomposedVerdict() {
4388
+ if (decomposedCache !== null) return decomposedCache;
4389
+ if (!updater || typeof updater.serverUpdateVerdict !== 'function') return null;
4390
+ try {
4391
+ const v = await updater.serverUpdateVerdict({ current });
4392
+ if (v && v.ok) decomposedCache = Boolean(v.decomposed);
4393
+ return decomposedCache;
4394
+ } catch {
4395
+ return null;
4396
+ }
4397
+ }
4398
+
4379
4399
  /**
4380
4400
  * `announce: false` (the default) is the background check: a network failure
4381
4401
  * is swallowed and re-tried on the backoff ladder. `announce: true` is a
@@ -4407,6 +4427,16 @@ function createNpmUpdateManager({
4407
4427
  attempts = 0;
4408
4428
  retryAt = 0;
4409
4429
  clearRetry();
4430
+ // A retired release is reported whether or not the registry found a
4431
+ // newer one — DECOMPOSED is the strongest thing the banner can say,
4432
+ // and it must not be swallowed by an 'up-to-date' registry answer.
4433
+ const decomposed = await decomposedVerdict();
4434
+ if (decomposed) {
4435
+ return set({
4436
+ status: 'decomposed', version: res.latest, error: null, reason: null,
4437
+ transient: false, attempts: 0, retryInMs: 0, decomposed: true,
4438
+ });
4439
+ }
4410
4440
  if (!updater.isNewer(res.latest, current)) {
4411
4441
  return set({
4412
4442
  status: 'up-to-date', version: res.latest, error: null, reason: null,
@@ -5185,7 +5215,15 @@ function bootstrap() {
5185
5215
  // "AEGIS One" is the casing a short-lived build used. A user can arrive
5186
5216
  // from either, so both are candidates and neither is assumed to exist.
5187
5217
  const parentDir = path.dirname(userDataDir);
5188
- const LEGACY_NAMES = ['AEGIS Desktop', 'AEGIS One'];
5218
+ // FOUR prior names, not two. `aegis one` is the fifth name this app has
5219
+ // shipped under: "AEGIS Desktop" (the packaged identity in
5220
+ // electron-builder.yml, still frozen) is what the first installs wrote, and
5221
+ // "AEGIS One" is the casing a short-lived build used. "Electron" is what
5222
+ // an un-renamed dev/running-from-source launch wrote (`app.name` defaults
5223
+ // to Electron before the first setName), and "aegiscode-gui" is the
5224
+ // pre-rename name of the very first GUI. A user can arrive from any of
5225
+ // the four, so all are candidates and none is assumed to exist.
5226
+ const LEGACY_NAMES = ['AEGIS Desktop', 'AEGIS One', 'Electron', 'aegiscode-gui'];
5189
5227
  // Electron creates the userData directory eagerly, and a single launch of
5190
5228
  // this version before the guard was correct leaves a NON-empty root full of
5191
5229
  // Chromium profile junk (Cache/, GPUCache/, Local Storage/, Preferences,
@@ -5215,6 +5253,10 @@ function bootstrap() {
5215
5253
  };
5216
5254
  // settings.json only counts as state when it carries the account key; the
5217
5255
  // stub a pre-migration launch wrote holds nothing but __quickLauncher.
5256
+ // A key found in the CURRENT root is not state: adoption moves TOWARD the
5257
+ // current root, so a key there means the last launch already stored its
5258
+ // account (safeStorage entries are still being written there); treating it
5259
+ // as state would point the legacy scan at the wrong end.
5218
5260
  const hasAccountKey = (dir) => {
5219
5261
  try {
5220
5262
  return fs.readFileSync(path.join(dir, 'settings.json'), 'utf8').includes('"__aegis"');
@@ -5236,12 +5278,24 @@ function bootstrap() {
5236
5278
  if (['sessions.json', 'avatar', 'xp.json', 'queue.jsonl'].some((n) => names.includes(n))) return true;
5237
5279
  return hasAccountKey(dir);
5238
5280
  };
5281
+ const isCurrentRoot = (dir) =>
5282
+ (() => {
5283
+ try {
5284
+ return fs.realpathSync(dir) === fs.realpathSync(userDataDir);
5285
+ } catch {
5286
+ return false;
5287
+ }
5288
+ })();
5239
5289
  const isEmptyDir = (p) => isDir(p) && fs.readdirSync(p).length === 0;
5240
5290
 
5241
5291
  // Prefer whichever legacy root actually carries state; among two that do,
5242
- // take the larger sessions.json (the more recently used install).
5292
+ // take the larger sessions.json (the more recently used install). The
5293
+ // CURRENT root is never a candidate — a symlink (or a launch that already
5294
+ // adopted and then moved on) would otherwise make the app try to adopt
5295
+ // itself, and a root holding only the account key written by THIS build is
5296
+ // not "legacy" state to move.
5243
5297
  const legacyDir = LEGACY_NAMES.map((n) => path.join(parentDir, n))
5244
- .filter((d) => hasUserState(d))
5298
+ .filter((d) => hasUserState(d) && !isCurrentRoot(d))
5245
5299
  .sort((a, b) => sizeOf(path.join(b, 'sessions.json')) - sizeOf(path.join(a, 'sessions.json')))[0];
5246
5300
 
5247
5301
  if (legacyDir && !hasUserState(userDataDir)) {
@@ -5287,6 +5341,106 @@ function bootstrap() {
5287
5341
  app.setPath('userData', legacyDir);
5288
5342
  }
5289
5343
  }
5344
+
5345
+ // The pre-unification desktop chats live in ~/.aegiscode/native-chat-history/
5346
+ // (one JSON file per conversation, catalogued by native-chat-index.json) —
5347
+ // a store nothing ever imports. The shared session-store's adopt() merges
5348
+ // a whole legacy sessions.json, but these are individual transcripts with
5349
+ // no session ids, so they need one import of their own: any file not
5350
+ // already represented in the shared store becomes a session, id minted by
5351
+ // the transcript's own timestamp, once and idempotently. No other store
5352
+ // in the tree reads these files, so the import makes them visible rather
5353
+ // than duplicating them.
5354
+ try {
5355
+ const nativeHistoryDir = path.join(os.homedir(), '.aegiscode', 'native-chat-history');
5356
+ const isDir = (p) => {
5357
+ try {
5358
+ return fs.statSync(p).isDirectory();
5359
+ } catch {
5360
+ return false;
5361
+ }
5362
+ };
5363
+ if (isDir(nativeHistoryDir)) {
5364
+ const entries = fs
5365
+ .readdirSync(nativeHistoryDir)
5366
+ .filter((f) => f.endsWith('.json'))
5367
+ .sort();
5368
+ const existing = new Set(
5369
+ (sessionStore.listSessions(sessionStore.resolveStoreDir(null)) || [])
5370
+ .map((s) => s && s.id)
5371
+ .filter(Boolean)
5372
+ );
5373
+ let adopted = 0;
5374
+ for (const file of entries) {
5375
+ let parsed = null;
5376
+ try {
5377
+ parsed = JSON.parse(fs.readFileSync(path.join(nativeHistoryDir, file), 'utf8'));
5378
+ } catch {
5379
+ /* not JSON or not readable: not a conversation */
5380
+ }
5381
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) continue;
5382
+ const marker =
5383
+ (typeof parsed.createdAt === 'string' && parsed.createdAt) ||
5384
+ (typeof parsed.created_at === 'string' && parsed.created_at) ||
5385
+ String(parsed.timestamp || '');
5386
+ if (!marker) continue;
5387
+ // Mint the id from the transcript's own timestamp — stable across
5388
+ // launches, and one id per file (duplicate timestamps get a suffix).
5389
+ let sessionId = `native-${marker.replace(/[^0-9T:.Z+-]/g, '')}`.slice(0, 80);
5390
+ if (existing.has(sessionId)) sessionId = `${sessionId}-${file.replace(/\.json$/, '').slice(-24)}`;
5391
+ if (existing.has(sessionId)) continue;
5392
+ const messages = Array.isArray(parsed.messages)
5393
+ ? parsed.messages
5394
+ : parsed.history && Array.isArray(parsed.history.messages)
5395
+ ? parsed.history.messages
5396
+ : parsed.history && Array.isArray(parsed.history)
5397
+ ? parsed.history
5398
+ : parsed.entries && Array.isArray(parsed.entries)
5399
+ ? parsed.entries
5400
+ : [];
5401
+ const clean = messages
5402
+ .map((m) => {
5403
+ const text =
5404
+ (m && (m.content || m.text)) !== undefined
5405
+ ? m.content || m.text
5406
+ : m && typeof m.prompt === 'string'
5407
+ ? m.prompt
5408
+ : m && typeof m.reply === 'string'
5409
+ ? m.reply
5410
+ : null;
5411
+ if (text == null || text === '') return null;
5412
+ const role =
5413
+ m && (m.role === 'user' || m.role === 'assistant')
5414
+ ? m.role
5415
+ : m && typeof m.prompt === 'string'
5416
+ ? 'user'
5417
+ : m && typeof m.reply === 'string'
5418
+ ? 'assistant'
5419
+ : 'unknown';
5420
+ return { role, content: String(text) };
5421
+ })
5422
+ .filter(Boolean);
5423
+ if (!clean.length) continue;
5424
+ const title = String(parsed.title || (parsed.session && parsed.session.title) || '').trim();
5425
+ sessionStore.upsertSession(sessionStore.resolveStoreDir(null), {
5426
+ id: sessionId,
5427
+ title: title || String((clean.find((m) => m.role === 'user') || {}).content || '').slice(0, 60),
5428
+ messages: clean,
5429
+ cwd: typeof parsed.cwd === 'string' ? parsed.cwd : '',
5430
+ updatedAt:
5431
+ Date.parse(parsed.updatedAt || parsed.updated_at || parsed.createdAt || parsed.created_at || 0) ||
5432
+ Date.now(),
5433
+ origin: 'native-chat',
5434
+ pending: false,
5435
+ });
5436
+ existing.add(sessionId);
5437
+ adopted += 1;
5438
+ }
5439
+ if (adopted) console.warn(`aegis: imported ${adopted} conversation(s) from ${nativeHistoryDir}`);
5440
+ }
5441
+ } catch (nativeErr) {
5442
+ console.warn(`aegis: native-chat import skipped: ${nativeErr && nativeErr.message}`);
5443
+ }
5290
5444
  } catch (renameErr) {
5291
5445
  console.warn(`aegis: userData adoption skipped: ${renameErr && renameErr.message}`);
5292
5446
  }
@@ -2,7 +2,7 @@
2
2
  "name": "aegis-desktop",
3
3
  "productName": "aegis one",
4
4
  "desktopName": "aegis-desktop",
5
- "version": "1.0.39",
5
+ "version": "1.0.41",
6
6
  "description": "Thin Electron host for AEGIS — a local chat UI over the shared client/aegis.js transport. Ships transport + UI only; engine logic stays server-side.",
7
7
  "author": {
8
8
  "name": "AEGIS Code",