aegis-desktop 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/SOURCE-OFFER.txt +9 -0
  2. package/bin/aegis.js +1 -32
  3. package/lib/account-key.js +1 -56
  4. package/lib/auto.js +1 -430
  5. package/lib/avatar/companion.js +1 -698
  6. package/lib/avatar/cosmetics.js +1 -532
  7. package/lib/avatar/events.js +1 -344
  8. package/lib/avatar/holder-turn.js +1 -350
  9. package/lib/avatar/holders.js +1 -612
  10. package/lib/avatar/identity.js +1 -641
  11. package/lib/avatar/level.js +1 -368
  12. package/lib/avatar/mirror.js +1 -524
  13. package/lib/avatar/persona.js +1 -388
  14. package/lib/avatar/profile.js +1 -977
  15. package/lib/avatar/register.js +1 -307
  16. package/lib/avatar/store.js +1 -472
  17. package/lib/avatar/tiers.js +1 -38
  18. package/lib/avatar/transfer.js +1 -415
  19. package/lib/avatar/turn.js +1 -216
  20. package/lib/avatar/voice.js +1 -328
  21. package/lib/avatar/xp.js +1 -404
  22. package/lib/deep-link.js +1 -120
  23. package/lib/fingerprint.js +2 -347
  24. package/lib/google-connect.js +1 -169
  25. package/lib/local/agents.js +1 -105
  26. package/lib/local/autonomous.js +1 -1045
  27. package/lib/local/claude-pro.js +1 -993
  28. package/lib/local/context.js +1 -95
  29. package/lib/local/engine.js +1 -3228
  30. package/lib/local/entitlement.js +1 -654
  31. package/lib/local/git-scope.js +1 -228
  32. package/lib/local/local.js +1 -2135
  33. package/lib/local/prompt.js +1 -275
  34. package/lib/local/queue.js +1 -560
  35. package/lib/local/session-rounds.js +1 -208
  36. package/lib/local/shell.js +1 -680
  37. package/lib/local/telemetry.js +1 -470
  38. package/lib/local/tools.js +1 -1238
  39. package/lib/local/turn-guard.js +1 -300
  40. package/lib/local/worktree-lock.js +1 -235
  41. package/lib/provider-key-mirror.js +1 -252
  42. package/lib/quick-launcher.js +1 -84
  43. package/lib/settings.js +1 -890
  44. package/lib/sync/memory-queue.js +1 -60
  45. package/lib/sync/persist-gate.js +1 -148
  46. package/lib/sync/sessions.js +1 -106
  47. package/lib/window-state.js +1 -66
  48. package/main.js +3 -4390
  49. package/package.json +3 -5
  50. package/preload.js +3 -628
  51. package/renderer/app.js +1 -6560
  52. package/renderer/avatar/assemble.js +1 -335
  53. package/renderer/avatar/avatar.js +1 -380
  54. package/renderer/avatar/cards.js +1 -141
  55. package/renderer/avatar/hud.js +1 -206
  56. package/renderer/avatar/machine.js +1 -213
  57. package/renderer/avatar/pane.js +1 -439
  58. package/renderer/avatar/parts.js +1 -437
  59. package/renderer/budget.js +1 -168
  60. package/renderer/companion.js +1 -223
  61. package/renderer/diff.js +1 -359
  62. package/renderer/diffview.js +1 -336
  63. package/renderer/fingerprint.js +3 -720
  64. package/renderer/markdown.js +1 -168
  65. package/renderer/provider-toolbar.js +1 -134
  66. package/renderer/providers.js +1 -259
  67. package/renderer/quick.js +1 -191
  68. package/renderer/stream-policy.js +1 -306
  69. package/renderer/transcript-view.js +1 -323
  70. package/renderer/usage.js +1 -1239
  71. package/vendor/aegis.js +1 -2054
  72. package/vendor/attest.js +1 -442
  73. package/vendor/authorship-key.js +1 -410
  74. package/vendor/auto-provision.js +1 -134
  75. package/vendor/brain-catalog.js +1 -268
  76. package/vendor/byok-catalog.js +1 -230
  77. package/vendor/credentials.js +1 -494
  78. package/vendor/device-fingerprint.js +1 -141
  79. package/vendor/drive-connect.js +1 -85
  80. package/vendor/drive-upload.js +1 -174
  81. package/vendor/env-file.js +1 -1273
  82. package/vendor/fingerprint.js +1 -1064
  83. package/vendor/foreign-memory.js +1 -669
  84. package/vendor/google-signin.js +1 -125
  85. package/vendor/hooks.js +1 -430
  86. package/vendor/model-discovery.js +1 -330
  87. package/vendor/platform.js +1 -937
  88. package/vendor/prefs.js +1 -351
  89. package/vendor/presence-constants.js +1 -107
  90. package/vendor/presence.js +1 -438
  91. package/vendor/record-vault.js +3 -1055
  92. package/vendor/session-store.js +1 -548
  93. package/vendor/topup.js +1 -297
  94. package/vendor/touch.js +1 -458
  95. package/vendor/update.js +1 -704
  96. package/vendor/user-models.js +1 -381
