aegisone 1.0.20 → 1.0.22

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.
Files changed (39) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -1
  3. package/scripts/predist.mjs +13 -2
  4. package/vendor/cli/bin/aegiscode.js +12 -0
  5. package/vendor/cli/package.json +2 -1
  6. package/vendor/cli/scripts/predist.mjs +6 -3
  7. package/vendor/cli/src/app.js +102 -1
  8. package/vendor/cli/src/chatflow.js +14 -2
  9. package/vendor/cli/src/commands.js +61 -5
  10. package/vendor/cli/src/limits.js +1 -1
  11. package/vendor/cli/src/provenance.lock.json +2 -2
  12. package/vendor/cli/src/update.js +103 -12
  13. package/vendor/cli/vendor/client/aegis.js +297 -6
  14. package/vendor/cli/vendor/client/drive-connect.js +112 -0
  15. package/vendor/cli/vendor/client/drive-upload.js +176 -0
  16. package/vendor/cli/vendor/client/google-signin.js +12 -4
  17. package/vendor/cli/vendor/client/model-discovery.js +43 -0
  18. package/vendor/cli/vendor/client/update.js +100 -8
  19. package/vendor/cli/vendor/desktop/lib/local/engine.js +138 -2
  20. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +7 -1
  21. package/vendor/cli/vendor/desktop/lib/local/prompt.js +67 -37
  22. package/vendor/cli/vendor/desktop/lib/local/tools.js +49 -13
  23. package/vendor/desktop/lib/google-connect.js +229 -0
  24. package/vendor/desktop/lib/local/engine.js +138 -2
  25. package/vendor/desktop/lib/local/entitlement.js +7 -1
  26. package/vendor/desktop/lib/local/prompt.js +67 -37
  27. package/vendor/desktop/lib/local/tools.js +49 -13
  28. package/vendor/desktop/main.js +446 -128
  29. package/vendor/desktop/package.json +2 -4
  30. package/vendor/desktop/preload.js +27 -5
  31. package/vendor/desktop/renderer/app.js +117 -7
  32. package/vendor/desktop/renderer/fingerprint.js +92 -2
  33. package/vendor/desktop/renderer/index.html +17 -0
  34. package/vendor/desktop/vendor/aegis.js +297 -6
  35. package/vendor/desktop/vendor/drive-connect.js +112 -0
  36. package/vendor/desktop/vendor/drive-upload.js +176 -0
  37. package/vendor/desktop/vendor/google-signin.js +12 -4
  38. package/vendor/desktop/vendor/model-discovery.js +43 -0
  39. package/vendor/desktop/vendor/update.js +100 -8
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegis-desktop",
3
3
  "productName": "AEGIS Desktop",
4
- "version": "1.0.12",
4
+ "version": "1.0.14",
5
5
  "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.",
