aegisone 1.0.17 → 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 +3 -3
- package/scripts/bump.mjs +29 -4
- package/scripts/predist.mjs +2 -0
- package/src/dispatch.js +1 -0
- package/vendor/cli/README.md +3 -3
- package/vendor/cli/bin/aegiscode.js +29 -0
- package/vendor/cli/package.json +2 -2
- package/vendor/cli/src/app.js +370 -30
- package/vendor/cli/src/autonomous.js +30 -4
- package/vendor/cli/src/chatflow.js +132 -4
- package/vendor/cli/src/commands.js +223 -64
- 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 +123 -7
- package/vendor/cli/src/fingerprint.js +46 -16
- package/vendor/cli/src/limits.js +1 -1
- package/vendor/cli/src/overlays.js +98 -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/autonomous.js +48 -8
- 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/README.md +1 -1
- package/vendor/desktop/lib/auto.js +11 -7
- package/vendor/desktop/lib/fingerprint.js +76 -17
- package/vendor/desktop/lib/local/autonomous.js +48 -8
- 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 +10 -5
- 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
|
@@ -524,27 +524,43 @@ const EFFORT_TOKEN_BUDGET = { low: 8192, medium: 16384, high: 32768 };
|
|
|
524
524
|
/**
|
|
525
525
|
* DeepSeek native reasoning level per config rung.
|
|
526
526
|
*
|
|
527
|
-
* The field is `
|
|
528
|
-
*
|
|
529
|
-
* `
|
|
530
|
-
*
|
|
531
|
-
* `reasoning_effort:"none"` produced 0 reasoning_content chars and `"max"`
|
|
532
|
-
* produced 138, whereas `effort:"none"` still produced 112 — thinking stayed
|
|
533
|
-
* on. So the old field was inert on every turn, and inertness is the worst
|
|
534
|
-
* failure here: it 200s, nothing surfaces, and the model merely thinks at the
|
|
535
|
-
* wrong depth.
|
|
527
|
+
* The field is `effort`, NOT `reasoning_effort`. Verified live 2026-10-21
|
|
528
|
+
* against the surface this client actually reaches — the relay's
|
|
529
|
+
* `https://api.deepseek.com/anthropic` transport — by measuring output tokens
|
|
530
|
+
* over interleaved paired samples (n=12) against an absent-field baseline:
|
|
536
531
|
*
|
|
537
|
-
*
|
|
538
|
-
* than the earlier (low|max, no medium) fold, which rested on the mistaken
|
|
539
|
-
* belief that DeepSeek had no `medium`. `max_tokens` (EFFORT_TOKEN_BUDGET)
|
|
540
|
-
* still scales as the output ceiling, since hidden chain-of-thought shares that
|
|
541
|
-
* budget on DeepSeek.
|
|
532
|
+
* absent 818 · low 772 · medium 836 · high 818 · max 1494
|
|
542
533
|
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
534
|
+
* Only `max` separates from sending nothing. `GET /models` reports
|
|
535
|
+
* `supported_levels: ["low","high","max"]`, default `high`, on both live ids
|
|
536
|
+
* (`deepseek-flash`, `deepseek-v4-pro`) — so `medium` is not a level these
|
|
537
|
+
* models have. It passes the deserializer (unknown values *do* 422 with the
|
|
538
|
+
* enum, so validation is real) and is then absorbed into the default, which is
|
|
539
|
+
* this codebase's worst failure mode: a 200, nothing surfaced, and the model
|
|
540
|
+
* thinking at a depth nobody chose.
|
|
541
|
+
*
|
|
542
|
+
* What the earlier version of this comment asserted — that `reasoning_effort`
|
|
543
|
+
* binds and `effort` is ignored — was measured on the vendor's OpenAI-shaped
|
|
544
|
+
* `/chat/completions`, a surface this client never reaches, and it led to the
|
|
545
|
+
* knob being dead end-to-end: aegis1 forwards `reasoning_effort` only for
|
|
546
|
+
* BYOK_REASONING_EFFORT_PROVIDERS (openai/groq/gemini/grok — deepseek is
|
|
547
|
+
* absent), so the field was dropped at the relay. The `effort` channel is the
|
|
548
|
+
* one aegis1 gates on `provider_id == "deepseek"` (app.py) and that the
|
|
549
|
+
* Anthropic adapter nests as `output_config.effort`; it is the only channel
|
|
550
|
+
* that reaches the vendor, and the only one that measurably binds.
|
|
551
|
+
*
|
|
552
|
+
* The map folds `medium` upward for the same reason the Gemini row does: the
|
|
553
|
+
* vendor has no such level, and a rung that 200s while doing nothing is worse
|
|
554
|
+
* than one that says what it does. `max` is deliberately NOT reachable — it is
|
|
555
|
+
* not a rung of this knob, and mapping the default rung onto it would silently
|
|
556
|
+
* multiply reasoning spend on every turn nobody asked to deepen.
|
|
557
|
+
* `max_tokens` (EFFORT_TOKEN_BUDGET) still scales as the output ceiling, since
|
|
558
|
+
* hidden chain-of-thought shares that budget on DeepSeek.
|
|
559
|
+
*
|
|
560
|
+
* desktop/renderer/budget.js carries the renderer's copy; test/budget.test.mjs
|
|
561
|
+
* compares the two tables, so the mirror cannot drift silently.
|
|
546
562
|
*/
|
|
547
|
-
const DEEPSEEK_EFFORT = { low: 'low', medium: '
|
|
563
|
+
const DEEPSEEK_EFFORT = { low: 'low', medium: 'high', high: 'high' };
|
|
548
564
|
|
|
549
565
|
/**
|
|
550
566
|
* Per-family effort translation, mirroring the upstream engine's
|
|
@@ -565,7 +581,7 @@ const DEEPSEEK_EFFORT = { low: 'low', medium: 'medium', high: 'high' };
|
|
|
565
581
|
const EFFORT_IDENTITY = { low: 'low', medium: 'medium', high: 'high' };
|
|
566
582
|
const EFFORT_INERT_RE = /non-reasoning/i;
|
|
567
583
|
const EFFORT_DIALECTS = [
|
|
568
|
-
{ provider: 'deepseek', re: DEEPSEEK_REASONING_MODEL_RE, field: '
|
|
584
|
+
{ provider: 'deepseek', re: DEEPSEEK_REASONING_MODEL_RE, field: 'effort', map: DEEPSEEK_EFFORT },
|
|
569
585
|
{ provider: 'openai', re: /^(gpt-5|o[0-9])/i, field: 'reasoning_effort', map: EFFORT_IDENTITY },
|
|
570
586
|
{ provider: 'groq', re: /^(openai\/gpt-oss|qwen\/qwen3)/i, field: 'reasoning_effort', map: EFFORT_IDENTITY },
|
|
571
587
|
{ provider: 'xai', re: /^grok-(4\.[5-9]|[5-9])/, field: 'reasoning_effort', map: EFFORT_IDENTITY },
|
|
@@ -1967,8 +1983,8 @@ function createLocalEngine({
|
|
|
1967
1983
|
const { provider, model: bareModel } = splitByokModel(opts.model);
|
|
1968
1984
|
// Translate the rung for THIS vendor once, and carry the verdict rather
|
|
1969
1985
|
// than a bare level: the relay validates strictly upstream and the field
|
|
1970
|
-
// name is not portable (DeepSeek's
|
|
1971
|
-
//
|
|
1986
|
+
// name is not portable (DeepSeek's `/anthropic` transport takes `effort`,
|
|
1987
|
+
// OpenAI-shaped vendors take `reasoning_effort`). Undefined for a family
|
|
1972
1988
|
// with no dialect, which the transport then omits entirely.
|
|
1973
1989
|
const effort = nativeEffort(provider, bareModel, opts.effort);
|
|
1974
1990
|
try {
|
|
@@ -1999,10 +2015,16 @@ function createLocalEngine({
|
|
|
1999
2015
|
toolChoice: opts.toolChoice,
|
|
2000
2016
|
// Native effort knob, field and level both from the dialect table.
|
|
2001
2017
|
// `bareModel` is already provider-less, so it matches the dialect
|
|
2002
|
-
// regexes without further stripping.
|
|
2003
|
-
//
|
|
2004
|
-
// `
|
|
2005
|
-
//
|
|
2018
|
+
// regexes without further stripping. Both wire channels are live, and
|
|
2019
|
+
// which one is used is the dialect's decision, not this call site's:
|
|
2020
|
+
// DeepSeek's `/anthropic` transport takes `effort` (aegis1 gates it on
|
|
2021
|
+
// provider_id == "deepseek" and the adapter nests it as
|
|
2022
|
+
// `output_config.effort`), while the OpenAI-shaped vendors take
|
|
2023
|
+
// `reasoning_effort`. Routing on the field name is what keeps a
|
|
2024
|
+
// dialect from being silently dropped here — the previous form
|
|
2025
|
+
// forwarded only `reasoning_effort`, so turning DeepSeek's dialect
|
|
2026
|
+
// over to `effort` would have died at this line.
|
|
2027
|
+
effort: effort && effort.field === 'effort' ? effort.level : undefined,
|
|
2006
2028
|
reasoningEffort: effort && effort.field === 'reasoning_effort' ? effort.level : undefined,
|
|
2007
2029
|
stream: true,
|
|
2008
2030
|
onStream: opts.onDelta,
|
|
@@ -103,6 +103,19 @@ const QUICK_LAUNCHER_NAMESPACE = '__quickLauncher';
|
|
|
103
103
|
* fighting existing app/OS bindings, memorable enough to type once. */
|
|
104
104
|
const DEFAULT_QUICK_LAUNCHER_SHORTCUT = 'CmdOrCtrl+Shift+Space';
|
|
105
105
|
|
|
106
|
+
/** Reserved namespace for where `fingerprint publish`/the vault card sends
|
|
107
|
+
* sealed records: `{ backend }`, one of VAULT_BACKEND_VALUES — app-level, not
|
|
108
|
+
* a provider, for the same reason the quick launcher isn't. Default is
|
|
109
|
+
* `aegiscloud` (unset reads as the default, same convention as confirm mode)
|
|
110
|
+
* because it is the only backend that exists on a fresh install — see
|
|
111
|
+
* client/record-vault.js's own DEFAULT_BACKEND. `drive` asks the fingerprint
|
|
112
|
+
* service to talk to rclone's `gdrive` remote instead (the user's own Drive,
|
|
113
|
+
* configured by them); `off` means publish/anchor/vault/audit refuse with a
|
|
114
|
+
* named reason rather than silently reaching either backend. */
|
|
115
|
+
const VAULT_BACKEND_NAMESPACE = '__vaultBackend';
|
|
116
|
+
const DEFAULT_VAULT_BACKEND = 'aegiscloud';
|
|
117
|
+
const VAULT_BACKEND_VALUES = Object.freeze(['aegiscloud', 'drive', 'off']);
|
|
118
|
+
|
|
106
119
|
/** Reserved namespace for the tool-call approval ("confirm mode") preference:
|
|
107
120
|
* `{ enabled }` — app-level, not a provider, so it stays out of the provider
|
|
108
121
|
* CRUD surface for the same reason the AEGIS key does. Default is ON
|
|
@@ -138,31 +151,34 @@ const AVATAR_NAMESPACE = '__avatar';
|
|
|
138
151
|
* main.js telemetryEnabled() through getTelemetryOptIn(). */
|
|
139
152
|
const TELEMETRY_NAMESPACE = '__telemetry';
|
|
140
153
|
|
|
141
|
-
/** Reserved namespace for the auto-drain
|
|
154
|
+
/** Reserved namespace for the auto-drain switch:
|
|
142
155
|
* `{ enabled, intervalMs }` — app-level, not a provider.
|
|
143
156
|
*
|
|
144
|
-
* DEFAULT
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* `__confirmMode`/`__memoryPersist` above. */
|
|
157
|
+
* DEFAULT ON (user request: the queue must work with no click and nothing on
|
|
158
|
+
* screen). An absent namespace means "drain in the background"; only an
|
|
159
|
+
* explicit `enabled: false` disarms it, and that is what the settings store
|
|
160
|
+
* writes when someone turns the worker off from the CLI or by hand.
|
|
161
|
+
*
|
|
162
|
+
* The guards are what make that default defensible, and they live in
|
|
163
|
+
* `lib/auto.js`, not here: a tick skips when the queue is empty (so an idle
|
|
164
|
+
* install costs one JSON parse and no lock I/O), when another host holds the
|
|
165
|
+
* drain lock, when a drain is already in flight, and when the switch was
|
|
166
|
+
* turned off since the last tick — the switch is re-read on EVERY tick, so
|
|
167
|
+
* disarming stops the very next one. Nothing secret lives here, so no
|
|
168
|
+
* encryption — same shape as `__confirmMode`/`__memoryPersist` above. */
|
|
157
169
|
const AUTO_DRAIN_NAMESPACE = '__autoDrain';
|
|
158
170
|
|
|
159
|
-
/** Reserved namespace for the auto-mint (seal-on-quiet)
|
|
171
|
+
/** Reserved namespace for the auto-mint (seal-on-quiet) switch:
|
|
160
172
|
* `{ enabled, publish }` — app-level, not a provider.
|
|
161
173
|
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
174
|
+
* `enabled` is DEFAULT ON, same as auto-drain: a session seals itself once it
|
|
175
|
+
* has been quiet, with nothing on screen asking for it. Only an explicit
|
|
176
|
+
* `enabled: false` disarms it.
|
|
177
|
+
*
|
|
178
|
+
* `publish` stays a separate, DEFAULT OFF switch: sealing writes a local
|
|
179
|
+
* record, whereas publishing sends those bytes to the vault over `rclone` and
|
|
180
|
+
* writes an anchor beside them. An automatic network copy is never implied by
|
|
181
|
+
* an automatic seal.
|
|
166
182
|
*
|
|
167
183
|
* The AI half of the record resolves through the shared rungs in
|
|
168
184
|
* client/attest.js (`$AEGIS_AI_SECRET`/`$AEGIS_AI_MODEL` in the app scope) —
|
|
@@ -195,6 +211,7 @@ const RESERVED_NAMESPACES = Object.freeze([
|
|
|
195
211
|
AEGIS_KEY_NAMESPACE,
|
|
196
212
|
LEGACY_AEGIS_NAMESPACE,
|
|
197
213
|
QUICK_LAUNCHER_NAMESPACE,
|
|
214
|
+
VAULT_BACKEND_NAMESPACE,
|
|
198
215
|
CONFIRM_MODE_NAMESPACE,
|
|
199
216
|
MEMORY_PERSIST_NAMESPACE,
|
|
200
217
|
AVATAR_NAMESPACE,
|
|
@@ -539,6 +556,24 @@ function createSettingsStore({ dir, safeStorage, prefsDir, env } = {}) {
|
|
|
539
556
|
return quickLauncherConfig();
|
|
540
557
|
}
|
|
541
558
|
|
|
559
|
+
// --- Vault backend: reserved namespace, plain (unencrypted) preference ---
|
|
560
|
+
// No secret lives here either — just which of three named destinations a
|
|
561
|
+
// publish goes to — so like the quick launcher there is nothing to encrypt.
|
|
562
|
+
|
|
563
|
+
function vaultBackendConfig() {
|
|
564
|
+
const cfg = load()[VAULT_BACKEND_NAMESPACE] || {};
|
|
565
|
+
const backend = VAULT_BACKEND_VALUES.includes(cfg.backend) ? cfg.backend : DEFAULT_VAULT_BACKEND;
|
|
566
|
+
return { backend };
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function setVaultBackendConfig(backend) {
|
|
570
|
+
if (!VAULT_BACKEND_VALUES.includes(backend)) return vaultBackendConfig();
|
|
571
|
+
const data = load();
|
|
572
|
+
data[VAULT_BACKEND_NAMESPACE] = { backend };
|
|
573
|
+
save(data);
|
|
574
|
+
return vaultBackendConfig();
|
|
575
|
+
}
|
|
576
|
+
|
|
542
577
|
// --- Confirm mode: SHARED preference (AEGISONE ON8, decision D8 rule 1) --
|
|
543
578
|
// "Confirm before running tools" — the switch for the renderer's tool-call
|
|
544
579
|
// approval gate (desktop/lib/local/engine.js gatedExecuteTool). ON (default,
|
|
@@ -726,10 +761,10 @@ function createSettingsStore({ dir, safeStorage, prefsDir, env } = {}) {
|
|
|
726
761
|
function getAutoDrain() {
|
|
727
762
|
const cfg = load()[AUTO_DRAIN_NAMESPACE] || {};
|
|
728
763
|
return {
|
|
729
|
-
// Unset ===
|
|
730
|
-
//
|
|
731
|
-
//
|
|
732
|
-
enabled: cfg.enabled
|
|
764
|
+
// Unset === TRUE. The queue drains in the background unless someone
|
|
765
|
+
// switched it off in as many words; `lib/auto.js` re-reads this on every
|
|
766
|
+
// tick, so that off switch stops the very next one.
|
|
767
|
+
enabled: cfg.enabled !== false,
|
|
733
768
|
intervalMs: clampAutoDrainInterval(cfg.intervalMs),
|
|
734
769
|
};
|
|
735
770
|
}
|
|
@@ -760,7 +795,8 @@ function createSettingsStore({ dir, safeStorage, prefsDir, env } = {}) {
|
|
|
760
795
|
function getAutoMint() {
|
|
761
796
|
const cfg = load()[AUTO_MINT_NAMESPACE] || {};
|
|
762
797
|
return {
|
|
763
|
-
|
|
798
|
+
// Unset === TRUE (background sealing). `publish` below stays opt-in.
|
|
799
|
+
enabled: cfg.enabled !== false,
|
|
764
800
|
// Independent of `enabled` on purpose: an automatic seal must not drag
|
|
765
801
|
// an automatic upload along with it.
|
|
766
802
|
publish: cfg.publish === true,
|
|
@@ -807,6 +843,8 @@ function createSettingsStore({ dir, safeStorage, prefsDir, env } = {}) {
|
|
|
807
843
|
migrateLegacyAegisKey,
|
|
808
844
|
quickLauncherConfig,
|
|
809
845
|
setQuickLauncherConfig,
|
|
846
|
+
vaultBackendConfig,
|
|
847
|
+
setVaultBackendConfig,
|
|
810
848
|
getConfirmMode,
|
|
811
849
|
setConfirmMode,
|
|
812
850
|
confirmModeState,
|
|
@@ -833,6 +871,7 @@ module.exports = {
|
|
|
833
871
|
AEGIS_KEY_NAMESPACE,
|
|
834
872
|
LEGACY_AEGIS_NAMESPACE,
|
|
835
873
|
QUICK_LAUNCHER_NAMESPACE,
|
|
874
|
+
VAULT_BACKEND_NAMESPACE,
|
|
836
875
|
CONFIRM_MODE_NAMESPACE,
|
|
837
876
|
MEMORY_PERSIST_NAMESPACE,
|
|
838
877
|
AVATAR_NAMESPACE,
|
|
@@ -844,6 +883,8 @@ module.exports = {
|
|
|
844
883
|
AUTO_DRAIN_INTERVAL_MAX_MS,
|
|
845
884
|
AVATAR_MOTION_MODES,
|
|
846
885
|
DEFAULT_QUICK_LAUNCHER_SHORTCUT,
|
|
886
|
+
DEFAULT_VAULT_BACKEND,
|
|
887
|
+
VAULT_BACKEND_VALUES,
|
|
847
888
|
RESERVED_NAMESPACES,
|
|
848
889
|
isReservedNamespace,
|
|
849
890
|
maskKey,
|
package/vendor/desktop/README.md
CHANGED
|
@@ -12,13 +12,17 @@
|
|
|
12
12
|
* BACKGROUND. desktop/main.js and desktop/preload.js both stated an absolute
|
|
13
13
|
* rule when the queue shipped: "NOTHING DRAINS UNLESS THE USER ASKED. There is
|
|
14
14
|
* no interval, no drain at startup, and no drain-on-idle anywhere in this
|
|
15
|
-
* file."
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
15
|
+
* file." A click was the only trigger, which made "queue a task and walk away"
|
|
16
|
+
* impossible — the one thing an unattended queue is FOR. The user asked for the
|
|
17
|
+
* automation (twice: "autonomous queue", then "work in the background
|
|
18
|
+
* instead"), so both switches now DEFAULT ON and the sidebar card that used to
|
|
19
|
+
* gate them is hidden: draining and sealing happen with nothing on screen.
|
|
20
|
+
*
|
|
21
|
+
* What keeps that safe is not an off-by-default — it is the guards below, which
|
|
22
|
+
* are unchanged and all of them skips rather than drains: an empty queue, a
|
|
23
|
+
* drain already in flight, another host holding the lock, and a switch turned
|
|
24
|
+
* off since the last tick (re-read EVERY tick, so off stops the very next one,
|
|
25
|
+
* whoever wrote it: the settings file, the CLI, a hand edit).
|
|
22
26
|
*
|
|
23
27
|
* There are exactly two automations, because there are exactly two acts in the
|
|
24
28
|
* app that are irreversible-ish and cost something:
|
|
@@ -94,12 +94,43 @@ function slug(value, max = 80) {
|
|
|
94
94
|
* @param {object} o
|
|
95
95
|
* @param {string} o.dir the app's data directory (userData in a package)
|
|
96
96
|
* @param {object} [o.env] process env, injectable for tests
|
|
97
|
+
* @param {() => string} [o.getVaultBackend] reads the live preference
|
|
98
|
+
* ('aegiscloud' | 'drive' | 'off', desktop/lib/settings.js's
|
|
99
|
+
* vaultBackendConfig) — a function, not a value, so a change made in
|
|
100
|
+
* Settings while the app is running reaches the very next vault call with
|
|
101
|
+
* no restart, the same contract getConfirmMode's gate already keeps.
|
|
97
102
|
*/
|
|
98
|
-
function createFingerprintService({ dir, env } = {}) {
|
|
103
|
+
function createFingerprintService({ dir, env, getVaultBackend } = {}) {
|
|
99
104
|
if (!dir) throw new Error('aegis-desktop: createFingerprintService needs a data dir');
|
|
100
105
|
// One store: the shared modules read AEGIS_HOME and nothing else.
|
|
101
106
|
const scope = { ...(env || process.env), AEGIS_HOME: (env || process.env).AEGIS_HOME || dir };
|
|
102
107
|
|
|
108
|
+
/** `true` only when the user has explicitly turned sync off — not when no
|
|
109
|
+
* preference has been recorded yet, which must keep resolving to whatever
|
|
110
|
+
* record-vault.js's own default is. */
|
|
111
|
+
function vaultDisabled() {
|
|
112
|
+
return typeof getVaultBackend === 'function' && getVaultBackend() === 'off';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* `scope`, with the vault backend layered on top of it when a preference
|
|
117
|
+
* names one. 'aegiscloud' and an absent preference both fall through to
|
|
118
|
+
* `scope` unchanged — client/record-vault.js's own DEFAULT_BACKEND is
|
|
119
|
+
* already 'aegiscloud', so there is nothing to add for either case. 'drive'
|
|
120
|
+
* is the one preference that actually changes the destination: it asks the
|
|
121
|
+
* rclone adapter for the `gdrive` remote (the user's own Google Drive,
|
|
122
|
+
* configured by them — see client/record-vault.js's DEFAULT_REMOTE). 'off'
|
|
123
|
+
* is handled by `vaultDisabled()` before this is ever called, not here.
|
|
124
|
+
*/
|
|
125
|
+
function vaultScope() {
|
|
126
|
+
if (typeof getVaultBackend === 'function' && getVaultBackend() === 'drive') {
|
|
127
|
+
return { ...scope, AEGIS_VAULT_BACKEND: 'rclone', AEGIS_VAULT_REMOTE: scope.AEGIS_VAULT_REMOTE || 'gdrive' };
|
|
128
|
+
}
|
|
129
|
+
return scope;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const VAULT_OFF_ERROR = 'the vault is turned off — turn it back on (Google Drive or AE) in Settings to publish or inspect it';
|
|
133
|
+
|
|
103
134
|
const recordPath = (record, session) =>
|
|
104
135
|
path.join(dir, 'fingerprints', `${slug(session)}.${String(record.createdAt).replace(/[:.]/g, '-')}.json`);
|
|
105
136
|
|
|
@@ -110,7 +141,22 @@ function createFingerprintService({ dir, env } = {}) {
|
|
|
110
141
|
const { fp, authorship, vault } = load();
|
|
111
142
|
const key = authorship.resolveKey({ argv: [], env: scope });
|
|
112
143
|
const history = path.join(authorship.dataDir(scope), 'history.jsonl');
|
|
113
|
-
|
|
144
|
+
if (vaultDisabled()) {
|
|
145
|
+
return {
|
|
146
|
+
ok: true,
|
|
147
|
+
configured: Boolean(key.secret),
|
|
148
|
+
keySource: key.source,
|
|
149
|
+
keyPath: key.path,
|
|
150
|
+
keyFingerprint: key.secret ? fp.keyFingerprint(key.secret) : null,
|
|
151
|
+
publicKey: key.public,
|
|
152
|
+
defaultKeyPath: authorship.defaultKeyPath(scope),
|
|
153
|
+
historyPath: history,
|
|
154
|
+
historyPresent: fs.existsSync(history),
|
|
155
|
+
dataDir: authorship.dataDir(scope),
|
|
156
|
+
vault: { backend: 'off', remote: null, root: null, recordsDir: null },
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const target = vault.vaultTarget(vaultScope());
|
|
114
160
|
return {
|
|
115
161
|
ok: true,
|
|
116
162
|
configured: Boolean(key.secret),
|
|
@@ -125,7 +171,12 @@ function createFingerprintService({ dir, env } = {}) {
|
|
|
125
171
|
// Where a publish goes, so the panel can say it before the user asks
|
|
126
172
|
// for one — and so a misconfigured root is visible, not discovered by
|
|
127
173
|
// a record landing in the wrong folder.
|
|
128
|
-
vault: {
|
|
174
|
+
vault: {
|
|
175
|
+
backend: target.backend,
|
|
176
|
+
remote: target.remote,
|
|
177
|
+
root: target.root,
|
|
178
|
+
recordsDir: target.backend === vault.BACKEND_CLOUD ? vault.CLOUD_PREFIX : `${target.root}/${vault.RECORDS_DIR}`,
|
|
179
|
+
},
|
|
129
180
|
};
|
|
130
181
|
} catch (e) {
|
|
131
182
|
return { ok: false, error: (e && e.message) || String(e) };
|
|
@@ -155,7 +206,7 @@ function createFingerprintService({ dir, env } = {}) {
|
|
|
155
206
|
* session carry the same behaviour digest — and the same AI digest, from the
|
|
156
207
|
* same turns.
|
|
157
208
|
*/
|
|
158
|
-
mint({ history = null, session = null, turns = null, label = null, account = null,
|
|
209
|
+
async mint({ history = null, session = null, turns = null, label = null, account = null,
|
|
159
210
|
model = null, tools = null, codeRoots = null, codeDirty = null, out = null,
|
|
160
211
|
createdAt = null, publish = false, aiSecret = undefined, aiModel = null } = {}) {
|
|
161
212
|
try {
|
|
@@ -196,11 +247,15 @@ function createFingerprintService({ dir, env } = {}) {
|
|
|
196
247
|
let vault = null;
|
|
197
248
|
let vaultError = null;
|
|
198
249
|
if (publish) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
250
|
+
if (vaultDisabled()) {
|
|
251
|
+
vaultError = VAULT_OFF_ERROR;
|
|
252
|
+
} else {
|
|
253
|
+
try {
|
|
254
|
+
const key = authorship.resolveKey({ argv: [], env: scope });
|
|
255
|
+
vault = await load().vault.publish({ file, argv: [], env: vaultScope(), secret: key.secret });
|
|
256
|
+
} catch (e) {
|
|
257
|
+
vaultError = (e && e.message) || String(e);
|
|
258
|
+
}
|
|
204
259
|
}
|
|
205
260
|
}
|
|
206
261
|
return {
|
|
@@ -225,13 +280,14 @@ function createFingerprintService({ dir, env } = {}) {
|
|
|
225
280
|
* preferred path is the file, because the sha256 in the anchor is then about
|
|
226
281
|
* the bytes on disk rather than a re-serialisation of them.
|
|
227
282
|
*/
|
|
228
|
-
publish({ file = null, record = null, dryRun = false } = {}) {
|
|
283
|
+
async publish({ file = null, record = null, dryRun = false } = {}) {
|
|
284
|
+
if (vaultDisabled()) return { ok: false, error: VAULT_OFF_ERROR };
|
|
229
285
|
try {
|
|
230
286
|
const { authorship, vault } = load();
|
|
231
287
|
const key = authorship.resolveKey({ argv: [], env: scope });
|
|
232
288
|
return {
|
|
233
289
|
ok: true,
|
|
234
|
-
...vault.publish({ file, record, argv: [], env:
|
|
290
|
+
...(await vault.publish({ file, record, argv: [], env: vaultScope(), secret: key.secret, dryRun })),
|
|
235
291
|
};
|
|
236
292
|
} catch (e) {
|
|
237
293
|
return { ok: false, error: (e && e.message) || String(e) };
|
|
@@ -246,22 +302,24 @@ function createFingerprintService({ dir, env } = {}) {
|
|
|
246
302
|
* sealed it has moved on" are three different situations and a single
|
|
247
303
|
* boolean would flatten them into one that hides the interesting case.
|
|
248
304
|
*/
|
|
249
|
-
anchor({ file = null, record = null, anchor = null } = {}) {
|
|
305
|
+
async anchor({ file = null, record = null, anchor = null } = {}) {
|
|
306
|
+
if (vaultDisabled()) return { ok: false, error: VAULT_OFF_ERROR };
|
|
250
307
|
try {
|
|
251
308
|
const { authorship, vault } = load();
|
|
252
309
|
if (!file && !record && !anchor) return { ok: false, error: 'anchor needs a record or an anchor' };
|
|
253
310
|
const key = authorship.resolveKey({ argv: [], env: scope });
|
|
254
|
-
return { ok: true, ...vault.checkAnchor({ file, record, anchor, argv: [], env:
|
|
311
|
+
return { ok: true, ...(await vault.checkAnchor({ file, record, anchor, argv: [], env: vaultScope(), key })) };
|
|
255
312
|
} catch (e) {
|
|
256
313
|
return { ok: false, error: (e && e.message) || String(e) };
|
|
257
314
|
}
|
|
258
315
|
},
|
|
259
316
|
|
|
260
317
|
/** What is in the vault. */
|
|
261
|
-
vaultList() {
|
|
318
|
+
async vaultList() {
|
|
319
|
+
if (vaultDisabled()) return { ok: false, error: VAULT_OFF_ERROR };
|
|
262
320
|
try {
|
|
263
321
|
const { vault } = load();
|
|
264
|
-
return { ok: true, ...vault.list({ argv: [], env:
|
|
322
|
+
return { ok: true, ...(await vault.list({ argv: [], env: vaultScope() })) };
|
|
265
323
|
} catch (e) {
|
|
266
324
|
return { ok: false, error: (e && e.message) || String(e) };
|
|
267
325
|
}
|
|
@@ -272,11 +330,12 @@ function createFingerprintService({ dir, env } = {}) {
|
|
|
272
330
|
* already there before publishing was restricted. A finding is a fact about
|
|
273
331
|
* the vault, not about this app, so it is returned rather than acted on.
|
|
274
332
|
*/
|
|
275
|
-
vaultAudit() {
|
|
333
|
+
async vaultAudit() {
|
|
334
|
+
if (vaultDisabled()) return { ok: false, error: VAULT_OFF_ERROR };
|
|
276
335
|
try {
|
|
277
336
|
const { authorship, vault } = load();
|
|
278
337
|
const key = authorship.resolveKey({ argv: [], env: scope });
|
|
279
|
-
return { ok: true, ...vault.audit({ argv: [], env:
|
|
338
|
+
return { ok: true, ...(await vault.audit({ argv: [], env: vaultScope(), secret: key.secret || null })) };
|
|
280
339
|
} catch (e) {
|
|
281
340
|
return { ok: false, error: (e && e.message) || String(e) };
|
|
282
341
|
}
|
|
@@ -209,8 +209,15 @@ const DEFAULT_MODEL = 'nexus-brain';
|
|
|
209
209
|
* depends on what the user's own daemon happens to have. Both REQUIRE an
|
|
210
210
|
* explicit model, refused by name instead of silently resolving to
|
|
211
211
|
* something nobody chose.
|
|
212
|
+
* - 'pro' DOES have a default, but not one this app chooses: a blank model
|
|
213
|
+
* means "the `claude` CLI picks for the subscription", which is what
|
|
214
|
+
* `--model` omitted says (engine.js sends no flag for `default`). Once a
|
|
215
|
+
* model IS stated it must be one of claude-pro.js's PRO_MODELS aliases —
|
|
216
|
+
* the same list the model picker offers — because the child accepts only
|
|
217
|
+
* those four spellings, and a `provider:model` id copied from a byok task
|
|
218
|
+
* would otherwise be handed to `claude --model` and fail there.
|
|
212
219
|
*/
|
|
213
|
-
const MODEL_CLASSES = Object.freeze(['aegis', 'byok', 'local']);
|
|
220
|
+
const MODEL_CLASSES = Object.freeze(['aegis', 'byok', 'local', 'pro']);
|
|
214
221
|
|
|
215
222
|
const AEGIS_MODEL_RE = /^(?:nexus|aegis)-brain(?:-(?:smart|neo))?$/;
|
|
216
223
|
const AEGIS_MODEL_IDS = Object.freeze(['nexus-brain', 'aegis-brain']);
|
|
@@ -270,6 +277,34 @@ function modelRefusal(id, cls) {
|
|
|
270
277
|
}
|
|
271
278
|
return '';
|
|
272
279
|
}
|
|
280
|
+
if (normalized === 'pro') {
|
|
281
|
+
// The subscription route. A blank model is legal and meaningful: engine.js
|
|
282
|
+
// sends no `--model` at all for 'default', so the child resolves the pick
|
|
283
|
+
// itself. Anything STATED must be a PRO_MODELS alias, because those four
|
|
284
|
+
// spellings are exactly what `claude --model` accepts — a byok-style
|
|
285
|
+
// "provider:model" copied between tasks would be handed to the child and
|
|
286
|
+
// fail there, three stages into a drain, with the queue's own file naming
|
|
287
|
+
// something the queue never validated.
|
|
288
|
+
if (!stated) return '';
|
|
289
|
+
// Required lazily: claude-pro.js is a heavy sibling (child spawn, session
|
|
290
|
+
// files) and this module is loaded by queue.js at every CLI start. The
|
|
291
|
+
// require is a plain sibling path with no back-require, so there is no
|
|
292
|
+
// cycle to guard — this is about load cost, not correctness.
|
|
293
|
+
let aliases;
|
|
294
|
+
try {
|
|
295
|
+
aliases = require('./claude-pro.js').PRO_MODELS;
|
|
296
|
+
} catch {
|
|
297
|
+
// If the alias list cannot be read we cannot validate a stated model, and
|
|
298
|
+
// accepting it unvalidated is the exact failure this arm exists to stop.
|
|
299
|
+
return `a pro task's model cannot be checked right now — queue it with no --model to let the claude CLI pick`;
|
|
300
|
+
}
|
|
301
|
+
const ids = (Array.isArray(aliases) ? aliases : []).map((m) => String(m && m.id).trim());
|
|
302
|
+
if (ids.includes(stated.toLowerCase())) return '';
|
|
303
|
+
return (
|
|
304
|
+
`the autonomous queue's Pro class runs the subscription through the claude CLI, ` +
|
|
305
|
+
`which accepts only its own model aliases (${ids.join('/')}); "${stated}" is not one`
|
|
306
|
+
);
|
|
307
|
+
}
|
|
273
308
|
// normalized === 'local'
|
|
274
309
|
if (!stated) return 'a local task needs a model — the tag of whatever is pulled into the local daemon';
|
|
275
310
|
return '';
|
|
@@ -594,13 +629,18 @@ function createQueueWorker({
|
|
|
594
629
|
*/
|
|
595
630
|
async function runTask(item, { carry = '', commit } = {}) {
|
|
596
631
|
const cwd = item.cwd || process.cwd();
|
|
597
|
-
//
|
|
598
|
-
// item whose model
|
|
599
|
-
// `--model` the CLI accepted before this rule existed,
|
|
600
|
-
// older build) would otherwise go out
|
|
601
|
-
//
|
|
602
|
-
// spelling, an opaque server error otherwise
|
|
603
|
-
//
|
|
632
|
+
// The task's own (model, class) pair checked BEFORE the turn, not at the
|
|
633
|
+
// server. An item whose model does not belong to its class (a hand-edited
|
|
634
|
+
// queue file, a `--model` the CLI accepted before this rule existed,
|
|
635
|
+
// another host's older build) would otherwise go out under a transport
|
|
636
|
+
// that does not serve it: billed work if it happens to be a per-provider
|
|
637
|
+
// spelling, an opaque server error otherwise, and for 'pro' a `claude
|
|
638
|
+
// --model` that the child rejects. Failing here names the model and the
|
|
639
|
+
// spellings that class accepts, and costs nothing.
|
|
640
|
+
//
|
|
641
|
+
// "Aegis Cloud or nothing" was this comment's old claim, and it stopped
|
|
642
|
+
// being true when byok/local were added (9eeef09) — modelRefusal is what
|
|
643
|
+
// actually enforces the rule now, per class, and it runs for all four.
|
|
604
644
|
const cls = normalizeClass(item.class);
|
|
605
645
|
const refusal = modelRefusal(item.model, cls);
|
|
606
646
|
if (refusal) {
|