@@ -1,170 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * Assistant-message markdown rendering: marked -> DOMPurify -> DOM
10
- * postprocessing (syntax highlight + copy buttons on fenced code, external
11
- * link rewiring). This is the ONLY path that may put model output into
12
- * innerHTML — everywhere else in app.js, assistant/user text stays
13
- * textContent. See renderInto() below.
14
- *
15
- * Loaded as a classic script (CSP script-src 'self', no bundler) after
16
- * vendor/marked.umd.js, vendor/purify.min.js and vendor/aegis-highlight.js
17
- * (all under renderer/vendor/ — desktop/vendor/ is a predist.mjs staging
18
- * dir that the repo's pre-commit hook blocks from ever being committed),
19
- * before app.js. Exposes window.AegisMarkdown.
20
- *
21
- * UMD-lite like aegis-highlight.js: CommonJS export for the pure, DOM-free
22
- * helpers so they're unit-testable in plain Node; the DOM-dependent half
23
- * (renderInto) only runs under a real document (Electron renderer).
24
- */
25
- (function (root, factory) {
26
- const mod = factory();
27
- if (typeof module === 'object' && module.exports) {
28
- module.exports = mod;
29
- } else {
30
- root.AegisMarkdown = mod;
31
- }
32
- })(typeof globalThis !== 'undefined' ? globalThis : this, function () {
33
- /**
34
- * Is `href` an absolute http(s) URL — something that could plausibly be
35
- * opened externally? Deliberately parsed with NO base: a relative path or
36
- * bare "#anchor" has no scheme and must fail to parse here, not silently
37
- * inherit https: from a placeholder base (that was the original bug —
38
- * every relative href came back "external"). This is defense in depth
39
- * only — main.js's isSafeExternalUrl is the real gate before anything
40
- * reaches the OS shell.
41
- */
42
- function isExternalHref(href) {
43
- if (typeof href !== 'string' || !href) return false;
44
- try {
45
- const url = new URL(href);
46
- return url.protocol === 'http:' || url.protocol === 'https:';
47
- } catch {
48
- return false;
49
- }
50
- }
51
-
52
- /** "language-js" -> "js"; "" for a code block with no fence language. */
53
- function langFromClassName(className) {
54
- const m = /language-([\w-]+)/.exec(className || '');
55
- return m ? m[1] : '';
56
- }
57
-
58
- let markedConfigured = false;
59
- function configureMarked(marked) {
60
- if (markedConfigured) return;
61
- marked.setOptions({ gfm: true, breaks: false });
62
- markedConfigured = true;
63
- }
64
-
65
- /** Markdown -> raw (unsanitized) HTML, or null if marked isn't loaded —
66
- * callers must treat null as "render as plain text", never as HTML. */
67
- function toHtml(markdownText) {
68
- const marked = typeof window !== 'undefined' ? window.marked : null;
69
- if (!marked || typeof marked.parse !== 'function') return null;
70
- configureMarked(marked);
71
- return marked.parse(markdownText == null ? '' : String(markdownText));
72
- }
73
-
74
- /** Raw HTML -> sanitized HTML, or null if DOMPurify isn't loaded/ready. */
75
- function sanitize(html) {
76
- const DOMPurify = typeof window !== 'undefined' ? window.DOMPurify : null;
77
- if (!DOMPurify || typeof DOMPurify.sanitize !== 'function') return null;
78
- return DOMPurify.sanitize(html, {
79
- // Restrict link/media URIs to what isExternalHref()/rewireLinks()
80
- // actually know how to handle; javascript:/data:/file:/mailto: etc.
81
- // never survive (mailto has no OS-shell path through openExternal,
82
- // which only allows http/https — see main.js isSafeExternalUrl).
83
- ALLOWED_URI_REGEXP: /^(?:https?:|#)/i,
84
- });
85
- }
86
-
87
- /**
88
- * Highlight + add a copy button to one fenced-code `<pre>`. Runs on the
89
- * live sanitized DOM, reading the code's real text (already unescaped by
90
- * the browser's own HTML parsing) and replacing it with our own
91
- * self-escaping highlighter output — never re-feeding anything through
92
- * innerHTML that didn't originate from AegisHighlight.escapeHtml.
93
- */
94
- function decorateCodeBlock(preEl) {
95
- const codeEl = preEl.querySelector('code');
96
- if (!codeEl) return;
97
- const lang = langFromClassName(codeEl.className);
98
- const raw = codeEl.textContent || '';
99
- const AegisHighlight = typeof window !== 'undefined' ? window.AegisHighlight : null;
100
- if (AegisHighlight) {
101
- codeEl.innerHTML = AegisHighlight.highlight(raw, lang);
102
- }
103
- preEl.classList.add('code-block');
104
-
105
- const btn = document.createElement('button');
106
- btn.type = 'button';
107
- btn.className = 'code-copy-btn';
108
- btn.textContent = 'copy';
109
- btn.addEventListener('click', () => {
110
- navigator.clipboard.writeText(raw).then(
111
- () => {
112
- btn.textContent = 'copied!';
113
- setTimeout(() => { btn.textContent = 'copy'; }, 1500);
114
- },
115
- () => {
116
- btn.textContent = 'copy failed';
117
- setTimeout(() => { btn.textContent = 'copy'; }, 1500);
118
- }
119
- );
120
- });
121
- preEl.appendChild(btn);
122
- }
123
-
124
- /**
125
- * Every link in rendered markdown opens in the OS default browser via the
126
- * aegis.openExternal IPC bridge, never as in-app navigation (a stray
127
- * `<a href>` reaching BrowserWindow's default handler would point the
128
- * chat UI itself at an arbitrary model-supplied origin).
129
- */
130
- function rewireLinks(container) {
131
- const aegis = typeof window !== 'undefined' ? window.aegis : null;
132
- const links = container.querySelectorAll('a[href]');
133
- for (const a of links) {
134
- const href = a.getAttribute('href');
135
- a.removeAttribute('target');
136
- a.setAttribute('rel', 'noopener noreferrer');
137
- if (!isExternalHref(href)) {
138
- // Not absolute http(s) (e.g. an in-page "#" anchor) — strip the
139
- // href outright rather than let it fall through to default
140
- // navigation inside the app's own BrowserWindow.
141
- a.removeAttribute('href');
142
- continue;
143
- }
144
- a.addEventListener('click', (e) => {
145
- e.preventDefault();
146
- if (aegis && typeof aegis.openExternal === 'function') aegis.openExternal(href);
147
- });
148
- }
149
- }
150
-
151
- /**
152
- * Render `markdownText` into `containerEl`, replacing its contents.
153
- * Always sanitized; falls back to a plain-text node (never raw innerHTML)
154
- * when marked or DOMPurify failed to load. This is the only function in
155
- * the renderer allowed to put model output into innerHTML.
156
- */
157
- function renderInto(containerEl, markdownText) {
158
- const html = toHtml(markdownText);
159
- const safe = html == null ? null : sanitize(html);
160
- if (safe == null) {
161
- containerEl.textContent = markdownText == null ? '' : String(markdownText);
162
- return;
163
- }
164
- containerEl.innerHTML = safe;
165
- for (const pre of containerEl.querySelectorAll('pre')) decorateCodeBlock(pre);
166
- rewireLinks(containerEl);
167
- }
168
-
169
- return { renderInto, isExternalHref, langFromClassName };
170
- });
3
+ "use strict";!function(t,e){const n=function(){function t(t){if("string"!=typeof t||!t)return!1;try{const e=new URL(t);return"http:"===e.protocol||"https:"===e.protocol}catch{return!1}}function e(t){const e=/language-([\w-]+)/.exec(t||"");return e?e[1]:""}let n=!1;function o(t){const e="undefined"!=typeof window?window.marked:null;return e&&"function"==typeof e.parse?(function(t){n||(t.setOptions({gfm:!0,breaks:!1}),n=!0)}(e),e.parse(null==t?"":String(t))):null}function r(t){const n=t.querySelector("code");if(!n)return;const o=e(n.className),r=n.textContent||"",i="undefined"!=typeof window?window.AegisHighlight:null;i&&(n.innerHTML=i.highlight(r,o)),t.classList.add("code-block");const l=document.createElement("button");l.type="button",l.className="code-copy-btn",l.textContent="copy",l.addEventListener("click",(()=>{navigator.clipboard.writeText(r).then((()=>{l.textContent="copied!",setTimeout((()=>{l.textContent="copy"}),1500)}),(()=>{l.textContent="copy failed",setTimeout((()=>{l.textContent="copy"}),1500)}))})),t.appendChild(l)}return{renderInto:function(e,n){const i=o(n),l=null==i?null:function(t){const e="undefined"!=typeof window?window.DOMPurify:null;return e&&"function"==typeof e.sanitize?e.sanitize(t,{ALLOWED_URI_REGEXP:/^(?:https?:|#)/i}):null}(i);if(null!=l){e.innerHTML=l;for(const t of e.querySelectorAll("pre"))r(t);!function(e){const n="undefined"!=typeof window?window.aegis:null,o=e.querySelectorAll("a[href]");for(const e of o){const o=e.getAttribute("href");e.removeAttribute("target"),e.setAttribute("rel","noopener noreferrer"),t(o)?e.addEventListener("click",(t=>{t.preventDefault(),n&&"function"==typeof n.openExternal&&n.openExternal(o)})):e.removeAttribute("href")}}(e)}else e.textContent=null==n?"":String(n)},isExternalHref:t,langFromClassName:e}}();"object"==typeof module&&module.exports?module.exports=n:t.AegisMarkdown=n}("undefined"!=typeof globalThis?globalThis:this);
@@ -1,136 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * provider-toolbar.js — the Providers & models card: one list, every provider
10
- * and every model, each with the URL its turn is sent to.
11
- *
12
- * Paints data from providers.js and nothing else; it never fetches, so the
13
- * list cannot disagree with the engine's own catalog. Two rules the markup
14
- * obeys:
15
- *
16
- * - A row is a <button> (not a div with a click handler) when it is
17
- * selectable, so it is reachable by keyboard and announces itself. A
18
- * non-selectable row (a class's state: "no key", "no daemon") is a plain
19
- * <li> — making it a button would promise a click that does nothing.
20
- * - The URL line is text, never a link: these are addresses the app sends to,
21
- * not things a user should open. A chrome-less window opening its own IPC
22
- * base in a browser is noise at best.
23
- */
24
-
25
- (function () {
26
- if (typeof window === 'undefined') return;
27
- const A = window.aegisProviders;
28
- if (!A) return; // providers.js missing: leave the card on its placeholder
29
-
30
- function el(tag, cls, text) {
31
- const n = document.createElement(tag);
32
- if (cls) n.className = cls;
33
- if (text != null) n.textContent = text;
34
- return n;
35
- }
36
-
37
- /**
38
- * @param {object} opts
39
- * @param {HTMLElement} opts.list container for the rows
40
- * @param {HTMLElement} opts.count "N of M" line
41
- * @param {HTMLInputElement} opts.search
42
- * @param {HTMLElement} opts.hint
43
- * @param {(sel:{class:string,model:string})=>void} opts.onSelect
44
- */
45
- function mount(opts) {
46
- const o = opts || {};
47
- let entries = [];
48
-
49
- function paintRow(e) {
50
- const li = el('li', 'pt-row');
51
- if (e.selectable) {
52
- const btn = el('button', 'pt-pick');
53
- btn.type = 'button';
54
- btn.appendChild(el('span', 'pt-model', e.modelLabel || e.model));
55
- if (e.model && e.modelLabel && e.modelLabel !== e.model) {
56
- btn.appendChild(el('span', 'pt-id', e.model));
57
- }
58
- btn.appendChild(el('span', 'pt-target', e.url ? `${e.method} ${e.url}` : 'no network route — runs as a local process'));
59
- btn.addEventListener('click', () => {
60
- if (o.onSelect) o.onSelect(A.selectionFor(e));
61
- });
62
- li.appendChild(btn);
63
- } else {
64
- li.appendChild(el('span', 'pt-model pt-muted', e.modelLabel));
65
- li.appendChild(el('span', 'pt-target', e.url ? `${e.method} ${e.url}` : '—'));
66
- }
67
- if (e.billing) li.appendChild(el('span', 'pt-billing', e.billing));
68
- if (e.blocked) li.appendChild(el('span', 'pt-blocked', e.blocked));
69
- return li;
70
- }
71
-
72
- /** Group rows under their class heading, preserving class order. */
73
- function paint(query) {
74
- const shown = A.filterEntries(entries, query);
75
- if (o.count) {
76
- o.count.textContent = entries.length
77
- ? `${shown.length} of ${entries.length} provider route${entries.length === 1 ? '' : 's'}`
78
- : 'no providers reported';
79
- }
80
- if (o.list) {
81
- o.list.innerHTML = '';
82
- let group = null;
83
- let ul = null;
84
- for (const e of shown) {
85
- if (e.group !== group) {
86
- group = e.group;
87
- const section = el('li', 'pt-group');
88
- section.appendChild(el('h3', 'pt-group-title', group));
89
- ul = el('ul', 'pt-rows');
90
- section.appendChild(ul);
91
- o.list.appendChild(section);
92
- }
93
- ul.appendChild(paintRow(e));
94
- }
95
- if (!shown.length) {
96
- o.list.appendChild(el('li', 'pt-empty', entries.length
97
- ? 'No provider or model matches that filter.'
98
- : 'No provider paths yet — press Refresh once a key is saved.'));
99
- }
100
- }
101
- if (o.hint && query && shown.length) {
102
- // Say where each hit goes, in one line, so the tallest question the
103
- // list answers ("does this leave my machine?") is answerable at a
104
- // glance rather than row by row.
105
- const remote = shown.filter((e) => e.url && !/localhost|127\.0\.0\.1/.test(e.url)).length;
106
- const local = shown.filter((e) => e.url && /localhost|127\.0\.0\.1/.test(e.url)).length;
107
- const off = shown.filter((e) => !e.url).length;
108
- o.hint.textContent = [
109
- remote ? `${remote} over the network` : '',
110
- local ? `${local} on this machine` : '',
111
- off ? `${off} with no route` : '',
112
- ].filter(Boolean).join(' · ');
113
- } else if (o.hint && !query) {
114
- o.hint.textContent = entries.length
115
- ? 'Every provider this build can address, and the URL a turn to it uses.'
116
- : '';
117
- }
118
- }
119
-
120
- if (o.search) {
121
- o.search.addEventListener('input', () => paint(o.search.value));
122
- }
123
-
124
- return {
125
- /** Replace the list. `rows` is the same shape buildProviderPaths takes. */
126
- set(rows) {
127
- entries = A.buildProviderPaths(rows);
128
- paint(o.search ? o.search.value : '');
129
- return entries;
130
- },
131
- entries: () => entries.slice(),
132
- };
133
- }
134
-
135
- window.aegisProviderToolbar = { mount };
136
- })();
3
+ "use strict";!function(){if("undefined"==typeof window)return;const e=window.aegisProviders;function t(e,t,n){const l=document.createElement(e);return t&&(l.className=t),null!=n&&(l.textContent=n),l}e&&(window.aegisProviderToolbar={mount:function(n){const l=n||{};let o=[];function i(n){const o=t("li","pt-row");if(n.selectable){const i=t("button","pt-pick");i.type="button",i.appendChild(t("span","pt-model",n.modelLabel||n.model)),n.model&&n.modelLabel&&n.modelLabel!==n.model&&i.appendChild(t("span","pt-id",n.model)),i.appendChild(t("span","pt-target",n.url?`${n.method} ${n.url}`:"no network route — runs as a local process")),i.addEventListener("click",(()=>{l.onSelect&&l.onSelect(e.selectionFor(n))})),o.appendChild(i)}else o.appendChild(t("span","pt-model pt-muted",n.modelLabel)),o.appendChild(t("span","pt-target",n.url?`${n.method} ${n.url}`:"—"));return n.billing&&o.appendChild(t("span","pt-billing",n.billing)),n.blocked&&o.appendChild(t("span","pt-blocked",n.blocked)),o}function r(n){const r=e.filterEntries(o,n);if(l.count&&(l.count.textContent=o.length?`${r.length} of ${o.length} provider route${1===o.length?"":"s"}`:"no providers reported"),l.list){l.list.innerHTML="";let e=null,n=null;for(const o of r){if(o.group!==e){e=o.group;const i=t("li","pt-group");i.appendChild(t("h3","pt-group-title",e)),n=t("ul","pt-rows"),i.appendChild(n),l.list.appendChild(i)}n.appendChild(i(o))}r.length||l.list.appendChild(t("li","pt-empty",o.length?"No provider or model matches that filter.":"No provider paths yet — press Refresh once a key is saved."))}if(l.hint&&n&&r.length){const e=r.filter((e=>e.url&&!/localhost|127\.0\.0\.1/.test(e.url))).length,t=r.filter((e=>e.url&&/localhost|127\.0\.0\.1/.test(e.url))).length,n=r.filter((e=>!e.url)).length;l.hint.textContent=[e?`${e} over the network`:"",t?`${t} on this machine`:"",n?`${n} with no route`:""].filter(Boolean).join(" · ")}else l.hint&&!n&&(l.hint.textContent=o.length?"Every provider this build can address, and the URL a turn to it uses.":"")}return l.search&&l.search.addEventListener("input",(()=>r(l.search.value))),{set:t=>(o=e.buildProviderPaths(t),r(l.search?l.search.value:""),o),entries:()=>o.slice()}}})}();
@@ -1,261 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * providers.js — one flat list of every provider and every model this build can
10
- * address, each with the URL a turn to it actually goes to.
11
- *
12
- * WHY THIS EXISTS. The Model card answers "what is selected"; it never answers
13
- * "what can I select, and where does that go". Those are different questions,
14
- * and the second one had no surface at all: a user could see four provider
15
- * classes and one model dropdown, and still have no way to learn that
16
- * `byok:anthropic:claude-sonnet-5` is sent to the relay, that `local:llama3.2`
17
- * goes to localhost, or that `pro` is not a URL at all but a child process.
18
- *
19
- * TWO DELIBERATE OMISSIONS, and they are the point of the file's shape:
20
- *
21
- * - No φ(α) seal row. The authorship panel is not a provider; it publishes a
22
- * record of a repo, and putting it in a provider table would invite the
23
- * reader to think a turn can be addressed to it.
24
- * - No autonomous-box row. The fan-out is a *property of a turn* on the
25
- * Aegis Cloud class (engine.js AUTONOMOUS_CLASS), not an endpoint — it
26
- * reaches no route the pooled row does not already name. It already has its
27
- * own toggle in the Model card, next to the class that has it at all.
28
- *
29
- * Both omissions are asserted in test/renderer-providers.test.mjs so a later
30
- * "why is this missing" pass cannot quietly re-add them.
31
- *
32
- * The URLS ARE READ OFF THE TRANSPORT, not guessed:
33
- * - pooled : vendor/aegis.js -> '/api/v1/chat/completions', under
34
- * DEFAULT_API_BASE ('https://aegiscloud.org')
35
- * - byok : vendor/aegis.js -> '/api/v1/byok/chat/completions', same base,
36
- * with a per-request X-Provider-Key
37
- * - local : lib/local/local.js -> `${base}/v1/chat/completions`, base
38
- * DEFAULT_BASE ('http://localhost:11434')
39
- * - pro : no route — a `claude` child process (claude-pro.js PRO_MODELS
40
- * are CLI aliases, not wire ids), so `url` is null and the row
41
- * says so instead of printing a plausible-looking URL.
42
- *
43
- * Pure: no DOM, no Electron, no fetch. Takes the engine's own listClasses /
44
- * listModels payloads and returns data; the toolbar paints it.
45
- */
46
-
47
- /** Paths, as the transport spells them. Not templates — literal strings. */
48
- const POOLED_PATH = '/api/v1/chat/completions';
49
- const BYOK_PATH = '/api/v1/byok/chat/completions';
50
- const LOCAL_PATH = '/v1/chat/completions';
51
- const DEFAULT_CLOUD_BASE = 'https://aegiscloud.org';
52
- const DEFAULT_LOCAL_BASE = 'http://localhost:11434';
53
-
54
- /** Join a base and a path without doubling or dropping the separator. */
55
- function joinUrl(base, suffix) {
56
- const b = typeof base === 'string' ? base.trim() : '';
57
- const p = typeof suffix === 'string' ? suffix.trim() : '';
58
- if (!b) return '';
59
- // An absolute URL in the path slot wins: a deployment may publish a full
60
- // base, and prefixing that with another base produces a URL that resolves to
61
- // nothing while looking correct on screen.
62
- if (/^https?:\/\//i.test(p)) return p;
63
- if (!p) return b.replace(/\/+$/, '');
64
- return `${b.replace(/\/+$/, '')}/${p.replace(/^\/+/, '')}`;
65
- }
66
-
67
- /**
68
- * The billing line for a row. Read from what the engine already reported rather
69
- * than assumed: a byok row's fee note only exists when the server publishes one
70
- * (`fee.require_balance`), and saying "funded balance required" on a
71
- * deployment that does not gate that way is the same lie pointing the other
72
- * way (see engine.listModels' byok branch).
73
- */
74
- function billingFor(cls, classRow, modelRow, listPayload) {
75
- if (cls === 'pro') {
76
- return 'Claude Code subscription — no AEGIS tokens spent';
77
- }
78
- if (cls === 'local') {
79
- return 'free — runs on this machine';
80
- }
81
- if (cls === 'byok') {
82
- const fee = (listPayload && listPayload.fee) || null;
83
- if (fee && fee.require_balance) {
84
- return 'your provider key pays the vendor; an AEGIS key and a funded balance pay the handling fee';
85
- }
86
- return 'your provider key pays the vendor; an AEGIS key attributes the handling fee';
87
- }
88
- // aegis (pooled): the account pays. No claim is made about which plan covers
89
- // it — `configured` already says whether a key is present, and the Status
90
- // card is where plan and balance actually live.
91
- return 'billed to your AEGIS account';
92
- }
93
-
94
- /**
95
- * Why a row cannot be used, or null when it can. Deliberately one short reason
96
- * per row: the Model card's hint already carries the full remedy for the
97
- * selected class, and duplicating that copy per row makes the list unreadable.
98
- */
99
- function blockedReason(cls, classRow, modelRow, listPayload) {
100
- if (cls === 'aegis' && listPayload && listPayload.needsKey) {
101
- return 'no AEGIS API key on this machine';
102
- }
103
- if (cls === 'local' && listPayload && listPayload.needsDaemon) {
104
- return 'no model server listening';
105
- }
106
- if (cls === 'local' && listPayload && listPayload.listed === false) {
107
- return 'server answered but lists no models';
108
- }
109
- if (cls === 'byok' && modelRow && modelRow.configured === false) {
110
- // The precise reason when the env file REFUSED a value it was given, rather
111
- // than never having been given one — that distinction is the difference
112
- // between "add a key" and "the key you added was rejected".
113
- return modelRow.keyRejected
114
- ? `provider key rejected: ${modelRow.keyRejected}`
115
- : 'no key saved for this provider';
116
- }
117
- if (cls === 'pro' && classRow && classRow.configured === false) {
118
- return 'not signed in to Claude Code';
119
- }
120
- return null;
121
- }
122
-
123
- /**
124
- * One row per addressable model, in class order, plus a placeholder row for a
125
- * class that offers no model list but is still a target (a pooled turn with no
126
- * model pinned, a local daemon with nothing pulled yet).
127
- *
128
- * `rows` is `[{ class, classLabel, classConfigured, list }]`, where `list` is
129
- * whatever `models.listModels(cls)` resolved to — including its error/state
130
- * shape, so a class that failed to list still gets a row that says why.
131
- */
132
- function buildProviderPaths(rows) {
133
- const out = [];
134
- const input = Array.isArray(rows) ? rows : [];
135
- for (const r of input) {
136
- if (!r || typeof r.class !== 'string') continue;
137
- const cls = r.class;
138
- const classRow = { configured: r.classConfigured !== false };
139
- const list = r.list && typeof r.list === 'object' ? r.list : null;
140
- const models = Array.isArray(list && list.models) ? list.models : [];
141
- const cloudBase = (list && (list.apiBase || list.baseURL)) || DEFAULT_CLOUD_BASE;
142
- const localBase = (list && list.baseURL) || DEFAULT_LOCAL_BASE;
143
-
144
- if (!models.length) {
145
- // No model row still means a real destination for two classes: the pooled
146
- // class runs the server's default when nothing is pinned, and a local
147
- // daemon with nothing pulled still answers on the same route once a tag
148
- // is typed (engine.listModels' local branch). For byok and pro an empty
149
- // list is genuinely "nothing to address", so only the reason is shown.
150
- const placeholderOk = cls === 'aegis' || cls === 'local';
151
- out.push({
152
- class: cls,
153
- classLabel: r.classLabel || cls,
154
- model: '',
155
- modelLabel:
156
- cls === 'aegis'
157
- ? 'server default (auto)'
158
- : cls === 'local'
159
- ? 'type a model tag in the Model card'
160
- : '—',
161
- provider: '',
162
- uniqueModel: cls,
163
- group: r.classLabel || cls,
164
- url: placeholderOk
165
- ? joinUrl(cls === 'local' ? localBase : cloudBase, cls === 'local' ? LOCAL_PATH : POOLED_PATH)
166
- : null,
167
- method: placeholderOk ? 'POST' : null,
168
- billing: billingFor(cls, classRow, null, list),
169
- blocked: blockedReason(cls, classRow, null, list),
170
- // A row with no model id is not a selectable target: it is the class's
171
- // own state, printed where its models would have gone.
172
- selectable: false,
173
- });
174
- continue;
175
- }
176
-
177
- for (const m of models) {
178
- if (!m || !m.id) continue;
179
- const provider = typeof m.provider === 'string' && m.provider ? m.provider : cls;
180
- let url = null;
181
- let method = null;
182
- if (cls === 'aegis') {
183
- url = joinUrl(cloudBase, POOLED_PATH);
184
- method = 'POST';
185
- } else if (cls === 'byok') {
186
- // The relay's route, INCLUDING for provider `custom`. That row looks
187
- // like an exception and is not: this app never dials the user's own
188
- // endpoint. It posts to the relay with `base_url` in the body and the
189
- // server makes the outbound call (client/aegis.js byokChatCompletion,
190
- // aegis1 `_byok_custom_base_url`). Printing the endpoint here would
191
- // describe a connection no part of this client opens.
192
- url = joinUrl(cloudBase, BYOK_PATH);
193
- method = 'POST';
194
- } else if (cls === 'local') {
195
- url = joinUrl(localBase, LOCAL_PATH);
196
- method = 'POST';
197
- }
198
- // cls === 'pro' leaves both null: it is a child process, not a route.
199
- out.push({
200
- class: cls,
201
- classLabel: r.classLabel || cls,
202
- model: m.id,
203
- modelLabel: m.label || m.id,
204
- provider,
205
- uniqueModel: `${cls}:${m.id}`,
206
- group: r.classLabel || cls,
207
- url,
208
- method,
209
- billing: billingFor(cls, classRow, m, list),
210
- blocked: blockedReason(cls, classRow, m, list),
211
- selectable: true,
212
- });
213
- }
214
- }
215
- return out;
216
- }
217
-
218
- /**
219
- * Case-insensitive substring match across everything a user might type: the
220
- * model id, its label, the provider, the class, and the URL's host+path.
221
- * Multi-term: every whitespace-separated term must match somewhere, so
222
- * "anthropic sonnet" narrows instead of returning nothing.
223
- */
224
- function filterEntries(entries, query) {
225
- const list = Array.isArray(entries) ? entries : [];
226
- const q = String(query == null ? '' : query).trim().toLowerCase();
227
- if (!q) return list.slice();
228
- const terms = q.split(/\s+/).filter(Boolean);
229
- return list.filter((e) => {
230
- const hay = [e.model, e.modelLabel, e.provider, e.class, e.classLabel, e.url || '']
231
- .join('\n')
232
- .toLowerCase();
233
- return terms.every((t) => hay.includes(t));
234
- });
235
- }
236
-
237
- /**
238
- * The selection a row would produce, in the shape the Model card's own controls
239
- * take: `{ class, model }` for the two <select>s. `model` is '' for a class
240
- * whose picker offers the "auto" entry, which is exactly what selecting that
241
- * option means today.
242
- */
243
- function selectionFor(entry) {
244
- if (!entry) return null;
245
- return {
246
- class: entry.class,
247
- model: entry.class === 'aegis' && !entry.model ? '' : entry.model,
248
- };
249
- }
250
-
251
- if (typeof module !== 'undefined' && module.exports) {
252
- module.exports = {
253
- buildProviderPaths,
254
- filterEntries,
255
- selectionFor,
256
- joinUrl,
257
- POOLED_PATH,
258
- BYOK_PATH,
259
- LOCAL_PATH,
260
- };
261
- }
3
+ "use strict";const POOLED_PATH="/api/v1/chat/completions",BYOK_PATH="/api/v1/byok/chat/completions",LOCAL_PATH="/v1/chat/completions",DEFAULT_CLOUD_BASE="https://aegiscloud.org",DEFAULT_LOCAL_BASE="http://localhost:11434";function joinUrl(e,l){const o="string"==typeof e?e.trim():"",r="string"==typeof l?l.trim():"";return o?/^https?:\/\//i.test(r)?r:r?`${o.replace(/\/+$/,"")}/${r.replace(/^\/+/,"")}`:o.replace(/\/+$/,""):""}function billingFor(e,l,o,r){if("pro"===e)return"Claude Code subscription — no AEGIS tokens spent";if("local"===e)return"free — runs on this machine";if("byok"===e){const e=r&&r.fee||null;return e&&e.require_balance?"your provider key pays the vendor; an AEGIS key and a funded balance pay the handling fee":"your provider key pays the vendor; an AEGIS key attributes the handling fee"}return"billed to your AEGIS account"}function blockedReason(e,l,o,r){return"aegis"===e&&r&&r.needsKey?"no AEGIS API key on this machine":"local"===e&&r&&r.needsDaemon?"no model server listening":"local"===e&&r&&!1===r.listed?"server answered but lists no models":"byok"===e&&o&&!1===o.configured?o.keyRejected?`provider key rejected: ${o.keyRejected}`:"no key saved for this provider":"pro"===e&&l&&!1===l.configured?"not signed in to Claude Code":null}function buildProviderPaths(e){const l=[],o=Array.isArray(e)?e:[];for(const e of o){if(!e||"string"!=typeof e.class)continue;const o=e.class,r={configured:!1!==e.classConfigured},n=e.list&&"object"==typeof e.list?e.list:null,s=Array.isArray(n&&n.models)?n.models:[],i=n&&(n.apiBase||n.baseURL)||DEFAULT_CLOUD_BASE,t=n&&n.baseURL||DEFAULT_LOCAL_BASE;if(s.length)for(const a of s){if(!a||!a.id)continue;const s="string"==typeof a.provider&&a.provider?a.provider:o;let c=null,d=null;"aegis"===o?(c=joinUrl(i,POOLED_PATH),d="POST"):"byok"===o?(c=joinUrl(i,BYOK_PATH),d="POST"):"local"===o&&(c=joinUrl(t,LOCAL_PATH),d="POST"),l.push({class:o,classLabel:e.classLabel||o,model:a.id,modelLabel:a.label||a.id,provider:s,uniqueModel:`${o}:${a.id}`,group:e.classLabel||o,url:c,method:d,billing:billingFor(o,r,a,n),blocked:blockedReason(o,r,a,n),selectable:!0})}else{const s="aegis"===o||"local"===o;l.push({class:o,classLabel:e.classLabel||o,model:"",modelLabel:"aegis"===o?"server default (auto)":"local"===o?"type a model tag in the Model card":"—",provider:"",uniqueModel:o,group:e.classLabel||o,url:s?joinUrl("local"===o?t:i,"local"===o?LOCAL_PATH:POOLED_PATH):null,method:s?"POST":null,billing:billingFor(o,r,null,n),blocked:blockedReason(o,r,null,n),selectable:!1})}}return l}function filterEntries(e,l){const o=Array.isArray(e)?e:[],r=String(null==l?"":l).trim().toLowerCase();if(!r)return o.slice();const n=r.split(/\s+/).filter(Boolean);return o.filter((e=>{const l=[e.model,e.modelLabel,e.provider,e.class,e.classLabel,e.url||""].join("\n").toLowerCase();return n.every((e=>l.includes(e)))}))}function selectionFor(e){return e?{class:e.class,model:"aegis"!==e.class||e.model?e.model:""}:null}"undefined"!=typeof module&&module.exports&&(module.exports={buildProviderPaths:buildProviderPaths,filterEntries:filterEntries,selectionFor:selectionFor,joinUrl:joinUrl,POOLED_PATH:POOLED_PATH,BYOK_PATH:BYOK_PATH,LOCAL_PATH:LOCAL_PATH});