6
6
  "author": {
7
7
  "name": "AEGIS Code",
@@ -26,6 +26,7 @@
26
26
  "scripts": {
27
27
  "start": "electron .",
28
28
  "predist": "node scripts/predist.mjs",
29
+ "prepack": "node scripts/predist.mjs --quiet",
29
30
  "prepublishOnly": "npm run predist",
30
31
  "icon": "node scripts/generate-icon.mjs",
31
32
  "shots": "node scripts/capture-marketing-shots.mjs",
@@ -63,9 +64,6 @@
63
64
  "engines": {
64
65
  "node": ">=22.0.0"
65
66
  },
66
- "dependencies": {
67
- "electron-updater": "^6.8.9"
68
- },
69
67
  "devDependencies": {
70
68
  "electron-builder": "^26.15.3",
71
69
  "electron": "^44.0.0"
@@ -33,6 +33,7 @@ const MENU_SEARCH_CHANNEL = `${IPC_PREFIX}menuSearch`;
33
33
  const MENU_EXPORT_MARKDOWN_CHANNEL = `${IPC_PREFIX}menuExportMarkdown`;
34
34
  const MENU_EXPORT_JSON_CHANNEL = `${IPC_PREFIX}menuExportJson`;
35
35
  const MENU_FINGERPRINT_CHANNEL = `${IPC_PREFIX}menuFingerprint`;
36
+ const MENU_GOOGLE_DRIVE_CHANNEL = `${IPC_PREFIX}menuGoogleDrive`;
36
37
  const DEEP_LINK_CHANNEL = `${IPC_PREFIX}deepLink`;
37
38
  const QUICK_LAUNCHER_PUSH_CHANNEL = `${IPC_PREFIX}quickLauncherPush`;
38
39
 
@@ -260,11 +261,10 @@ const api = {
260
261
  getMemoryPersist: () => invoke('memoryPersist.get'),
261
262
  setMemoryPersist: (enabled) => invoke('memoryPersist.set', { enabled: Boolean(enabled) }),
262
263
 
263
- // Auto-update (electron-updater over GitHub Releases — see main.js
264
- // createUpdateManager). check/download resolve the same status shape the
265
- // push channel delivers; both are no-ops that resolve `{ status:
266
- // 'disabled' }` in an unpackaged dev build. quitAndInstallUpdate must only
267
- // ever be called from an explicit user action (the banner's "Restart to
264
+ // Auto-update (npm registry — see main.js createUpdateManager). check and
265
+ // download resolve the same status shape the push channel delivers: download
266
+ // installs on an explicit click and only then, and quitAndInstallUpdate must
267
+ // only ever be called from an explicit user action (the banner's "Restart to
268
268
  // install" button) — main.js never restarts on its own.
269
269
  checkForUpdates: () => invoke('checkForUpdates'),
270
270
  downloadUpdate: () => invoke('downloadUpdate'),
@@ -285,6 +285,20 @@ const api = {
285
285
  ipcRenderer.on(ACCOUNT_STATUS_CHANNEL, listener);
286
286
  return () => ipcRenderer.removeListener(ACCOUNT_STATUS_CHANNEL, listener);
287
287
  },
288
+ // Google sign-in + Drive connect/sync (main.js lib/google-connect.js).
289
+ // `driveSignIn` opens a browser for aegis1's `/auth/google` round-trip and
290
+ // replaces this machine's saved key with the Google-linked one — the
291
+ // desktop counterpart of the CLI's `aegiscode connect`. `driveConnect`
292
+ // opens `/connect/drive` and polls until this (now Google-linked) account
293
+ // shows a Drive token on file; it is only coherent once `driveSignIn` has
294
+ // actually run. `driveStatus` is a one-shot, no-browser read for painting
295
+ // the card on load. `driveSyncMemory` pulls this account's AEGIS cloud
296
+ // memory and backs it up to a dedicated "AEGIS Memory" Drive folder. Every
297
+ // one resolves `{ ok, … }` / `{ ok: false, error }`, never throws.
298
+ driveSignIn: () => invoke('driveSignIn'),
299
+ driveConnect: () => invoke('driveConnect'),
300
+ driveStatus: () => invoke('driveStatus'),
301
+ driveSyncMemory: () => invoke('driveSyncMemory'),
288
302
  // Native menu accelerators with no built-in Electron role (Cmd/Ctrl+N,
289
303
  // Cmd/Ctrl+K — see main.js buildAppMenu): main.js just pings the channel,
290
304
  // the renderer owns what "new chat" / "search" actually do.
@@ -315,6 +329,14 @@ const api = {
315
329
  ipcRenderer.on(MENU_FINGERPRINT_CHANNEL, listener);
316
330
  return () => ipcRenderer.removeListener(MENU_FINGERPRINT_CHANNEL, listener);
317
331
  },
332
+ // Account > Google Drive Backup… — same sheet as Authorship Panel above,
333
+ // opened straight to the Drive row instead of leaving the Google sign-in
334
+ // buttons to be found by scrolling past the unrelated φ(α) key controls.
335
+ onMenuGoogleDrive: (onTrigger) => {
336
+ const listener = () => onTrigger();
337
+ ipcRenderer.on(MENU_GOOGLE_DRIVE_CHANNEL, listener);
338
+ return () => ipcRenderer.removeListener(MENU_GOOGLE_DRIVE_CHANNEL, listener);
339
+ },
318
340
  onMenuExportJson: (onTrigger) => {
319
341
  const listener = () => onTrigger();
320
342
  ipcRenderer.on(MENU_EXPORT_JSON_CHANNEL, listener);
@@ -1183,12 +1183,21 @@ function renderUpdateBanner(state) {
1183
1183
  let showRetry = false;
1184
1184
  const version = state.version ? `v${state.version} ` : '';
1185
1185
  if (status === 'available') {
1186
- // The npm channel cannot install itself, so its banner names the command
1187
- // instead of offering a Download button that would do nothing.
1186
+ // A channel the main process can install for (npm, pip) gets a real
1187
+ // Download button — `canDownload` is true only when it has an argv to run.
1188
+ // The rest (npx, a source checkout) have nothing to install, so the banner
1189
+ // names the command instead of offering a button that would do nothing.
1190
+ // `commandIsSentence` is the main process saying this channel has no
1191
+ // command to type — a packaged build, an npx run, a source checkout. Those
1192
+ // get the sentence as written; prefixing "run:" to prose reads as a command
1193
+ // that does not exist.
1188
1194
  text = state.command
1189
- ? `Update ${version}available — run: ${state.command}`
1195
+ ? (state.commandIsSentence
1196
+ ? `Update ${version}available. ${state.command}`
1197
+ : `Update ${version}available — run: ${state.command}`)
1190
1198
  : `Update ${version}available.`;
1191
1199
  showDownload = !!state.canDownload;
1200
+ if (showDownload) text = `Update ${version}available.`;
1192
1201
  } else if (status === 'downloading') {
1193
1202
  const pct = typeof state.progress === 'number' ? ` (${Math.round(state.progress)}%)` : '';
1194
1203
  text = `Downloading update${pct}…`;
@@ -3072,6 +3081,13 @@ async function applyWelcomeAiLine() {
3072
3081
  tools: false,
3073
3082
  singlePass: true,
3074
3083
  effort: 'low',
3084
+ // A sentence the user never asked for, asked for on boot while the window
3085
+ // is still painting. If the provider stalls past its budget, main resolves
3086
+ // this with `bestEffortFailed` and logs one classified line instead of
3087
+ // Electron printing "Error occurred in handler for 'model:chat'" plus a
3088
+ // provider stack as the first thing the app says. The catch below already
3089
+ // treats "no answer" as "keep the fact line".
3090
+ bestEffort: true,
3075
3091
  };
3076
3092
  if (modelId) payload.model = modelId;
3077
3093
 
@@ -3720,11 +3736,38 @@ async function spawnPath(card, spec) {
3720
3736
  // one provider call, always.
3721
3737
  singlePass: true,
3722
3738
  sessionId: id,
3739
+ // A discovery path is a background dispatch beside the answer the user
3740
+ // actually waited for. When it stalls, the catch below already renders
3741
+ // "Path unavailable: …" into its own card — that IS the failure UI. So
3742
+ // it is marked best-effort: main resolves a classified payload rather
3743
+ // than rejecting, and the terminal gets one line instead of Electron's
3744
+ // raw "Error occurred in handler for 'model:chat'" stack for a card the
3745
+ // user can already see is stopped.
3746
+ bestEffort: true,
3723
3747
  },
3724
3748
  onDelta
3725
3749
  );
3726
3750
 
3727
3751
  const choice = (data && data.choices && data.choices[0]) || {};
3752
+ // `bestEffort` above means a stalled lane RESOLVES instead of rejecting,
3753
+ // so the throw-handler at the bottom of this function no longer runs for
3754
+ // it. Without this branch a timeout would render as a successful card
3755
+ // reading "(no path found)" — claiming the model looked and found nothing
3756
+ // when in fact it never answered. Say which one happened.
3757
+ if (data && data.bestEffortFailed) {
3758
+ throw new Error(data.message || 'the provider did not answer');
3759
+ }
3760
+ // Same rebuild as the turn path: a card's own stop button aborts this
3761
+ // lane's session, and that abort now resolves instead of rejecting. Left
3762
+ // unhandled it would fall through to the success branch and mark a
3763
+ // cancelled card "done" — claiming a path completed when the user cut it
3764
+ // off. The catch below already renders it stopped.
3765
+ if (data && data.aborted) {
3766
+ const stop = new Error(data.message || 'This operation was aborted');
3767
+ stop.name = 'AbortError';
3768
+ stop.code = 'ABORT_ERR';
3769
+ throw stop;
3770
+ }
3728
3771
  const text =
3729
3772
  (choice.message && choice.message.content) || streamed || '(no path found)';
3730
3773
  renderMessageBody(body, 'assistant', text);
@@ -4333,6 +4376,16 @@ async function loadModels(cls) {
4333
4376
  // which serve Ollama's /api/tags, so the user can still type a model id.
4334
4377
  const needsDaemon = Boolean(data && data.needsDaemon);
4335
4378
  const listed = !(data && data.listed === false);
4379
+ // BYOK's two states the other classes cannot have, both reported by
4380
+ // engine.listModels so this file never has to infer them. `providersFailed`
4381
+ // means the CATALOG CALL failed — distinct from a catalog that answered
4382
+ // with nothing, and distinct from `listed` above (that one is the local
4383
+ // class's tag list). `unmatchedProviders` names declarations in
4384
+ // `models.json` for providers the catalog does not list.
4385
+ const providersFailed = Boolean(data && data.providersFailed);
4386
+ const unmatchedProviders = Array.isArray(data && data.unmatchedProviders)
4387
+ ? data.unmatchedProviders
4388
+ : [];
4336
4389
  // Typed tag: shown only when the picker has nothing to offer, which is
4337
4390
  // precisely the state the transport's own error message names ("pick one
4338
4391
  // from the model list, or type a tag"). When the daemon hands us a list the
@@ -4361,6 +4414,17 @@ async function loadModels(cls) {
4361
4414
  // surface is plain OpenAI-compatible, so a typed tag works.
4362
4415
  hint = 'That address answered but listed no models — not Ollama? ' +
4363
4416
  'Type the model tag in the box above and send.';
4417
+ } else if (cls === 'byok' && providersFailed) {
4418
+ // The catalog call itself failed — offline, a 5xx, a relay hiccup. The
4419
+ // empty picker below would otherwise render as "No models listed.", which
4420
+ // reads as an account with nothing configured and would hide the reason
4421
+ // the user actually needs. Nothing is lost: the saved provider key and
4422
+ // the `models.json` declaration live on disk and come back on Refresh.
4423
+ // Placed BEFORE the empty-list branch because an empty list is the
4424
+ // symptom here, not the state.
4425
+ hint = 'Provider catalog unreachable — your saved keys and declared ' +
4426
+ 'models are unaffected. Refresh to try again.' +
4427
+ (data && data.providersError ? ` (${data.providersError})` : '');
4364
4428
  } else if (!list.length) {
4365
4429
  // The Aegis Cloud class offers no model to pin (engine.js's aegis branch
4366
4430
  // omits the aegiscloud ids on purpose), so an empty list there is the
@@ -4408,6 +4472,21 @@ async function loadModels(cls) {
4408
4472
  } else {
4409
4473
  hint = `${list.length} model${list.length === 1 ? '' : 's'} available.`;
4410
4474
  }
4475
+ // Declarations for providers the catalog does not name (typo, or a provider
4476
+ // renamed/dropped server-side) are never turned into a row — `withUserModels`
4477
+ // refuses to fabricate one, because it would 401 on its first turn. Saying
4478
+ // so is the alternative to silence: the model is still in `models.json` and
4479
+ // the user would otherwise just notice it missing. Appended to whatever
4480
+ // state the list is in, including a successful one.
4481
+ //
4482
+ // NOT appended when the catalog itself failed: every declaration is
4483
+ // "unmatched" against a list that never arrived, and naming them as bad
4484
+ // would send the user to fix provider names that are perfectly correct.
4485
+ if (cls === 'byok' && !providersFailed && unmatchedProviders.length) {
4486
+ const names = unmatchedProviders.join(', ');
4487
+ hint = `${hint} Not shown: ${names} — declared in models.json, but not in ` +
4488
+ 'the provider catalog. Check the provider name in Settings.';
4489
+ }
4411
4490
  // Display-only: what this model says its own output limit is. It sizes no
4412
4491
  // request — budgetFor() answers that from the Effort rung.
4413
4492
  const ceiling = maxTokensCeiling(modelMeta.get(currentModelId()));
@@ -4788,7 +4867,9 @@ async function loadSettings() {
4788
4867
  text.textContent =
4789
4868
  `BYOK handling fee: ${per1k(fee.in_usd_per_1k)} / 1k in, ` +
4790
4869
  `${per1k(fee.out_usd_per_1k)} / 1k out — billed to your AEGIS account ` +
4791
- 'on top of your own provider bill.';
4870
+ 'on top of your own provider bill. This is the published rate, not a ' +
4871
+ 'personal quote — Unlimited subscribers pay no handling fee at all, ' +
4872
+ 'and neither do users on the free 1-month Unlimited trial.';
4792
4873
  note.appendChild(text);
4793
4874
  els.settingsList.appendChild(note);
4794
4875
  }
@@ -5804,6 +5885,21 @@ async function send() {
5804
5885
  onDelta
5805
5886
  );
5806
5887
 
5888
+ // A stop that crossed IPC arrives as a resolved payload, not a rejection:
5889
+ // main cannot let the abort reject, because `ipcMain.handle` prints every
5890
+ // rejection with a full stack and a user-pressed stop is not a crash (see
5891
+ // the `aborted` note in registerModelIpc). Rebuild the AbortError here so
5892
+ // the catch below runs EXACTLY as it did before — `isCancellation` →
5893
+ // `salvageTurn` → a kept, half-written answer labelled "stopped by you".
5894
+ // Without this the salvaged text would be thrown away and the stop would
5895
+ // read as a completed turn with an empty reply.
5896
+ if (data && data.aborted) {
5897
+ const stop = new Error(data.message || 'This operation was aborted');
5898
+ stop.name = 'AbortError';
5899
+ stop.code = 'ABORT_ERR';
5900
+ throw stop;
5901
+ }
5902
+
5807
5903
  const choice = (data && data.choices && data.choices[0]) || {};
5808
5904
  const text =
5809
5905
  (choice.message && choice.message.content) ||
@@ -6175,6 +6271,13 @@ async function init() {
6175
6271
  if (fpPanel && typeof fpPanel.open === 'function') fpPanel.open();
6176
6272
  });
6177
6273
  }
6274
+ // Account > Google Drive Backup… — same panel, scrolled straight to the
6275
+ // Drive row instead of leaving Sign in with Google to be found by hand.
6276
+ if (aegis.onMenuGoogleDrive) {
6277
+ aegis.onMenuGoogleDrive(() => {
6278
+ if (fpPanel && typeof fpPanel.open === 'function') fpPanel.open({ focus: 'drive' });
6279
+ });
6280
+ }
6178
6281
  if (aegis.onMenuExportMarkdown) aegis.onMenuExportMarkdown(() => exportSession('markdown'));
6179
6282
  if (aegis.onMenuExportJson) aegis.onMenuExportJson(() => exportSession('json'));
6180
6283
  // aegis:// deep link (main.js sendDeepLinkToWindow) — delivered once the
@@ -6467,9 +6570,16 @@ async function init() {
6467
6570
 
6468
6571
  els.updateDownloadBtn.addEventListener('click', () => {
6469
6572
  els.updateDownloadBtn.disabled = true;
6470
- aegis.downloadUpdate().finally(() => {
6471
- els.updateDownloadBtn.disabled = false;
6472
- });
6573
+ // The resolved value is the post-install state: render it as well as
6574
+ // waiting for the push, so a channel whose installer finishes inside the
6575
+ // invoke still repaints (and so a failure surfaces even if the push
6576
+ // channel is not wired yet).
6577
+ Promise.resolve(aegis.downloadUpdate())
6578
+ .then((state) => { if (state && state.status) renderUpdateBanner(state); })
6579
+ .catch(() => {})
6580
+ .finally(() => {
6581
+ els.updateDownloadBtn.disabled = false;
6582
+ });
6473
6583
  });
6474
6584
 
6475
6585
  // The only place quitAndInstallUpdate is ever called — an explicit user
@@ -78,6 +78,10 @@
78
78
  audit: 'fp-audit',
79
79
  vaultList: 'fp-vault-list',
80
80
  out: 'fp-out',
81
+ driveStatus: 'fp-drive-status',
82
+ driveSignIn: 'fp-drive-signin',
83
+ driveConnect: 'fp-drive-connect',
84
+ driveSyncNow: 'fp-drive-sync',
81
85
  };
82
86
 
83
87
  // ------------------------------------------------------------- formatting
@@ -139,6 +143,23 @@
139
143
  });
140
144
  }
141
145
 
146
+ /**
147
+ * The one-line summary of the Google Drive card — `desktop/lib/
148
+ * google-connect.js`'s `status()` shape, `{signedIn, connected, email}`.
149
+ *
150
+ * Three distinct states, because "not connected" means something different
151
+ * depending on whether this machine has signed in with Google at all:
152
+ * connecting Drive before signing in attaches the tokens to a different
153
+ * account than the one this machine polls (see google-connect.js's header
154
+ * comment), so the line has to say WHICH step is next, not just "no".
155
+ */
156
+ function driveLine(status) {
157
+ if (!status || status.ok === false) return (status && status.error) || 'unavailable';
158
+ if (!status.signedIn) return 'not signed in — sign in with Google first';
159
+ if (!status.connected) return 'signed in · Google Drive not connected yet';
160
+ return `Google Drive connected${status.email ? ` · ${status.email}` : ''}`;
161
+ }
162
+
142
163
  /** The anchor answer, kept as three separate claims on purpose: "the file is
143
164
  * gone", "the file was replaced" and "the key that sealed it has moved on"
144
165
  * are three different situations, and one boolean hides the interesting one
@@ -342,6 +363,50 @@
342
363
  say: (r) => (r.ok ? `vault backend set to ${dash(r.backend)}` : `could not save that: ${r.error}`),
343
364
  });
344
365
 
366
+ /**
367
+ * Google Drive — memory backup (desktop/lib/google-connect.js, exposed
368
+ * over `aegis.driveSignIn`/`driveConnect`/`driveStatus`/`driveSyncMemory`).
369
+ *
370
+ * Distinct from the vault backend buttons above: those choose where a
371
+ * SEALED φ(α) RECORD is published (rclone or the account vault). This is
372
+ * the account's AEGIS CLOUD MEMORY, backed up to the user's own Drive
373
+ * through real Google OAuth — unrelated data, unrelated credential.
374
+ */
375
+ function paintDrive(status) {
376
+ const line = el(IDS.driveStatus);
377
+ if (line) line.textContent = driveLine(status);
378
+ const connectBtn = el(IDS.driveConnect);
379
+ if (connectBtn) connectBtn.disabled = Boolean(status && !status.signedIn);
380
+ const syncBtn = el(IDS.driveSyncNow);
381
+ if (syncBtn) syncBtn.disabled = Boolean(!status || !status.connected);
382
+ }
383
+
384
+ async function loadDriveStatus() {
385
+ const r = await call('driveStatus');
386
+ state.drive = r;
387
+ paintDrive(r);
388
+ return r;
389
+ }
390
+
391
+ const doDriveSignIn = () =>
392
+ action('sign in with Google', () => call('driveSignIn'), {
393
+ after: (r) => (r && r.ok ? loadDriveStatus() : null),
394
+ say: (r) => (r.ok ? `signed in${r.username ? ` as ${r.username}` : ''}` : `sign-in failed: ${r.error}`),
395
+ });
396
+
397
+ const doDriveConnect = () =>
398
+ action('connect Google Drive', () => call('driveConnect'), {
399
+ after: (r) => (r && r.ok ? loadDriveStatus() : null),
400
+ say: (r) => (r.ok ? `Google Drive connected${r.email ? ` · ${r.email}` : ''}` : `could not connect: ${r.error}`),
401
+ });
402
+
403
+ const doDriveSyncNow = () =>
404
+ action('back up memory to Drive', () => call('driveSyncMemory'), {
405
+ say: (r) => (r.ok
406
+ ? `backed up ${r.count} memory entr${r.count === 1 ? 'y' : 'ies'}${r.webViewLink ? ` → ${r.webViewLink}` : ''}`
407
+ : `backup failed: ${r.error}`),
408
+ });
409
+
345
410
  function paintVault(list) {
346
411
  const ul = el(IDS.vaultList);
347
412
  if (!ul) return;
@@ -368,6 +433,7 @@
368
433
  paintStatus();
369
434
  await loadAutoMint();
370
435
  await loadVaultBackend();
436
+ await loadDriveStatus();
371
437
  return state.status;
372
438
  }
373
439
 
@@ -555,7 +621,7 @@
555
621
  return Boolean(o) && !o.hidden;
556
622
  };
557
623
 
558
- async function open() {
624
+ async function open(opts) {
559
625
  const o = el(IDS.overlay);
560
626
  if (!o) return;
561
627
  o.hidden = false;
@@ -564,6 +630,22 @@
564
630
  if (d.body && d.body.classList) d.body.classList.add('fp-open');
565
631
  await refresh();
566
632
  await doVault();
633
+ // The Google Drive row sits at the bottom of a panel most of whose
634
+ // controls are unrelated (the φ(α) key). The top-menu entry for it
635
+ // (main.js's "Google Drive Backup…") opens straight here instead of
636
+ // leaving the user to find it among Seal/Verify/Publish/Vault.
637
+ if (opts && opts.focus === 'drive') {
638
+ const row = el(IDS.driveStatus);
639
+ if (row && row.scrollIntoView) row.scrollIntoView({ block: 'center' });
640
+ // Whichever Drive action is actually clickable right now — sign-in
641
+ // first, then connect, then sync — so focus lands on the next step
642
+ // instead of a disabled button.
643
+ const next = [IDS.driveSignIn, IDS.driveConnect, IDS.driveSyncNow]
644
+ .map(el)
645
+ .find((btn) => btn && !btn.disabled);
646
+ if (next) next.focus();
647
+ return;
648
+ }
567
649
  const f = el(IDS.close);
568
650
  if (f) f.focus();
569
651
  }
@@ -606,6 +688,9 @@
606
688
  bind(IDS.vaultBackendDrive, 'click', () => doSetVaultBackend('drive'));
607
689
  bind(IDS.vaultBackendCloud, 'click', () => doSetVaultBackend('aegiscloud'));
608
690
  bind(IDS.vaultBackendOff, 'click', () => doSetVaultBackend('off'));
691
+ bind(IDS.driveSignIn, 'click', doDriveSignIn);
692
+ bind(IDS.driveConnect, 'click', doDriveConnect);
693
+ bind(IDS.driveSyncNow, 'click', doDriveSyncNow);
609
694
  // The auto-seal switch is the ONE control on this panel that can file a
610
695
  // record with nobody watching, so it is the one that must repaint from
611
696
  // main's answer rather than from the checkbox the user just clicked.
@@ -626,8 +711,12 @@
626
711
  state,
627
712
  // Exposed for the test and for app.js's on-demand repaint. Every one is
628
713
  // idempotent, so calling them from a console is safe.
629
- actions: { doKeygen, doSeal, doSealNow, doVerify, doPublish, doAnchor, doBackup, doVault, doAudit, doSetVaultBackend },
714
+ actions: {
715
+ doKeygen, doSeal, doSealNow, doVerify, doPublish, doAnchor, doBackup, doVault, doAudit,
716
+ doSetVaultBackend, doDriveSignIn, doDriveConnect, doDriveSyncNow,
717
+ },
630
718
  loadVaultBackend,
719
+ loadDriveStatus,
631
720
  };
632
721
  }
633
722
 
@@ -643,6 +732,7 @@
643
732
  auditVerdict,
644
733
  sealLine,
645
734
  autoMintLine,
735
+ driveLine,
646
736
  dash,
647
737
  };
