aegisone 1.0.41 → 1.0.43
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 +1 -1
- package/scripts/predist.mjs +1 -1
- package/vendor/cli/package.json +1 -1
- package/vendor/cli/src/chatflow.js +1 -1
- package/vendor/cli/src/commands.js +2 -2
- package/vendor/cli/src/limits.js +1 -1
- package/vendor/cli/src/permissions.js +4 -0
- package/vendor/cli/src/provenance.lock.json +2 -2
- package/vendor/cli/vendor/desktop/lib/local/check-command.js +3 -0
- package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -1
- package/vendor/cli/vendor/desktop/lib/local/integrity.js +1 -1
- package/vendor/cli/vendor/desktop/lib/local/perm-store.js +7 -2
- package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -1
- package/vendor/cli/vendor/desktop/lib/local/repeat-guard.js +3 -0
- package/vendor/cli/vendor/desktop/lib/local/tools.js +185 -1
- package/vendor/cli/vendor/desktop/lib/local/verify-stop.js +3 -0
- package/vendor/cli/vendor/desktop/main.js +133 -32
- package/vendor/desktop/lib/local/check-command.js +3 -0
- package/vendor/desktop/lib/local/engine.js +1 -1
- package/vendor/desktop/lib/local/integrity.js +1 -1
- package/vendor/desktop/lib/local/perm-store.js +7 -2
- package/vendor/desktop/lib/local/prompt.js +1 -1
- package/vendor/desktop/lib/local/repeat-guard.js +3 -0
- package/vendor/desktop/lib/local/tools.js +185 -1
- package/vendor/desktop/lib/local/verify-stop.js +3 -0
- package/vendor/desktop/lib/sync/persist-gate.js +1 -1
- package/vendor/desktop/lib/sync/sessions.js +1 -1
- package/vendor/desktop/main.js +133 -32
- package/vendor/desktop/package.json +3 -2
- package/vendor/desktop/preload.js +1 -1
- package/vendor/desktop/renderer/app.js +3 -3
- package/vendor/desktop/renderer/index.html +43 -15
- package/vendor/desktop/renderer/library.js +3 -0
- package/vendor/desktop/renderer/style.css +149 -0
- package/vendor/desktop/vendor/faces/cli/package.json +1 -1
- package/vendor/desktop/vendor/faces/cli/src/chatflow.js +1 -1
- package/vendor/desktop/vendor/faces/cli/src/commands.js +2 -2
- package/vendor/desktop/vendor/faces/cli/src/limits.js +1 -1
- package/vendor/desktop/vendor/faces/cli/src/permissions.js +1 -1
- package/vendor/desktop/vendor/faces/cli/src/provenance.lock.json +2 -2
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/check-command.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/engine.js +1 -1
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/integrity.js +1 -1
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/perm-store.js +1 -1
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/prompt.js +1 -1
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/repeat-guard.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/tools.js +1 -1
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/verify-stop.js +3 -0
- package/vendor/desktop/vendor/faces/cli/vendor/desktop/main.js +3 -3
- package/vendor/desktop/vendor/sandbox/provenance.json +7 -7
|
@@ -120,6 +120,14 @@ const sandbox = require('./sandbox.js');
|
|
|
120
120
|
const integrity = require('./integrity.js');
|
|
121
121
|
const READ_LINE_CAP = 2000; // default line limit for readFile
|
|
122
122
|
const MATCH_CAP = 100; // max glob/grep hits per call
|
|
123
|
+
// websearch — see the executor below. The result count is capped so a single
|
|
124
|
+
// call can never spend OUTPUT_CAP on snippets alone.
|
|
125
|
+
const WEBSEARCH_RESULTS = 8;
|
|
126
|
+
const WEBSEARCH_RESULTS_CAP = 20;
|
|
127
|
+
const WEBSEARCH_TIMEOUT = 20_000;
|
|
128
|
+
// A hostile or huge response must not be read into memory; the parsed hits are
|
|
129
|
+
// a few KB, so a truncated document is still a usable one.
|
|
130
|
+
const WEBSEARCH_MAX_BYTES = 2 * 1024 * 1024;
|
|
123
131
|
// readFileSync loads the whole file before `limit` ever truncates — refuse
|
|
124
132
|
// oversized reads outright instead of freezing the turn on a multi-GB log.
|
|
125
133
|
const READ_SIZE_CAP = 25 * 1024 * 1024;
|
|
@@ -315,6 +323,19 @@ const SCHEMAS = {
|
|
|
315
323
|
additionalProperties: false,
|
|
316
324
|
},
|
|
317
325
|
},
|
|
326
|
+
websearch: {
|
|
327
|
+
name: 'websearch',
|
|
328
|
+
description:
|
|
329
|
+
'Search the web (no key needed). Returns titles, URLs, snippets; then read a page with exec + curl.',
|
|
330
|
+
parameters: {
|
|
331
|
+
type: 'object',
|
|
332
|
+
properties: {
|
|
333
|
+
query: { type: 'string', description: 'What to search for' },
|
|
334
|
+
},
|
|
335
|
+
required: ['query'],
|
|
336
|
+
additionalProperties: false,
|
|
337
|
+
},
|
|
338
|
+
},
|
|
318
339
|
task: {
|
|
319
340
|
name: 'task',
|
|
320
341
|
description:
|
|
@@ -1146,6 +1167,159 @@ function hooks({ sub, cwd } = {}) {
|
|
|
1146
1167
|
}
|
|
1147
1168
|
}
|
|
1148
1169
|
|
|
1170
|
+
// ── websearch ───────────────────────────────────────────────────────────────
|
|
1171
|
+
//
|
|
1172
|
+
// Neither host could reach the web before this: the eight advertised tools all
|
|
1173
|
+
// operate on this machine, so a model asked about anything else had to guess,
|
|
1174
|
+
// or shell out and get an HTML soup back. The avatar even matched the word
|
|
1175
|
+
// (`renderer/avatar/machine.js`, a `tool.run` signal) for a tool that did not
|
|
1176
|
+
// exist.
|
|
1177
|
+
//
|
|
1178
|
+
// DuckDuckGo's no-JavaScript endpoint is the backend because it is the only
|
|
1179
|
+
// widely-used one that needs NO key: the CLI and the desktop both run on the
|
|
1180
|
+
// user's own machine with no account required, and a search that only works
|
|
1181
|
+
// after `aegis login` would be a new setup step for a one-line question. The
|
|
1182
|
+
// trade is markup parsing, which is why the parser is deliberately narrow and
|
|
1183
|
+
// every failure is a tool error rather than a throw.
|
|
1184
|
+
//
|
|
1185
|
+
// Two things this deliberately does NOT do: it does not run a browser (no
|
|
1186
|
+
// renderer, no cookies, no JS), and it does not follow result links — the
|
|
1187
|
+
// model gets snippets plus URLs and reads a page itself if it needs to.
|
|
1188
|
+
|
|
1189
|
+
const NAMED_ENTITIES = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ' };
|
|
1190
|
+
|
|
1191
|
+
/** Decode the entity forms DDG actually emits (`'`, `&`, `"`…). */
|
|
1192
|
+
function decodeEntities(s) {
|
|
1193
|
+
return String(s == null ? '' : s).replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (m, body) => {
|
|
1194
|
+
if (body[0] === '#') {
|
|
1195
|
+
const code = body[1] === 'x' || body[1] === 'X'
|
|
1196
|
+
? parseInt(body.slice(2), 16)
|
|
1197
|
+
: parseInt(body.slice(1), 10);
|
|
1198
|
+
return Number.isFinite(code) && code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : m;
|
|
1199
|
+
}
|
|
1200
|
+
const named = NAMED_ENTITIES[body.toLowerCase()];
|
|
1201
|
+
return named === undefined ? m : named;
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
/** Strip tags, decode entities, collapse whitespace — snippet text as prose. */
|
|
1206
|
+
function plainText(html) {
|
|
1207
|
+
return decodeEntities(String(html || '').replace(/<[^>]*>/g, '')).replace(/\s+/g, ' ').trim();
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* DDG wraps every hit as `//duckduckgo.com/l/?uddg=<encoded target>` (plus an
|
|
1212
|
+
* opaque `rut` token). The real URL is the `uddg` parameter; anything that is
|
|
1213
|
+
* not that shape (an ad slot, a malformed href) is returned unchanged so the
|
|
1214
|
+
* model can still see where a hit points instead of the tool silently dropping
|
|
1215
|
+
* it.
|
|
1216
|
+
*/
|
|
1217
|
+
function realUrl(href) {
|
|
1218
|
+
const raw = decodeEntities(String(href || '').trim());
|
|
1219
|
+
if (!raw) return '';
|
|
1220
|
+
let u;
|
|
1221
|
+
try {
|
|
1222
|
+
u = new URL(raw, 'https://duckduckgo.com');
|
|
1223
|
+
} catch {
|
|
1224
|
+
return raw;
|
|
1225
|
+
}
|
|
1226
|
+
const target = u.searchParams.get('uddg');
|
|
1227
|
+
if (target) {
|
|
1228
|
+
try { return decodeURIComponent(target); } catch { return target; }
|
|
1229
|
+
}
|
|
1230
|
+
return raw.startsWith('//') ? `https:${raw}` : raw;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* Parse one DDG results page into `{title, url, snippet}` entries.
|
|
1235
|
+
*
|
|
1236
|
+
* Written against the shipped markup rather than a real parser (this module
|
|
1237
|
+
* carries no dependencies — see the header). A result is an
|
|
1238
|
+
* `<a class="result__a" href=…>title</a>`; its snippet is the NEXT
|
|
1239
|
+
* `result__snippet` in the document, which is why this walks the matches in
|
|
1240
|
+
* document order in a single pass instead of pairing two independent lists.
|
|
1241
|
+
*/
|
|
1242
|
+
function parseResults(html) {
|
|
1243
|
+
const out = [];
|
|
1244
|
+
const re = /<a\b[^>]*\bclass="[^"]*\bresult__a\b[^"]*"[^>]*>([\s\S]*?)<\/a>|<a\b[^>]*\bclass="[^"]*\bresult__snippet\b[^"]*"[^>]*>([\s\S]*?)<\/a>/gi;
|
|
1245
|
+
const hrefRe = /\bhref="([^"]*)"/i;
|
|
1246
|
+
let m;
|
|
1247
|
+
while ((m = re.exec(html)) !== null) {
|
|
1248
|
+
const tag = m[0];
|
|
1249
|
+
const isTitle = m[1] !== undefined;
|
|
1250
|
+
if (isTitle) {
|
|
1251
|
+
const href = hrefRe.exec(tag);
|
|
1252
|
+
out.push({ title: plainText(m[1]), url: realUrl(href ? href[1] : ''), snippet: '' });
|
|
1253
|
+
} else if (out.length) {
|
|
1254
|
+
// Only the FIRST snippet after a title belongs to it: DDG emits one per
|
|
1255
|
+
// hit, and a stray later one must not overwrite a real description.
|
|
1256
|
+
const last = out[out.length - 1];
|
|
1257
|
+
if (!last.snippet) last.snippet = plainText(m[2]);
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
return out.filter((r) => r.title && r.url);
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* Search the web. Read-only from this machine's point of view (it writes no
|
|
1265
|
+
* file, spawns no process), so it is NOT in MUTATING_TOOLS — but it is the one
|
|
1266
|
+
* tool whose text LEAVES the machine, which is why the query is the user's own
|
|
1267
|
+
* words and this never appends anything from the session or the working tree.
|
|
1268
|
+
*/
|
|
1269
|
+
async function websearch({ query, max_results } = {}) {
|
|
1270
|
+
const q = String(query == null ? '' : query).trim();
|
|
1271
|
+
if (!q) return fail('query is required');
|
|
1272
|
+
if (typeof fetch !== 'function') {
|
|
1273
|
+
return fail('this build has no fetch — node >= 18 (or a desktop app on a bundled runtime) is required');
|
|
1274
|
+
}
|
|
1275
|
+
const limit = Math.max(1, Math.min(Math.floor(Number(max_results) || WEBSEARCH_RESULTS), WEBSEARCH_RESULTS_CAP));
|
|
1276
|
+
const endpoint = `https://html.duckduckgo.com/html/?q=${encodeURIComponent(q)}`;
|
|
1277
|
+
const controller = typeof AbortController === 'function' ? new AbortController() : null;
|
|
1278
|
+
const timer = controller ? setTimeout(() => controller.abort(), WEBSEARCH_TIMEOUT) : null;
|
|
1279
|
+
try {
|
|
1280
|
+
const res = await fetch(endpoint, {
|
|
1281
|
+
method: 'GET',
|
|
1282
|
+
redirect: 'follow',
|
|
1283
|
+
signal: controller ? controller.signal : undefined,
|
|
1284
|
+
headers: {
|
|
1285
|
+
// The endpoint is a plain web page: it serves the no-JS markup to a
|
|
1286
|
+
// normal browser UA. The default undici UA gets a challenge page.
|
|
1287
|
+
'user-agent': 'Mozilla/5.0 (compatible; AEGIS-Code; +https://aegiscode.org)',
|
|
1288
|
+
accept: 'text/html,application/xhtml+xml',
|
|
1289
|
+
'accept-language': 'en-US,en;q=0.9',
|
|
1290
|
+
},
|
|
1291
|
+
});
|
|
1292
|
+
if (!res.ok) {
|
|
1293
|
+
return fail(
|
|
1294
|
+
`websearch: the search backend answered HTTP ${res.status}${res.status === 429 ? ' (rate-limited — wait a moment and retry)' : ''}`
|
|
1295
|
+
);
|
|
1296
|
+
}
|
|
1297
|
+
const html = (await res.text()).slice(0, WEBSEARCH_MAX_BYTES);
|
|
1298
|
+
const hits = parseResults(html);
|
|
1299
|
+
if (!hits.length) {
|
|
1300
|
+
// Distinguishable from "no matches": a challenge page, a layout change
|
|
1301
|
+
// and a genuinely empty result set all land here, and the model should
|
|
1302
|
+
// not conclude the web is empty.
|
|
1303
|
+
return fail('websearch: no results were parsed — the search backend returned no recognisable result markup');
|
|
1304
|
+
}
|
|
1305
|
+
const shown = hits.slice(0, limit);
|
|
1306
|
+
const lines = shown.map(
|
|
1307
|
+
(r, i) => `${i + 1}. ${r.title}\n ${r.url}${r.snippet ? `\n ${r.snippet}` : ''}`
|
|
1308
|
+
);
|
|
1309
|
+
const footer = hits.length > shown.length ? `\n\n(showing ${shown.length} of ${hits.length})` : '';
|
|
1310
|
+
return ok(`websearch: ${q}\n\n${lines.join('\n\n')}${footer}`);
|
|
1311
|
+
} catch (e) {
|
|
1312
|
+
if (e && (e.name === 'AbortError' || e.code === 'ABORT_ERR')) {
|
|
1313
|
+
return fail(`websearch: no answer within ${WEBSEARCH_TIMEOUT / 1000}s — retry, or narrow the query`);
|
|
1314
|
+
}
|
|
1315
|
+
// Offline, DNS failure, TLS, a proxy that eats the request: all one line
|
|
1316
|
+
// back to the model, never a throw (the module's contract).
|
|
1317
|
+
return fail(`websearch: ${e && e.message ? e.message : String(e)}`);
|
|
1318
|
+
} finally {
|
|
1319
|
+
if (timer) clearTimeout(timer);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1149
1323
|
/** Mutating: install the repo's guard hooks (core.hooksPath -> .githooks/). */
|
|
1150
1324
|
function installHooks({ cwd, dry_run } = {}) {
|
|
1151
1325
|
if (!hooksLib) return fail(HOOKS_LIB_MISSING);
|
|
@@ -1168,7 +1342,7 @@ function installHooks({ cwd, dry_run } = {}) {
|
|
|
1168
1342
|
+ `${plan}\n ${res.status.execNote}\n a commit and a push in this tree are now gated.`);
|
|
1169
1343
|
}
|
|
1170
1344
|
|
|
1171
|
-
const EXECUTORS = { readFile, writeFile, editFile, listDir, glob, grep, exec, hooks, installHooks };
|
|
1345
|
+
const EXECUTORS = { readFile, writeFile, editFile, listDir, glob, grep, exec, websearch, hooks, installHooks };
|
|
1172
1346
|
|
|
1173
1347
|
/** True when `name` is a tool this layer can run (task is excluded — see SUBAGENT_TOOL). */
|
|
1174
1348
|
function isTool(name) {
|
|
@@ -1341,7 +1515,17 @@ module.exports = {
|
|
|
1341
1515
|
normalizeArgs,
|
|
1342
1516
|
TOOL_PATH_ARGS,
|
|
1343
1517
|
PATH_ARG_DESC,
|
|
1518
|
+
// websearch pieces (tests assert the parser against real backend markup
|
|
1519
|
+
// instead of reaching the network, and drive the executor directly so the
|
|
1520
|
+
// unit does not depend on this tree's integrity seal being green)
|
|
1521
|
+
websearch,
|
|
1522
|
+
parseResults,
|
|
1523
|
+
realUrl,
|
|
1524
|
+
decodeEntities,
|
|
1344
1525
|
// limits (unit tests assert against them instead of hard-coding numbers)
|
|
1526
|
+
WEBSEARCH_RESULTS,
|
|
1527
|
+
WEBSEARCH_RESULTS_CAP,
|
|
1528
|
+
WEBSEARCH_TIMEOUT,
|
|
1345
1529
|
OUTPUT_CAP,
|
|
1346
1530
|
READ_LINE_CAP,
|
|
1347
1531
|
MATCH_CAP,
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
+
"use strict";const CODE_EXT=new Set([".js",".mjs",".cjs",".jsx",".ts",".tsx",".mts",".cts",".py",".rb",".go",".rs",".java",".kt",".kts",".scala",".swift",".c",".h",".cc",".cpp",".hpp",".cxx",".hh",".m",".mm",".cs",".fs",".php",".pl",".pm",".lua",".r",".jl",".dart",".ex",".exs",".erl",".hrl",".hs",".clj",".cljs",".ml",".mli",".sh",".bash",".zsh",".fish",".ps1",".sql",".vue",".svelte",".zig",".nim",".cr",".v",".sv",".sol",".tf"]),EXEC_TOOLS=new Set(["exec"]),NUDGE="You edited %s and the turn is ending, but no command has been run since that edit. Editing a file proves it compiles no more than describing it did. Run the project's check now — its tests, a type check, or at minimum the file's own linter — and report what it printed. If you already know the change cannot be checked by a command (a comment, a docs string, a config value), say so explicitly and finish; do not claim the change \"works\" without evidence.",NUDGE_WITH_CMD='You edited %s and the turn is ending, but no command has been run since that edit. Editing a file proves it compiles no more than describing it did. The check for this repo is likely `%s` (%s) — run it and report what it printed. If you disagree with that command, run what actually checks this change. If the change cannot be checked by a command (a comment, a docs string, a config value), say so explicitly and finish; do not claim the change "works" without evidence.',MODES=new Set(["off","dark","enforce"]);function resolveMode(e){const t=String(e&&e.mode||"").trim().toLowerCase();if(MODES.has(t))return t;const n=String(process.env.AEGIS_VERIFY_STOP||"").trim().toLowerCase();return MODES.has(n)?n:"dark"}function beginVerifyGuard(e){const t=resolveMode(e);return{mode:t,cwd:e&&e.cwd||null,active:"off"!==t,dirty:[],ranSince:!1,nudged:!1,fired:0}}function extOf(e){const t=String(e||"").split(/[/\\]/).pop()||"",n=t.lastIndexOf(".");return n<=0?"":t.slice(n).toLowerCase()}function isCodePath(e){return CODE_EXT.has(extOf(e))}function recordMutation(e,t){e&&e.active&&isCodePath(t)&&(e.dirty.push(String(t)),e.ranSince=!1)}function recordExec(e){e&&e.active&&(e.ranSince=!0,e.dirty=[])}function shouldNudge(e){if(!e||!e.active)return{nudge:!1};if(!e.dirty.length)return{nudge:!1};if(e.ranSince)return{nudge:!1};if(e.nudged)return{nudge:!1};const t=e.dirty.slice(-3),n=t.join(", ")+(e.dirty.length>3?` (+${e.dirty.length-3} more)`:"");if(e.fired=1,"enforce"!==e.mode)return{nudge:!1,fired:!0,paths:t};e.nudged=!0;let i=null;if(e.cwd)try{const{detectCheckCommand:t}=require("./check-command.js");i=t(e.cwd,e.dirty[e.dirty.length-1])}catch{i=null}if(i){const e=[n,i.cmd,i.why];let r=0;return{nudge:!0,text:NUDGE_WITH_CMD.replace(/%s/g,(()=>String(e[r++]))),paths:t,cmd:i.cmd}}return{nudge:!0,text:NUDGE.replace("%s",n),paths:t}}module.exports={beginVerifyGuard:beginVerifyGuard,recordMutation:recordMutation,recordExec:recordExec,shouldNudge:shouldNudge,resolveMode:resolveMode,isCodePath:isCodePath,extOf:extOf,EXEC_TOOLS:EXEC_TOOLS,CODE_EXT:CODE_EXT,NUDGE:NUDGE};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
"use strict";const fs=require("node:fs"),path=require("node:path"),{MEMORY_PERSIST_NAMESPACE:MEMORY_PERSIST_NAMESPACE,SETTINGS_FILE:SETTINGS_FILE}=require("../settings.js"),prefs=(()=>{try{return require("../../../client/prefs.js")}catch{return require("../../vendor/prefs.js")}})();function settingsFile(e){const t=e||"";return t.endsWith(SETTINGS_FILE)?t:path.join(t,SETTINGS_FILE)}function readSettings(e){try{const t=JSON.parse(fs.readFileSync(settingsFile(e),"utf8"));return t&&"object"==typeof t?t:{}}catch{return{}}}function gateState(e,t){const r=t||{},n=prefs.load({dir:r.prefsDir,env:r.env});if("boolean"==typeof n.memoryPersist)return{enabled:n.memoryPersist,source:"config"};const s=readSettings(e)[MEMORY_PERSIST_NAMESPACE];return s&&void 0!==s.enabled?{enabled:Boolean(s.enabled),source:"config"}:{enabled:!0,source:"default"}}function createAutoPush({push:e,dir:t,gate:r,prefsDir:n,env:s}={}){if("function"!=typeof e)throw new Error("createAutoPush requires a push()");const i="function"==typeof r?r:()=>gateState(t,{prefsDir:n,env:s});let o=null;return{auto:function(){return o||(o=async function(){const t=i();if(!t.enabled)return{ok:!0,skipped:!0,gate:t,reason:"
|
|
3
|
+
"use strict";const fs=require("node:fs"),path=require("node:path"),{MEMORY_PERSIST_NAMESPACE:MEMORY_PERSIST_NAMESPACE,SETTINGS_FILE:SETTINGS_FILE}=require("../settings.js"),prefs=(()=>{try{return require("../../../client/prefs.js")}catch{return require("../../vendor/prefs.js")}})();function settingsFile(e){const t=e||"";return t.endsWith(SETTINGS_FILE)?t:path.join(t,SETTINGS_FILE)}function readSettings(e){try{const t=JSON.parse(fs.readFileSync(settingsFile(e),"utf8"));return t&&"object"==typeof t?t:{}}catch{return{}}}function gateState(e,t){const r=t||{},n=prefs.load({dir:r.prefsDir,env:r.env});if("boolean"==typeof n.memoryPersist)return{enabled:n.memoryPersist,source:"config"};const s=readSettings(e)[MEMORY_PERSIST_NAMESPACE];return s&&void 0!==s.enabled?{enabled:Boolean(s.enabled),source:"config"}:{enabled:!0,source:"default"}}function createAutoPush({push:e,dir:t,gate:r,prefsDir:n,env:s}={}){if("function"!=typeof e)throw new Error("createAutoPush requires a push()");const i="function"==typeof r?r:()=>gateState(t,{prefsDir:n,env:s});let o=null;return{auto:function(){return o||(o=async function(){const t=i();if(!t.enabled)return{ok:!0,skipped:!0,gate:t,reason:"cloud sync is off"};try{const r=await e();return Object.assign({},r,{skipped:!1,gate:t})}catch(e){return{ok:!1,skipped:!1,gate:t,reason:e&&e.message||String(e)}}}().finally((()=>{o=null})),o)},gate:()=>i(),state:()=>i()}}module.exports={settingsFile:settingsFile,readSettings:readSettings,gateState:gateState,createAutoPush:createAutoPush};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
"use strict";const shared=(()=>{try{return require("../../../client/session-store.js")}catch{return require("../../vendor/session-store.js")}})(),credentials=(()=>{try{return require("../../../client/credentials.js")}catch{return require("../../vendor/credentials.js")}})();function resolveStoreDir(e){const s=credentials.aegisHome();return e&&e!==s&&adopt(s,e),s}const{storeFile:storeFile,load:load,save:save,upsertSession:upsertSession,appendMessage:appendMessage,recordExchange:recordExchange,listSessions:listSessions,getSession:getSession,deleteSession:deleteSession,markSynced:markSynced,markPending:markPending,listPending:listPending,mergeRemoteSessions:mergeRemoteSessions,listSummaries:listSummaries,readTranscript:readTranscript,adopt:adopt,toMarkdown:toMarkdown,toJson:toJson}=shared,sessionsFile=storeFile;module.exports={sessionsFile:sessionsFile,storeFile:storeFile,resolveStoreDir:resolveStoreDir,load:load,save:save,upsertSession:upsertSession,appendMessage:appendMessage,recordExchange:recordExchange,listSessions:listSessions,getSession:getSession,deleteSession:deleteSession,markSynced:markSynced,markPending:markPending,listPending:listPending,mergeRemoteSessions:mergeRemoteSessions,listSummaries:listSummaries,readTranscript:readTranscript,adopt:adopt,toMarkdown:toMarkdown,toJson:toJson};
|
|
3
|
+
"use strict";const shared=(()=>{try{return require("../../../client/session-store.js")}catch{return require("../../vendor/session-store.js")}})(),credentials=(()=>{try{return require("../../../client/credentials.js")}catch{return require("../../vendor/credentials.js")}})();function resolveStoreDir(e){const s=credentials.aegisHome();return e&&e!==s&&adopt(s,e),s}const{storeFile:storeFile,load:load,save:save,upsertSession:upsertSession,appendMessage:appendMessage,recordExchange:recordExchange,listSessions:listSessions,getSession:getSession,deleteSession:deleteSession,markSynced:markSynced,markPending:markPending,listPending:listPending,mergeRemoteSessions:mergeRemoteSessions,listSummaries:listSummaries,readTranscript:readTranscript,adopt:adopt,toMarkdown:toMarkdown,toJson:toJson}=shared,sessionsFile=storeFile,namingStore={getSession:getSession,setTitle:(e,s,n,r)=>shared.setTitle(e,s,n,r)};function renameSession(e,s,n){const r=String(null==n?"":n).trim();return s&&r?shared.setTitle(e,s,r,{named:!0}):null}module.exports={sessionsFile:sessionsFile,renameSession:renameSession,namingStore:namingStore,storeFile:storeFile,resolveStoreDir:resolveStoreDir,load:load,save:save,upsertSession:upsertSession,appendMessage:appendMessage,recordExchange:recordExchange,listSessions:listSessions,getSession:getSession,deleteSession:deleteSession,markSynced:markSynced,markPending:markPending,listPending:listPending,mergeRemoteSessions:mergeRemoteSessions,listSummaries:listSummaries,readTranscript:readTranscript,adopt:adopt,toMarkdown:toMarkdown,toJson:toJson};
|
package/vendor/desktop/main.js
CHANGED
|
@@ -756,6 +756,7 @@ function watchTopupCredit(aegis, opts) {
|
|
|
756
756
|
*/
|
|
757
757
|
let memoryIndexHandle = null;
|
|
758
758
|
let memoryIndexOff = false;
|
|
759
|
+
let memoryIndexTries = 0;
|
|
759
760
|
function memoryIndex(dir) {
|
|
760
761
|
if (memoryIndexHandle) return memoryIndexHandle;
|
|
761
762
|
if (memoryIndexOff || !dir) return null;
|
|
@@ -763,13 +764,19 @@ function memoryIndex(dir) {
|
|
|
763
764
|
const store = new memoryStore.MemoryStore({ dir });
|
|
764
765
|
const opened = store.open();
|
|
765
766
|
if (!opened.ok) {
|
|
766
|
-
|
|
767
|
+
// `node:sqlite` missing is permanent, so latch on sight. Anything else
|
|
768
|
+
// (EACCES on the dir, EBUSY, a corrupt file) may be transient and must
|
|
769
|
+
// not kill indexing for the whole process — but search runs on every
|
|
770
|
+
// keystroke, so stop attempting a doomed open after a few rather than
|
|
771
|
+
// retrying it per character.
|
|
772
|
+
if (!memoryStore.isAvailable() || ++memoryIndexTries >= 3) memoryIndexOff = true;
|
|
767
773
|
return null;
|
|
768
774
|
}
|
|
775
|
+
memoryIndexTries = 0;
|
|
769
776
|
memoryIndexHandle = store;
|
|
770
777
|
return memoryIndexHandle;
|
|
771
778
|
} catch {
|
|
772
|
-
memoryIndexOff = true;
|
|
779
|
+
if (!memoryStore.isAvailable() || ++memoryIndexTries >= 3) memoryIndexOff = true;
|
|
773
780
|
return null;
|
|
774
781
|
}
|
|
775
782
|
}
|
|
@@ -2711,26 +2718,78 @@ function createSyncDispatch(sessions, dir, aegis, settingsDir, modelDispatch) {
|
|
|
2711
2718
|
auto: () => autoPush.auto(),
|
|
2712
2719
|
memoryPersistState: () => autoPush.gate(),
|
|
2713
2720
|
listSessions: () => ({ sessions: sessions.listSessions(dir) }),
|
|
2714
|
-
// The
|
|
2715
|
-
//
|
|
2716
|
-
// store is a main-process file, and `listSessions()` truncates — it returns
|
|
2717
|
-
// title/messages/updatedAt, so a renderer-side filter would be a second,
|
|
2718
|
-
// weaker copy of the same read. `searchSessions` takes the query and returns
|
|
2719
|
-
// the ranked matches plus WHICH field matched, so the row can say why it is
|
|
2720
|
-
// in the list. An empty query returns the newest N unchanged, so the sheet
|
|
2721
|
-
// opens on something instead of a blank pane.
|
|
2721
|
+
// The ONE search the menu's "Search" (Cmd/Ctrl+K) runs — sessions AND
|
|
2722
|
+
// memory under a single query box.
|
|
2722
2723
|
//
|
|
2723
|
-
//
|
|
2724
|
-
// /
|
|
2725
|
-
//
|
|
2724
|
+
// It used to be two sheets on two accelerators: Cmd/Ctrl+K searched
|
|
2725
|
+
// sessions, Cmd/Ctrl+Shift+K opened the memory inspector. Same verb, two
|
|
2726
|
+
// surfaces, and neither could answer "I know I wrote this down somewhere".
|
|
2727
|
+
// This channel now returns both stores in one payload so the renderer can
|
|
2728
|
+
// paint one list; the inspector keeps its own door in the Memory pane.
|
|
2729
|
+
//
|
|
2730
|
+
// Why the ranking is HERE and not in the renderer: both stores are
|
|
2731
|
+
// main-process files (sessions.json, memory.db), and `listSessions()`
|
|
2732
|
+
// truncates — it returns title/messages/updatedAt — so a renderer-side
|
|
2733
|
+
// filter would be a second, weaker copy of the same read.
|
|
2734
|
+
//
|
|
2735
|
+
// The session ranking is `client/session-search.js`, the same module the
|
|
2736
|
+
// CLI's /resume picker filters with, so the two faces cannot order the same
|
|
2737
|
+
// conversation differently. Memory ranks through `memory-store.js`'s own
|
|
2738
|
+
// `search()`, which is FTS5 when the build has it — its tiers are not
|
|
2739
|
+
// comparable to the session tiers, which is exactly why the sheet draws the
|
|
2740
|
+
// two groups as SECTIONS with a flat cursor order rather than one
|
|
2741
|
+
// cross-type column.
|
|
2742
|
+
//
|
|
2743
|
+
// An empty query returns the newest N of each, so the sheet opens on
|
|
2744
|
+
// something instead of a blank pane.
|
|
2726
2745
|
searchSessions: (payload) => {
|
|
2727
2746
|
const query = payload && typeof payload.query === 'string' ? payload.query : '';
|
|
2728
2747
|
const limit = Number.isInteger(payload && payload.limit) ? payload.limit : 50;
|
|
2748
|
+
const cap = Math.max(1, limit);
|
|
2729
2749
|
const all = sessions.listSessions(dir) || [];
|
|
2730
|
-
const ranked = sessionSearch.rankSessions(query, all).slice(0,
|
|
2750
|
+
const ranked = sessionSearch.rankSessions(query, all).slice(0, cap);
|
|
2751
|
+
// Memory is READ-ONLY here: `search()` is a local index read, never a
|
|
2752
|
+
// cloud round trip, so a keystroke cannot cost the user a metered call.
|
|
2753
|
+
// An unavailable index (no SQLite in this build) is an empty section, not
|
|
2754
|
+
// an error — a search that still works for sessions beats one that fails
|
|
2755
|
+
// because the other store is missing.
|
|
2756
|
+
let memory = [];
|
|
2757
|
+
let memoryTotal = 0;
|
|
2758
|
+
// `ok` | `unavailable` (no SQLite in this build) | `error` (index exists
|
|
2759
|
+
// but could not be read). The renderer must tell these apart: reporting
|
|
2760
|
+
// "0 memories" would claim the store is empty when the truth is that it
|
|
2761
|
+
// was never searched.
|
|
2762
|
+
let memoryStatus = 'ok';
|
|
2763
|
+
try {
|
|
2764
|
+
const index = memoryIndex(dir);
|
|
2765
|
+
if (index) {
|
|
2766
|
+
const found = index.search(query, { limit: cap });
|
|
2767
|
+
if (found && found.ok) {
|
|
2768
|
+
memory = (found.results || []).map((r) => ({
|
|
2769
|
+
id: r.id,
|
|
2770
|
+
content: r.body || '',
|
|
2771
|
+
scope: r.scope || '',
|
|
2772
|
+
tags: Array.isArray(r.tags) ? r.tags : [],
|
|
2773
|
+
updated: r.updated || null,
|
|
2774
|
+
}));
|
|
2775
|
+
memoryTotal = index.count();
|
|
2776
|
+
} else {
|
|
2777
|
+
memoryStatus = 'error';
|
|
2778
|
+
}
|
|
2779
|
+
} else {
|
|
2780
|
+
memoryStatus = memoryStore.isAvailable() && dir ? 'error' : 'unavailable';
|
|
2781
|
+
}
|
|
2782
|
+
} catch {
|
|
2783
|
+
memory = [];
|
|
2784
|
+
memoryTotal = 0;
|
|
2785
|
+
memoryStatus = 'error';
|
|
2786
|
+
}
|
|
2731
2787
|
return {
|
|
2732
2788
|
query,
|
|
2733
2789
|
total: all.length,
|
|
2790
|
+
memoryStatus,
|
|
2791
|
+
memoryTotal,
|
|
2792
|
+
memory,
|
|
2734
2793
|
sessions: ranked.map((s) => ({
|
|
2735
2794
|
id: s && s.id,
|
|
2736
2795
|
title: (s && s.title) || (s && s.id) || 'untitled',
|
|
@@ -2756,6 +2815,20 @@ function createSyncDispatch(sessions, dir, aegis, settingsDir, modelDispatch) {
|
|
|
2756
2815
|
),
|
|
2757
2816
|
delete: (payload) =>
|
|
2758
2817
|
sessions.deleteSession(dir, payload && payload.sessionId),
|
|
2818
|
+
// Rename a thread by hand (the library pane's Rename button).
|
|
2819
|
+
//
|
|
2820
|
+
// `renameSession`, not `setTitle`: lib/sync/sessions.js explains at length
|
|
2821
|
+
// why the shared store's `setTitle` is deliberately NOT re-exported under
|
|
2822
|
+
// that name (client/naming.js duck-checks it to decide whether to spend a
|
|
2823
|
+
// model round). The write it performs is the same one, marked `named` so
|
|
2824
|
+
// no later naming round can overwrite a name the user typed. An empty
|
|
2825
|
+
// title is refused rather than written — blanking a name is not a rename.
|
|
2826
|
+
rename: (payload) =>
|
|
2827
|
+
sessions.renameSession(
|
|
2828
|
+
dir,
|
|
2829
|
+
payload && payload.sessionId,
|
|
2830
|
+
payload && payload.title
|
|
2831
|
+
),
|
|
2759
2832
|
// The naming ladder (client/naming.js), run in the MAIN process.
|
|
2760
2833
|
//
|
|
2761
2834
|
// The window used to name a thread `prompt.slice(0, 60)` — in the renderer,
|
|
@@ -2794,7 +2867,15 @@ function createSyncDispatch(sessions, dir, aegis, settingsDir, modelDispatch) {
|
|
|
2794
2867
|
prompt: text,
|
|
2795
2868
|
system: opts.system,
|
|
2796
2869
|
maxTokens: 64,
|
|
2797
|
-
sessionId
|
|
2870
|
+
// NOT the turn's `sessionId`. The engine keys its cancel registry
|
|
2871
|
+
// by that id (lib/local/engine.js `controllers`), and the desktop
|
|
2872
|
+
// reuses the conversation id for the turn it is streaming — so a
|
|
2873
|
+
// naming round sharing it fought the live turn for the Stop
|
|
2874
|
+
// button. The engine now refuses to lose the turn's controller
|
|
2875
|
+
// either way, but a decoration should not be claiming the turn's
|
|
2876
|
+
// identity in the first place: approvals, round counts and
|
|
2877
|
+
// cancellation all hang off this id, and naming is none of them.
|
|
2878
|
+
sessionId: `${sessionId}:naming`,
|
|
2798
2879
|
// `tools: false` is the engine's own opt-out (a naming round must
|
|
2799
2880
|
// not run the agent loop); nothing else here is a wire field.
|
|
2800
2881
|
tools: false,
|
|
@@ -2805,8 +2886,20 @@ function createSyncDispatch(sessions, dir, aegis, settingsDir, modelDispatch) {
|
|
|
2805
2886
|
return null;
|
|
2806
2887
|
}
|
|
2807
2888
|
};
|
|
2889
|
+
// `sessions.namingStore`, not `sessions`: the binding deliberately does
|
|
2890
|
+
// not carry a bare `setTitle`, because naming.js arms itself on that
|
|
2891
|
+
// name and an incidental re-export would turn a model round per
|
|
2892
|
+
// conversation on invisibly (see lib/sync/sessions.js). Passing the
|
|
2893
|
+
// adapter is what arms it, here, on purpose — this ladder was dead for
|
|
2894
|
+
// as long as the binding was handed over directly.
|
|
2808
2895
|
try {
|
|
2809
|
-
return await namingLib.nameSession(
|
|
2896
|
+
return await namingLib.nameSession(
|
|
2897
|
+
sessions.namingStore,
|
|
2898
|
+
dir,
|
|
2899
|
+
sessionId,
|
|
2900
|
+
prompt,
|
|
2901
|
+
{ callModel }
|
|
2902
|
+
);
|
|
2810
2903
|
} catch {
|
|
2811
2904
|
return null;
|
|
2812
2905
|
}
|
|
@@ -4221,8 +4314,7 @@ function sendDeepLinkToWindow(win, parsed) {
|
|
|
4221
4314
|
|
|
4222
4315
|
/** Application menu: the platform defaults (Edit roles, mac's app/quit
|
|
4223
4316
|
* items) plus the native-shell accelerators this plan adds — New Chat
|
|
4224
|
-
* (Cmd/Ctrl+N), Search
|
|
4225
|
-
* (Cmd/Ctrl+Shift+K), Reload (Cmd/Ctrl+R) and Toggle DevTools
|
|
4317
|
+
* (Cmd/Ctrl+N), Search (Cmd/Ctrl+K), Reload (Cmd/Ctrl+R) and Toggle DevTools
|
|
4226
4318
|
* (Cmd/Ctrl+Shift+I) are plain Electron roles that already carry the right
|
|
4227
4319
|
* accelerator on every platform — plus a manual "Check for Updates…" entry,
|
|
4228
4320
|
* since the automatic checks in createUpdateManager.start() only run on ready
|
|
@@ -4234,8 +4326,9 @@ function sendDeepLinkToWindow(win, parsed) {
|
|
|
4234
4326
|
*
|
|
4235
4327
|
* * Cmd/Ctrl+K opened the MEMORY inspector while the item said "Search…", so
|
|
4236
4328
|
* the label named neither the sheet nor the thing the user wanted. The
|
|
4237
|
-
* chord now goes to
|
|
4238
|
-
*
|
|
4329
|
+
* chord now goes to one search over sessions AND memory (sessions ranked by
|
|
4330
|
+
* client/session-search.js, memory by memory-store.js), and the two are
|
|
4331
|
+
* drawn as sections of a single list rather than as two sheets.
|
|
4239
4332
|
* * There was no licence surface anywhere in the app. `Help` is now on every
|
|
4240
4333
|
* platform and leads with Credits & Licence, which renders
|
|
4241
4334
|
* client/credits.js — the licence, the program notice and every vendored
|
|
@@ -4270,25 +4363,33 @@ function buildAppMenu({ app, Menu, BrowserWindow, updateManager, loggedIn }) {
|
|
|
4270
4363
|
accelerator: 'CmdOrCtrl+N',
|
|
4271
4364
|
click: () => sendToAppWindow(BrowserWindow, MENU_NEW_CHAT_CHANNEL),
|
|
4272
4365
|
};
|
|
4273
|
-
// View > Search
|
|
4366
|
+
// View > Search (Cmd/Ctrl+K).
|
|
4274
4367
|
//
|
|
4275
|
-
//
|
|
4276
|
-
// accelerator, the label and the sheet
|
|
4277
|
-
//
|
|
4278
|
-
//
|
|
4279
|
-
//
|
|
4280
|
-
//
|
|
4368
|
+
// Two corrections live in this item's history. It once said `Search…` and
|
|
4369
|
+
// opened the MEMORY inspector, so the accelerator, the label and the sheet
|
|
4370
|
+
// disagreed. It then said `Search sessions…` and searched only conversations,
|
|
4371
|
+
// while memory kept a parallel sheet on Cmd/Ctrl+Shift+K — one verb, two
|
|
4372
|
+
// surfaces, and no way to answer "I know I wrote this down somewhere".
|
|
4373
|
+
// It is now one sheet over both stores (see `searchSessions` above), so the
|
|
4374
|
+
// label promises exactly what the sheet does and stops naming one store.
|
|
4281
4375
|
const searchItem = {
|
|
4282
|
-
label: 'Search
|
|
4376
|
+
label: 'Search',
|
|
4283
4377
|
accelerator: 'CmdOrCtrl+K',
|
|
4284
4378
|
click: () => sendToAppWindow(BrowserWindow, MENU_SEARCH_CHANNEL),
|
|
4285
4379
|
};
|
|
4286
|
-
//
|
|
4287
|
-
//
|
|
4288
|
-
//
|
|
4380
|
+
// Cmd/Ctrl+Shift+K still opens the same sheet, pre-scoped to memory — the
|
|
4381
|
+
// chord people already learned keeps working, and it lands them in the one
|
|
4382
|
+
// search rather than a second one.
|
|
4383
|
+
//
|
|
4384
|
+
// `visible: false` is deliberate. Electron registers the accelerator of a
|
|
4385
|
+
// hidden item, so the key survives; what goes away is the MENU ROW that
|
|
4386
|
+
// advertised a separate memory search. Removing the item entirely would have
|
|
4387
|
+
// silently killed a chord users have muscle memory for; leaving it visible
|
|
4388
|
+
// would keep advertising the split this change exists to remove.
|
|
4289
4389
|
const searchMemoryItem = {
|
|
4290
|
-
label: 'Search memory
|
|
4390
|
+
label: 'Search memory',
|
|
4291
4391
|
accelerator: 'CmdOrCtrl+Shift+K',
|
|
4392
|
+
visible: false,
|
|
4292
4393
|
click: () => sendToAppWindow(BrowserWindow, MENU_SEARCH_MEMORY_CHANNEL),
|
|
4293
4394
|
};
|
|
4294
4395
|
// Help > Credits & licence — the AGPL licence, the program notice, and every
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "aegis-desktop",
|
|
3
3
|
"productName": "AEGIS Desktop",
|
|
4
4
|
"desktopName": "aegis-desktop",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.35",
|
|
6
6
|
"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.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "AEGIS Code",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dist": "npm run predist && npm run obf && npm run obf:check && npm run sandbox:check && npm run bytenode && npm run bytenode:check && npm run bytenode:boot && electron-builder",
|
|
36
36
|
"dist:dir": "npm run predist && npm run obf && npm run obf:check && npm run sandbox:check && npm run bytenode && npm run bytenode:check && npm run bytenode:boot && electron-builder --dir",
|
|
37
37
|
"obf": "node ../tools/obfuscate-faces.mjs --only desktop",
|
|
38
|
-
"check": "node --check main.js && node --check preload.js && node --check renderer/app.js && node --check renderer/quick.js && node --check renderer/providers.js && node --check renderer/provider-toolbar.js && node --check renderer/companion.js && node --check renderer/budget.js && node --check renderer/usage.js && node --check renderer/stream-policy.js && node --check renderer/transcript-view.js && node --check renderer/diff.js && node --check renderer/diffview.js && node --check renderer/markdown.js && node --check renderer/vendor/aegis-highlight.js && node --check scripts/predist.mjs && node --check scripts/generate-icon.mjs && node --check scripts/bundle-fonts.mjs && node --check lib/local/local.js && node --check lib/local/context.js && node --check lib/local/engine.js && node --check lib/local/session-rounds.js && node --check lib/local/tools.js && node --check lib/local/prompt.js && node --check lib/local/shell.js && node --check lib/local/exec-plan.js && node --check lib/local/agents.js && node --check lib/local/queue.js && node --check lib/local/autonomous.js && node --check lib/account-key.js && node --check lib/settings.js && node --check lib/sync/sessions.js && node --check lib/sync/memory-queue.js && node --check lib/window-state.js && node --check lib/deep-link.js && node --check lib/quick-launcher.js && node --check lib/avatar/tiers.js && node --check lib/avatar/xp.js && node --check lib/avatar/level.js && node --check lib/avatar/events.js && node --check lib/avatar/persona.js && node --check bin/aegis.js",
|
|
38
|
+
"check": "node --check main.js && node --check preload.js && node --check renderer/app.js && node --check renderer/quick.js && node --check renderer/providers.js && node --check renderer/provider-toolbar.js && node --check renderer/companion.js && node --check renderer/budget.js && node --check renderer/usage.js && node --check renderer/stream-policy.js && node --check renderer/transcript-view.js && node --check renderer/diff.js && node --check renderer/diffview.js && node --check renderer/library.js && node --check renderer/markdown.js && node --check renderer/vendor/aegis-highlight.js && node --check scripts/predist.mjs && node --check scripts/generate-icon.mjs && node --check scripts/bundle-fonts.mjs && node --check lib/local/local.js && node --check lib/local/context.js && node --check lib/local/engine.js && node --check lib/local/session-rounds.js && node --check lib/local/tools.js && node --check lib/local/prompt.js && node --check lib/local/shell.js && node --check lib/local/exec-plan.js && node --check lib/local/agents.js && node --check lib/local/queue.js && node --check lib/local/autonomous.js && node --check lib/account-key.js && node --check lib/settings.js && node --check lib/sync/sessions.js && node --check lib/sync/memory-queue.js && node --check lib/window-state.js && node --check lib/deep-link.js && node --check lib/quick-launcher.js && node --check lib/avatar/tiers.js && node --check lib/avatar/xp.js && node --check lib/avatar/level.js && node --check lib/avatar/events.js && node --check lib/avatar/persona.js && node --check bin/aegis.js",
|
|
39
39
|
"test:shell": "node ../test/desktop-shell.mjs",
|
|
40
40
|
"test:model": "node ../test/model-dispatch.mjs",
|
|
41
41
|
"test:budget": "node ../test/budget.test.mjs",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"test:renderer-wiring": "node ../test/renderer-wiring.test.mjs",
|
|
57
57
|
"test:toolbar-search-credits": "node ../test/toolbar-search-credits.test.mjs",
|
|
58
58
|
"test:session-search": "node ../test/session-search.test.mjs",
|
|
59
|
+
"test:library": "node ../test/renderer-library.test.mjs",
|
|
59
60
|
"test:credits": "node ../test/credits.test.mjs",
|
|
60
61
|
"test:renderer-welcome": "node test/renderer-welcome.test.mjs",
|
|
61
62
|
"test:renderer-providers": "node ../test/renderer-providers.test.mjs",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
"use strict";const{contextBridge:contextBridge,ipcRenderer:ipcRenderer}=require("electron"),IPC_PREFIX="aegis:",MODEL_PREFIX="model:",SYNC_PREFIX="sync:",QUICK_PREFIX="quick:",QUEUE_PREFIX="queue:",AUTO_PREFIX="auto:",QUEUE_PROGRESS_CHANNEL=`${QUEUE_PREFIX}progress`,CHAT_DELTA_CHANNEL="aegis:chatDelta",UPDATE_STATUS_CHANNEL="aegis:updateStatus",ACCOUNT_STATUS_CHANNEL="aegis:accountStatusChanged",MENU_NEW_CHAT_CHANNEL="aegis:menuNewChat",MENU_SEARCH_CHANNEL="aegis:menuSearch",MENU_SEARCH_MEMORY_CHANNEL="aegis:menuSearchMemory",MENU_CREDITS_CHANNEL="aegis:menuCredits",MENU_EXPORT_MARKDOWN_CHANNEL="aegis:menuExportMarkdown",MENU_EXPORT_JSON_CHANNEL="aegis:menuExportJson",MENU_FINGERPRINT_CHANNEL="aegis:menuFingerprint",MENU_GOOGLE_DRIVE_CHANNEL="aegis:menuGoogleDrive",DEEP_LINK_CHANNEL="aegis:deepLink",QUICK_LAUNCHER_PUSH_CHANNEL="aegis:quickLauncherPush";function invoke(e,n){return ipcRenderer.invoke("aegis:"+e,void 0===n?void 0:n)}function invokeModel(e,n){return ipcRenderer.invoke("model:"+e,void 0===n?void 0:n)}function invokeSync(e,n){return ipcRenderer.invoke("sync:"+e,void 0===n?void 0:n)}function invokeQuick(e,n){return ipcRenderer.invoke("quick:"+e,void 0===n?void 0:n)}function invokeQueue(e,n){return ipcRenderer.invoke(QUEUE_PREFIX+e,void 0===n?void 0:n)}function invokeAuto(e,n){return ipcRenderer.invoke("auto:"+e,void 0===n?void 0:n)}function deltaListener(e,n){const o=e||null;return(e,i)=>{(i&&i.id?i.id:null)===o&&n(i)}}const api={status:()=>invoke("status"),attachments:Object.freeze({pathFor:e=>{try{const{webUtils:n}=require("electron");return n&&"function"==typeof n.getPathForFile&&n.getPathForFile(e)||""}catch{return""}},ingest:e=>invoke("attachments:ingest",{path:String(null==e?"":e)})}),setApiKey:e=>invoke("setApiKey",{key:e}),verifyApiKey:()=>invoke("verifyApiKey"),tokenBankBalance:()=>invoke("tokenBankBalance"),billingCheckout:()=>invoke("billingCheckout"),tokenBankTopup:e=>invoke("tokenBankTopup",{amountEur:e}),listModels:()=>invoke("listModels"),readTextFile:(e,n)=>{try{return ipcRenderer.sendSync("model:readTextFile",{file:e,cwd:n})}catch{return null}},chatCompletion:(e,n)=>{const o=e||{};if("function"!=typeof n)return invoke("chatCompletion",{...o,stream:!1});const i=deltaListener(o.sessionId,n),r=()=>ipcRenderer.removeListener("aegis:chatDelta",i);return ipcRenderer.on("aegis:chatDelta",i),invoke("chatCompletion",{...o,stream:!0}).then((e=>(r(),e)),(e=>{throw r(),e}))},byokStatus:()=>invoke("byokStatus"),byokSet:(e,n)=>invoke("byokSet",{provider:e,apiKey:n}),memorySearch:(e,n)=>invoke("memorySearch",{query:e,limit:n}),memorySave:e=>invoke("memorySave",{entry:e}),memoryList:e=>invoke("memoryList",{limit:e}),verifyToken:e=>invoke("verifyToken",{token:e}),memoryActivate:e=>invoke("memoryActivate",{token:e}),memoryPull:e=>invoke("memoryPull",{since:e}),memorySaveBatch:e=>invoke("memorySaveBatch",{entries:e}),memoryImport:e=>invoke("memoryImport",e||{}),sessionsImportScan:()=>invoke("sessionsImportScan"),sessionsImport:e=>invoke("sessionsImport",e||{}),importConversation:e=>invoke("importConversation",e||{}),openExternal:e=>invoke("openExternal",{url:e}),fingerprintStatus:()=>invoke("fingerprintStatus"),fingerprintKeygen:e=>invoke("fingerprintKeygen",e||{}),fingerprintMint:e=>invoke("fingerprintMint",e||{}),fingerprintVerify:e=>invoke("fingerprintVerify",e||{}),fingerprintBackup:e=>invoke("fingerprintBackup",e||{}),fingerprintPublish:e=>invoke("fingerprintPublish",e||{}),fingerprintAnchor:e=>invoke("fingerprintAnchor",e||{}),fingerprintVault:()=>invoke("fingerprintVault"),fingerprintVaultAudit:()=>invoke("fingerprintVaultAudit"),getConfirmMode:()=>invoke("getConfirmMode"),setConfirmMode:e=>invoke("setConfirmMode",{enabled:Boolean(e)}),getPermissionMode:()=>invoke("getPermissionMode"),setPermissionMode:e=>invoke("setPermissionMode",{mode:e?"plan":null}),permRulesList:()=>invoke("permRulesList"),permRulesAdd:(e,n)=>invoke("permRulesAdd",{list:String(e||""),rule:String(n||"")}),permRulesRemove:(e,n)=>invoke("permRulesRemove",{list:String(e||""),rule:String(n||"")}),getSandboxPolicy:()=>invoke("getSandboxPolicy"),setSandboxPolicy:(e,n)=>invoke("setSandboxPolicy",{mode:String(e||""),network:String(n||"")}),getVaultBackend:()=>invoke("getVaultBackend"),setVaultBackend:e=>invoke("setVaultBackend",{backend:String(e||"")}),telemetryEvent:(e,n)=>{const o=n||{};return invoke("telemetryEvent",{event:null==e?"":String(e),campaign:null==o.campaign?null:String(o.campaign),surface:null==o.surface?null:String(o.surface)})},telemetryReport:()=>invoke("telemetryReport"),covenantStatus:()=>invoke("covenantStatus"),covenantGapReport:()=>invoke("covenantGapReport"),getMemoryPersist:()=>invoke("memoryPersist.get"),setMemoryPersist:e=>invoke("memoryPersist.set",{enabled:Boolean(e)}),checkForUpdates:()=>invoke("checkForUpdates"),downloadUpdate:()=>invoke("downloadUpdate"),quitAndInstallUpdate:()=>invoke("quitAndInstallUpdate"),updateStatus:()=>invoke("updateStatus"),onUpdateStatus:e=>{const n=(n,o)=>e(o);return ipcRenderer.on("aegis:updateStatus",n),()=>ipcRenderer.removeListener("aegis:updateStatus",n)},accountStatus:()=>invoke("accountStatus"),registerAccount:()=>invoke("registerAccount"),onAccountStatus:e=>{const n=(n,o)=>e(o);return ipcRenderer.on(ACCOUNT_STATUS_CHANNEL,n),()=>ipcRenderer.removeListener(ACCOUNT_STATUS_CHANNEL,n)},driveSignIn:()=>invoke("driveSignIn"),driveConnect:()=>invoke("driveConnect"),driveStatus:()=>invoke("driveStatus"),driveSyncMemory:()=>invoke("driveSyncMemory"),driveBackupConversation:e=>invoke("driveBackupConversation",{sessionId:e}),onMenuNewChat:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuNewChat",n),()=>ipcRenderer.removeListener("aegis:menuNewChat",n)},onMenuSearch:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuSearch",n),()=>ipcRenderer.removeListener("aegis:menuSearch",n)},onMenuSearchMemory:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuSearchMemory",n),()=>ipcRenderer.removeListener("aegis:menuSearchMemory",n)},onMenuCredits:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuCredits",n),()=>ipcRenderer.removeListener("aegis:menuCredits",n)},credits:()=>invoke("credits"),onMenuExportMarkdown:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuExportMarkdown",n),()=>ipcRenderer.removeListener("aegis:menuExportMarkdown",n)},onMenuFingerprint:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuFingerprint",n),()=>ipcRenderer.removeListener("aegis:menuFingerprint",n)},onMenuGoogleDrive:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuGoogleDrive",n),()=>ipcRenderer.removeListener("aegis:menuGoogleDrive",n)},onMenuExportJson:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuExportJson",n),()=>ipcRenderer.removeListener("aegis:menuExportJson",n)},exportSession:(e,n)=>invoke("exportSession",{sessionId:e,format:n}),onDeepLink:e=>{const n=(n,o)=>e(o);return ipcRenderer.on("aegis:deepLink",n),()=>ipcRenderer.removeListener("aegis:deepLink",n)},onQuickLauncherPush:e=>{const n=(n,o)=>e(o);return ipcRenderer.on("aegis:quickLauncherPush",n),()=>ipcRenderer.removeListener("aegis:quickLauncherPush",n)}},models={listClasses:()=>invokeModel("listClasses"),listModels:e=>invokeModel("listModels",{class:e}),chat:(e,n)=>{const o=e||{};if("function"!=typeof n)return invokeModel("chat",o);const i=deltaListener(o.sessionId,n),r=()=>ipcRenderer.removeListener("aegis:chatDelta",i);return ipcRenderer.on("aegis:chatDelta",i),invokeModel("chat",o).then((e=>(r(),e)),(e=>{throw r(),e}))},settings:{get:()=>invokeModel("settings.get"),set:(e,n)=>invokeModel("settings.set",{provider:e,baseURL:n&&n.baseURL,key:n&&n.key}),remove:e=>invokeModel("settings.remove",{provider:e})},userModels:{get:()=>invokeModel("userModels.get"),add:(e,n)=>invokeModel("userModels.add",{provider:e,model:n}),remove:(e,n)=>invokeModel("userModels.remove",{provider:e,model:n}),discover:e=>invokeModel("userModels.discover",{provider:e}),addAll:(e,n)=>invokeModel("userModels.addAll",{provider:e,ids:n}),canDiscover:e=>invokeModel("userModels.canDiscover",{provider:e}),discoverable:()=>invokeModel("userModels.discoverable")},cancel:e=>invokeModel("cancel",{sessionId:e}),respondApproval:(e,n)=>invokeModel("respondApproval",{approvalId:e,decision:n}),respondRoundsAsk:(e,n)=>invokeModel("respondRoundsAsk",{roundsAskId:e,decision:n}),clearApprovals:e=>invokeModel("clearApprovals",{sessionId:e}),listUndoable:e=>invokeModel("listUndoable",{sessionId:e}),undoMutation:(e,n)=>invokeModel("undoMutation",{sessionId:e,id:n})},sync={listSessions:()=>invokeSync("listSessions"),searchSessions:(e,n)=>invokeSync("searchSessions",{query:e,limit:n}),open:e=>invokeSync("open",{sessionId:e}),save:e=>invokeSync("save",e||{}),nameSession:e=>invokeSync("nameSession",{sessionId:e&&e.sessionId,prompt:e&&e.prompt,class:e&&e.class,model:e&&e.model}),append:(e,n)=>invokeSync("append",{sessionId:e,message:n}),delete:e=>invokeSync("delete",{sessionId:e}),push:()=>invokeSync("push"),pull:()=>invokeSync("pull"),status:()=>invokeSync("status"),auto:()=>invokeSync("auto"),memoryPersistState:()=>invokeSync("memoryPersistState")},quickLauncher={status:()=>invokeQuick("status"),setConfig:e=>invokeQuick("setConfig",{enabled:e&&e.enabled,shortcut:e&&e.shortcut}),pushToMain:e=>invokeQuick("pushToMain",e||{})},queue={enqueue:e=>invokeQueue("enqueue",queueTaskFields(e)),list:()=>invokeQueue("list"),clear:e=>invokeQueue("clear",{all:Boolean(e)}),entitlement:e=>invokeQueue("entitlement",{force:Boolean(e)}),retry:e=>queueWithId("retry",e),remove:e=>queueWithId("remove",e),drain:()=>invokeQueue("drain",{}),proceed:()=>invokeQueue("proceed",{}),stop:e=>{const n=queueTaskId(e);return invokeQueue("stop",null==n?{}:{id:n})},onProgress:e=>{if("function"!=typeof e)return()=>{};const n=(n,o)=>e(o);return ipcRenderer.on(QUEUE_PROGRESS_CHANNEL,n),()=>ipcRenderer.removeListener(QUEUE_PROGRESS_CHANNEL,n)}},auto={status:()=>invokeAuto("autoStatus"),setDrain:e=>{const n=e||{},o={enabled:Boolean(n.enabled)};return null!=n.intervalMs&&Number.isFinite(Number(n.intervalMs))&&(o.intervalMs=Number(n.intervalMs)),invokeAuto("autoSetDrain",o)},setMint:e=>{const n=e||{};return invokeAuto("autoSetMint",{enabled:Boolean(n.enabled),publish:Boolean(n.publish)})},sealNow:e=>invokeAuto("autoSealNow",{publish:Boolean(e)})};function queueTaskId(e){const n=Number(e);return Number.isInteger(n)&&n>0?n:null}function queueWithId(e,n){const o=queueTaskId(n);return null==o?Promise.resolve({ok:!1,reason:`${e} needs a task id`}):invokeQueue(e,{id:o})}function queueTaskFields(e){const n=e||{};return{task:String(null==n.task?"":n.task),cwd:String(null==n.cwd?"":n.cwd),class:null==n.class?null:String(n.class),model:null==n.model?null:String(n.model),effort:null==n.effort?null:String(n.effort),workers:null==n.workers?null:Number(n.workers),maxRounds:null==n.maxRounds?null:Number(n.maxRounds),fanout:Boolean(n.fanout),commit:Boolean(n.commit)}}contextBridge.exposeInMainWorld("aegis",Object.freeze(api)),contextBridge.exposeInMainWorld("models",Object.freeze(models)),contextBridge.exposeInMainWorld("sync",Object.freeze(sync)),contextBridge.exposeInMainWorld("quickLauncher",Object.freeze(quickLauncher)),contextBridge.exposeInMainWorld("queue",Object.freeze(queue)),contextBridge.exposeInMainWorld("auto",Object.freeze(auto));
|
|
3
|
+
"use strict";const{contextBridge:contextBridge,ipcRenderer:ipcRenderer}=require("electron"),IPC_PREFIX="aegis:",MODEL_PREFIX="model:",SYNC_PREFIX="sync:",QUICK_PREFIX="quick:",QUEUE_PREFIX="queue:",AUTO_PREFIX="auto:",QUEUE_PROGRESS_CHANNEL=`${QUEUE_PREFIX}progress`,CHAT_DELTA_CHANNEL="aegis:chatDelta",UPDATE_STATUS_CHANNEL="aegis:updateStatus",ACCOUNT_STATUS_CHANNEL="aegis:accountStatusChanged",MENU_NEW_CHAT_CHANNEL="aegis:menuNewChat",MENU_SEARCH_CHANNEL="aegis:menuSearch",MENU_SEARCH_MEMORY_CHANNEL="aegis:menuSearchMemory",MENU_CREDITS_CHANNEL="aegis:menuCredits",MENU_EXPORT_MARKDOWN_CHANNEL="aegis:menuExportMarkdown",MENU_EXPORT_JSON_CHANNEL="aegis:menuExportJson",MENU_FINGERPRINT_CHANNEL="aegis:menuFingerprint",MENU_GOOGLE_DRIVE_CHANNEL="aegis:menuGoogleDrive",DEEP_LINK_CHANNEL="aegis:deepLink",QUICK_LAUNCHER_PUSH_CHANNEL="aegis:quickLauncherPush";function invoke(e,n){return ipcRenderer.invoke("aegis:"+e,void 0===n?void 0:n)}function invokeModel(e,n){return ipcRenderer.invoke("model:"+e,void 0===n?void 0:n)}function invokeSync(e,n){return ipcRenderer.invoke("sync:"+e,void 0===n?void 0:n)}function invokeQuick(e,n){return ipcRenderer.invoke("quick:"+e,void 0===n?void 0:n)}function invokeQueue(e,n){return ipcRenderer.invoke(QUEUE_PREFIX+e,void 0===n?void 0:n)}function invokeAuto(e,n){return ipcRenderer.invoke("auto:"+e,void 0===n?void 0:n)}function deltaListener(e,n){const o=e||null;return(e,i)=>{(i&&i.id?i.id:null)===o&&n(i)}}const api={status:()=>invoke("status"),attachments:Object.freeze({pathFor:e=>{try{const{webUtils:n}=require("electron");return n&&"function"==typeof n.getPathForFile&&n.getPathForFile(e)||""}catch{return""}},ingest:e=>invoke("attachments:ingest",{path:String(null==e?"":e)})}),setApiKey:e=>invoke("setApiKey",{key:e}),verifyApiKey:()=>invoke("verifyApiKey"),tokenBankBalance:()=>invoke("tokenBankBalance"),billingCheckout:()=>invoke("billingCheckout"),tokenBankTopup:e=>invoke("tokenBankTopup",{amountEur:e}),listModels:()=>invoke("listModels"),readTextFile:(e,n)=>{try{return ipcRenderer.sendSync("model:readTextFile",{file:e,cwd:n})}catch{return null}},chatCompletion:(e,n)=>{const o=e||{};if("function"!=typeof n)return invoke("chatCompletion",{...o,stream:!1});const i=deltaListener(o.sessionId,n),r=()=>ipcRenderer.removeListener("aegis:chatDelta",i);return ipcRenderer.on("aegis:chatDelta",i),invoke("chatCompletion",{...o,stream:!0}).then((e=>(r(),e)),(e=>{throw r(),e}))},byokStatus:()=>invoke("byokStatus"),byokSet:(e,n)=>invoke("byokSet",{provider:e,apiKey:n}),memorySearch:(e,n)=>invoke("memorySearch",{query:e,limit:n}),memorySave:e=>invoke("memorySave",{entry:e}),memoryList:e=>invoke("memoryList",{limit:e}),verifyToken:e=>invoke("verifyToken",{token:e}),memoryActivate:e=>invoke("memoryActivate",{token:e}),memoryPull:e=>invoke("memoryPull",{since:e}),memorySaveBatch:e=>invoke("memorySaveBatch",{entries:e}),memoryImport:e=>invoke("memoryImport",e||{}),sessionsImportScan:()=>invoke("sessionsImportScan"),sessionsImport:e=>invoke("sessionsImport",e||{}),importConversation:e=>invoke("importConversation",e||{}),openExternal:e=>invoke("openExternal",{url:e}),fingerprintStatus:()=>invoke("fingerprintStatus"),fingerprintKeygen:e=>invoke("fingerprintKeygen",e||{}),fingerprintMint:e=>invoke("fingerprintMint",e||{}),fingerprintVerify:e=>invoke("fingerprintVerify",e||{}),fingerprintBackup:e=>invoke("fingerprintBackup",e||{}),fingerprintPublish:e=>invoke("fingerprintPublish",e||{}),fingerprintAnchor:e=>invoke("fingerprintAnchor",e||{}),fingerprintVault:()=>invoke("fingerprintVault"),fingerprintVaultAudit:()=>invoke("fingerprintVaultAudit"),getConfirmMode:()=>invoke("getConfirmMode"),setConfirmMode:e=>invoke("setConfirmMode",{enabled:Boolean(e)}),getPermissionMode:()=>invoke("getPermissionMode"),setPermissionMode:e=>invoke("setPermissionMode",{mode:e?"plan":null}),permRulesList:()=>invoke("permRulesList"),permRulesAdd:(e,n)=>invoke("permRulesAdd",{list:String(e||""),rule:String(n||"")}),permRulesRemove:(e,n)=>invoke("permRulesRemove",{list:String(e||""),rule:String(n||"")}),getSandboxPolicy:()=>invoke("getSandboxPolicy"),setSandboxPolicy:(e,n)=>invoke("setSandboxPolicy",{mode:String(e||""),network:String(n||"")}),getVaultBackend:()=>invoke("getVaultBackend"),setVaultBackend:e=>invoke("setVaultBackend",{backend:String(e||"")}),telemetryEvent:(e,n)=>{const o=n||{};return invoke("telemetryEvent",{event:null==e?"":String(e),campaign:null==o.campaign?null:String(o.campaign),surface:null==o.surface?null:String(o.surface)})},telemetryReport:()=>invoke("telemetryReport"),covenantStatus:()=>invoke("covenantStatus"),covenantGapReport:()=>invoke("covenantGapReport"),getMemoryPersist:()=>invoke("memoryPersist.get"),setMemoryPersist:e=>invoke("memoryPersist.set",{enabled:Boolean(e)}),checkForUpdates:()=>invoke("checkForUpdates"),downloadUpdate:()=>invoke("downloadUpdate"),quitAndInstallUpdate:()=>invoke("quitAndInstallUpdate"),updateStatus:()=>invoke("updateStatus"),onUpdateStatus:e=>{const n=(n,o)=>e(o);return ipcRenderer.on("aegis:updateStatus",n),()=>ipcRenderer.removeListener("aegis:updateStatus",n)},accountStatus:()=>invoke("accountStatus"),registerAccount:()=>invoke("registerAccount"),onAccountStatus:e=>{const n=(n,o)=>e(o);return ipcRenderer.on(ACCOUNT_STATUS_CHANNEL,n),()=>ipcRenderer.removeListener(ACCOUNT_STATUS_CHANNEL,n)},driveSignIn:()=>invoke("driveSignIn"),driveConnect:()=>invoke("driveConnect"),driveStatus:()=>invoke("driveStatus"),driveSyncMemory:()=>invoke("driveSyncMemory"),driveBackupConversation:e=>invoke("driveBackupConversation",{sessionId:e}),onMenuNewChat:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuNewChat",n),()=>ipcRenderer.removeListener("aegis:menuNewChat",n)},onMenuSearch:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuSearch",n),()=>ipcRenderer.removeListener("aegis:menuSearch",n)},onMenuSearchMemory:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuSearchMemory",n),()=>ipcRenderer.removeListener("aegis:menuSearchMemory",n)},onMenuCredits:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuCredits",n),()=>ipcRenderer.removeListener("aegis:menuCredits",n)},credits:()=>invoke("credits"),onMenuExportMarkdown:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuExportMarkdown",n),()=>ipcRenderer.removeListener("aegis:menuExportMarkdown",n)},onMenuFingerprint:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuFingerprint",n),()=>ipcRenderer.removeListener("aegis:menuFingerprint",n)},onMenuGoogleDrive:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuGoogleDrive",n),()=>ipcRenderer.removeListener("aegis:menuGoogleDrive",n)},onMenuExportJson:e=>{const n=()=>e();return ipcRenderer.on("aegis:menuExportJson",n),()=>ipcRenderer.removeListener("aegis:menuExportJson",n)},exportSession:(e,n)=>invoke("exportSession",{sessionId:e,format:n}),onDeepLink:e=>{const n=(n,o)=>e(o);return ipcRenderer.on("aegis:deepLink",n),()=>ipcRenderer.removeListener("aegis:deepLink",n)},onQuickLauncherPush:e=>{const n=(n,o)=>e(o);return ipcRenderer.on("aegis:quickLauncherPush",n),()=>ipcRenderer.removeListener("aegis:quickLauncherPush",n)}},models={listClasses:()=>invokeModel("listClasses"),listModels:e=>invokeModel("listModels",{class:e}),chat:(e,n)=>{const o=e||{};if("function"!=typeof n)return invokeModel("chat",o);const i=deltaListener(o.sessionId,n),r=()=>ipcRenderer.removeListener("aegis:chatDelta",i);return ipcRenderer.on("aegis:chatDelta",i),invokeModel("chat",o).then((e=>(r(),e)),(e=>{throw r(),e}))},settings:{get:()=>invokeModel("settings.get"),set:(e,n)=>invokeModel("settings.set",{provider:e,baseURL:n&&n.baseURL,key:n&&n.key}),remove:e=>invokeModel("settings.remove",{provider:e})},userModels:{get:()=>invokeModel("userModels.get"),add:(e,n)=>invokeModel("userModels.add",{provider:e,model:n}),remove:(e,n)=>invokeModel("userModels.remove",{provider:e,model:n}),discover:e=>invokeModel("userModels.discover",{provider:e}),addAll:(e,n)=>invokeModel("userModels.addAll",{provider:e,ids:n}),canDiscover:e=>invokeModel("userModels.canDiscover",{provider:e}),discoverable:()=>invokeModel("userModels.discoverable")},cancel:e=>invokeModel("cancel",{sessionId:e}),respondApproval:(e,n)=>invokeModel("respondApproval",{approvalId:e,decision:n}),respondRoundsAsk:(e,n)=>invokeModel("respondRoundsAsk",{roundsAskId:e,decision:n}),clearApprovals:e=>invokeModel("clearApprovals",{sessionId:e}),listUndoable:e=>invokeModel("listUndoable",{sessionId:e}),undoMutation:(e,n)=>invokeModel("undoMutation",{sessionId:e,id:n})},sync={listSessions:()=>invokeSync("listSessions"),searchSessions:(e,n)=>invokeSync("searchSessions",{query:e,limit:n}),open:e=>invokeSync("open",{sessionId:e}),save:e=>invokeSync("save",e||{}),nameSession:e=>invokeSync("nameSession",{sessionId:e&&e.sessionId,prompt:e&&e.prompt,class:e&&e.class,model:e&&e.model}),append:(e,n)=>invokeSync("append",{sessionId:e,message:n}),delete:e=>invokeSync("delete",{sessionId:e}),rename:(e,n)=>invokeSync("rename",{sessionId:e,title:n}),push:()=>invokeSync("push"),pull:()=>invokeSync("pull"),status:()=>invokeSync("status"),auto:()=>invokeSync("auto"),memoryPersistState:()=>invokeSync("memoryPersistState")},quickLauncher={status:()=>invokeQuick("status"),setConfig:e=>invokeQuick("setConfig",{enabled:e&&e.enabled,shortcut:e&&e.shortcut}),pushToMain:e=>invokeQuick("pushToMain",e||{})},queue={enqueue:e=>invokeQueue("enqueue",queueTaskFields(e)),list:()=>invokeQueue("list"),clear:e=>invokeQueue("clear",{all:Boolean(e)}),entitlement:e=>invokeQueue("entitlement",{force:Boolean(e)}),retry:e=>queueWithId("retry",e),remove:e=>queueWithId("remove",e),drain:()=>invokeQueue("drain",{}),proceed:()=>invokeQueue("proceed",{}),stop:e=>{const n=queueTaskId(e);return invokeQueue("stop",null==n?{}:{id:n})},onProgress:e=>{if("function"!=typeof e)return()=>{};const n=(n,o)=>e(o);return ipcRenderer.on(QUEUE_PROGRESS_CHANNEL,n),()=>ipcRenderer.removeListener(QUEUE_PROGRESS_CHANNEL,n)}},auto={status:()=>invokeAuto("autoStatus"),setDrain:e=>{const n=e||{},o={enabled:Boolean(n.enabled)};return null!=n.intervalMs&&Number.isFinite(Number(n.intervalMs))&&(o.intervalMs=Number(n.intervalMs)),invokeAuto("autoSetDrain",o)},setMint:e=>{const n=e||{};return invokeAuto("autoSetMint",{enabled:Boolean(n.enabled),publish:Boolean(n.publish)})},sealNow:e=>invokeAuto("autoSealNow",{publish:Boolean(e)})};function queueTaskId(e){const n=Number(e);return Number.isInteger(n)&&n>0?n:null}function queueWithId(e,n){const o=queueTaskId(n);return null==o?Promise.resolve({ok:!1,reason:`${e} needs a task id`}):invokeQueue(e,{id:o})}function queueTaskFields(e){const n=e||{};return{task:String(null==n.task?"":n.task),cwd:String(null==n.cwd?"":n.cwd),class:null==n.class?null:String(n.class),model:null==n.model?null:String(n.model),effort:null==n.effort?null:String(n.effort),workers:null==n.workers?null:Number(n.workers),maxRounds:null==n.maxRounds?null:Number(n.maxRounds),fanout:Boolean(n.fanout),commit:Boolean(n.commit)}}contextBridge.exposeInMainWorld("aegis",Object.freeze(api)),contextBridge.exposeInMainWorld("models",Object.freeze(models)),contextBridge.exposeInMainWorld("sync",Object.freeze(sync)),contextBridge.exposeInMainWorld("quickLauncher",Object.freeze(quickLauncher)),contextBridge.exposeInMainWorld("queue",Object.freeze(queue)),contextBridge.exposeInMainWorld("auto",Object.freeze(auto));
|