aegisone 1.0.20 → 1.0.21
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/commands.js +45 -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 +169 -3
- package/vendor/cli/vendor/client/drive-connect.js +87 -0
- package/vendor/cli/vendor/client/drive-upload.js +176 -0
- package/vendor/cli/vendor/client/update.js +100 -8
- package/vendor/cli/vendor/desktop/lib/local/engine.js +64 -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 +171 -0
- package/vendor/desktop/lib/local/engine.js +64 -1
- package/vendor/desktop/lib/local/prompt.js +67 -37
- package/vendor/desktop/lib/local/tools.js +49 -13
- package/vendor/desktop/main.js +191 -12
- package/vendor/desktop/package.json +2 -1
- package/vendor/desktop/preload.js +14 -0
- package/vendor/desktop/renderer/app.js +15 -5
- package/vendor/desktop/renderer/fingerprint.js +75 -1
- package/vendor/desktop/renderer/index.html +17 -0
- package/vendor/desktop/vendor/aegis.js +169 -3
- package/vendor/desktop/vendor/drive-connect.js +87 -0
- package/vendor/desktop/vendor/drive-upload.js +176 -0
- package/vendor/desktop/vendor/update.js +100 -8
|
@@ -30,50 +30,62 @@
|
|
|
30
30
|
|
|
31
31
|
/** Identity + work rules. Ported from the upstream engine reference. */
|
|
32
32
|
const MAIN_CHAT_PROMPT =
|
|
33
|
-
`You are Aegiscodex, a terminal coding assistant
|
|
34
|
-
`
|
|
35
|
-
|
|
33
|
+
`You are Aegiscodex, a terminal coding assistant working in the user's repository: read and ` +
|
|
34
|
+
`reason about code, write and edit files, run shell commands, investigate bugs. Work rules:\n` +
|
|
35
|
+
`- Output is billed by the token and is the largest line on the bill, so spend it where it is ` +
|
|
36
|
+
` read. Before a tool call, one short sentence on what you are about to find out. Do NOT ` +
|
|
37
|
+
` restate file contents, diffs, command output or test results the user can already see. ` +
|
|
38
|
+
` Finish with the answer in a few lines — expand only when asked to explain, or when the ` +
|
|
39
|
+
` change's correctness depends on a detail the user must check.\n` +
|
|
40
|
+
`- Batch independent tool calls into ONE turn: read several files, or grep for several ` +
|
|
41
|
+
` patterns, at once, or use one exec command that does the whole job. Every round ` +
|
|
42
|
+
` re-sends the prefix and bills fresh output; one call per round is the expensive shape.\n` +
|
|
36
43
|
`- Use tools silently. A one-line reason is enough; do not narrate your plan as a story. ` +
|
|
37
44
|
`- Never claim what a tool found or what a command returned before the tool actually runs. ` +
|
|
38
45
|
` Report only the results you really received. ` +
|
|
39
|
-
`- Before
|
|
40
|
-
` it
|
|
41
|
-
`
|
|
42
|
-
`
|
|
43
|
-
`
|
|
44
|
-
`
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
`
|
|
48
|
-
`
|
|
46
|
+
`- Before starting a fix or feature, check whether they have asked for it before and whether ` +
|
|
47
|
+
` it was delivered: recalled memory, \`queue.jsonl\`, \`PLAN.md\`/notes and \`git log\` — ` +
|
|
48
|
+
` ONE batched command over sources that exist: if the Environment block says this ` +
|
|
49
|
+
` directory has no version control, skip it. ` +
|
|
50
|
+
` If it was resolved before and the problem is back, report how it was resolved and ` +
|
|
51
|
+
` why it regressed, then fix the cause — never re-fix blind as if it were new. ` +
|
|
52
|
+
` If it was never met, say so plainly before starting. ` +
|
|
53
|
+
`- Match the response to the request. A greeting, a question you already know the answer to, ` +
|
|
54
|
+
` or a request for an opinion is answered in plain words with NO tools. Reach for a tool ` +
|
|
55
|
+
` only when the answer depends on something in this repo or on this machine. ` +
|
|
56
|
+
` "hey" is not a task.\n` +
|
|
49
57
|
`- WHEN THE USER HAS ASKED FOR WORK: act, don't just inspect. After at most 2 rounds of ` +
|
|
50
58
|
` reading or exploration, start making changes with writeFile or editFile. Reconnaissance ` +
|
|
51
|
-
` is not progress — implement, then verify. This
|
|
52
|
-
`
|
|
59
|
+
` is not progress — implement, then verify. This is about HOW to carry out a task you were ` +
|
|
60
|
+
` given; it is never a reason to invent one. Never write or modify a file the user ` +
|
|
53
61
|
` did not ask you to touch.\n` +
|
|
54
|
-
`- Zero tolerance for stalling: once the
|
|
55
|
-
`
|
|
56
|
-
`
|
|
57
|
-
`
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
` user's question. Never end your turn with an intention like "Let me check…" or "I'll now…" ` +
|
|
61
|
-
` — that is not an answer. ` +
|
|
62
|
+
`- Zero tolerance for stalling: once the cause is identified and only the edit remains, make ` +
|
|
63
|
+
` it in the same turn. Never end a turn with an empty or no-op response, or a "let me ` +
|
|
64
|
+
` continue"/"I'll now…" placeholder when the user says continue — that wastes their turn. ` +
|
|
65
|
+
` This has been flagged as non-compliance before; treat it as a hard rule. ` +
|
|
66
|
+
`- When you have what you need, stop using tools and give a concise, direct answer. Never ` +
|
|
67
|
+
` end a turn with an intention like "Let me check…" — that is not an answer. ` +
|
|
62
68
|
`- When a focused multi-step sub-task can be delegated, use the task tool to spawn a ` +
|
|
63
|
-
` specialist subagent rather than doing
|
|
69
|
+
` specialist subagent rather than doing it inline. ` +
|
|
64
70
|
`- If the user references a workflow you don't recognize, inspect the repo/scripts for that ` +
|
|
65
|
-
` mechanism before acting
|
|
71
|
+
` mechanism before acting.`;
|
|
66
72
|
|
|
67
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* The tool line: what each tool is, and the two facts a schema cannot carry.
|
|
75
|
+
*
|
|
76
|
+
* It used to restate the path rule in full — absolute, `~` expansion, relative
|
|
77
|
+
* resolution — which `PATH_ARG_DESC` already says once per path argument in nine
|
|
78
|
+
* schemas. That duplication is what `d01068b` unwound from the schemas; this is
|
|
79
|
+
* the other end of it. What stays is the part no schema carries: the
|
|
80
|
+
* platform-specific example (the one form a model gets wrong) and the persistent
|
|
81
|
+
* shell, which is a property of the session rather than an argument.
|
|
82
|
+
*/
|
|
68
83
|
const TOOL_LINE =
|
|
69
|
-
'Tools: readFile, writeFile, editFile, listDir, glob, grep, exec, task. Paths are absolute
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'exec runs in a persistent shell session on this machine — cd and exported env vars carry ' +
|
|
75
|
-
'across calls within the turn, like a real terminal. task spawns a specialist subagent ' +
|
|
76
|
-
'(its own tool loop, same model) for a focused, self-contained piece of work.';
|
|
84
|
+
'Tools: readFile, writeFile, editFile, listDir, glob, grep, exec, task. Paths are absolute ' +
|
|
85
|
+
'in the form THIS machine uses (see the Environment block): on win32 that means ' +
|
|
86
|
+
'C:\\Users\\you\\Desktop\\file.txt, not /home/you/Desktop/file.txt or /tmp/file.txt. ' +
|
|
87
|
+
'exec runs in a persistent shell session — cd and exported env vars carry across calls ' +
|
|
88
|
+
'within the turn. task spawns a specialist subagent (its own tool loop, same model).';
|
|
77
89
|
|
|
78
90
|
/**
|
|
79
91
|
* One durable-language entry as a sentence fragment, accepting the three shapes
|
|
@@ -109,6 +121,7 @@ function environmentPreamble(env = {}) {
|
|
|
109
121
|
localeName,
|
|
110
122
|
languages,
|
|
111
123
|
cwd,
|
|
124
|
+
vcs,
|
|
112
125
|
shell,
|
|
113
126
|
shellKind,
|
|
114
127
|
roots,
|
|
@@ -164,8 +177,7 @@ function environmentPreamble(env = {}) {
|
|
|
164
177
|
if (desktopdir) {
|
|
165
178
|
bits.push(
|
|
166
179
|
`desktop directory: ${desktopdir} — use this exact path when the user says "my desktop"; ` +
|
|
167
|
-
'do NOT build it yourself from the home directory,
|
|
168
|
-
'called "Desktop" there',
|
|
180
|
+
'do NOT build it yourself from the home directory',
|
|
169
181
|
);
|
|
170
182
|
}
|
|
171
183
|
// Same failure mode as the desktop line, one directory over, and reported
|
|
@@ -176,13 +188,31 @@ function environmentPreamble(env = {}) {
|
|
|
176
188
|
// missing path cannot tell a typo from an empty directory.
|
|
177
189
|
if (dataDir) {
|
|
178
190
|
bits.push(
|
|
179
|
-
`AEGIS data directory: ${dataDir} —
|
|
191
|
+
`AEGIS data directory: ${dataDir} — the store itself (config, sessions, ` +
|
|
180
192
|
'credentials, queue). Use this exact path; do NOT append it to the home directory ' +
|
|
181
193
|
'yourself, because a dropped separator ("C:\\Users\\you.aegiscode") names a path that ' +
|
|
182
194
|
'does not exist and looks like an empty directory rather than a mistake',
|
|
183
195
|
);
|
|
184
196
|
}
|
|
185
197
|
if (cwd) bits.push(`working directory: ${cwd}`);
|
|
198
|
+
// The version-control fact, which turns the work rules' "check whether this
|
|
199
|
+
// was already delivered" from a guess into a decision. Measured: in a temp
|
|
200
|
+
// workspace with no `.git`, the model still ran `git log` on its second round
|
|
201
|
+
// of all three tasks, spent a round on a guaranteed failure, and carried the
|
|
202
|
+
// error into the rest of the turn. Stated only when the host actually probed
|
|
203
|
+
// (`null`/`undefined` means "could not tell", and silence beats a wrong fact).
|
|
204
|
+
if (vcs === 'git') {
|
|
205
|
+
bits.push(
|
|
206
|
+
`version control: this directory IS inside a git work tree, so \`git log\`, ` +
|
|
207
|
+
'`git diff` and `git status` are usable for checking what was already done',
|
|
208
|
+
);
|
|
209
|
+
} else if (vcs === '') {
|
|
210
|
+
bits.push(
|
|
211
|
+
`version control: this directory is NOT a git repository and has no history to ` +
|
|
212
|
+
'consult — do NOT run `git log`, `git diff`, `git blame` or `git status`; they ' +
|
|
213
|
+
'fail here and cost a round. Read the files that exist instead',
|
|
214
|
+
);
|
|
215
|
+
}
|
|
186
216
|
if (shell) bits.push(`exec shell: ${shell}${shellKind ? ` (${shellKind})` : ''}`);
|
|
187
217
|
if (model) bits.push(`model: ${model}`);
|
|
188
218
|
if (appVersion) bits.push(`AEGIS Desktop ${appVersion}`);
|
|
@@ -86,10 +86,18 @@ const OUTPUT_CAP = 30_000; // chars fed back to the model per tool result
|
|
|
86
86
|
* Desktop. The schema is the first place to say so — a refusal after the fact
|
|
87
87
|
* costs the model a round, a correct description costs it nothing.
|
|
88
88
|
*/
|
|
89
|
+
// Kept SHORT on purpose. This sentence is repeated in the description of every
|
|
90
|
+
// path argument (9 of the 10 tools), so its length is paid once per tool, every
|
|
91
|
+
// round, and the tool schemas are part of the wire prefix the provider is asked
|
|
92
|
+
// to cache. The long form spelled out win32 examples and the Environment-block
|
|
93
|
+
// cross-reference — 267 chars, ~68 tokens, ~616 tokens per round once
|
|
94
|
+
// multiplied across the nine. That instruction is NOT lost: prompt.js's
|
|
95
|
+
// TOOL_LINE states the same rule once, in the system prompt where it belongs
|
|
96
|
+
// and where it costs one copy instead of nine. `test/tool-paths.test.mjs`
|
|
97
|
+
// asserts this constant appears in each path argument, so it must stay the
|
|
98
|
+
// single shared string rather than being inlined per tool.
|
|
89
99
|
const PATH_ARG_DESC =
|
|
90
|
-
'Absolute path
|
|
91
|
-
'directory — a win32 host needs C:\\Users\\you\\file.txt, never /home/you/file.txt), or "~" / ' +
|
|
92
|
-
'"~/…" for the home directory. A relative path resolves against the working directory.';
|
|
100
|
+
'Absolute path on THIS machine; "~"/"~/…" = home. Relative resolves against the working directory.';
|
|
93
101
|
|
|
94
102
|
/** `<what>. <the path rules>` — the shape every path argument's description takes. */
|
|
95
103
|
const pathDesc = (what) => `${what}. ${PATH_ARG_DESC}`;
|
|
@@ -297,18 +305,45 @@ const SCHEMAS = {
|
|
|
297
305
|
// MAX_SUBAGENT_DEPTH, hard-bounding runaway recursion.
|
|
298
306
|
const SUBAGENT_TOOL = 'task';
|
|
299
307
|
|
|
308
|
+
/**
|
|
309
|
+
* The hook layer (`hooks`, `installHooks`) is the ONE part of this registry that
|
|
310
|
+
* is not agent work, and it is the one part the benchmark never touches.
|
|
311
|
+
*
|
|
312
|
+
* Measured on `benchmarks/raw/beat-pi-20261022-2318` (three tasks, the same wire
|
|
313
|
+
* model, nine trials): the advertised schemas are re-sent as a wire PREFIX on
|
|
314
|
+
* every round, and these two are 427 of its ~1,757 tokens. On the round that
|
|
315
|
+
* misses the prefix cache they are billed at the miss rate; on every later round
|
|
316
|
+
* they are billed at the cheap hit rate but are still tokens the model reads
|
|
317
|
+
* before it reads the task. Pi ships seven tools and no hook surface at all.
|
|
318
|
+
*
|
|
319
|
+
* So they stay RUNNABLE (`isTool`, `executeTool`, `toolList`, the CLI's `/hooks`)
|
|
320
|
+
* and stay on the schema list for a caller that asks for them, but they are no
|
|
321
|
+
* longer advertised to the model by default. Capability is unchanged; the
|
|
322
|
+
* prefix it was paying for is gone.
|
|
323
|
+
*/
|
|
324
|
+
const HOOK_TOOLS = new Set(['hooks', 'installHooks']);
|
|
325
|
+
|
|
300
326
|
/** Tool names in advertisement order. `includeSubagent: false` drops task (depth cap). */
|
|
301
|
-
function toolNames({ includeSubagent = true } = {}) {
|
|
302
|
-
return schemaList(includeSubagent).map((s) => s.name);
|
|
327
|
+
function toolNames({ includeSubagent = true, includeHooks = false } = {}) {
|
|
328
|
+
return schemaList({ includeSubagent, includeHooks }).map((s) => s.name);
|
|
303
329
|
}
|
|
304
330
|
|
|
305
|
-
function schemaList(includeSubagent) {
|
|
306
|
-
return Object.values(SCHEMAS).filter(
|
|
331
|
+
function schemaList({ includeSubagent = true, includeHooks = false } = {}) {
|
|
332
|
+
return Object.values(SCHEMAS).filter(
|
|
333
|
+
(s) =>
|
|
334
|
+
(includeSubagent || s.name !== SUBAGENT_TOOL) &&
|
|
335
|
+
(includeHooks || !HOOK_TOOLS.has(s.name))
|
|
336
|
+
);
|
|
307
337
|
}
|
|
308
338
|
|
|
309
|
-
/**
|
|
310
|
-
|
|
311
|
-
|
|
339
|
+
/**
|
|
340
|
+
* OpenAI-compatible /chat/completions tool definitions ({type:'function', function}).
|
|
341
|
+
* `includeHooks: true` re-advertises the hook tools; the default is the agent
|
|
342
|
+
* set, because a hook install is a thing the USER asks the CLI for, not a step
|
|
343
|
+
* in a coding task.
|
|
344
|
+
*/
|
|
345
|
+
function openaiTools({ includeSubagent = true, includeHooks = false } = {}) {
|
|
346
|
+
return schemaList({ includeSubagent, includeHooks }).map((s) => ({
|
|
312
347
|
type: 'function',
|
|
313
348
|
function: { name: s.name, description: s.description, parameters: s.parameters },
|
|
314
349
|
}));
|
|
@@ -319,10 +354,10 @@ function openaiTools({ includeSubagent = true } = {}) {
|
|
|
319
354
|
* goes through the AEGIS relay, which speaks the OpenAI shape — so this takes
|
|
320
355
|
* no `wire` argument. The Anthropic-shaped variant went away with the
|
|
321
356
|
* direct-dial transport. `includeSubagent: false` drops the task tool
|
|
322
|
-
* (subagent depth cap).
|
|
357
|
+
* (subagent depth cap); `includeHooks: true` re-adds hooks/installHooks.
|
|
323
358
|
*/
|
|
324
|
-
function toolsFor({ includeSubagent = true } = {}) {
|
|
325
|
-
return openaiTools({ includeSubagent });
|
|
359
|
+
function toolsFor({ includeSubagent = true, includeHooks = false } = {}) {
|
|
360
|
+
return openaiTools({ includeSubagent, includeHooks });
|
|
326
361
|
}
|
|
327
362
|
|
|
328
363
|
// ── Path normalisation ──────────────────────────────────────────────────────
|
|
@@ -1175,6 +1210,7 @@ module.exports = {
|
|
|
1175
1210
|
// schemas
|
|
1176
1211
|
SCHEMAS,
|
|
1177
1212
|
SUBAGENT_TOOL,
|
|
1213
|
+
HOOK_TOOLS,
|
|
1178
1214
|
toolNames,
|
|
1179
1215
|
openaiTools,
|
|
1180
1216
|
toolsFor,
|
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
|
|
@@ -2771,6 +2796,10 @@ function createNpmUpdateManager({
|
|
|
2771
2796
|
fetchImpl,
|
|
2772
2797
|
setTimeoutImpl = setTimeout,
|
|
2773
2798
|
clearTimeoutImpl = clearTimeout,
|
|
2799
|
+
// Both injectable so the install path is testable without running npm or
|
|
2800
|
+
// killing the test runner's own process.
|
|
2801
|
+
runUpgrade,
|
|
2802
|
+
relaunch,
|
|
2774
2803
|
} = {}) {
|
|
2775
2804
|
const PKG = 'aegis-desktop';
|
|
2776
2805
|
let current = 'unknown';
|
|
@@ -2792,6 +2821,11 @@ function createNpmUpdateManager({
|
|
|
2792
2821
|
attempts: 0,
|
|
2793
2822
|
retryInMs: 0,
|
|
2794
2823
|
command: null,
|
|
2824
|
+
// `plan` is the shared verdict the banner was rendered from. `download()`
|
|
2825
|
+
// installs from THIS object rather than re-deriving a command, so the
|
|
2826
|
+
// button can only ever run what the banner promised.
|
|
2827
|
+
plan: null,
|
|
2828
|
+
method: null,
|
|
2795
2829
|
canDownload: false,
|
|
2796
2830
|
};
|
|
2797
2831
|
const set = (patch) => {
|
|
@@ -2818,6 +2852,34 @@ function createNpmUpdateManager({
|
|
|
2818
2852
|
let inFlight = null;
|
|
2819
2853
|
let interval = null;
|
|
2820
2854
|
|
|
2855
|
+
/**
|
|
2856
|
+
* How THIS desktop copy was installed: 'npm' | 'pip' | 'npx' | 'source'.
|
|
2857
|
+
*
|
|
2858
|
+
* Memoised — it cannot change while the process runs. `entry` is the app
|
|
2859
|
+
* directory: an unpackaged run is either a global npm install (a path with
|
|
2860
|
+
* `node_modules` in it), a checkout (`desktop/` beside `.git`), or a pip
|
|
2861
|
+
* launcher, which declares itself through AEGIS_INSTALL_METHOD because
|
|
2862
|
+
* nothing in the filesystem would otherwise say so.
|
|
2863
|
+
*/
|
|
2864
|
+
let methodCache = null;
|
|
2865
|
+
function detectMethod() {
|
|
2866
|
+
if (methodCache) return methodCache;
|
|
2867
|
+
const detect = updater && updater.detectInstallMethod;
|
|
2868
|
+
if (typeof detect !== 'function') { methodCache = 'npm'; return methodCache; }
|
|
2869
|
+
try {
|
|
2870
|
+
methodCache = detect({
|
|
2871
|
+
env: process.env,
|
|
2872
|
+
argv: process.argv,
|
|
2873
|
+
pkg: PKG,
|
|
2874
|
+
entry: __dirname,
|
|
2875
|
+
fileExists: (rel) => fs.existsSync(path.resolve(__dirname, '..', rel)),
|
|
2876
|
+
});
|
|
2877
|
+
} catch {
|
|
2878
|
+
methodCache = 'npm';
|
|
2879
|
+
}
|
|
2880
|
+
return methodCache;
|
|
2881
|
+
}
|
|
2882
|
+
|
|
2821
2883
|
/** 1m, 5m, 15m, 60m, 60m… — capped, never unbounded. */
|
|
2822
2884
|
const delayFor = () =>
|
|
2823
2885
|
UPDATE_RETRY_BACKOFF_MS[Math.min(Math.max(attempts - 1, 0), UPDATE_RETRY_BACKOFF_MS.length - 1)];
|
|
@@ -2917,8 +2979,14 @@ function createNpmUpdateManager({
|
|
|
2917
2979
|
// The npm applier's instruction comes from the ONE shared verdict
|
|
2918
2980
|
// (`updatePlan`), the same call `aegiscode`'s notice and `aegis doctor`
|
|
2919
2981
|
// render — so the banner cannot offer a command the terminal would not.
|
|
2982
|
+
//
|
|
2983
|
+
// `method` is this copy's install channel, detected the same way the
|
|
2984
|
+
// CLI does. It matters because `npm i -g` against a pip-installed
|
|
2985
|
+
// aegis-desktop writes a second copy beside the one the user actually
|
|
2986
|
+
// runs: the button would appear to work and change nothing.
|
|
2987
|
+
const method = detectMethod();
|
|
2920
2988
|
const plan = typeof updater.updatePlan === 'function'
|
|
2921
|
-
? updater.updatePlan({ current, latest: res.latest, behind: true, channel: 'npm', pkg: PKG })
|
|
2989
|
+
? updater.updatePlan({ current, latest: res.latest, behind: true, channel: 'npm', pkg: PKG, method })
|
|
2922
2990
|
: null;
|
|
2923
2991
|
return set({
|
|
2924
2992
|
status: 'available',
|
|
@@ -2928,11 +2996,13 @@ function createNpmUpdateManager({
|
|
|
2928
2996
|
transient: false,
|
|
2929
2997
|
attempts: 0,
|
|
2930
2998
|
retryInMs: 0,
|
|
2999
|
+
plan,
|
|
3000
|
+
method,
|
|
2931
3001
|
command: (plan && plan.instruction) || `npm i -g ${PKG}@latest`,
|
|
2932
|
-
//
|
|
2933
|
-
//
|
|
2934
|
-
//
|
|
2935
|
-
canDownload:
|
|
3002
|
+
// A channel with an `apply` argv has something this process can run;
|
|
3003
|
+
// `npx` and a source checkout do not, and offering a button that
|
|
3004
|
+
// silently does nothing is worse than the command alone.
|
|
3005
|
+
canDownload: Boolean(plan && plan.apply),
|
|
2936
3006
|
});
|
|
2937
3007
|
}
|
|
2938
3008
|
|
|
@@ -2974,16 +3044,97 @@ function createNpmUpdateManager({
|
|
|
2974
3044
|
}
|
|
2975
3045
|
}
|
|
2976
3046
|
|
|
3047
|
+
/**
|
|
3048
|
+
* Run one installer argv and resolve to a status patch. Never rejects.
|
|
3049
|
+
*
|
|
3050
|
+
* `npm i -g` against a global prefix needs no elevation the way a system
|
|
3051
|
+
* package does, but it still writes outside the app dir and it can fail on a
|
|
3052
|
+
* permissions wall — so a failure is reported with npm's own last lines
|
|
3053
|
+
* rather than a blanket "update failed".
|
|
3054
|
+
*/
|
|
3055
|
+
function runInstall(target) {
|
|
3056
|
+
const exec = runUpgrade || ((cmd, args) => new Promise((resolve) => {
|
|
3057
|
+
execFile(cmd, args, { timeout: 180_000, windowsHide: true }, (err, stdout, stderr) => {
|
|
3058
|
+
if (err) return resolve({ ok: false, output: String(stderr || stdout || err.message || err) });
|
|
3059
|
+
resolve({ ok: true, output: String(stdout || '') });
|
|
3060
|
+
});
|
|
3061
|
+
}));
|
|
3062
|
+
return Promise.resolve(exec(target.command, target.args)).then(
|
|
3063
|
+
(res) => ({ ok: Boolean(res && res.ok), output: String((res && res.output) || '') }),
|
|
3064
|
+
(err) => ({ ok: false, output: errorText(err) }),
|
|
3065
|
+
);
|
|
3066
|
+
}
|
|
3067
|
+
|
|
2977
3068
|
return {
|
|
2978
3069
|
status: () => state,
|
|
2979
3070
|
check,
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
3071
|
+
/**
|
|
3072
|
+
* The banner's Download button. It INSTALLS.
|
|
3073
|
+
*
|
|
3074
|
+
* This used to be a no-op that re-set `command` and `canDownload:false`:
|
|
3075
|
+
* the button was hidden for every npm install, so the affordance and the
|
|
3076
|
+
* action were both missing, and the only way to update the window was to
|
|
3077
|
+
* read a shell command off a banner and type it into a different app.
|
|
3078
|
+
*
|
|
3079
|
+
* It still runs only on an explicit click (nothing here installs on a
|
|
3080
|
+
* timer), and it still does not hot-swap the running process: after a
|
|
3081
|
+
* successful install the honest state is 'downloaded' — "restart to install"
|
|
3082
|
+
* — because the new files are on disk and this process is still the old
|
|
3083
|
+
* ones. That is the same promise the packaged electron-updater path makes,
|
|
3084
|
+
* so the banner needs no branch.
|
|
3085
|
+
*/
|
|
3086
|
+
download: async () => {
|
|
3087
|
+
const target = state.plan && state.plan.apply;
|
|
3088
|
+
if (!target) {
|
|
3089
|
+
// Nothing to install on this channel (npx fetches fresh every run; a
|
|
3090
|
+
// checkout belongs to its git remote). Say who owns it instead of
|
|
3091
|
+
// pretending to act.
|
|
3092
|
+
return set({
|
|
3093
|
+
status: state.status === 'available' ? 'available' : state.status,
|
|
3094
|
+
command: (state.plan && state.plan.instruction) || state.command,
|
|
3095
|
+
canDownload: false,
|
|
3096
|
+
});
|
|
3097
|
+
}
|
|
3098
|
+
set({ status: 'downloading', error: null, progress: 0 });
|
|
3099
|
+
const res = await runInstall(target);
|
|
3100
|
+
if (!res.ok) {
|
|
3101
|
+
// `transient: false` deliberately: an installer that refused is not a
|
|
3102
|
+
// network blip, and the retry ladder must not quietly re-run an npm
|
|
3103
|
+
// install every minute.
|
|
3104
|
+
return set({
|
|
3105
|
+
status: 'error',
|
|
3106
|
+
transient: false,
|
|
3107
|
+
error: res.output.trim().split('\n').slice(-3).join(' ').trim() || 'the installer failed',
|
|
3108
|
+
command: `${target.command} ${target.args.join(' ')}`,
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
return set({
|
|
3112
|
+
status: 'downloaded',
|
|
3113
|
+
version: state.version,
|
|
3114
|
+
error: null,
|
|
3115
|
+
progress: 100,
|
|
3116
|
+
command: `npm i -g ${PKG}@latest`,
|
|
3117
|
+
canDownload: false,
|
|
3118
|
+
});
|
|
3119
|
+
},
|
|
3120
|
+
/**
|
|
3121
|
+
* "Restart to install". Relaunches the app so the freshly installed files
|
|
3122
|
+
* are what runs — `app.relaunch()` before `app.exit()`, the standard pair,
|
|
3123
|
+
* because `app.quit()` alone would not start a new process.
|
|
3124
|
+
*/
|
|
3125
|
+
quitAndInstall: () => {
|
|
3126
|
+
if (state.status !== 'downloaded') return;
|
|
3127
|
+
const again = relaunch || (() => {
|
|
3128
|
+
try {
|
|
3129
|
+
const { app } = require('electron');
|
|
3130
|
+
app.relaunch();
|
|
3131
|
+
app.exit(0);
|
|
3132
|
+
} catch {
|
|
3133
|
+
/* not under Electron (a test or the CLI): nothing to relaunch */
|
|
3134
|
+
}
|
|
3135
|
+
});
|
|
3136
|
+
again();
|
|
3137
|
+
},
|
|
2987
3138
|
start: () => {
|
|
2988
3139
|
check().catch(() => {});
|
|
2989
3140
|
interval = setInterval(() => check().catch(() => {}), UPDATE_CHECK_INTERVAL_MS);
|
|
@@ -3396,6 +3547,26 @@ function bootstrap() {
|
|
|
3396
3547
|
describeFailure: autoProvision.provisionFailureText,
|
|
3397
3548
|
onChange: (state) => broadcastAccountStatus(state),
|
|
3398
3549
|
});
|
|
3550
|
+
|
|
3551
|
+
// Google sign-in + Drive connect (lib/google-connect.js). Same key store as
|
|
3552
|
+
// accountKey above (settings.setAegisKey) — one saved key, whichever door
|
|
3553
|
+
// last wrote it — and the same banner: a successful Google sign-in clears
|
|
3554
|
+
// whatever "no key" state accountKey was showing, same as a successful
|
|
3555
|
+
// register-device retry does.
|
|
3556
|
+
const googleConnect = createGoogleConnect({
|
|
3557
|
+
aegis,
|
|
3558
|
+
credentials,
|
|
3559
|
+
persistKey: (key) => settings.setAegisKey(key),
|
|
3560
|
+
openUrl: (url) => {
|
|
3561
|
+
if (!isSafeExternalUrl(url)) return false;
|
|
3562
|
+
shell.openExternal(url);
|
|
3563
|
+
return true;
|
|
3564
|
+
},
|
|
3565
|
+
googleSignIn,
|
|
3566
|
+
driveConnect: driveConnectLib,
|
|
3567
|
+
driveUpload: driveUploadLib,
|
|
3568
|
+
onAccountChange: () => broadcastAccountStatus(accountKey.status()),
|
|
3569
|
+
});
|
|
3399
3570
|
const keyPresentAtStart = Boolean(aegis.apiKey);
|
|
3400
3571
|
const earlyKeyProvision = autoProvision.autoProvisionApiKey(aegis, credentials, { app: 'desktop' }).then((result) => {
|
|
3401
3572
|
accountKey.recordStartup(result);
|
|
@@ -3873,6 +4044,14 @@ function bootstrap() {
|
|
|
3873
4044
|
registerUpdateIpc(ipcMain, updateManager);
|
|
3874
4045
|
ipcMain.handle(`${IPC_PREFIX}accountStatus`, () => accountKey.status());
|
|
3875
4046
|
ipcMain.handle(`${IPC_PREFIX}registerAccount`, () => accountKey.registerAccount());
|
|
4047
|
+
// Google sign-in + Drive connect/sync (lib/google-connect.js). Every call
|
|
4048
|
+
// resolves `{ ok, … }` / `{ ok: false, error }` rather than throwing, same
|
|
4049
|
+
// contract as the fingerprint* handlers below — the renderer shows the
|
|
4050
|
+
// actual reason instead of Electron's opaque "Error invoking remote method".
|
|
4051
|
+
ipcMain.handle(`${IPC_PREFIX}driveSignIn`, () => googleConnect.signInWithGoogle());
|
|
4052
|
+
ipcMain.handle(`${IPC_PREFIX}driveConnect`, () => googleConnect.connectDrive());
|
|
4053
|
+
ipcMain.handle(`${IPC_PREFIX}driveStatus`, () => googleConnect.status());
|
|
4054
|
+
ipcMain.handle(`${IPC_PREFIX}driveSyncMemory`, () => googleConnect.syncMemoryNow());
|
|
3876
4055
|
registerExportIpc(
|
|
3877
4056
|
ipcMain,
|
|
3878
4057
|
sessionStore,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegis-desktop",
|
|
3
3
|
"productName": "AEGIS Desktop",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.13",
|
|
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",
|
|
@@ -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.
|
|
@@ -1183,12 +1183,15 @@ function renderUpdateBanner(state) {
|
|
|
1183
1183
|
let showRetry = false;
|
|
1184
1184
|
const version = state.version ? `v${state.version} ` : '';
|
|
1185
1185
|
if (status === 'available') {
|
|
1186
|
-
//
|
|
1187
|
-
//
|
|
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.
|
|
1188
1190
|
text = state.command
|
|
1189
1191
|
? `Update ${version}available — run: ${state.command}`
|
|
1190
1192
|
: `Update ${version}available.`;
|
|
1191
1193
|
showDownload = !!state.canDownload;
|
|
1194
|
+
if (showDownload) text = `Update ${version}available.`;
|
|
1192
1195
|
} else if (status === 'downloading') {
|
|
1193
1196
|
const pct = typeof state.progress === 'number' ? ` (${Math.round(state.progress)}%)` : '';
|
|
1194
1197
|
text = `Downloading update${pct}…`;
|
|
@@ -6467,9 +6470,16 @@ async function init() {
|
|
|
6467
6470
|
|
|
6468
6471
|
els.updateDownloadBtn.addEventListener('click', () => {
|
|
6469
6472
|
els.updateDownloadBtn.disabled = true;
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
+
// The resolved value is the post-install state: render it as well as
|
|
6474
|
+
// waiting for the push, so a channel whose installer finishes inside the
|
|
6475
|
+
// invoke still repaints (and so a failure surfaces even if the push
|
|
6476
|
+
// channel is not wired yet).
|
|
6477
|
+
Promise.resolve(aegis.downloadUpdate())
|
|
6478
|
+
.then((state) => { if (state && state.status) renderUpdateBanner(state); })
|
|
6479
|
+
.catch(() => {})
|
|
6480
|
+
.finally(() => {
|
|
6481
|
+
els.updateDownloadBtn.disabled = false;
|
|
6482
|
+
});
|
|
6473
6483
|
});
|
|
6474
6484
|
|
|
6475
6485
|
// The only place quitAndInstallUpdate is ever called — an explicit user
|