648
738
  });
@@ -927,6 +927,23 @@
927
927
 
928
928
  <ul class="fp-vault-list" id="fp-vault-list"></ul>
929
929
 
930
+ <!-- Google Drive — memory backup. Unrelated to the vault above: that
931
+ publishes a sealed φ(α) RECORD; this backs up the account's AEGIS
932
+ CLOUD MEMORY to the user's own Drive through real Google OAuth
933
+ (desktop/lib/google-connect.js). Two buttons because connecting
934
+ Drive is only coherent once this machine has signed in with the
935
+ SAME Google identity — see that file's header comment — so
936
+ "Connect Drive" stays disabled (fingerprint.js paintDrive()) until
937
+ sign-in has actually landed. -->
938
+ <div class="fp-controls">
939
+ <div class="fp-row"><span class="fp-k">Google Drive</span><span class="fp-v" id="fp-drive-status">–</span></div>
940
+ <div class="fp-actions">
941
+ <button type="button" id="fp-drive-signin" class="ghost-btn">Sign in with Google</button>
942
+ <button type="button" id="fp-drive-connect" class="ghost-btn" disabled>Connect Drive</button>
943
+ <button type="button" id="fp-drive-sync" class="ghost-btn" disabled>Back up memory now</button>
944
+ </div>
945
+ </div>
946
+
930
947
  <div class="fp-out" id="fp-out">Ready. The key is never displayed.</div>
931
948
  </div>
932
949
  </div>