aegisone 1.0.18 → 1.0.20
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 +2 -2
- package/package.json +1 -1
- package/scripts/bump.mjs +29 -4
- package/scripts/predist.mjs +2 -0
- package/src/dispatch.js +1 -0
- package/vendor/cli/bin/aegiscode.js +29 -0
- package/vendor/cli/package.json +1 -1
- package/vendor/cli/src/app.js +335 -24
- package/vendor/cli/src/autonomous.js +19 -2
- package/vendor/cli/src/chatflow.js +77 -4
- package/vendor/cli/src/commands.js +175 -5
- package/vendor/cli/src/config.js +21 -0
- package/vendor/cli/src/connect.js +351 -0
- package/vendor/cli/src/deps.js +97 -1
- package/vendor/cli/src/engine.js +98 -8
- package/vendor/cli/src/fingerprint.js +46 -16
- package/vendor/cli/src/limits.js +1 -1
- package/vendor/cli/src/overlays.js +54 -0
- package/vendor/cli/src/provenance.lock.json +3 -3
- package/vendor/cli/src/screens.js +14 -1
- package/vendor/cli/vendor/client/credentials.js +9 -2
- package/vendor/cli/vendor/client/google-signin.js +127 -0
- package/vendor/cli/vendor/client/record-vault.js +431 -113
- package/vendor/cli/vendor/client/update.js +266 -0
- package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +134 -11
- package/vendor/cli/vendor/desktop/lib/local/engine.js +47 -25
- package/vendor/cli/vendor/desktop/lib/settings.js +65 -24
- package/vendor/desktop/lib/auto.js +11 -7
- package/vendor/desktop/lib/fingerprint.js +76 -17
- package/vendor/desktop/lib/local/claude-pro.js +134 -11
- package/vendor/desktop/lib/local/engine.js +47 -25
- package/vendor/desktop/lib/settings.js +65 -24
- package/vendor/desktop/main.js +79 -24
- package/vendor/desktop/package.json +4 -2
- package/vendor/desktop/preload.js +31 -12
- package/vendor/desktop/renderer/app.js +676 -17
- package/vendor/desktop/renderer/budget.js +18 -9
- package/vendor/desktop/renderer/companion.js +225 -0
- package/vendor/desktop/renderer/fingerprint.css +16 -0
- package/vendor/desktop/renderer/fingerprint.js +62 -2
- package/vendor/desktop/renderer/index.html +285 -121
- package/vendor/desktop/renderer/provider-toolbar.js +136 -0
- package/vendor/desktop/renderer/providers.js +261 -0
- package/vendor/desktop/renderer/style.css +547 -171
- package/vendor/desktop/vendor/credentials.js +9 -2
- package/vendor/desktop/vendor/google-signin.js +127 -0
- package/vendor/desktop/vendor/record-vault.js +431 -113
- package/vendor/desktop/vendor/update.js +266 -0
|
@@ -158,6 +158,198 @@ function fetchLatest(opts = {}) {
|
|
|
158
158
|
return fetchLatestDetailed(opts).then((r) => (r.ok ? r.latest : null));
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
//: Where the AEGIS server answers "am I still allowed to talk to you".
|
|
162
|
+
const DEFAULT_API_BASE = 'https://aegiscloud.org';
|
|
163
|
+
/** /api/v1/version is a tiny JSON document; anything bigger is a proxy page. */
|
|
164
|
+
const VERSION_BODY_CAP = 64 * 1024;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Ask the SERVER whether this client is still serviceable.
|
|
168
|
+
*
|
|
169
|
+
* Why this exists next to the npm check: they answer different questions.
|
|
170
|
+
* The registry says what was *published*; the server says what it will
|
|
171
|
+
* *accept*. aegis1 refuses every request from a client below
|
|
172
|
+
* `MIN_CLIENT_VERSION` with a 426, so a client that only asks npm learns it is
|
|
173
|
+
* unservicable by being refused mid-task — an outage, not a notice. Asking
|
|
174
|
+
* `/api/v1/version` first turns the same fact into a sentence the user reads
|
|
175
|
+
* before they hit the wall.
|
|
176
|
+
*
|
|
177
|
+
* `/api/v1/version` is informational: it never refuses anyone, and it echoes
|
|
178
|
+
* the verdict for the version header we send (`upgrade_required`).
|
|
179
|
+
*
|
|
180
|
+
* Resolves `{ ok, minClient, latestCli, latestDesktop, upgradeRequired,
|
|
181
|
+
* downloadUrl, reason, status }` and never rejects — same contract as
|
|
182
|
+
* `fetchLatestDetailed`, so a host can render "registry unreachable" and
|
|
183
|
+
* "server unreachable" differently instead of inventing a third story.
|
|
184
|
+
*/
|
|
185
|
+
function fetchServerVersionDetailed({
|
|
186
|
+
base = DEFAULT_API_BASE,
|
|
187
|
+
clientVersion = null,
|
|
188
|
+
timeoutMs = TIMEOUT_MS,
|
|
189
|
+
getImpl = null,
|
|
190
|
+
} = {}) {
|
|
191
|
+
return new Promise((resolve) => {
|
|
192
|
+
let settled = false;
|
|
193
|
+
const done = (v) => {
|
|
194
|
+
if (!settled) {
|
|
195
|
+
settled = true;
|
|
196
|
+
resolve(v);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const fail = (reason, status = null) =>
|
|
200
|
+
done({
|
|
201
|
+
ok: false, minClient: null, latestCli: null, latestDesktop: null,
|
|
202
|
+
upgradeRequired: null, downloadUrl: '', reason, status,
|
|
203
|
+
});
|
|
204
|
+
const succeed = (body, status) => {
|
|
205
|
+
const minClient = body && typeof body.min_client === 'string' ? body.min_client : null;
|
|
206
|
+
// A 200 without `min_client` is malformed, not a slow network: do not
|
|
207
|
+
// invite a retry ladder for a document that will parse the same way.
|
|
208
|
+
if (!minClient) return fail(REASONS.MALFORMED, status);
|
|
209
|
+
done({
|
|
210
|
+
ok: true,
|
|
211
|
+
minClient,
|
|
212
|
+
latestCli: typeof body.latest_cli === 'string' ? body.latest_cli : '',
|
|
213
|
+
latestDesktop: typeof body.latest_desktop === 'string' ? body.latest_desktop : '',
|
|
214
|
+
// Trust the header echo only when we actually sent a version: without
|
|
215
|
+
// one the server answers for `require_header=False` and the answer is
|
|
216
|
+
// about nothing in particular. `null` here means "the server did not
|
|
217
|
+
// say", which is different from "the server said no" — the caller must
|
|
218
|
+
// be able to fall back without overriding an answer it was given.
|
|
219
|
+
upgradeRequired:
|
|
220
|
+
clientVersion && typeof body.upgrade_required === 'boolean'
|
|
221
|
+
? body.upgrade_required
|
|
222
|
+
: null,
|
|
223
|
+
downloadUrl: typeof body.download_url === 'string' ? body.download_url : '',
|
|
224
|
+
reason: null,
|
|
225
|
+
status,
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
const url = `${String(base || DEFAULT_API_BASE).replace(/\/+$/, '')}/api/v1/version`;
|
|
231
|
+
const headers = { accept: 'application/json' };
|
|
232
|
+
if (clientVersion) headers['X-AEGIS-Version'] = String(clientVersion);
|
|
233
|
+
|
|
234
|
+
const onResponse = (res) => {
|
|
235
|
+
const status = res.statusCode;
|
|
236
|
+
if (status !== 200) {
|
|
237
|
+
res.resume();
|
|
238
|
+
if (status === 404) return fail(REASONS.NOT_FOUND, status);
|
|
239
|
+
if (status === 401 || status === 403) return fail(REASONS.FORBIDDEN, status);
|
|
240
|
+
// 426 here would mean the endpoint itself were gated; treat it as a
|
|
241
|
+
// real answer rather than a transport failure if it ever happens.
|
|
242
|
+
if (status === 426) return fail(REASONS.HTTP, status);
|
|
243
|
+
return fail(REASONS.HTTP, status);
|
|
244
|
+
}
|
|
245
|
+
let body = '';
|
|
246
|
+
res.setEncoding('utf8');
|
|
247
|
+
res.on('data', (c) => {
|
|
248
|
+
body += c;
|
|
249
|
+
if (body.length > VERSION_BODY_CAP) {
|
|
250
|
+
res.destroy();
|
|
251
|
+
fail(REASONS.TOO_LARGE, status);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
res.on('end', () => {
|
|
255
|
+
if (settled) return;
|
|
256
|
+
try {
|
|
257
|
+
succeed(JSON.parse(body), status);
|
|
258
|
+
} catch {
|
|
259
|
+
fail(REASONS.MALFORMED, status);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
if (typeof getImpl === 'function') {
|
|
265
|
+
// Injected transport for tests and hosts that already own a fetch:
|
|
266
|
+
// `getImpl({url, headers, timeoutMs})` resolves `{status, text}`.
|
|
267
|
+
Promise.resolve(getImpl({ url, headers, timeoutMs }))
|
|
268
|
+
.then((r) => {
|
|
269
|
+
const status = r && r.status != null ? r.status : 0;
|
|
270
|
+
if (!status) return fail(REASONS.NETWORK);
|
|
271
|
+
if (status !== 200) {
|
|
272
|
+
if (status === 404) return fail(REASONS.NOT_FOUND, status);
|
|
273
|
+
if (status === 401 || status === 403) return fail(REASONS.FORBIDDEN, status);
|
|
274
|
+
return fail(REASONS.HTTP, status);
|
|
275
|
+
}
|
|
276
|
+
const text = r && typeof r.text === 'string' ? r.text : '';
|
|
277
|
+
if (text.length > VERSION_BODY_CAP) return fail(REASONS.TOO_LARGE, status);
|
|
278
|
+
try {
|
|
279
|
+
succeed(JSON.parse(text), status);
|
|
280
|
+
} catch {
|
|
281
|
+
fail(REASONS.MALFORMED, status);
|
|
282
|
+
}
|
|
283
|
+
})
|
|
284
|
+
.catch(() => fail(REASONS.NETWORK));
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const req = require(/^http:\/\//i.test(url) ? 'node:http' : 'node:https')
|
|
289
|
+
.get(url, { headers, timeout: timeoutMs }, onResponse);
|
|
290
|
+
req.on('timeout', () => {
|
|
291
|
+
req.destroy();
|
|
292
|
+
fail(REASONS.TIMEOUT);
|
|
293
|
+
});
|
|
294
|
+
req.on('error', () => fail(REASONS.NETWORK));
|
|
295
|
+
} catch {
|
|
296
|
+
fail(REASONS.NETWORK);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** The server's minimum client version, or null. */
|
|
302
|
+
function fetchServerVersion(opts = {}) {
|
|
303
|
+
return fetchServerVersionDetailed(opts).then((r) => (r.ok ? r.minClient : null));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* The server's verdict, expressed in the shape the notice/plan code already
|
|
308
|
+
* speaks: `{ behind, latest, required, downloadUrl, ok, reason, status }`.
|
|
309
|
+
*
|
|
310
|
+
* `behind` is true when the SERVER says this client is below its minimum —
|
|
311
|
+
* regardless of whether npm happens to have something newer. That ordering is
|
|
312
|
+
* deliberate: being refused is actionable now, being merely superseded is not.
|
|
313
|
+
*/
|
|
314
|
+
async function serverUpdateVerdict({
|
|
315
|
+
current,
|
|
316
|
+
base = DEFAULT_API_BASE,
|
|
317
|
+
timeoutMs = TIMEOUT_MS,
|
|
318
|
+
getImpl = null,
|
|
319
|
+
} = {}) {
|
|
320
|
+
const res = await fetchServerVersionDetailed({ base, clientVersion: current, timeoutMs, getImpl });
|
|
321
|
+
if (!res.ok) {
|
|
322
|
+
return { ok: false, behind: false, latest: null, required: null, downloadUrl: '', reason: res.reason, status: res.status };
|
|
323
|
+
}
|
|
324
|
+
const required = res.minClient || null;
|
|
325
|
+
// The server's echo decides. Falling back to local arithmetic only when it
|
|
326
|
+
// said nothing (`null`) — OR'ing the two would let our own comparison
|
|
327
|
+
// override the very authority we asked, which is the bug this line exists to
|
|
328
|
+
// not have.
|
|
329
|
+
const behind =
|
|
330
|
+
res.upgradeRequired === true
|
|
331
|
+
? true
|
|
332
|
+
: res.upgradeRequired === false
|
|
333
|
+
? false
|
|
334
|
+
: required
|
|
335
|
+
? isNewer(required, current)
|
|
336
|
+
: false;
|
|
337
|
+
return {
|
|
338
|
+
ok: true,
|
|
339
|
+
behind,
|
|
340
|
+
// The server's own minimum is the target when it is the thing refusing us;
|
|
341
|
+
// a published version is preferred when it names one, because that is what
|
|
342
|
+
// the user should actually install.
|
|
343
|
+
latest: (behind && (res.latestCli || res.latestDesktop)) || required,
|
|
344
|
+
latestCli: res.latestCli,
|
|
345
|
+
latestDesktop: res.latestDesktop,
|
|
346
|
+
required,
|
|
347
|
+
downloadUrl: res.downloadUrl,
|
|
348
|
+
reason: null,
|
|
349
|
+
status: res.status,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
161
353
|
/**
|
|
162
354
|
* The notice to show, from cache. Never waits on the network.
|
|
163
355
|
*
|
|
@@ -333,10 +525,83 @@ function updateLine({ current, latest, behind, pkg = PKG }) {
|
|
|
333
525
|
return `Update available: ${plan.current} → ${plan.latest} run: ${plan.instruction}`;
|
|
334
526
|
}
|
|
335
527
|
|
|
528
|
+
/**
|
|
529
|
+
* The server's verdict, from cache. Never waits on the network.
|
|
530
|
+
*
|
|
531
|
+
* Same contract and the same once-a-day rule as `updateNotice`, for the same
|
|
532
|
+
* reason: the welcome box draws from what the last run learned, and the
|
|
533
|
+
* refresh lands for the next one. A first run shows nothing, which is right —
|
|
534
|
+
* it has no verdict yet.
|
|
535
|
+
*
|
|
536
|
+
* Returns `{ behind, latest, required, downloadUrl }`. `behind` is the server's
|
|
537
|
+
* answer, not a comparison this module invented, so the box says "update" only
|
|
538
|
+
* when the server would actually refuse this client.
|
|
539
|
+
*/
|
|
540
|
+
function serverNotice({
|
|
541
|
+
current,
|
|
542
|
+
cache,
|
|
543
|
+
save,
|
|
544
|
+
now = Date.now(),
|
|
545
|
+
verdictImpl = serverUpdateVerdict,
|
|
546
|
+
intervalMs = CHECK_INTERVAL_MS,
|
|
547
|
+
} = {}) {
|
|
548
|
+
const c = cache || {};
|
|
549
|
+
const fresh = typeof c.checkedAt === 'number' && now - c.checkedAt < intervalMs;
|
|
550
|
+
|
|
551
|
+
if (!fresh) {
|
|
552
|
+
Promise.resolve()
|
|
553
|
+
.then(() => verdictImpl({ current }))
|
|
554
|
+
.then((v) => {
|
|
555
|
+
if (!v || typeof save !== 'function') return;
|
|
556
|
+
// Persist the verdict even when it is "not behind": that is what tells
|
|
557
|
+
// the next run it already asked today, and stops a check per launch.
|
|
558
|
+
save({
|
|
559
|
+
checkedAt: now,
|
|
560
|
+
behind: Boolean(v.behind),
|
|
561
|
+
required: v.required || null,
|
|
562
|
+
latest: v.latest || null,
|
|
563
|
+
downloadUrl: v.downloadUrl || '',
|
|
564
|
+
reason: v.reason || null,
|
|
565
|
+
});
|
|
566
|
+
})
|
|
567
|
+
.catch(() => {});
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
return {
|
|
571
|
+
behind: Boolean(c.behind),
|
|
572
|
+
latest: c.latest || null,
|
|
573
|
+
required: c.required || null,
|
|
574
|
+
downloadUrl: c.downloadUrl || '',
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* The line for the welcome box when the SERVER says this build is too old.
|
|
580
|
+
*
|
|
581
|
+
* Distinct from `updateLine` on purpose: "a newer release exists" and "the
|
|
582
|
+
* server will refuse you" are different urgency, and only the second one means
|
|
583
|
+
* the app is about to stop working. Says where to get it, because a user who
|
|
584
|
+
* is being cut off needs a destination, not a version number.
|
|
585
|
+
*/
|
|
586
|
+
function serverUpdateLine({ behind, latest, required, downloadUrl } = {}) {
|
|
587
|
+
if (!behind) return null;
|
|
588
|
+
const target = latest || required || '';
|
|
589
|
+
const head = target
|
|
590
|
+
? `This build is no longer served — update to v${target}.`
|
|
591
|
+
: 'This build is no longer served — update to the latest release.';
|
|
592
|
+
const where = downloadUrl ? ` ${downloadUrl}` : '';
|
|
593
|
+
return `${head}${where}`;
|
|
594
|
+
}
|
|
595
|
+
|
|
336
596
|
module.exports = {
|
|
337
597
|
isNewer,
|
|
338
598
|
fetchLatest,
|
|
339
599
|
fetchLatestDetailed,
|
|
600
|
+
fetchServerVersion,
|
|
601
|
+
fetchServerVersionDetailed,
|
|
602
|
+
serverUpdateVerdict,
|
|
603
|
+
serverNotice,
|
|
604
|
+
serverUpdateLine,
|
|
340
605
|
isTransientReason,
|
|
341
606
|
updateNotice,
|
|
342
607
|
checkPublished,
|
|
@@ -345,4 +610,5 @@ module.exports = {
|
|
|
345
610
|
PKG,
|
|
346
611
|
CHECK_INTERVAL_MS,
|
|
347
612
|
REASONS,
|
|
613
|
+
DEFAULT_API_BASE,
|
|
348
614
|
};
|