aegisone 1.0.42 → 1.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +1 -1
- package/scripts/predist.mjs +1 -1
- package/src/doctor.js +1 -1
- package/vendor/cli/README.md +5 -5
- package/vendor/cli/package.json +2 -2
- package/vendor/cli/src/chatflow.js +1 -1
- package/vendor/cli/src/commands.js +2 -2
- package/vendor/cli/src/deps.js +1 -1
- 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 +186 -2
- package/vendor/cli/vendor/desktop/lib/local/verify-stop.js +3 -0
- package/vendor/cli/vendor/desktop/lib/settings.js +1 -1
- package/vendor/cli/vendor/desktop/main.js +802 -54
- package/vendor/desktop/README.md +3 -3
- package/vendor/desktop/bin/aegis.js +1 -1
- package/vendor/desktop/lib/avatar/events.js +1 -1
- package/vendor/desktop/lib/avatar/persona.js +1 -1
- package/vendor/desktop/lib/avatar/store.js +1 -1
- package/vendor/desktop/lib/local/check-command.js +3 -0
- package/vendor/desktop/lib/local/cli-face.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 +186 -2
- package/vendor/desktop/lib/local/verify-stop.js +3 -0
- package/vendor/desktop/lib/settings.js +1 -1
- package/vendor/desktop/lib/sync/persist-gate.js +1 -1
- package/vendor/desktop/lib/sync/sessions.js +1 -1
- package/vendor/desktop/main.js +802 -54
- package/vendor/desktop/package.json +8 -4
- package/vendor/desktop/preload.js +1 -1
- package/vendor/desktop/renderer/app.js +3 -3
- package/vendor/desktop/renderer/avatar/pane.js +1 -1
- package/vendor/desktop/renderer/avatar/parts.js +1 -1
- package/vendor/desktop/renderer/commands.js +3 -0
- package/vendor/desktop/renderer/composer-triggers.js +3 -0
- package/vendor/desktop/renderer/find-in-conversation.js +3 -0
- package/vendor/desktop/renderer/fonts/fonts.css +42 -0
- package/vendor/desktop/renderer/fonts/ubuntu-vf-italic.woff2 +0 -0
- package/vendor/desktop/renderer/fonts/ubuntu-vf.woff2 +0 -0
- package/vendor/desktop/renderer/index.html +941 -484
- package/vendor/desktop/renderer/library.js +3 -0
- package/vendor/desktop/renderer/nav-history.js +3 -0
- package/vendor/desktop/renderer/palette-filter.js +3 -0
- package/vendor/desktop/renderer/shortcuts.js +3 -0
- package/vendor/desktop/renderer/style.css +2602 -380
- package/vendor/desktop/renderer/transcript-view.js +1 -1
- package/vendor/desktop/renderer/welcome-rows.js +3 -0
- package/vendor/desktop/vendor/faces/cli/README.md +5 -5
- package/vendor/desktop/vendor/faces/cli/package.json +2 -2
- 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/deps.js +1 -1
- 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/lib/settings.js +1 -1
- 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:
|
|
@@ -482,7 +503,7 @@ function normalizeArgs(name, args, ctx = {}) {
|
|
|
482
503
|
*
|
|
483
504
|
* `process.cwd()` is wrong here and was visibly wrong off Linux: the Electron
|
|
484
505
|
* main process inherits whatever the OS launched the app from — `/` from a .desktop
|
|
485
|
-
* entry, `C:\Program Files\
|
|
506
|
+
* entry, `C:\Program Files\aegis one` from a Windows shortcut — so a bare
|
|
486
507
|
* `listDir`/`glob`/`grep` searched the install directory instead of the user's
|
|
487
508
|
* repo. It stays the fallback for a direct call that supplies no ctx.
|
|
488
509
|
*/
|
|
@@ -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"),{execFileSync:execFileSync}=require("node:child_process"),prefs=(()=>{try{return require("../../client/prefs.js")}catch{return require("../vendor/prefs.js")}})(),credentials=(()=>{try{return require("../../client/credentials.js")}catch{return require("../vendor/credentials.js")}})(),localTransport=require("./local/local.js"),LOCAL_NAMESPACE="local",SETTINGS_FILE="settings.json",AEGIS_KEY_NAMESPACE="__aegis",LEGACY_AEGIS_NAMESPACE="aegis",QUICK_LAUNCHER_NAMESPACE="__quickLauncher",DEFAULT_QUICK_LAUNCHER_SHORTCUT="CmdOrCtrl+Shift+Space",VAULT_BACKEND_NAMESPACE="__vaultBackend",DEFAULT_VAULT_BACKEND="aegiscloud",VAULT_BACKEND_VALUES=Object.freeze(["aegiscloud","drive","off"]),CONFIRM_MODE_NAMESPACE="__confirmMode",MEMORY_PERSIST_NAMESPACE="__memoryPersist",AVATAR_NAMESPACE="__avatar",TELEMETRY_NAMESPACE="__telemetry",AUTO_DRAIN_NAMESPACE="__autoDrain",AUTO_MINT_NAMESPACE="__autoMint",AUTO_DRAIN_INTERVAL_DEFAULT_MS=6e4,AUTO_DRAIN_INTERVAL_MIN_MS=15e3,AUTO_DRAIN_INTERVAL_MAX_MS=18e5,RESERVED_NAMESPACES=Object.freeze(["__aegis","aegis","__quickLauncher","__vaultBackend","__confirmMode","__memoryPersist","__avatar","__telemetry","__autoDrain","__autoMint"]),AVATAR_MOTION_MODES=Object.freeze(["system","full","minimal"]);function isReservedNamespace(e){return RESERVED_NAMESPACES.includes(e)}function maskKey(e){return e?e.length<=10?"configured":`${e.slice(0,9)}…${e.slice(-4)}`:null}const IS_WIN32="win32"===process.platform;function restrictFile(e){if(IS_WIN32){const n=process.env.USERNAME||process.env.USER||process.env.USERDOMAIN;if(!n)return void console.error(`[settings] cannot restrict ${e}: no current user to grant (USERNAME unset)`);try{execFileSync("icacls",[e,"/inheritance:r","/grant:r",`${n}:(F)`],{stdio:"ignore"})}catch(n){console.error(`[settings] failed to restrict ACL on ${e}: ${n.message}`)}}else try{fs.chmodSync(e,384)}catch(n){console.error(`[settings] failed to chmod ${e} to 0600: ${n.message}`)}}function createSettingsStore({dir:e,safeStorage:n,prefsDir:t,env:r}={}){if(!e)throw new Error("createSettingsStore requires a storage dir");const o=path.join(e,SETTINGS_FILE),i=(()=>{const e=null==t?"":String(t).trim();return e?path.resolve(e):credentials.aegisHome(r)})(),s=(()=>{try{return prefs.adopt({dir:i,legacyDir:e})}catch(e){return(process.env.AEGISCODE_DEBUG||process.env.AEGIS_HIST_DEBUG)&&process.stderr.write(`aegis-desktop: shared-preference adoption failed: ${e.message}\n`),{adopted:!1,keys:[],reason:`adoption failed: ${e.message}`}}})();function a(){try{return prefs.load({dir:i})}catch{return{}}}function c(e){if(!prefs.SHARED_PREF_KEYS.includes(e))throw new Error(`"${e}" is not a shared preference (see client/prefs.js SHARED_PREF_KEYS)`);const n=a()[e];return void 0===n?null:n}const u=()=>Boolean(n&&"function"==typeof n.isEncryptionAvailable&&n.isEncryptionAvailable());function _(e){return null==e?null:u()?n.encryptString(String(e)).toString("base64"):Buffer.from(String(e),"utf8").toString("base64")}function l(e){if(!e)return null;try{const t=Buffer.from(String(e),"base64");return u()?n.decryptString(t):t.toString("utf8")}catch{return null}}function d(){try{return JSON.parse(fs.readFileSync(o,"utf8"))||{}}catch{return{}}}function f(e){fs.mkdirSync(path.dirname(o),{recursive:!0});const n=`${o}.tmp-${process.pid}`;fs.writeFileSync(n,JSON.stringify(e,null,2),{mode:384}),fs.renameSync(n,o),restrictFile(o)}function A(e){if(isReservedNamespace(e))throw new Error(`reserved namespace "${e}" is not a provider config — use setAegisKey()/aegisRawKey() for the AEGIS key`)}function E(e){const n=d()[e]||{},t=l(n.key);return{provider:e,baseURL:n.baseURL||"",configured:Boolean(t),keyMask:maskKey(t)}}function S(){const e=l((d().__aegis||{}).key);return{configured:Boolean(e),keyMask:maskKey(e)}}function m(){const e=d().__quickLauncher||{},n="string"==typeof e.shortcut&&e.shortcut.trim()?e.shortcut.trim():"CmdOrCtrl+Shift+Space";return{enabled:Boolean(e.enabled),shortcut:n}}function M(){const e=d().__vaultBackend||{};return{backend:VAULT_BACKEND_VALUES.includes(e.backend)?e.backend:"aegiscloud"}}function p(){const e=a();if("boolean"==typeof e.confirmMode)return{enabled:e.confirmMode,source:"config"};const n=d().__confirmMode||{};return void 0===n.enabled?{enabled:!0,source:"default"}:{enabled:Boolean(n.enabled),source:"config"}}function y(){const e=a().sandboxPolicy;return e&&"object"==typeof e?e:null}function g(){const e=a();return"string"==typeof e.permissionMode?e.permissionMode:null}function N(){return!0===(d().__telemetry||{}).enabled}function b(){const e=a();if("boolean"==typeof e.memoryPersist)return{enabled:e.memoryPersist,source:"config"};const n=d().__memoryPersist||{};return void 0===n.enabled?{enabled:!0,source:"default"}:{enabled:Boolean(n.enabled),source:"config"}}function v(){const e=d().__avatar||{};return{enabled:void 0===e.enabled||Boolean(e.enabled),showLevel:void 0===e.showLevel||Boolean(e.showLevel),motion:AVATAR_MOTION_MODES.includes(e.motion)?e.motion:"system"}}function R(){const e=d().__avatar||{};return{...v(),source:void 0===e.enabled?"default":"config"}}function T(e){const n=Number(e);if(!Number.isFinite(n))return 6e4;const t=Math.round(n);return t<15e3||t>18e5?6e4:t}function h(){const e=d().__autoDrain||{};return{enabled:!1!==e.enabled,intervalMs:T(e.intervalMs)}}function C(){const e=d().__autoDrain||{};return{...h(),source:void 0===e.enabled?"default":"config"}}function I(){const e=d().__autoMint||{};return{enabled:!1!==e.enabled,publish:!0===e.publish}}function L(){const e=d().__autoMint||{};return{...I(),source:void 0===e.enabled?"default":"config"}}return{file:o,sharedDir:i,adoption:s,sharedFile:function(){return prefs.prefsFile({dir:i})},getSharedPref:c,setSharedPref:function(e,n){if(!prefs.SHARED_PREF_KEYS.includes(e))throw new Error(`"${e}" is not a shared preference (see client/prefs.js SHARED_PREF_KEYS)`);return prefs.set({[e]:n},{dir:i}),c(e)},get:E,set:function(e,{baseURL:n,key:t}={}){A(e);let r=n;if("local"===e&&n){const e=localTransport.remoteRefusal(n);if(e)throw e;r=localTransport.normalizeBase(n)}const o=d(),i=o[e]||{};return void 0!==r&&(i.baseURL=r),void 0!==t&&(i.key=t?_(t):null),o[e]=i,f(o),E(e)},rawKey:function(e){return l((d()[e]||{}).key)},remove:function(e){A(e);const n=d();return delete n[e],f(n),{ok:!0}},list:function(){const e=d();return Object.keys(e).filter((e=>!isReservedNamespace(e))).map((e=>E(e)))},maskKey:maskKey,aegisKey:S,aegisRawKey:function(){return l((d().__aegis||{}).key)},aegisKeySavedAt:function(){return(d().__aegis||{}).savedAt||null},setAegisKey:function(e){const n=d();return n.__aegis={...n.__aegis||{},key:e?_(e):null,savedAt:e?(new Date).toISOString():null},f(n),S()},migrateLegacyAegisKey:function(){try{const e=d();if(!e.aegis)return{migrated:!1};const n=e.aegis||{},t=e.__aegis||{},r={...e};return n.key&&!t.key&&(r.__aegis={...t,key:n.key}),delete r.aegis,f(r),{migrated:!0}}catch{return{migrated:!1}}},quickLauncherConfig:m,setQuickLauncherConfig:function({enabled:e,shortcut:n}={}){const t=d();return t.__quickLauncher={enabled:Boolean(e),shortcut:"string"==typeof n&&n.trim()?n.trim():"CmdOrCtrl+Shift+Space"},f(t),m()},vaultBackendConfig:M,setVaultBackendConfig:function(e){if(!VAULT_BACKEND_VALUES.includes(e))return M();const n=d();return n.__vaultBackend={backend:e},f(n),M()},getConfirmMode:function(){return p().enabled},setConfirmMode:function(e){prefs.set({confirmMode:Boolean(e)},{dir:i});const n=d();return void 0!==n.__confirmMode&&(delete n.__confirmMode,f(n)),p().enabled},confirmModeState:p,getPermissionMode:g,setPermissionMode:function(e){if(null==e||""===e||"off"===e||"none"===e)return prefs.remove("permissionMode",{dir:i}),null;const n=String(e),t=function(){const e=[path.join(__dirname,"..","..","one","src","permissions.js"),path.join(__dirname,"..","vendor","one","src","permissions.js")];for(const n of e)try{const e=require(n);if(e&&Array.isArray(e.PERMISSION_MODES)&&e.PERMISSION_MODES.length)return[...e.PERMISSION_MODES]}catch{}return["acceptEdits","auto","bypassPermissions","manual","dontAsk","plan"]}();if(!t.includes(n))throw new Error(`"${n}" is not one of ${t.join("|")} (or 'off' to clear it)`);return prefs.set({permissionMode:n},{dir:i}),g()},getSandboxPolicy:y,setSandboxPolicy:function(e){return e&&"object"==typeof e?(prefs.set({sandboxPolicy:e},{dir:i}),y()):(prefs.set({sandboxPolicy:null},{dir:i}),null)},getTelemetryOptIn:N,setTelemetryOptIn:function(e){const n=d();return n.__telemetry={enabled:Boolean(e)},f(n),N()},getMemoryPersist:function(){return b().enabled},memoryPersistState:b,setMemoryPersist:function(e){prefs.set({memoryPersist:Boolean(e)},{dir:i});const n=d();return void 0!==n.__memoryPersist&&(delete n.__memoryPersist,f(n)),b()},getAvatar:v,avatarState:R,setAvatar:function(e={}){const n=v(),t=e&&"object"==typeof e?e:{},r={enabled:void 0===t.enabled?n.enabled:Boolean(t.enabled),showLevel:void 0===t.showLevel?n.showLevel:Boolean(t.showLevel),motion:AVATAR_MOTION_MODES.includes(t.motion)?t.motion:n.motion},o=d();return o.__avatar=r,f(o),R()},getAutoDrain:h,autoDrainState:C,setAutoDrain:function(e={}){const n=h(),t=e&&"object"==typeof e?e:{},r=d();return r.__autoDrain={enabled:void 0===t.enabled?n.enabled:Boolean(t.enabled),intervalMs:void 0===t.intervalMs?n.intervalMs:T(t.intervalMs)},f(r),C()},getAutoMint:I,autoMintState:L,setAutoMint:function(e={}){const n=I(),t=e&&"object"==typeof e?e:{},r=d();return r.__autoMint={enabled:void 0===t.enabled?n.enabled:Boolean(t.enabled),publish:void 0===t.publish?n.publish:Boolean(t.publish)},f(r),L()},clampAutoDrainInterval:T}}module.exports={SETTINGS_FILE:SETTINGS_FILE,AEGIS_KEY_NAMESPACE:"__aegis",LEGACY_AEGIS_NAMESPACE:"aegis",QUICK_LAUNCHER_NAMESPACE:"__quickLauncher",VAULT_BACKEND_NAMESPACE:"__vaultBackend",CONFIRM_MODE_NAMESPACE:"__confirmMode",MEMORY_PERSIST_NAMESPACE:"__memoryPersist",AVATAR_NAMESPACE:"__avatar",TELEMETRY_NAMESPACE:"__telemetry",AUTO_DRAIN_NAMESPACE:"__autoDrain",AUTO_MINT_NAMESPACE:"__autoMint",AUTO_DRAIN_INTERVAL_DEFAULT_MS:6e4,AUTO_DRAIN_INTERVAL_MIN_MS:15e3,AUTO_DRAIN_INTERVAL_MAX_MS:18e5,AVATAR_MOTION_MODES:AVATAR_MOTION_MODES,DEFAULT_QUICK_LAUNCHER_SHORTCUT:"CmdOrCtrl+Shift+Space",DEFAULT_VAULT_BACKEND:"aegiscloud",VAULT_BACKEND_VALUES:VAULT_BACKEND_VALUES,RESERVED_NAMESPACES:RESERVED_NAMESPACES,isReservedNamespace:isReservedNamespace,maskKey:maskKey,createSettingsStore:createSettingsStore};
|
|
3
|
+
"use strict";const fs=require("node:fs"),path=require("node:path"),{execFileSync:execFileSync}=require("node:child_process"),prefs=(()=>{try{return require("../../client/prefs.js")}catch{return require("../vendor/prefs.js")}})(),credentials=(()=>{try{return require("../../client/credentials.js")}catch{return require("../vendor/credentials.js")}})(),localTransport=require("./local/local.js"),LOCAL_NAMESPACE="local",SETTINGS_FILE="settings.json",AEGIS_KEY_NAMESPACE="__aegis",LEGACY_AEGIS_NAMESPACE="aegis",QUICK_LAUNCHER_NAMESPACE="__quickLauncher",DEFAULT_QUICK_LAUNCHER_SHORTCUT="CmdOrCtrl+Shift+Space",VAULT_BACKEND_NAMESPACE="__vaultBackend",DEFAULT_VAULT_BACKEND="aegiscloud",VAULT_BACKEND_VALUES=Object.freeze(["aegiscloud","drive","off"]),CONFIRM_MODE_NAMESPACE="__confirmMode",FONT_SCALE_NAMESPACE="__fontScale",ACCENT_NAMESPACE="__accent",MEMORY_PERSIST_NAMESPACE="__memoryPersist",AVATAR_NAMESPACE="__avatar",TELEMETRY_NAMESPACE="__telemetry",AUTO_DRAIN_NAMESPACE="__autoDrain",AUTO_MINT_NAMESPACE="__autoMint",AUTO_DRAIN_INTERVAL_DEFAULT_MS=6e4,AUTO_DRAIN_INTERVAL_MIN_MS=15e3,AUTO_DRAIN_INTERVAL_MAX_MS=18e5,RESERVED_NAMESPACES=Object.freeze(["__aegis","aegis","__quickLauncher","__vaultBackend","__confirmMode","__memoryPersist","__avatar","__telemetry","__autoDrain","__autoMint"]),AVATAR_MOTION_MODES=Object.freeze(["system","full","minimal"]);function isReservedNamespace(e){return RESERVED_NAMESPACES.includes(e)}function maskKey(e){return e?e.length<=10?"configured":`${e.slice(0,9)}…${e.slice(-4)}`:null}const IS_WIN32="win32"===process.platform;function restrictFile(e){if(IS_WIN32){const n=process.env.USERNAME||process.env.USER||process.env.USERDOMAIN;if(!n)return void console.error(`[settings] cannot restrict ${e}: no current user to grant (USERNAME unset)`);try{execFileSync("icacls",[e,"/inheritance:r","/grant:r",`${n}:(F)`],{stdio:"ignore"})}catch(n){console.error(`[settings] failed to restrict ACL on ${e}: ${n.message}`)}}else try{fs.chmodSync(e,384)}catch(n){console.error(`[settings] failed to chmod ${e} to 0600: ${n.message}`)}}function createSettingsStore({dir:e,safeStorage:n,prefsDir:t,env:r}={}){if(!e)throw new Error("createSettingsStore requires a storage dir");const o=path.join(e,SETTINGS_FILE),i=(()=>{const e=null==t?"":String(t).trim();return e?path.resolve(e):credentials.aegisHome(r)})(),s=(()=>{try{return prefs.adopt({dir:i,legacyDir:e})}catch(e){return(process.env.AEGISCODE_DEBUG||process.env.AEGIS_HIST_DEBUG)&&process.stderr.write(`aegis-desktop: shared-preference adoption failed: ${e.message}\n`),{adopted:!1,keys:[],reason:`adoption failed: ${e.message}`}}})();function a(){try{return prefs.load({dir:i})}catch{return{}}}function c(e){if(!prefs.SHARED_PREF_KEYS.includes(e))throw new Error(`"${e}" is not a shared preference (see client/prefs.js SHARED_PREF_KEYS)`);const n=a()[e];return void 0===n?null:n}const u=()=>Boolean(n&&"function"==typeof n.isEncryptionAvailable&&n.isEncryptionAvailable());function _(e){return null==e?null:u()?n.encryptString(String(e)).toString("base64"):Buffer.from(String(e),"utf8").toString("base64")}function l(e){if(!e)return null;try{const t=Buffer.from(String(e),"base64");return u()?n.decryptString(t):t.toString("utf8")}catch{return null}}function d(){try{return JSON.parse(fs.readFileSync(o,"utf8"))||{}}catch{return{}}}function f(e){fs.mkdirSync(path.dirname(o),{recursive:!0});const n=`${o}.tmp-${process.pid}`;fs.writeFileSync(n,JSON.stringify(e,null,2),{mode:384}),fs.renameSync(n,o),restrictFile(o)}function A(e){if(isReservedNamespace(e))throw new Error(`reserved namespace "${e}" is not a provider config — use setAegisKey()/aegisRawKey() for the AEGIS key`)}function E(e){const n=d()[e]||{},t=l(n.key);return{provider:e,baseURL:n.baseURL||"",configured:Boolean(t),keyMask:maskKey(t)}}function S(){const e=l((d().__aegis||{}).key);return{configured:Boolean(e),keyMask:maskKey(e)}}function m(e){return Number.isFinite(e)?Math.min(1.3,Math.max(.85,Math.round(100*e)/100)):1}function M(){return m((d().__fontScale||{}).scale)}const p=["default","cobalt","amber"];function g(e){const n="string"==typeof e?e.trim().toLowerCase():"";return p.includes(n)?n:"default"}function y(){return g((d().__accent||{}).name)}function N(){const e=d().__quickLauncher||{},n="string"==typeof e.shortcut&&e.shortcut.trim()?e.shortcut.trim():"CmdOrCtrl+Shift+Space";return{enabled:Boolean(e.enabled),shortcut:n}}function b(){const e=d().__vaultBackend||{};return{backend:VAULT_BACKEND_VALUES.includes(e.backend)?e.backend:"aegiscloud"}}function v(){const e=a();if("boolean"==typeof e.confirmMode)return{enabled:e.confirmMode,source:"config"};const n=d().__confirmMode||{};return void 0===n.enabled?{enabled:!0,source:"default"}:{enabled:Boolean(n.enabled),source:"config"}}function C(){const e=a().sandboxPolicy;return e&&"object"==typeof e?e:null}function T(){const e=a();return"string"==typeof e.permissionMode?e.permissionMode:null}function h(){return!0===(d().__telemetry||{}).enabled}function R(){const e=a();if("boolean"==typeof e.memoryPersist)return{enabled:e.memoryPersist,source:"config"};const n=d().__memoryPersist||{};return void 0===n.enabled?{enabled:!0,source:"default"}:{enabled:Boolean(n.enabled),source:"config"}}function I(){const e=d().__avatar||{};return{enabled:void 0===e.enabled||Boolean(e.enabled),showLevel:void 0===e.showLevel||Boolean(e.showLevel),motion:AVATAR_MOTION_MODES.includes(e.motion)?e.motion:"system"}}function L(){const e=d().__avatar||{};return{...I(),source:void 0===e.enabled?"default":"config"}}function D(e){const n=Number(e);if(!Number.isFinite(n))return 6e4;const t=Math.round(n);return t<15e3||t>18e5?6e4:t}function P(){const e=d().__autoDrain||{};return{enabled:!1!==e.enabled,intervalMs:D(e.intervalMs)}}function O(){const e=d().__autoDrain||{};return{...P(),source:void 0===e.enabled?"default":"config"}}function U(){const e=d().__autoMint||{};return{enabled:!1!==e.enabled,publish:!0===e.publish}}function k(){const e=d().__autoMint||{};return{...U(),source:void 0===e.enabled?"default":"config"}}return{file:o,sharedDir:i,adoption:s,sharedFile:function(){return prefs.prefsFile({dir:i})},getSharedPref:c,setSharedPref:function(e,n){if(!prefs.SHARED_PREF_KEYS.includes(e))throw new Error(`"${e}" is not a shared preference (see client/prefs.js SHARED_PREF_KEYS)`);return prefs.set({[e]:n},{dir:i}),c(e)},get:E,set:function(e,{baseURL:n,key:t}={}){A(e);let r=n;if("local"===e&&n){const e=localTransport.remoteRefusal(n);if(e)throw e;r=localTransport.normalizeBase(n)}const o=d(),i=o[e]||{};return void 0!==r&&(i.baseURL=r),void 0!==t&&(i.key=t?_(t):null),o[e]=i,f(o),E(e)},rawKey:function(e){return l((d()[e]||{}).key)},remove:function(e){A(e);const n=d();return delete n[e],f(n),{ok:!0}},list:function(){const e=d();return Object.keys(e).filter((e=>!isReservedNamespace(e))).map((e=>E(e)))},maskKey:maskKey,aegisKey:S,aegisRawKey:function(){return l((d().__aegis||{}).key)},aegisKeySavedAt:function(){return(d().__aegis||{}).savedAt||null},setAegisKey:function(e){const n=d();return n.__aegis={...n.__aegis||{},key:e?_(e):null,savedAt:e?(new Date).toISOString():null},f(n),S()},migrateLegacyAegisKey:function(){try{const e=d();if(!e.aegis)return{migrated:!1};const n=e.aegis||{},t=e.__aegis||{},r={...e};return n.key&&!t.key&&(r.__aegis={...t,key:n.key}),delete r.aegis,f(r),{migrated:!0}}catch{return{migrated:!1}}},quickLauncherConfig:N,setQuickLauncherConfig:function({enabled:e,shortcut:n}={}){const t=d();return t.__quickLauncher={enabled:Boolean(e),shortcut:"string"==typeof n&&n.trim()?n.trim():"CmdOrCtrl+Shift+Space"},f(t),N()},vaultBackendConfig:b,setVaultBackendConfig:function(e){if(!VAULT_BACKEND_VALUES.includes(e))return b();const n=d();return n.__vaultBackend={backend:e},f(n),b()},getConfirmMode:function(){return v().enabled},setConfirmMode:function(e){prefs.set({confirmMode:Boolean(e)},{dir:i});const n=d();return void 0!==n.__confirmMode&&(delete n.__confirmMode,f(n)),v().enabled},confirmModeState:v,getFontScale:M,setFontScale:function(e){const n=d();return n.__fontScale={scale:m(e)},f(n),M()},clampFontScale:m,getAccent:y,setAccent:function(e){const n=d();return n.__accent={name:g(e)},f(n),y()},clampAccent:g,ACCENT_SKINS:p,getPermissionMode:T,setPermissionMode:function(e){if(null==e||""===e||"off"===e||"none"===e)return prefs.remove("permissionMode",{dir:i}),null;const n=String(e),t=function(){const e=[path.join(__dirname,"..","..","one","src","permissions.js"),path.join(__dirname,"..","vendor","one","src","permissions.js")];for(const n of e)try{const e=require(n);if(e&&Array.isArray(e.PERMISSION_MODES)&&e.PERMISSION_MODES.length)return[...e.PERMISSION_MODES]}catch{}return["acceptEdits","auto","bypassPermissions","manual","dontAsk","plan"]}();if(!t.includes(n))throw new Error(`"${n}" is not one of ${t.join("|")} (or 'off' to clear it)`);return prefs.set({permissionMode:n},{dir:i}),T()},getSandboxPolicy:C,setSandboxPolicy:function(e){return e&&"object"==typeof e?(prefs.set({sandboxPolicy:e},{dir:i}),C()):(prefs.set({sandboxPolicy:null},{dir:i}),null)},getTelemetryOptIn:h,setTelemetryOptIn:function(e){const n=d();return n.__telemetry={enabled:Boolean(e)},f(n),h()},getMemoryPersist:function(){return R().enabled},memoryPersistState:R,setMemoryPersist:function(e){prefs.set({memoryPersist:Boolean(e)},{dir:i});const n=d();return void 0!==n.__memoryPersist&&(delete n.__memoryPersist,f(n)),R()},getAvatar:I,avatarState:L,setAvatar:function(e={}){const n=I(),t=e&&"object"==typeof e?e:{},r={enabled:void 0===t.enabled?n.enabled:Boolean(t.enabled),showLevel:void 0===t.showLevel?n.showLevel:Boolean(t.showLevel),motion:AVATAR_MOTION_MODES.includes(t.motion)?t.motion:n.motion},o=d();return o.__avatar=r,f(o),L()},getAutoDrain:P,autoDrainState:O,setAutoDrain:function(e={}){const n=P(),t=e&&"object"==typeof e?e:{},r=d();return r.__autoDrain={enabled:void 0===t.enabled?n.enabled:Boolean(t.enabled),intervalMs:void 0===t.intervalMs?n.intervalMs:D(t.intervalMs)},f(r),O()},getAutoMint:U,autoMintState:k,setAutoMint:function(e={}){const n=U(),t=e&&"object"==typeof e?e:{},r=d();return r.__autoMint={enabled:void 0===t.enabled?n.enabled:Boolean(t.enabled),publish:void 0===t.publish?n.publish:Boolean(t.publish)},f(r),k()},clampAutoDrainInterval:D}}module.exports={SETTINGS_FILE:SETTINGS_FILE,AEGIS_KEY_NAMESPACE:"__aegis",LEGACY_AEGIS_NAMESPACE:"aegis",QUICK_LAUNCHER_NAMESPACE:"__quickLauncher",VAULT_BACKEND_NAMESPACE:"__vaultBackend",CONFIRM_MODE_NAMESPACE:"__confirmMode",MEMORY_PERSIST_NAMESPACE:"__memoryPersist",AVATAR_NAMESPACE:"__avatar",TELEMETRY_NAMESPACE:"__telemetry",AUTO_DRAIN_NAMESPACE:"__autoDrain",AUTO_MINT_NAMESPACE:"__autoMint",AUTO_DRAIN_INTERVAL_DEFAULT_MS:6e4,AUTO_DRAIN_INTERVAL_MIN_MS:15e3,AUTO_DRAIN_INTERVAL_MAX_MS:18e5,AVATAR_MOTION_MODES:AVATAR_MOTION_MODES,DEFAULT_QUICK_LAUNCHER_SHORTCUT:"CmdOrCtrl+Shift+Space",DEFAULT_VAULT_BACKEND:"aegiscloud",VAULT_BACKEND_VALUES:VAULT_BACKEND_VALUES,RESERVED_NAMESPACES:RESERVED_NAMESPACES,isReservedNamespace:isReservedNamespace,maskKey:maskKey,createSettingsStore:createSettingsStore};
|
|
@@ -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};
|