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.
- package/README.md +1 -1
- package/package.json +2 -1
- package/scripts/predist.mjs +13 -2
- package/vendor/cli/bin/aegiscode.js +12 -0
- package/vendor/cli/package.json +2 -1
- package/vendor/cli/scripts/predist.mjs +6 -3
- package/vendor/cli/src/app.js +102 -1
- package/vendor/cli/src/chatflow.js +14 -2
- package/vendor/cli/src/commands.js +61 -5
- package/vendor/cli/src/limits.js +1 -1
- package/vendor/cli/src/provenance.lock.json +2 -2
- package/vendor/cli/src/update.js +103 -12
- package/vendor/cli/vendor/client/aegis.js +297 -6
- package/vendor/cli/vendor/client/drive-connect.js +112 -0
- package/vendor/cli/vendor/client/drive-upload.js +176 -0
- package/vendor/cli/vendor/client/google-signin.js +12 -4
- package/vendor/cli/vendor/client/model-discovery.js +43 -0
- package/vendor/cli/vendor/client/update.js +100 -8
- package/vendor/cli/vendor/desktop/lib/local/engine.js +138 -2
- package/vendor/cli/vendor/desktop/lib/local/entitlement.js +7 -1
- package/vendor/cli/vendor/desktop/lib/local/prompt.js +67 -37
- package/vendor/cli/vendor/desktop/lib/local/tools.js +49 -13
- package/vendor/desktop/lib/google-connect.js +229 -0
- package/vendor/desktop/lib/local/engine.js +138 -2
- package/vendor/desktop/lib/local/entitlement.js +7 -1
- package/vendor/desktop/lib/local/prompt.js +67 -37
- package/vendor/desktop/lib/local/tools.js +49 -13
- package/vendor/desktop/main.js +446 -128
- package/vendor/desktop/package.json +2 -4
- package/vendor/desktop/preload.js +27 -5
- package/vendor/desktop/renderer/app.js +117 -7
- package/vendor/desktop/renderer/fingerprint.js +92 -2
- package/vendor/desktop/renderer/index.html +17 -0
- package/vendor/desktop/vendor/aegis.js +297 -6
- package/vendor/desktop/vendor/drive-connect.js +112 -0
- package/vendor/desktop/vendor/drive-upload.js +176 -0
- package/vendor/desktop/vendor/google-signin.js +12 -4
- package/vendor/desktop/vendor/model-discovery.js +43 -0
- package/vendor/desktop/vendor/update.js +100 -8
package/vendor/desktop/main.js
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
const path = require('node:path');
|
|
28
28
|
const fs = require('node:fs');
|
|
29
|
+
const { execFile } = require('node:child_process');
|
|
29
30
|
const { pathToFileURL } = require('node:url');
|
|
30
31
|
|
|
31
32
|
// Dev / CI / smoke-test layout: desktop/ lives inside the repo, so the shared
|
|
@@ -88,6 +89,30 @@ try {
|
|
|
88
89
|
sharedTopup = require('./vendor/topup.js');
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
// Google identity + Drive (client/google-signin.js, client/drive-connect.js,
|
|
93
|
+
// client/drive-upload.js). google-signin.js already existed for the CLI's
|
|
94
|
+
// `connect --google`; this is the first time desktop wires any of it. See
|
|
95
|
+
// lib/google-connect.js for how the three are sequenced.
|
|
96
|
+
let googleSignIn;
|
|
97
|
+
try {
|
|
98
|
+
googleSignIn = require('../client/google-signin.js');
|
|
99
|
+
} catch {
|
|
100
|
+
googleSignIn = require('./vendor/google-signin.js');
|
|
101
|
+
}
|
|
102
|
+
let driveConnectLib;
|
|
103
|
+
try {
|
|
104
|
+
driveConnectLib = require('../client/drive-connect.js');
|
|
105
|
+
} catch {
|
|
106
|
+
driveConnectLib = require('./vendor/drive-connect.js');
|
|
107
|
+
}
|
|
108
|
+
let driveUploadLib;
|
|
109
|
+
try {
|
|
110
|
+
driveUploadLib = require('../client/drive-upload.js');
|
|
111
|
+
} catch {
|
|
112
|
+
driveUploadLib = require('./vendor/drive-upload.js');
|
|
113
|
+
}
|
|
114
|
+
const { createGoogleConnect } = require('./lib/google-connect.js');
|
|
115
|
+
|
|
91
116
|
// The device fingerprint (client/device-fingerprint.js) — the SAME identity the
|
|
92
117
|
// auto-provision path registers a device-key against, now also carried in every
|
|
93
118
|
// presence beat so one laptop is one machine in the admin panel rather than one
|
|
@@ -267,6 +292,12 @@ const MENU_EXPORT_JSON_CHANNEL = `${IPC_PREFIX}menuExportJson`;
|
|
|
267
292
|
* as the channels above: main has no panel state, it just asks the renderer to
|
|
268
293
|
* open the sheet it already owns. */
|
|
269
294
|
const MENU_FINGERPRINT_CHANNEL = `${IPC_PREFIX}menuFingerprint`;
|
|
295
|
+
/** Account > Google Drive Backup… — opens the same φ(α) sheet as the item
|
|
296
|
+
* above, scrolled straight to the Drive row. Only on the menu once an AEGIS
|
|
297
|
+
* account key exists (buildAppMenu's `enabled`, rebuilt on accountKey's
|
|
298
|
+
* onChange): signing in with Google is itself how an anonymous install gets
|
|
299
|
+
* one, so the item stays but disabled until that first key lands. */
|
|
300
|
+
const MENU_GOOGLE_DRIVE_CHANNEL = `${IPC_PREFIX}menuGoogleDrive`;
|
|
270
301
|
|
|
271
302
|
/**
|
|
272
303
|
* Main -> renderer push for a resolved aegis:// deep link (D? deep linking).
|
|
@@ -388,6 +419,54 @@ function errorText(err) {
|
|
|
388
419
|
return err && err.message ? err.message : String(err);
|
|
389
420
|
}
|
|
390
421
|
|
|
422
|
+
/** Is this rejection the user pressing stop?
|
|
423
|
+
*
|
|
424
|
+
* `engine.cancel()` aborts the session's AbortController, and the in-flight
|
|
425
|
+
* transport turn rejects with `DOMException [AbortError]: This operation was
|
|
426
|
+
* aborted`. That is the app working exactly as asked — but `ipcMain.handle`
|
|
427
|
+
* prints EVERY rejection with a full stack ("Error occurred in handler for
|
|
428
|
+
* 'model:chat':"), so a deliberate Ctrl-X was the loudest thing in the
|
|
429
|
+
* terminal and read like a crash. The renderer cannot tell it either: an
|
|
430
|
+
* abort that crosses IPC loses `name`/`code` and arrives as a bare message,
|
|
431
|
+
* which is why the classification is made HERE, where the object is intact,
|
|
432
|
+
* and handed on as data (see the `aborted` resolution in registerModelIpc).
|
|
433
|
+
*
|
|
434
|
+
* Evidence only — `aegisCancelled`, `name`, `code` — and never the message.
|
|
435
|
+
*
|
|
436
|
+
* The first version also matched any message containing "abort", as the
|
|
437
|
+
* renderer's `isCancellation` backstop does. That is wrong on this side of the
|
|
438
|
+
* boundary: the renderer has a per-turn `userStopped` flag to corroborate a
|
|
439
|
+
* fuzzy match against, and main has no such notion, so the message WAS the
|
|
440
|
+
* whole signal. A genuine failure saying "connection aborted by peer" or
|
|
441
|
+
* "upstream aborted the connection" would have been resolved as a clean stop
|
|
442
|
+
* and quietly discarded, since this branch rethrows everything else. The bit
|
|
443
|
+
* that cannot lie is stamped on the error by the engine at the point it knows
|
|
444
|
+
* for certain — its own controller's signal read aborted — which no upstream
|
|
445
|
+
* cause can fake. `name`/`code` are kept because a DOMException raised by
|
|
446
|
+
* `AbortController.abort()` itself carries them reliably.
|
|
447
|
+
*/
|
|
448
|
+
function isAbortShapedError(err) {
|
|
449
|
+
if (!err || typeof err !== 'object') return false;
|
|
450
|
+
if (err.aegisCancelled === true) return true;
|
|
451
|
+
return err.name === 'AbortError' || err.code === 'ABORT_ERR';
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/** The resolved stand-in for a stopped turn.
|
|
455
|
+
*
|
|
456
|
+
* Same shape as the `bestEffortFailed` payload below, so every existing
|
|
457
|
+
* `data.choices[0].message.content` reader keeps working, plus the
|
|
458
|
+
* `aborted` discriminator the renderer keys its salvage path off.
|
|
459
|
+
*/
|
|
460
|
+
function abortedTurnPayload(err) {
|
|
461
|
+
return {
|
|
462
|
+
aborted: true,
|
|
463
|
+
status: 0,
|
|
464
|
+
code: 'ABORT_ERR',
|
|
465
|
+
message: errorText(err),
|
|
466
|
+
choices: [{ message: { content: '' } }],
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
|
|
391
470
|
/**
|
|
392
471
|
* Precise classification of a cloud-sync refusal — the desktop port of
|
|
393
472
|
* `describeError()` in cli/src/cloudsync.js, so both hosts name a 402/401 the
|
|
@@ -2049,6 +2128,21 @@ function registerModelIpc(ipcMain, engine, sessionsDir, aegis, onReplyFinished,
|
|
|
2049
2128
|
if (name === 'chat') {
|
|
2050
2129
|
ipcMain.handle(`${MODEL_PREFIX}${name}`, (event, payload) => {
|
|
2051
2130
|
const opts = { ...(payload || {}) };
|
|
2131
|
+
// A background dispatch the user never typed — the welcome panel's
|
|
2132
|
+
// greeting, a discovery lane — is allowed to fail quietly. A REJECTED
|
|
2133
|
+
// ipcMain.handle is printed by Electron itself ("Error occurred in
|
|
2134
|
+
// handler for 'model:chat':" plus the whole stack), and the renderer
|
|
2135
|
+
// that catches it is another process, so a greeting that timed out on
|
|
2136
|
+
// boot put a provider stack trace in the terminal as the first thing
|
|
2137
|
+
// the app said. Nothing was lost: those lanes already treat "no answer"
|
|
2138
|
+
// as "keep what is on screen". So the flag turns the rejection into a
|
|
2139
|
+
// resolved classified payload (the renderer gets MORE than it used to —
|
|
2140
|
+
// status and code, which `ipcRenderer.invoke` would have flattened to a
|
|
2141
|
+
// message string anyway) and the terminal gets one line, not a stack.
|
|
2142
|
+
const bestEffort = opts.bestEffort === true;
|
|
2143
|
+
// …and it never reaches the wire: this is a host-side instruction, not
|
|
2144
|
+
// a provider field, and the engine forwards what it recognises.
|
|
2145
|
+
delete opts.bestEffort;
|
|
2052
2146
|
// The rung every renderer sends is low|medium|high; this is the one
|
|
2053
2147
|
// place a stale window can still hand us the retired `auto` (a page
|
|
2054
2148
|
// loaded before the select lost that row, or a renderer that forgot to
|
|
@@ -2074,10 +2168,59 @@ function registerModelIpc(ipcMain, engine, sessionsDir, aegis, onReplyFinished,
|
|
|
2074
2168
|
sender.send(CHAT_DELTA_CHANNEL, taggedChunk(chunk, opts.sessionId));
|
|
2075
2169
|
}
|
|
2076
2170
|
};
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2171
|
+
const lane = opts.class || 'model';
|
|
2172
|
+
const turn = handler({ ...opts, onStream: forward });
|
|
2173
|
+
if (!bestEffort) {
|
|
2174
|
+
// A user-pressed stop must not be printed as an app error. The
|
|
2175
|
+
// rejection itself is correct — it is how the turn unwinds — so the
|
|
2176
|
+
// catch is added AFTER withReplyNotify, which means the success and
|
|
2177
|
+
// "reply ready" notification paths are untouched and only the
|
|
2178
|
+
// rejection is reclassified. Anything that is not an abort rethrows
|
|
2179
|
+
// verbatim: a genuine provider failure still reaches the renderer as
|
|
2180
|
+
// a rejection, and still prints, because that is information.
|
|
2181
|
+
//
|
|
2182
|
+
// Resolved rather than rethrown because `ipcMain.handle` prints what
|
|
2183
|
+
// it rejects and no flag suppresses that. The renderer turns this
|
|
2184
|
+
// payload back into an AbortError (see `models.chat` in app.js), so
|
|
2185
|
+
// `isCancellation` → `salvageTurn` still runs and a half-written
|
|
2186
|
+
// answer is kept and labelled "stopped by you" — the same outcome as
|
|
2187
|
+
// before, minus the stack trace.
|
|
2188
|
+
return withReplyNotify(turn, event, onReplyFinished).catch((err) => {
|
|
2189
|
+
if (!isAbortShapedError(err)) throw err;
|
|
2190
|
+
console.warn(
|
|
2191
|
+
`[model] ${lane} turn stopped before it finished: ${errorText(err)} [ABORT_ERR]`
|
|
2192
|
+
);
|
|
2193
|
+
return abortedTurnPayload(err);
|
|
2194
|
+
});
|
|
2195
|
+
}
|
|
2196
|
+
return turn.then(
|
|
2197
|
+
(result) => {
|
|
2198
|
+
if (onReplyFinished) onReplyFinished(event, result);
|
|
2199
|
+
return result;
|
|
2200
|
+
},
|
|
2201
|
+
(err) => {
|
|
2202
|
+
// Classified, not verbatim: the status and code are what tell an
|
|
2203
|
+
// operator which failure this was (0/timeout, 402 balance, 401
|
|
2204
|
+
// key), and neither survives the IPC boundary unless it is stated
|
|
2205
|
+
// here. The stack does not survive anything useful.
|
|
2206
|
+
const status = err && typeof err.status === 'number' ? err.status : 0;
|
|
2207
|
+
const code = (err && err.code) || '';
|
|
2208
|
+
console.warn(
|
|
2209
|
+
`[model] background ${lane} turn produced no answer: ${errorText(err)}` +
|
|
2210
|
+
`${status ? ` (status ${status})` : ''}${code ? ` [${code}]` : ''}`
|
|
2211
|
+
);
|
|
2212
|
+
// Resolved, so Electron does not print the rejection and the lane
|
|
2213
|
+
// that asked can read "nothing came back" without a try/catch.
|
|
2214
|
+
// `bestEffortFailed` is the discriminator; the empty content keeps
|
|
2215
|
+
// every existing `data.choices[0].message.content` reader working.
|
|
2216
|
+
return {
|
|
2217
|
+
bestEffortFailed: true,
|
|
2218
|
+
status,
|
|
2219
|
+
code: code || undefined,
|
|
2220
|
+
message: errorText(err),
|
|
2221
|
+
choices: [{ message: { content: '' } }],
|
|
2222
|
+
};
|
|
2223
|
+
}
|
|
2081
2224
|
);
|
|
2082
2225
|
});
|
|
2083
2226
|
continue;
|
|
@@ -2698,35 +2841,39 @@ const ACCOUNT_STATUS_CHANNEL = `${IPC_PREFIX}accountStatusChanged`;
|
|
|
2698
2841
|
const UPDATE_CHECK_INTERVAL_MS = 4 * 60 * 60 * 1000;
|
|
2699
2842
|
|
|
2700
2843
|
/**
|
|
2701
|
-
*
|
|
2702
|
-
*
|
|
2703
|
-
*
|
|
2844
|
+
* The npm registry is the ONLY update channel, packaged build included.
|
|
2845
|
+
*
|
|
2846
|
+
* There used to be a second one: electron-updater reading GitHub Releases via
|
|
2847
|
+
* electron-builder.yml's `publish:` feed. That feed never existed. The repo
|
|
2848
|
+
* named there (aegiscloud-devs/aegiscode-plugin) is private and has no
|
|
2849
|
+
* published release, so every launch of a packaged app failed its check with
|
|
2704
2850
|
*
|
|
2705
|
-
*
|
|
2706
|
-
*
|
|
2707
|
-
* calling checkForUpdates() there would just throw on every launch. Rather
|
|
2708
|
-
* than special-case that error, `isPackaged: false` skips wiring the real
|
|
2709
|
-
* autoUpdater entirely and every method resolves a harmless 'disabled'
|
|
2710
|
-
* state — dev never touches the network or the update machinery.
|
|
2851
|
+
* 404 "method: GET url: .../releases.atom Please double check that your
|
|
2852
|
+
* authentication token is correct..."
|
|
2711
2853
|
*
|
|
2712
|
-
*
|
|
2713
|
-
*
|
|
2714
|
-
*
|
|
2715
|
-
*
|
|
2716
|
-
*
|
|
2717
|
-
*
|
|
2854
|
+
* — GitHub answers 404 rather than 403 to an unauthenticated request on a
|
|
2855
|
+
* private repo, and electron-updater reports every non-200 as an auth problem,
|
|
2856
|
+
* so the banner blamed the user's token for a destination that was never
|
|
2857
|
+
* public and never had a release. Meanwhile aegis-desktop ships to npm on
|
|
2858
|
+
* every release. So the packaged path now uses the same npm manager as every
|
|
2859
|
+
* other install, and `publish:`/electron-updater are gone rather than left
|
|
2860
|
+
* pointing at a feed nobody can read.
|
|
2861
|
+
*
|
|
2862
|
+
* Checking happens automatically on ready and on the interval below; nothing
|
|
2863
|
+
* here installs or restarts on its own. `download()` runs only on the banner's
|
|
2864
|
+
* explicit click, and `quitAndInstall()` only on "Restart to install".
|
|
2718
2865
|
*/
|
|
2719
2866
|
|
|
2720
2867
|
/**
|
|
2721
|
-
* Update state backed by the npm registry
|
|
2722
|
-
*
|
|
2868
|
+
* Update state backed by the npm registry — the channel for EVERY install,
|
|
2869
|
+
* packaged AppImage/deb/NSIS/dmg included.
|
|
2723
2870
|
*
|
|
2724
|
-
*
|
|
2725
|
-
*
|
|
2726
|
-
*
|
|
2727
|
-
*
|
|
2728
|
-
*
|
|
2729
|
-
*
|
|
2871
|
+
* Keeps the state shape the IPC dispatch and the renderer banner consume
|
|
2872
|
+
* (status/check/download/quitAndInstall/start), so neither needed a branch
|
|
2873
|
+
* when the packaged path stopped using electron-updater. Which installer owns
|
|
2874
|
+
* this copy is `detectInstallMethod`'s answer, and the command shown is that
|
|
2875
|
+
* plan's `instruction` — an AppImage or a global npm install must not be told
|
|
2876
|
+
* to run a command that writes a different copy.
|
|
2730
2877
|
*/
|
|
2731
2878
|
/**
|
|
2732
2879
|
* How long to wait before re-checking after a FAILED background check: 1m, 5m,
|
|
@@ -2767,10 +2914,21 @@ function describeRegistryFailure(reason, status, pkg) {
|
|
|
2767
2914
|
|
|
2768
2915
|
function createNpmUpdateManager({
|
|
2769
2916
|
onStatus,
|
|
2917
|
+
// A packaged build (AppImage/deb/NSIS/dmg) is NOT the npm copy. `npm i -g`
|
|
2918
|
+
// from inside one writes a SECOND install beside the running binary and the
|
|
2919
|
+
// relaunch then starts the unchanged original — a button that appears to work
|
|
2920
|
+
// and changes nothing. The version news still comes from npm (there is no
|
|
2921
|
+
// other channel), but the packaged case names the install instead of
|
|
2922
|
+
// pretending to apply it.
|
|
2923
|
+
packaged = false,
|
|
2770
2924
|
now = () => Date.now(),
|
|
2771
2925
|
fetchImpl,
|
|
2772
2926
|
setTimeoutImpl = setTimeout,
|
|
2773
2927
|
clearTimeoutImpl = clearTimeout,
|
|
2928
|
+
// Both injectable so the install path is testable without running npm or
|
|
2929
|
+
// killing the test runner's own process.
|
|
2930
|
+
runUpgrade,
|
|
2931
|
+
relaunch,
|
|
2774
2932
|
} = {}) {
|
|
2775
2933
|
const PKG = 'aegis-desktop';
|
|
2776
2934
|
let current = 'unknown';
|
|
@@ -2792,6 +2950,11 @@ function createNpmUpdateManager({
|
|
|
2792
2950
|
attempts: 0,
|
|
2793
2951
|
retryInMs: 0,
|
|
2794
2952
|
command: null,
|
|
2953
|
+
// `plan` is the shared verdict the banner was rendered from. `download()`
|
|
2954
|
+
// installs from THIS object rather than re-deriving a command, so the
|
|
2955
|
+
// button can only ever run what the banner promised.
|
|
2956
|
+
plan: null,
|
|
2957
|
+
method: null,
|
|
2795
2958
|
canDownload: false,
|
|
2796
2959
|
};
|
|
2797
2960
|
const set = (patch) => {
|
|
@@ -2818,6 +2981,34 @@ function createNpmUpdateManager({
|
|
|
2818
2981
|
let inFlight = null;
|
|
2819
2982
|
let interval = null;
|
|
2820
2983
|
|
|
2984
|
+
/**
|
|
2985
|
+
* How THIS desktop copy was installed: 'npm' | 'pip' | 'npx' | 'source'.
|
|
2986
|
+
*
|
|
2987
|
+
* Memoised — it cannot change while the process runs. `entry` is the app
|
|
2988
|
+
* directory: an unpackaged run is either a global npm install (a path with
|
|
2989
|
+
* `node_modules` in it), a checkout (`desktop/` beside `.git`), or a pip
|
|
2990
|
+
* launcher, which declares itself through AEGIS_INSTALL_METHOD because
|
|
2991
|
+
* nothing in the filesystem would otherwise say so.
|
|
2992
|
+
*/
|
|
2993
|
+
let methodCache = null;
|
|
2994
|
+
function detectMethod() {
|
|
2995
|
+
if (methodCache) return methodCache;
|
|
2996
|
+
const detect = updater && updater.detectInstallMethod;
|
|
2997
|
+
if (typeof detect !== 'function') { methodCache = 'npm'; return methodCache; }
|
|
2998
|
+
try {
|
|
2999
|
+
methodCache = detect({
|
|
3000
|
+
env: process.env,
|
|
3001
|
+
argv: process.argv,
|
|
3002
|
+
pkg: PKG,
|
|
3003
|
+
entry: __dirname,
|
|
3004
|
+
fileExists: (rel) => fs.existsSync(path.resolve(__dirname, '..', rel)),
|
|
3005
|
+
});
|
|
3006
|
+
} catch {
|
|
3007
|
+
methodCache = 'npm';
|
|
3008
|
+
}
|
|
3009
|
+
return methodCache;
|
|
3010
|
+
}
|
|
3011
|
+
|
|
2821
3012
|
/** 1m, 5m, 15m, 60m, 60m… — capped, never unbounded. */
|
|
2822
3013
|
const delayFor = () =>
|
|
2823
3014
|
UPDATE_RETRY_BACKOFF_MS[Math.min(Math.max(attempts - 1, 0), UPDATE_RETRY_BACKOFF_MS.length - 1)];
|
|
@@ -2853,8 +3044,8 @@ function createNpmUpdateManager({
|
|
|
2853
3044
|
*
|
|
2854
3045
|
* `intervalMs: 0` is deliberate: the *schedule* stays this manager's (it
|
|
2855
3046
|
* polls every `UPDATE_CHECK_INTERVAL_MS` and drives its retry ladder off the
|
|
2856
|
-
* result), but the *check* is not re-implemented here. The desktop
|
|
2857
|
-
*
|
|
3047
|
+
* result), but the *check* is not re-implemented here. The desktop's applier
|
|
3048
|
+
* is the npm install above; it has no version fetch of its own.
|
|
2858
3049
|
*/
|
|
2859
3050
|
async function fetchDetailed() {
|
|
2860
3051
|
if (fetchImpl) return fetchImpl({ pkg: PKG });
|
|
@@ -2917,8 +3108,14 @@ function createNpmUpdateManager({
|
|
|
2917
3108
|
// The npm applier's instruction comes from the ONE shared verdict
|
|
2918
3109
|
// (`updatePlan`), the same call `aegiscode`'s notice and `aegis doctor`
|
|
2919
3110
|
// render — so the banner cannot offer a command the terminal would not.
|
|
3111
|
+
//
|
|
3112
|
+
// `method` is this copy's install channel, detected the same way the
|
|
3113
|
+
// CLI does. It matters because `npm i -g` against a pip-installed
|
|
3114
|
+
// aegis-desktop writes a second copy beside the one the user actually
|
|
3115
|
+
// runs: the button would appear to work and change nothing.
|
|
3116
|
+
const method = detectMethod();
|
|
2920
3117
|
const plan = typeof updater.updatePlan === 'function'
|
|
2921
|
-
? updater.updatePlan({ current, latest: res.latest, behind: true, channel: 'npm', pkg: PKG })
|
|
3118
|
+
? updater.updatePlan({ current, latest: res.latest, behind: true, channel: 'npm', pkg: PKG, method })
|
|
2922
3119
|
: null;
|
|
2923
3120
|
return set({
|
|
2924
3121
|
status: 'available',
|
|
@@ -2928,11 +3125,24 @@ function createNpmUpdateManager({
|
|
|
2928
3125
|
transient: false,
|
|
2929
3126
|
attempts: 0,
|
|
2930
3127
|
retryInMs: 0,
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
//
|
|
2934
|
-
//
|
|
2935
|
-
|
|
3128
|
+
plan,
|
|
3129
|
+
method,
|
|
3130
|
+
// A packaged build is not the npm copy, so it must not be told to run
|
|
3131
|
+
// `npm i -g` — that writes a second install and the relaunch starts
|
|
3132
|
+
// the unchanged original. It gets the same version news, addressed to
|
|
3133
|
+
// the install that actually owns it.
|
|
3134
|
+
command: packaged
|
|
3135
|
+
? `${res.latest} is published — reinstall AEGIS Desktop from the installer to pick it up`
|
|
3136
|
+
: (plan && plan.instruction) || `npm i -g ${PKG}@latest`,
|
|
3137
|
+
// Whether `command` is something to TYPE or a sentence to READ. The
|
|
3138
|
+
// banner otherwise prefixes "run:" to it, which is right for
|
|
3139
|
+
// `npm i -g aegis-desktop@latest` and wrong for a channel with no
|
|
3140
|
+
// command at all (packaged, npx, a source checkout).
|
|
3141
|
+
commandIsSentence: packaged || Boolean(plan && !plan.apply),
|
|
3142
|
+
// A channel with an `apply` argv has something this process can run;
|
|
3143
|
+
// `npx`, a source checkout and a packaged build do not, and offering
|
|
3144
|
+
// a button that silently does nothing is worse than the command alone.
|
|
3145
|
+
canDownload: Boolean(plan && plan.apply) && !packaged,
|
|
2936
3146
|
});
|
|
2937
3147
|
}
|
|
2938
3148
|
|
|
@@ -2974,16 +3184,98 @@ function createNpmUpdateManager({
|
|
|
2974
3184
|
}
|
|
2975
3185
|
}
|
|
2976
3186
|
|
|
3187
|
+
/**
|
|
3188
|
+
* Run one installer argv and resolve to a status patch. Never rejects.
|
|
3189
|
+
*
|
|
3190
|
+
* `npm i -g` against a global prefix needs no elevation the way a system
|
|
3191
|
+
* package does, but it still writes outside the app dir and it can fail on a
|
|
3192
|
+
* permissions wall — so a failure is reported with npm's own last lines
|
|
3193
|
+
* rather than a blanket "update failed".
|
|
3194
|
+
*/
|
|
3195
|
+
function runInstall(target) {
|
|
3196
|
+
const exec = runUpgrade || ((cmd, args) => new Promise((resolve) => {
|
|
3197
|
+
execFile(cmd, args, { timeout: 180_000, windowsHide: true }, (err, stdout, stderr) => {
|
|
3198
|
+
if (err) return resolve({ ok: false, output: String(stderr || stdout || err.message || err) });
|
|
3199
|
+
resolve({ ok: true, output: String(stdout || '') });
|
|
3200
|
+
});
|
|
3201
|
+
}));
|
|
3202
|
+
return Promise.resolve(exec(target.command, target.args)).then(
|
|
3203
|
+
(res) => ({ ok: Boolean(res && res.ok), output: String((res && res.output) || '') }),
|
|
3204
|
+
(err) => ({ ok: false, output: errorText(err) }),
|
|
3205
|
+
);
|
|
3206
|
+
}
|
|
3207
|
+
|
|
2977
3208
|
return {
|
|
2978
3209
|
status: () => state,
|
|
2979
3210
|
check,
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
3211
|
+
/**
|
|
3212
|
+
* The banner's Download button. It INSTALLS.
|
|
3213
|
+
*
|
|
3214
|
+
* This used to be a no-op that re-set `command` and `canDownload:false`:
|
|
3215
|
+
* the button was hidden for every npm install, so the affordance and the
|
|
3216
|
+
* action were both missing, and the only way to update the window was to
|
|
3217
|
+
* read a shell command off a banner and type it into a different app.
|
|
3218
|
+
*
|
|
3219
|
+
* It still runs only on an explicit click (nothing here installs on a
|
|
3220
|
+
* timer), and it still does not hot-swap the running process: after a
|
|
3221
|
+
* successful install the honest state is 'downloaded' — "restart to install"
|
|
3222
|
+
* — because the new files are on disk and this process is still the old
|
|
3223
|
+
* ones. Packaged and npm installs share that promise, so the banner needs
|
|
3224
|
+
* no branch.
|
|
3225
|
+
*/
|
|
3226
|
+
download: async () => {
|
|
3227
|
+
// Nothing to run for a packaged build — see the `packaged` option above.
|
|
3228
|
+
const target = !packaged && state.plan && state.plan.apply;
|
|
3229
|
+
if (!target) {
|
|
3230
|
+
// Nothing to install on this channel (npx fetches fresh every run; a
|
|
3231
|
+
// checkout belongs to its git remote). Say who owns it instead of
|
|
3232
|
+
// pretending to act.
|
|
3233
|
+
return set({
|
|
3234
|
+
status: state.status === 'available' ? 'available' : state.status,
|
|
3235
|
+
command: (state.plan && state.plan.instruction) || state.command,
|
|
3236
|
+
canDownload: false,
|
|
3237
|
+
});
|
|
3238
|
+
}
|
|
3239
|
+
set({ status: 'downloading', error: null, progress: 0 });
|
|
3240
|
+
const res = await runInstall(target);
|
|
3241
|
+
if (!res.ok) {
|
|
3242
|
+
// `transient: false` deliberately: an installer that refused is not a
|
|
3243
|
+
// network blip, and the retry ladder must not quietly re-run an npm
|
|
3244
|
+
// install every minute.
|
|
3245
|
+
return set({
|
|
3246
|
+
status: 'error',
|
|
3247
|
+
transient: false,
|
|
3248
|
+
error: res.output.trim().split('\n').slice(-3).join(' ').trim() || 'the installer failed',
|
|
3249
|
+
command: `${target.command} ${target.args.join(' ')}`,
|
|
3250
|
+
});
|
|
3251
|
+
}
|
|
3252
|
+
return set({
|
|
3253
|
+
status: 'downloaded',
|
|
3254
|
+
version: state.version,
|
|
3255
|
+
error: null,
|
|
3256
|
+
progress: 100,
|
|
3257
|
+
command: `npm i -g ${PKG}@latest`,
|
|
3258
|
+
canDownload: false,
|
|
3259
|
+
});
|
|
3260
|
+
},
|
|
3261
|
+
/**
|
|
3262
|
+
* "Restart to install". Relaunches the app so the freshly installed files
|
|
3263
|
+
* are what runs — `app.relaunch()` before `app.exit()`, the standard pair,
|
|
3264
|
+
* because `app.quit()` alone would not start a new process.
|
|
3265
|
+
*/
|
|
3266
|
+
quitAndInstall: () => {
|
|
3267
|
+
if (state.status !== 'downloaded') return;
|
|
3268
|
+
const again = relaunch || (() => {
|
|
3269
|
+
try {
|
|
3270
|
+
const { app } = require('electron');
|
|
3271
|
+
app.relaunch();
|
|
3272
|
+
app.exit(0);
|
|
3273
|
+
} catch {
|
|
3274
|
+
/* not under Electron (a test or the CLI): nothing to relaunch */
|
|
3275
|
+
}
|
|
3276
|
+
});
|
|
3277
|
+
again();
|
|
3278
|
+
},
|
|
2987
3279
|
start: () => {
|
|
2988
3280
|
check().catch(() => {});
|
|
2989
3281
|
interval = setInterval(() => check().catch(() => {}), UPDATE_CHECK_INTERVAL_MS);
|
|
@@ -3000,7 +3292,7 @@ function createNpmUpdateManager({
|
|
|
3000
3292
|
};
|
|
3001
3293
|
}
|
|
3002
3294
|
|
|
3003
|
-
function createUpdateManager({
|
|
3295
|
+
function createUpdateManager({ isPackaged, onStatus }) {
|
|
3004
3296
|
let state = { status: 'idle', version: null, error: null, canDownload: false };
|
|
3005
3297
|
|
|
3006
3298
|
function setState(patch) {
|
|
@@ -3008,76 +3300,16 @@ function createUpdateManager({ autoUpdater, isPackaged, onStatus }) {
|
|
|
3008
3300
|
if (onStatus) onStatus(state);
|
|
3009
3301
|
}
|
|
3010
3302
|
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
// feed the packaged path depends on does not exist, while the registry we
|
|
3022
|
-
// actually publish to does.
|
|
3023
|
-
//
|
|
3024
|
-
// npm is therefore the real update channel. Checking it costs one request
|
|
3025
|
-
// a day, reports the version and the exact command, and deliberately does
|
|
3026
|
-
// NOT self-install: replacing your own running process mid-session is a
|
|
3027
|
-
// different promise from telling you an update exists.
|
|
3028
|
-
return createNpmUpdateManager({ onStatus: setState });
|
|
3029
|
-
}
|
|
3030
|
-
|
|
3031
|
-
autoUpdater.autoDownload = false;
|
|
3032
|
-
autoUpdater.autoInstallOnAppQuit = false;
|
|
3033
|
-
|
|
3034
|
-
autoUpdater.on('checking-for-update', () => setState({ status: 'checking', error: null }));
|
|
3035
|
-
autoUpdater.on('update-available', (info) =>
|
|
3036
|
-
setState({ status: 'available', version: info && info.version, error: null, canDownload: true })
|
|
3037
|
-
);
|
|
3038
|
-
autoUpdater.on('update-not-available', () => setState({ status: 'up-to-date', error: null }));
|
|
3039
|
-
autoUpdater.on('download-progress', (progress) =>
|
|
3040
|
-
setState({ status: 'downloading', progress: progress && progress.percent })
|
|
3041
|
-
);
|
|
3042
|
-
autoUpdater.on('update-downloaded', (info) =>
|
|
3043
|
-
setState({ status: 'downloaded', version: info && info.version, error: null })
|
|
3044
|
-
);
|
|
3045
|
-
// Any failure — offline, a malformed feed, a 404 on latest.yml — lands
|
|
3046
|
-
// here instead of an unhandled rejection, since electron-updater emits
|
|
3047
|
-
// 'error' for background failures that occur outside the promise a
|
|
3048
|
-
// check()/download() call is awaiting.
|
|
3049
|
-
autoUpdater.on('error', (err) => setState({ status: 'error', error: errorText(err) }));
|
|
3050
|
-
|
|
3051
|
-
async function check() {
|
|
3052
|
-
try {
|
|
3053
|
-
await autoUpdater.checkForUpdates();
|
|
3054
|
-
} catch (err) {
|
|
3055
|
-
setState({ status: 'error', error: errorText(err) });
|
|
3056
|
-
}
|
|
3057
|
-
return state;
|
|
3058
|
-
}
|
|
3059
|
-
|
|
3060
|
-
async function download() {
|
|
3061
|
-
try {
|
|
3062
|
-
await autoUpdater.downloadUpdate();
|
|
3063
|
-
} catch (err) {
|
|
3064
|
-
setState({ status: 'error', error: errorText(err) });
|
|
3065
|
-
}
|
|
3066
|
-
return state;
|
|
3067
|
-
}
|
|
3068
|
-
|
|
3069
|
-
function quitAndInstall() {
|
|
3070
|
-
autoUpdater.quitAndInstall();
|
|
3071
|
-
}
|
|
3072
|
-
|
|
3073
|
-
function start() {
|
|
3074
|
-
check();
|
|
3075
|
-
const timer = setInterval(check, UPDATE_CHECK_INTERVAL_MS);
|
|
3076
|
-
// Never keep the process alive solely to poll for updates.
|
|
3077
|
-
if (timer.unref) timer.unref();
|
|
3078
|
-
}
|
|
3079
|
-
|
|
3080
|
-
return { status: () => state, check, download, quitAndInstall, start };
|
|
3303
|
+
// ONE channel for every install shape: packaged or `npm i -g`, AppImage, deb,
|
|
3304
|
+
// NSIS, dmg. There is no second applier any more — see this section's header
|
|
3305
|
+
// for the 404 the GitHub Releases feed produced on every packaged launch.
|
|
3306
|
+
//
|
|
3307
|
+
// The old branch here existed only because electron-updater needed a
|
|
3308
|
+
// build-time app-update.yml and a non-packaged run had none. npm needs
|
|
3309
|
+
// neither, so there is nothing left to branch on: the npm manager reads the
|
|
3310
|
+
// registry, reports the version, and names the command that updates THIS
|
|
3311
|
+
// copy (its install method is detected, not assumed).
|
|
3312
|
+
return createNpmUpdateManager({ onStatus: setState, packaged: Boolean(isPackaged) });
|
|
3081
3313
|
}
|
|
3082
3314
|
|
|
3083
3315
|
/** Pure mapping: IPC payload -> update-manager call, same shape as
|
|
@@ -3147,7 +3379,7 @@ function sendDeepLinkToWindow(win, parsed) {
|
|
|
3147
3379
|
* hours, and an About item (mac gets one for free in the app submenu; other
|
|
3148
3380
|
* platforms get a Help menu — role 'about' shows app.setAboutPanelOptions()
|
|
3149
3381
|
* cross-platform since Electron 15). */
|
|
3150
|
-
function buildAppMenu({ app, Menu, BrowserWindow, updateManager }) {
|
|
3382
|
+
function buildAppMenu({ app, Menu, BrowserWindow, updateManager, loggedIn }) {
|
|
3151
3383
|
const isMac = process.platform === 'darwin';
|
|
3152
3384
|
|
|
3153
3385
|
app.setAboutPanelOptions({
|
|
@@ -3190,6 +3422,11 @@ function buildAppMenu({ app, Menu, BrowserWindow, updateManager }) {
|
|
|
3190
3422
|
label: 'Authorship Panel…',
|
|
3191
3423
|
click: () => sendToFocusedWindow(BrowserWindow, MENU_FINGERPRINT_CHANNEL),
|
|
3192
3424
|
};
|
|
3425
|
+
const googleDriveItem = {
|
|
3426
|
+
label: 'Google Drive Backup…',
|
|
3427
|
+
enabled: Boolean(loggedIn),
|
|
3428
|
+
click: () => sendToFocusedWindow(BrowserWindow, MENU_GOOGLE_DRIVE_CHANNEL),
|
|
3429
|
+
};
|
|
3193
3430
|
|
|
3194
3431
|
const template = [
|
|
3195
3432
|
...(isMac
|
|
@@ -3241,6 +3478,7 @@ function buildAppMenu({ app, Menu, BrowserWindow, updateManager }) {
|
|
|
3241
3478
|
searchItem,
|
|
3242
3479
|
{ type: 'separator' },
|
|
3243
3480
|
fingerprintItem,
|
|
3481
|
+
googleDriveItem,
|
|
3244
3482
|
{ type: 'separator' },
|
|
3245
3483
|
{ role: 'reload', accelerator: 'CmdOrCtrl+R' },
|
|
3246
3484
|
{ role: 'forceReload' },
|
|
@@ -3290,6 +3528,60 @@ function bootstrap() {
|
|
|
3290
3528
|
app.commandLine.appendSwitch('disable-software-rasterizer');
|
|
3291
3529
|
app.commandLine.appendSwitch('disable-gpu-compositing');
|
|
3292
3530
|
|
|
3531
|
+
// Chromium asks xdg-desktop-portal for the desktop accent colour on Linux so
|
|
3532
|
+
// form controls can match the system palette. On this Cinnamon session the
|
|
3533
|
+
// portal's appearance backend does not answer that request the way Chromium
|
|
3534
|
+
// expects, so Chromium cancels it and the portal framework prints to stderr:
|
|
3535
|
+
//
|
|
3536
|
+
// [<pid>:<date>:ERROR:components/dbus/xdg/request.cc(173)]
|
|
3537
|
+
// Request ended (non-user cancelled).
|
|
3538
|
+
//
|
|
3539
|
+
// Harmless — Chromium falls back to its default accent — but it lands in the
|
|
3540
|
+
// terminal of every `npm start` next to real errors, and reads like an app
|
|
3541
|
+
// failure. This app renders its own theme tokens and never consults the
|
|
3542
|
+
// system accent colour (no nativeTheme/accentColor reference in main.js,
|
|
3543
|
+
// preload.js, renderer/ or lib/), so that lookup is pure cost here.
|
|
3544
|
+
//
|
|
3545
|
+
// Measured on this Electron build (44.8.0) via dbus-monitor: the switch is
|
|
3546
|
+
// honoured and halves startup portal traffic — org.freedesktop.portal.
|
|
3547
|
+
// Settings Reads go 4 -> 2 and accent-color calls 2 -> 0 per launch. The
|
|
3548
|
+
// surviving Reads are color-scheme, which Electron 44 exposes no gate for;
|
|
3549
|
+
// left alone deliberately, since the window chrome follows light/dark.
|
|
3550
|
+
app.commandLine.appendSwitch('disable-features', 'UsePortalAccentColor');
|
|
3551
|
+
|
|
3552
|
+
// The X11 clipboard advertises its drag-and-drop target formats by looking
|
|
3553
|
+
// each MIME atom up in Chromium's atom cache, and Chromium logs an ERROR for
|
|
3554
|
+
// every atom it has to mint on the spot:
|
|
3555
|
+
//
|
|
3556
|
+
// [<pid>:<date>:ERROR:ui/gfx/x/atom_cache.cc(236)]
|
|
3557
|
+
// Add application/vnd.portal.filetransfer to kAtomsToCache
|
|
3558
|
+
// [<pid>:<date>:ERROR:ui/gfx/x/atom_cache.cc(236)]
|
|
3559
|
+
// Add application/vnd.portal.files to kAtomsToCache
|
|
3560
|
+
//
|
|
3561
|
+
// They fire the first time you CUT (Ctrl-X) or drag a selection, because the
|
|
3562
|
+
// initial atom table covers copy but not the portal file-transfer pair, and
|
|
3563
|
+
// they are printed at ERROR level even though the behaviour is correct: the
|
|
3564
|
+
// atoms get added and the clipboard works.
|
|
3565
|
+
//
|
|
3566
|
+
// Measured on this Electron build (44.8.0): no feature gate suppresses these
|
|
3567
|
+
// — `--disable-features=XdgFileTransferPortal` left them at 2, and adding
|
|
3568
|
+
// UsePortalAccentColor above also left them at 2. Only the log level does
|
|
3569
|
+
// (2 -> 0 at `--log-level=3`). So this is a logging decision, not a feature
|
|
3570
|
+
// one, and it is deliberately the LAST such switch: `3` = FATAL, which
|
|
3571
|
+
// silences ERROR-level chatter like the above while still printing anything
|
|
3572
|
+
// that actually kills the process.
|
|
3573
|
+
//
|
|
3574
|
+
// Never applied over a level the user chose: `--log-level` on the command
|
|
3575
|
+
// line, or ELECTRON_ENABLE_LOGGING (which asks for the verbose output this
|
|
3576
|
+
// would undo), wins. Neither is something this app sets for itself, so a
|
|
3577
|
+
// developer debugging Chromium still sees everything.
|
|
3578
|
+
const argvLogLevel = process.argv.some((a) =>
|
|
3579
|
+
/^--(log-level|enable-logging)/.test(a)
|
|
3580
|
+
);
|
|
3581
|
+
if (!argvLogLevel && !process.env.ELECTRON_ENABLE_LOGGING) {
|
|
3582
|
+
app.commandLine.appendSwitch('log-level', '3');
|
|
3583
|
+
}
|
|
3584
|
+
|
|
3293
3585
|
// A second launch (double-clicking the icon again, `aegis` from a second
|
|
3294
3586
|
// terminal, …) must focus the existing window, not spawn a second process
|
|
3295
3587
|
// fighting the first over the same on-disk settings/session/queue files —
|
|
@@ -3396,6 +3688,26 @@ function bootstrap() {
|
|
|
3396
3688
|
describeFailure: autoProvision.provisionFailureText,
|
|
3397
3689
|
onChange: (state) => broadcastAccountStatus(state),
|
|
3398
3690
|
});
|
|
3691
|
+
|
|
3692
|
+
// Google sign-in + Drive connect (lib/google-connect.js). Same key store as
|
|
3693
|
+
// accountKey above (settings.setAegisKey) — one saved key, whichever door
|
|
3694
|
+
// last wrote it — and the same banner: a successful Google sign-in clears
|
|
3695
|
+
// whatever "no key" state accountKey was showing, same as a successful
|
|
3696
|
+
// register-device retry does.
|
|
3697
|
+
const googleConnect = createGoogleConnect({
|
|
3698
|
+
aegis,
|
|
3699
|
+
credentials,
|
|
3700
|
+
persistKey: (key) => settings.setAegisKey(key),
|
|
3701
|
+
openUrl: (url) => {
|
|
3702
|
+
if (!isSafeExternalUrl(url)) return false;
|
|
3703
|
+
shell.openExternal(url);
|
|
3704
|
+
return true;
|
|
3705
|
+
},
|
|
3706
|
+
googleSignIn,
|
|
3707
|
+
driveConnect: driveConnectLib,
|
|
3708
|
+
driveUpload: driveUploadLib,
|
|
3709
|
+
onAccountChange: () => broadcastAccountStatus(accountKey.status()),
|
|
3710
|
+
});
|
|
3399
3711
|
const keyPresentAtStart = Boolean(aegis.apiKey);
|
|
3400
3712
|
const earlyKeyProvision = autoProvision.autoProvisionApiKey(aegis, credentials, { app: 'desktop' }).then((result) => {
|
|
3401
3713
|
accountKey.recordStartup(result);
|
|
@@ -3841,18 +4153,6 @@ function bootstrap() {
|
|
|
3841
4153
|
});
|
|
3842
4154
|
});
|
|
3843
4155
|
|
|
3844
|
-
// electron-updater touches the network and expects a build-time
|
|
3845
|
-
// app-update.yml that only exists in a packaged app; requiring it is safe
|
|
3846
|
-
// either way, but it's wrapped defensively so a version mismatch or a
|
|
3847
|
-
// missing optional native dep degrades to "updates disabled" instead of
|
|
3848
|
-
// taking the whole app down.
|
|
3849
|
-
let realAutoUpdater = null;
|
|
3850
|
-
try {
|
|
3851
|
-
realAutoUpdater = require('electron-updater').autoUpdater;
|
|
3852
|
-
} catch {
|
|
3853
|
-
realAutoUpdater = null;
|
|
3854
|
-
}
|
|
3855
|
-
|
|
3856
4156
|
const openWindows = new Set();
|
|
3857
4157
|
function broadcastUpdateStatus(state) {
|
|
3858
4158
|
for (const win of openWindows) {
|
|
@@ -3863,16 +4163,33 @@ function bootstrap() {
|
|
|
3863
4163
|
for (const win of openWindows) {
|
|
3864
4164
|
if (!win.isDestroyed()) win.webContents.send(ACCOUNT_STATUS_CHANNEL, state);
|
|
3865
4165
|
}
|
|
4166
|
+
// The Google Drive menu item is enabled/disabled on login state (see
|
|
4167
|
+
// buildAppMenu) — native menus don't repaint themselves, so every path
|
|
4168
|
+
// that can change aegis.apiKey (register-device, Google sign-in) has to
|
|
4169
|
+
// rebuild through here, the one place both already call.
|
|
4170
|
+
rebuildAppMenu();
|
|
4171
|
+
}
|
|
4172
|
+
function rebuildAppMenu() {
|
|
4173
|
+
Menu.setApplicationMenu(
|
|
4174
|
+
buildAppMenu({ app, Menu, BrowserWindow, updateManager, loggedIn: Boolean(aegis.apiKey) })
|
|
4175
|
+
);
|
|
3866
4176
|
}
|
|
3867
4177
|
|
|
3868
4178
|
const updateManager = createUpdateManager({
|
|
3869
|
-
autoUpdater: realAutoUpdater,
|
|
3870
4179
|
isPackaged: app.isPackaged,
|
|
3871
4180
|
onStatus: broadcastUpdateStatus,
|
|
3872
4181
|
});
|
|
3873
4182
|
registerUpdateIpc(ipcMain, updateManager);
|
|
3874
4183
|
ipcMain.handle(`${IPC_PREFIX}accountStatus`, () => accountKey.status());
|
|
3875
4184
|
ipcMain.handle(`${IPC_PREFIX}registerAccount`, () => accountKey.registerAccount());
|
|
4185
|
+
// Google sign-in + Drive connect/sync (lib/google-connect.js). Every call
|
|
4186
|
+
// resolves `{ ok, … }` / `{ ok: false, error }` rather than throwing, same
|
|
4187
|
+
// contract as the fingerprint* handlers below — the renderer shows the
|
|
4188
|
+
// actual reason instead of Electron's opaque "Error invoking remote method".
|
|
4189
|
+
ipcMain.handle(`${IPC_PREFIX}driveSignIn`, () => googleConnect.signInWithGoogle());
|
|
4190
|
+
ipcMain.handle(`${IPC_PREFIX}driveConnect`, () => googleConnect.connectDrive());
|
|
4191
|
+
ipcMain.handle(`${IPC_PREFIX}driveStatus`, () => googleConnect.status());
|
|
4192
|
+
ipcMain.handle(`${IPC_PREFIX}driveSyncMemory`, () => googleConnect.syncMemoryNow());
|
|
3876
4193
|
registerExportIpc(
|
|
3877
4194
|
ipcMain,
|
|
3878
4195
|
sessionStore,
|
|
@@ -3880,7 +4197,7 @@ function bootstrap() {
|
|
|
3880
4197
|
(opts) => dialog.showSaveDialog(BrowserWindow.getFocusedWindow(), opts),
|
|
3881
4198
|
(filePath, content) => fs.promises.writeFile(filePath, content, 'utf8')
|
|
3882
4199
|
);
|
|
3883
|
-
|
|
4200
|
+
rebuildAppMenu();
|
|
3884
4201
|
|
|
3885
4202
|
// The local file this window is allowed to be at — used both to restore a
|
|
3886
4203
|
// saved position/reload and to recognise (and block) any navigation away
|
|
@@ -4158,6 +4475,7 @@ module.exports = {
|
|
|
4158
4475
|
MENU_EXPORT_MARKDOWN_CHANNEL,
|
|
4159
4476
|
MENU_EXPORT_JSON_CHANNEL,
|
|
4160
4477
|
MENU_FINGERPRINT_CHANNEL,
|
|
4478
|
+
MENU_GOOGLE_DRIVE_CHANNEL,
|
|
4161
4479
|
DEEP_LINK_CHANNEL,
|
|
4162
4480
|
UPDATE_STATUS_CHANNEL,
|
|
4163
4481
|
UPDATE_CHECK_INTERVAL_MS,
|